Subversion Repositories LedShow

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 9
Line 1... Line 1...
1
/**
1
/**
2
  ******************************************************************************
2
  ******************************************************************************
3
  * @file    stm32f1xx_hal_pccard.c
3
  * @file    stm32f1xx_hal_pccard.c
4
  * @author  MCD Application Team
4
  * @author  MCD Application Team
5
  * @brief   PCCARD HAL module driver.
5
  * @brief   PCCARD HAL module driver.
6
  *          This file provides a generic firmware to drive PCCARD memories mounted
6
  *          This file provides a generic firmware to drive PCCARD memories mounted
7
  *          as external device.
7
  *          as external device.
8
  *        
8
  *
9
  @verbatim
9
  @verbatim
10
 ===============================================================================
10
 ===============================================================================
11
                        ##### How to use this driver #####
11
                        ##### How to use this driver #####
12
 ===============================================================================  
12
 ===============================================================================
13
   [..]
13
   [..]
14
     This driver is a generic layered driver which contains a set of APIs used to
14
     This driver is a generic layered driver which contains a set of APIs used to
15
     control PCCARD/compact flash memories. It uses the FSMC/FSMC layer functions
15
      control PCCARD/compact flash memories. It uses the FSMC layer functions
16
     to interface with PCCARD devices. This driver is used for:
16
     to interface with PCCARD devices. This driver is used for:
17
   
17
 
18
    (+) PCCARD/compact flash memory configuration sequence using the function
18
    (+) PCCARD/Compact Flash memory configuration sequence using the function
19
        HAL_PCCARD_Init() with control and timing parameters for both common and
19
        HAL_PCCARD_Init()/HAL_CF_Init() with control and timing parameters for
20
        attribute spaces.
20
        both common and attribute spaces.
21
           
21
 
22
    (+) Read PCCARD/compact flash memory maker and device IDs using the function
22
    (+) Read PCCARD/Compact Flash memory maker and device IDs using the function
23
        HAL_PCCARD_Read_ID(). The read information is stored in the CompactFlash_ID
23
        HAL_PCCARD_Read_ID()/HAL_CF_Read_ID(). The read information is stored in
24
        structure declared by the function caller.
24
        the CompactFlash_ID structure declared by the function caller.
25
       
25
 
26
    (+) Access PCCARD/compact flash memory by read/write operations using the functions
26
    (+) Access PCCARD/Compact Flash memory by read/write operations using the functions
-
 
27
        HAL_PCCARD_Read_Sector()/ HAL_PCCARD_Write_Sector() -
27
        HAL_PCCARD_Read_Sector()/HAL_PCCARD_Write_Sector(), to read/write sector.
28
        HAL_CF_Read_Sector()/HAL_CF_Write_Sector(), to read/write sector.
28
       
29
 
29
    (+) Perform PCCARD/compact flash Reset chip operation using the function HAL_PCCARD_Reset().
30
    (+) Perform PCCARD/Compact Flash Reset chip operation using the function
30
       
31
        HAL_PCCARD_Reset()/HAL_CF_Reset.
-
 
32
 
31
    (+) Perform PCCARD/compact flash erase sector operation using the function
33
    (+) Perform PCCARD/Compact Flash erase sector operation using the function
32
        HAL_PCCARD_Erase_Sector().
34
        HAL_PCCARD_Erase_Sector()/HAL_CF_Erase_Sector.
33
   
35
 
34
    (+) Read the PCCARD/compact flash status operation using the function HAL_PCCARD_ReadStatus().
36
    (+) Read the PCCARD/Compact Flash status operation using the function
-
 
37
        HAL_PCCARD_ReadStatus()/HAL_CF_ReadStatus().
35
     
38
 
36
    (+) You can monitor the PCCARD/compact flash  device HAL state by calling the function
39
    (+) You can monitor the PCCARD/Compact Flash  device HAL state by calling
37
        HAL_PCCARD_GetState()    
40
        the function HAL_PCCARD_GetState()/HAL_CF_GetState()
38
       
41
 
39
   [..]
42
   [..]
40
     (@) This driver is a set of generic APIs which handle standard PCCARD/compact flash
43
     (@) This driver is a set of generic APIs which handle standard PCCARD/compact flash
41
         operations. If a PCCARD/compact flash device contains different operations
44
         operations. If a PCCARD/Compact Flash device contains different operations
42
         and/or implementations, it should be implemented separately.
45
         and/or implementations, it should be implemented separately.
-
 
46
 
-
 
47
      *** Callback registration ***
-
 
48
    =============================================
43
   
49
    [..]
-
 
50
      The compilation define  USE_HAL_PCCARD_REGISTER_CALLBACKS when set to 1
-
 
51
      allows the user to configure dynamically the driver callbacks.
-
 
52
 
-
 
53
      Use Functions @ref HAL_PCCARD_RegisterCallback() to register a user callback,
-
 
54
      it allows to register following callbacks:
-
 
55
        (+) MspInitCallback    : PCCARD MspInit.
-
 
56
        (+) MspDeInitCallback  : PCCARD MspDeInit.
-
 
57
      This function takes as parameters the HAL peripheral handle, the Callback ID
-
 
58
      and a pointer to the user callback function.
-
 
59
 
-
 
60
      Use function @ref HAL_PCCARD_UnRegisterCallback() to reset a callback to the default
-
 
61
      weak (surcharged) function. It allows to reset following callbacks:
-
 
62
        (+) MspInitCallback    : PCCARD MspInit.
-
 
63
        (+) MspDeInitCallback  : PCCARD MspDeInit.
-
 
64
      This function) takes as parameters the HAL peripheral handle and the Callback ID.
-
 
65
 
-
 
66
      By default, after the @ref HAL_PCCARD_Init and if the state is HAL_PCCARD_STATE_RESET
-
 
67
      all callbacks are reset to the corresponding legacy weak (surcharged) functions.
-
 
68
      Exception done for MspInit and MspDeInit callbacks that are respectively
-
 
69
      reset to the legacy weak (surcharged) functions in the @ref HAL_PCCARD_Init
-
 
70
      and @ref  HAL_PCCARD_DeInit only when these callbacks are null (not registered beforehand).
-
 
71
      If not, MspInit or MspDeInit are not null, the @ref HAL_PCCARD_Init and @ref HAL_PCCARD_DeInit
-
 
72
      keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
-
 
73
 
-
 
74
      Callbacks can be registered/unregistered in READY state only.
-
 
75
      Exception done for MspInit/MspDeInit callbacks that can be registered/unregistered
-
 
76
      in READY or RESET state, thus registered (user) MspInit/DeInit callbacks can be used
-
 
77
      during the Init/DeInit.
-
 
78
      In that case first register the MspInit/MspDeInit user callbacks
-
 
79
      using @ref HAL_PCCARD_RegisterCallback before calling @ref HAL_PCCARD_DeInit
-
 
80
      or @ref HAL_PCCARD_Init function.
-
 
81
 
-
 
82
      When The compilation define USE_HAL_PCCARD_REGISTER_CALLBACKS is set to 0 or
-
 
83
      not defined, the callback registering feature is not available
-
 
84
      and weak (surcharged) callbacks are used.
-
 
85
 
44
  @endverbatim
86
  @endverbatim
45
  ******************************************************************************
87
  ******************************************************************************
46
  * @attention
88
  * @attention
47
  *
89
  *
48
  * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
90
  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
-
 
91
  * All rights reserved.</center></h2>
49
  *
92
  *
50
  * Redistribution and use in source and binary forms, with or without modification,
93
  * This software component is licensed by ST under BSD 3-Clause license,
51
  * are permitted provided that the following conditions are met:
94
  * the "License"; You may not use this file except in compliance with the
52
  *   1. Redistributions of source code must retain the above copyright notice,
-
 
53
  *      this list of conditions and the following disclaimer.
95
  * License. You may obtain a copy of the License at:
54
  *   2. Redistributions in binary form must reproduce the above copyright notice,
-
 
55
  *      this list of conditions and the following disclaimer in the documentation
-
 
56
  *      and/or other materials provided with the distribution.
96
  *                       opensource.org/licenses/BSD-3-Clause
57
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
-
 
58
  *      may be used to endorse or promote products derived from this software
-
 
59
  *      without specific prior written permission.
-
 
60
  *
-
 
61
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-
 
62
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-
 
63
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-
 
64
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
-
 
65
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-
 
66
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-
 
67
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-
 
68
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-
 
69
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-
 
70
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
 
71
  *
97
  *
72
  ******************************************************************************
98
  ******************************************************************************
73
  */
99
  */
74
 
100
 
75
/* Includes ------------------------------------------------------------------*/
101
/* Includes ------------------------------------------------------------------*/
76
#include "stm32f1xx_hal.h"
102
#include "stm32f1xx_hal.h"
77
 
103
 
-
 
104
#if defined(FSMC_BANK4)
-
 
105
 
78
/** @addtogroup STM32F1xx_HAL_Driver
106
/** @addtogroup STM32F1xx_HAL_Driver
79
  * @{
107
  * @{
80
  */
108
  */
81
 
109
 
82
#ifdef HAL_PCCARD_MODULE_ENABLED
110
#ifdef HAL_PCCARD_MODULE_ENABLED
83
#if defined (STM32F101xE) || defined(STM32F103xE) || defined(STM32F101xG) || defined(STM32F103xG)
-
 
84
 
111
 
85
/** @defgroup PCCARD PCCARD
112
/** @defgroup PCCARD PCCARD
86
  * @brief PCCARD HAL module driver
113
  * @brief PCCARD HAL module driver
87
  * @{
114
  * @{
88
  */
115
  */
89
 
-
 
90
/* Private typedef -----------------------------------------------------------*/
116
/* Private typedef -----------------------------------------------------------*/
91
/* Private define ------------------------------------------------------------*/
117
/* Private define ------------------------------------------------------------*/
-
 
118
 
92
/** @defgroup PCCARD_Private_Constants PCCARD Private Constants
119
/** @defgroup PCCARD_Private_Defines PCCARD Private Defines
93
  * @{
120
  * @{
94
  */
121
  */
-
 
122
#define PCCARD_TIMEOUT_READ_ID                 0x0000FFFFU
-
 
123
#define PCCARD_TIMEOUT_READ_WRITE_SECTOR       0x0000FFFFU
-
 
124
#define PCCARD_TIMEOUT_ERASE_SECTOR            0x00000400U
-
 
125
#define PCCARD_TIMEOUT_STATUS                  0x01000000U
95
 
126
 
96
#define PCCARD_TIMEOUT_READ_ID      0x0000FFFFU
-
 
97
#define PCCARD_TIMEOUT_SECTOR       0x0000FFFFU
-
 
98
#define PCCARD_TIMEOUT_STATUS       0x01000000U
-
 
99
 
-
 
100
#define PCCARD_STATUS_OK            (uint8_t)0x58
127
#define PCCARD_STATUS_OK                       (uint8_t)0x58
101
#define PCCARD_STATUS_WRITE_OK      (uint8_t)0x50
128
#define PCCARD_STATUS_WRITE_OK                 (uint8_t)0x50
102
/**
129
/**
103
  * @}
130
  * @}
104
  */
131
  */
105
 
132
 
106
/* Private macro -------------------------------------------------------------*/
133
/* Private macro -------------------------------------------------------------*/
107
/* Private variables ---------------------------------------------------------*/
134
/* Private variables ---------------------------------------------------------*/
108
/* Private function prototypes -----------------------------------------------*/
135
/* Private function ----------------------------------------------------------*/
109
/* Exported functions ---------------------------------------------------------*/
136
/* Exported functions --------------------------------------------------------*/
110
 
-
 
111
/** @defgroup PCCARD_Exported_Functions PCCARD Exported Functions
137
/** @defgroup PCCARD_Exported_Functions PCCARD Exported Functions
112
  * @{
138
  * @{
113
  */
139
  */
114
 
140
 
115
/** @defgroup PCCARD_Exported_Functions_Group1 Initialization and de-initialization functions
141
/** @defgroup PCCARD_Exported_Functions_Group1 Initialization and de-initialization functions
116
  * @brief    Initialization and Configuration functions
142
  * @brief    Initialization and Configuration functions
117
  *
143
  *
118
  @verbatim    
144
  @verbatim
119
  ==============================================================================
145
  ==============================================================================
120
          ##### PCCARD Initialization and de-initialization functions #####
146
          ##### PCCARD Initialization and de-initialization functions #####
121
  ==============================================================================
147
  ==============================================================================
122
  [..]  
148
  [..]
123
    This section provides functions allowing to initialize/de-initialize
149
    This section provides functions allowing to initialize/de-initialize
124
    the PCCARD memory
150
    the PCCARD memory
125
 
151
 
126
@endverbatim
152
@endverbatim
127
  * @{
153
  * @{
128
  */
154
  */
129
   
155
 
130
/**
156
/**
131
  * @brief  Perform the PCCARD memory Initialization sequence
157
  * @brief  Perform the PCCARD memory Initialization sequence
132
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
158
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
133
  *                the configuration information for PCCARD module.
159
  *                the configuration information for PCCARD module.
134
  * @param  ComSpaceTiming: Common space timing structure
160
  * @param  ComSpaceTiming Common space timing structure
135
  * @param  AttSpaceTiming: Attribute space timing structure
161
  * @param  AttSpaceTiming Attribute space timing structure
136
  * @param  IOSpaceTiming: IO space timing structure    
162
  * @param  IOSpaceTiming IO space timing structure
137
  * @retval HAL status
163
  * @retval HAL status
138
  */
164
  */
139
HAL_StatusTypeDef HAL_PCCARD_Init(PCCARD_HandleTypeDef *hpccard, FSMC_NAND_PCC_TimingTypeDef *ComSpaceTiming, FSMC_NAND_PCC_TimingTypeDef *AttSpaceTiming, FSMC_NAND_PCC_TimingTypeDef *IOSpaceTiming)
165
HAL_StatusTypeDef HAL_PCCARD_Init(PCCARD_HandleTypeDef *hpccard, FSMC_NAND_PCC_TimingTypeDef *ComSpaceTiming,
-
 
166
                                  FSMC_NAND_PCC_TimingTypeDef *AttSpaceTiming, FSMC_NAND_PCC_TimingTypeDef *IOSpaceTiming)
140
{
167
{
141
  /* Check the PCCARD controller state */
168
  /* Check the PCCARD controller state */
142
  if(hpccard == NULL)
169
  if (hpccard == NULL)
143
  {
170
  {
144
     return HAL_ERROR;
171
    return HAL_ERROR;
145
  }
172
  }
146
 
173
 
147
  if(hpccard->State == HAL_PCCARD_STATE_RESET)
174
  if (hpccard->State == HAL_PCCARD_STATE_RESET)
148
  {  
175
  {
149
    /* Allocate lock resource and initialize it */
176
    /* Allocate lock resource and initialize it */
150
    hpccard->Lock = HAL_UNLOCKED;
177
    hpccard->Lock = HAL_UNLOCKED;
-
 
178
#if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
-
 
179
    if (hpccard->MspInitCallback == NULL)
-
 
180
    {
-
 
181
      hpccard->MspInitCallback = HAL_PCCARD_MspInit;
151
   
182
    }
-
 
183
    hpccard->ItCallback = HAL_PCCARD_ITCallback;
-
 
184
 
-
 
185
    /* Init the low level hardware */
-
 
186
    hpccard->MspInitCallback(hpccard);
-
 
187
#else
152
    /* Initialize the low level hardware (MSP) */
188
    /* Initialize the low level hardware (MSP) */
153
    HAL_PCCARD_MspInit(hpccard);
189
    HAL_PCCARD_MspInit(hpccard);
-
 
190
#endif
154
  }
191
  }
155
 
192
 
156
  /* Initialize the PCCARD state */
193
  /* Initialize the PCCARD state */
157
  hpccard->State = HAL_PCCARD_STATE_BUSY;    
194
  hpccard->State = HAL_PCCARD_STATE_BUSY;
158
 
195
 
159
  /* Initialize PCCARD control Interface */
196
  /* Initialize PCCARD control Interface */
160
  FSMC_PCCARD_Init(hpccard->Instance, &(hpccard->Init));
197
  FSMC_PCCARD_Init(hpccard->Instance, &(hpccard->Init));
161
 
198
 
162
  /* Init PCCARD common space timing Interface */
199
  /* Init PCCARD common space timing Interface */
163
  FSMC_PCCARD_CommonSpace_Timing_Init(hpccard->Instance, ComSpaceTiming);
200
  FSMC_PCCARD_CommonSpace_Timing_Init(hpccard->Instance, ComSpaceTiming);
164
 
201
 
165
  /* Init PCCARD attribute space timing Interface */  
202
  /* Init PCCARD attribute space timing Interface */
166
  FSMC_PCCARD_AttributeSpace_Timing_Init(hpccard->Instance, AttSpaceTiming);
203
  FSMC_PCCARD_AttributeSpace_Timing_Init(hpccard->Instance, AttSpaceTiming);
167
 
204
 
168
  /* Init PCCARD IO space timing Interface */  
205
  /* Init PCCARD IO space timing Interface */
169
  FSMC_PCCARD_IOSpace_Timing_Init(hpccard->Instance, IOSpaceTiming);
206
  FSMC_PCCARD_IOSpace_Timing_Init(hpccard->Instance, IOSpaceTiming);
170
 
207
 
171
  /* Enable the PCCARD device */
208
  /* Enable the PCCARD device */
172
  __FSMC_PCCARD_ENABLE(hpccard->Instance);
209
  __FSMC_PCCARD_ENABLE(hpccard->Instance);
173
 
210
 
174
  /* Update the PCCARD state */
211
  /* Update the PCCARD state */
175
  hpccard->State = HAL_PCCARD_STATE_READY;  
212
  hpccard->State = HAL_PCCARD_STATE_READY;
176
 
213
 
177
  return HAL_OK;
214
  return HAL_OK;
178
 
215
 
179
}
216
}
180
 
217
 
181
/**
218
/**
182
  * @brief  Perform the PCCARD memory De-initialization sequence
219
  * @brief  Perform the PCCARD memory De-initialization sequence
183
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
220
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
184
  *                the configuration information for PCCARD module.
221
  *                the configuration information for PCCARD module.
185
  * @retval HAL status
222
  * @retval HAL status
186
  */
223
  */
187
HAL_StatusTypeDef  HAL_PCCARD_DeInit(PCCARD_HandleTypeDef *hpccard)
224
HAL_StatusTypeDef  HAL_PCCARD_DeInit(PCCARD_HandleTypeDef *hpccard)
188
{
225
{
-
 
226
#if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
-
 
227
  if (hpccard->MspDeInitCallback == NULL)
-
 
228
  {
-
 
229
    hpccard->MspDeInitCallback = HAL_PCCARD_MspDeInit;
-
 
230
  }
-
 
231
 
-
 
232
  /* DeInit the low level hardware */
-
 
233
  hpccard->MspDeInitCallback(hpccard);
-
 
234
#else
189
  /* De-Initialize the low level hardware (MSP) */
235
  /* De-Initialize the low level hardware (MSP) */
190
  HAL_PCCARD_MspDeInit(hpccard);
236
  HAL_PCCARD_MspDeInit(hpccard);
-
 
237
#endif
191
   
238
 
192
  /* Configure the PCCARD registers with their reset values */
239
  /* Configure the PCCARD registers with their reset values */
193
  FSMC_PCCARD_DeInit(hpccard->Instance);
240
  FSMC_PCCARD_DeInit(hpccard->Instance);
194
 
241
 
195
  /* Update the PCCARD controller state */
242
  /* Update the PCCARD controller state */
196
  hpccard->State = HAL_PCCARD_STATE_RESET;
243
  hpccard->State = HAL_PCCARD_STATE_RESET;
197
 
244
 
198
  /* Release Lock */
245
  /* Release Lock */
199
  __HAL_UNLOCK(hpccard);
246
  __HAL_UNLOCK(hpccard);
200
 
247
 
201
  return HAL_OK;
248
  return HAL_OK;
202
}
249
}
203
 
250
 
204
/**
251
/**
205
  * @brief  PCCARD MSP Init
252
  * @brief  PCCARD MSP Init
206
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
253
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
207
  *                the configuration information for PCCARD module.
254
  *                the configuration information for PCCARD module.
208
  * @retval None
255
  * @retval None
209
  */
256
  */
210
__weak void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef *hpccard)
257
__weak void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef *hpccard)
211
{
258
{
212
  /* Prevent unused argument(s) compilation warning */
259
  /* Prevent unused argument(s) compilation warning */
213
  UNUSED(hpccard);
260
  UNUSED(hpccard);
214
  /* NOTE : This function Should not be modified, when the callback is needed,
261
  /* NOTE : This function Should not be modified, when the callback is needed,
215
            the HAL_PCCARD_MspInit could be implemented in the user file
262
            the HAL_PCCARD_MspInit could be implemented in the user file
216
   */
263
   */
217
}
264
}
218
 
265
 
219
/**
266
/**
220
  * @brief  PCCARD MSP DeInit
267
  * @brief  PCCARD MSP DeInit
221
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
268
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
222
  *                the configuration information for PCCARD module.
269
  *                the configuration information for PCCARD module.
223
  * @retval None
270
  * @retval None
224
  */
271
  */
225
__weak void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef *hpccard)
272
__weak void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef *hpccard)
226
{
273
{
227
  /* Prevent unused argument(s) compilation warning */
274
  /* Prevent unused argument(s) compilation warning */
228
  UNUSED(hpccard);
275
  UNUSED(hpccard);
229
  /* NOTE : This function Should not be modified, when the callback is needed,
276
  /* NOTE : This function Should not be modified, when the callback is needed,
230
            the HAL_PCCARD_MspDeInit could be implemented in the user file
277
            the HAL_PCCARD_MspDeInit could be implemented in the user file
231
   */
278
   */
232
}
279
}
233
 
280
 
234
/**
281
/**
235
  * @}
282
  * @}
236
  */
283
  */
237
 
284
 
238
/** @defgroup PCCARD_Exported_Functions_Group2 Input Output and memory functions
285
/** @defgroup PCCARD_Exported_Functions_Group2 Input and Output functions
239
  * @brief    Input Output and memory control functions
286
  * @brief    Input Output and memory control functions
240
  *
287
  *
241
  @verbatim    
288
  @verbatim
242
  ==============================================================================
289
  ==============================================================================
243
                ##### PCCARD Input Output and memory functions #####
290
                    ##### PCCARD Input and Output functions #####
244
  ==============================================================================
291
  ==============================================================================
245
  [..]  
292
  [..]
246
    This section provides functions allowing to use and control the PCCARD memory
293
    This section provides functions allowing to use and control the PCCARD memory
247
 
294
 
248
@endverbatim
295
@endverbatim
249
  * @{
296
  * @{
250
  */
297
  */
251
 
298
 
252
/**
299
/**
253
  * @brief  Read Compact Flash's ID.
300
  * @brief  Read Compact Flash's ID.
254
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
301
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
255
  *                the configuration information for PCCARD module.
302
  *                the configuration information for PCCARD module.
256
  * @param  CompactFlash_ID: Compact flash ID structure.  
303
  * @param  CompactFlash_ID Compact flash ID structure.
257
  * @param  pStatus: pointer to compact flash status        
304
  * @param  pStatus pointer to compact flash status
258
  * @retval HAL status
305
  * @retval HAL status
259
  *  
306
  *
260
  */
307
  */
261
HAL_StatusTypeDef HAL_PCCARD_Read_ID(PCCARD_HandleTypeDef *hpccard, uint8_t CompactFlash_ID[], uint8_t *pStatus)
308
HAL_StatusTypeDef HAL_PCCARD_Read_ID(PCCARD_HandleTypeDef *hpccard, uint8_t CompactFlash_ID[], uint8_t *pStatus)
262
{
309
{
263
  uint32_t timeout = PCCARD_TIMEOUT_READ_ID, index = 0U;
310
  uint32_t timeout = PCCARD_TIMEOUT_READ_ID, index = 0U;
264
  uint8_t status = 0U;
311
  uint8_t status = 0;
265
 
312
 
266
  /* Process Locked */
313
  /* Process Locked */
267
  __HAL_LOCK(hpccard);  
314
  __HAL_LOCK(hpccard);
268
 
315
 
269
  /* Check the PCCARD controller state */
316
  /* Check the PCCARD controller state */
270
  if(hpccard->State == HAL_PCCARD_STATE_BUSY)
317
  if (hpccard->State == HAL_PCCARD_STATE_BUSY)
271
  {
318
  {
272
     return HAL_BUSY;
319
    return HAL_BUSY;
273
  }
320
  }
274
 
321
 
275
  /* Update the PCCARD controller state */
322
  /* Update the PCCARD controller state */
276
  hpccard->State = HAL_PCCARD_STATE_BUSY;
323
  hpccard->State = HAL_PCCARD_STATE_BUSY;
277
 
324
 
278
  /* Initialize the CF status */
325
  /* Initialize the PCCARD status */
279
  *pStatus = PCCARD_READY;  
326
  *pStatus = PCCARD_READY;
280
 
327
 
281
  /* Send the Identify Command */
328
  /* Send the Identify Command */
282
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD)  = 0xECECU;
329
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD)  = (uint16_t)0xECEC;
283
   
330
 
284
  /* Read CF IDs and timeout treatment */
331
  /* Read PCCARD IDs and timeout treatment */
285
  do
332
  do
286
  {
333
  {
287
     /* Read the CF status */
334
    /* Read the PCCARD status */
288
     status = *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
335
    status = *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
289
     
336
 
290
     timeout--;
337
    timeout--;
291
  }while((status != PCCARD_STATUS_OK) && timeout);
338
  } while ((status != PCCARD_STATUS_OK) && timeout);
292
 
339
 
293
  if(timeout == 0U)
340
  if (timeout == 0U)
294
  {
341
  {
295
    *pStatus = PCCARD_TIMEOUT_ERROR;
342
    *pStatus = PCCARD_TIMEOUT_ERROR;
296
  }
343
  }
297
  else
344
  else
298
  {
345
  {
299
     /* Read CF ID bytes */
346
    /* Read PCCARD ID bytes */
300
    for(index = 0U; index < 16U; index++)
347
    for (index = 0U; index < 16U; index++)
301
    {
348
    {
302
      CompactFlash_ID[index] = *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_DATA);
349
      CompactFlash_ID[index] = *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_DATA);
303
    }    
350
    }
304
  }
351
  }
305
 
352
 
306
  /* Update the PCCARD controller state */
353
  /* Update the PCCARD controller state */
307
  hpccard->State = HAL_PCCARD_STATE_READY;
354
  hpccard->State = HAL_PCCARD_STATE_READY;
308
 
355
 
309
  /* Process unlocked */
356
  /* Process unlocked */
310
  __HAL_UNLOCK(hpccard);  
357
  __HAL_UNLOCK(hpccard);
311
 
358
 
312
  return HAL_OK;
359
  return HAL_OK;
313
}
360
}
314
   
361
 
315
/**
362
/**
316
  * @brief  Read sector from PCCARD memory
363
  * @brief  Read sector from PCCARD memory
317
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
364
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
318
  *                the configuration information for PCCARD module.
365
  *                the configuration information for PCCARD module.
319
  * @param  pBuffer: pointer to destination read buffer
366
  * @param  pBuffer pointer to destination read buffer
320
  * @param  SectorAddress: Sector address to read
367
  * @param  SectorAddress Sector address to read
321
  * @param  pStatus: pointer to CF status
368
  * @param  pStatus pointer to PCCARD status
322
  * @retval HAL status
369
  * @retval HAL status
323
  */    
370
  */
324
HAL_StatusTypeDef HAL_PCCARD_Read_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress, uint8_t *pStatus)
371
HAL_StatusTypeDef HAL_PCCARD_Read_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress,
-
 
372
                                         uint8_t *pStatus)
325
{
373
{
326
  uint32_t timeout = PCCARD_TIMEOUT_SECTOR, index = 0U;
374
  uint32_t timeout = PCCARD_TIMEOUT_READ_WRITE_SECTOR, index = 0U;
327
  uint8_t status = 0U;
375
  uint8_t status = 0;
328
 
376
 
329
  /* Process Locked */
377
  /* Process Locked */
330
  __HAL_LOCK(hpccard);
378
  __HAL_LOCK(hpccard);
331
 
379
 
332
  /* Check the PCCARD controller state */
380
  /* Check the PCCARD controller state */
333
  if(hpccard->State == HAL_PCCARD_STATE_BUSY)
381
  if (hpccard->State == HAL_PCCARD_STATE_BUSY)
334
  {
382
  {
335
     return HAL_BUSY;
383
    return HAL_BUSY;
336
  }
384
  }
337
 
385
 
338
  /* Update the PCCARD controller state */
386
  /* Update the PCCARD controller state */
339
  hpccard->State = HAL_PCCARD_STATE_BUSY;
387
  hpccard->State = HAL_PCCARD_STATE_BUSY;
340
 
388
 
341
  /* Initialize CF status */
389
  /* Initialize PCCARD status */
342
  *pStatus = PCCARD_READY;
390
  *pStatus = PCCARD_READY;
343
 
391
 
344
  /* Set the parameters to write a sector */
392
  /* Set the parameters to write a sector */
345
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_CYLINDER_HIGH) = (uint16_t)0x00;
393
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_CYLINDER_HIGH) = (uint16_t)0x0000;
346
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_SECTOR_COUNT)  = ((uint16_t)0x0100) | ((uint16_t)SectorAddress);
394
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_SECTOR_COUNT)  = ((uint16_t)0x0100) | ((uint16_t)SectorAddress);
347
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD)    = (uint16_t)0xE4A0;
395
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD)    = (uint16_t)0xE4A0;
348
 
396
 
349
  do
397
  do
350
  {
398
  {
351
    /* wait till the Status = 0x80 */
399
    /* wait till the Status = 0x80 */
352
    status =  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
400
    status =  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
353
    timeout--;
401
    timeout--;
354
  }while((status == 0x80U) && timeout);
402
  } while ((status == 0x80U) && timeout);
355
 
403
 
356
  if(timeout == 0U)
404
  if (timeout == 0U)
357
  {
405
  {
358
    *pStatus = PCCARD_TIMEOUT_ERROR;
406
    *pStatus = PCCARD_TIMEOUT_ERROR;
359
  }
407
  }
360
 
408
 
361
  timeout = 0xFFFFU;
409
  timeout = PCCARD_TIMEOUT_READ_WRITE_SECTOR;
362
 
410
 
363
  do
411
  do
364
  {
412
  {
365
    /* wait till the Status = PCCARD_STATUS_OK */
413
    /* wait till the Status = PCCARD_STATUS_OK */
366
    status =  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
414
    status =  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
367
    timeout--;
415
    timeout--;
368
  }while((status != PCCARD_STATUS_OK) && timeout);
416
  } while ((status != PCCARD_STATUS_OK) && timeout);
369
 
417
 
370
  if(timeout == 0U)
418
  if (timeout == 0U)
371
  {
419
  {
372
    *pStatus = PCCARD_TIMEOUT_ERROR;
420
    *pStatus = PCCARD_TIMEOUT_ERROR;
373
  }
421
  }
374
 
422
 
375
  /* Read bytes */
423
  /* Read bytes */
376
  for(; index < PCCARD_SECTOR_SIZE; index++)
424
  for (; index < PCCARD_SECTOR_SIZE; index++)
377
  {
425
  {
378
    *(uint16_t *)pBuffer++ = *(uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR);
426
    *(uint16_t *)pBuffer++ = *(uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR);
379
  }
427
  }
380
 
428
 
381
  /* Update the PCCARD controller state */
429
  /* Update the PCCARD controller state */
382
  hpccard->State = HAL_PCCARD_STATE_READY;
430
  hpccard->State = HAL_PCCARD_STATE_READY;
383
 
431
 
384
  /* Process unlocked */
432
  /* Process unlocked */
385
  __HAL_UNLOCK(hpccard);
433
  __HAL_UNLOCK(hpccard);
386
     
434
 
387
  return HAL_OK;
435
  return HAL_OK;
388
}
436
}
389
 
437
 
390
 
438
 
391
/**
439
/**
392
  * @brief  Write sector to PCCARD memory
440
  * @brief  Write sector to PCCARD memory
393
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
441
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
394
  *                the configuration information for PCCARD module.
442
  *                the configuration information for PCCARD module.
395
  * @param  pBuffer: pointer to source write buffer
443
  * @param  pBuffer pointer to source write buffer
396
  * @param  SectorAddress: Sector address to write
444
  * @param  SectorAddress Sector address to write
397
  * @param  pStatus: pointer to CF status
445
  * @param  pStatus pointer to PCCARD status
398
  * @retval HAL status
446
  * @retval HAL status
399
  */
447
  */
400
HAL_StatusTypeDef HAL_PCCARD_Write_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress,  uint8_t *pStatus)
448
HAL_StatusTypeDef HAL_PCCARD_Write_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress,
-
 
449
                                          uint8_t *pStatus)
401
{
450
{
402
  uint32_t timeout = PCCARD_TIMEOUT_SECTOR, index = 0U;
451
  uint32_t timeout = PCCARD_TIMEOUT_READ_WRITE_SECTOR, index = 0U;
403
  uint8_t status = 0U;
452
  uint8_t status = 0;
404
 
453
 
405
  /* Process Locked */
454
  /* Process Locked */
406
  __HAL_LOCK(hpccard);  
455
  __HAL_LOCK(hpccard);
407
 
456
 
408
  /* Check the PCCARD controller state */
457
  /* Check the PCCARD controller state */
409
  if(hpccard->State == HAL_PCCARD_STATE_BUSY)
458
  if (hpccard->State == HAL_PCCARD_STATE_BUSY)
410
  {
459
  {
411
     return HAL_BUSY;
460
    return HAL_BUSY;
412
  }
461
  }
413
   
462
 
414
  /* Update the PCCARD controller state */
463
  /* Update the PCCARD controller state */
415
  hpccard->State = HAL_PCCARD_STATE_BUSY;
464
  hpccard->State = HAL_PCCARD_STATE_BUSY;
416
   
465
 
417
  /* Initialize CF status */
466
  /* Initialize PCCARD status */
418
  *pStatus = PCCARD_READY;  
467
  *pStatus = PCCARD_READY;
419
   
468
 
420
  /* Set the parameters to write a sector */
469
  /* Set the parameters to write a sector */
421
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_CYLINDER_HIGH) = (uint16_t)0x00;
470
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_CYLINDER_HIGH) = (uint16_t)0x0000;
422
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_SECTOR_COUNT)  = ((uint16_t)0x0100) | ((uint16_t)SectorAddress);
471
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_SECTOR_COUNT)  = ((uint16_t)0x0100) | ((uint16_t)SectorAddress);
423
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD)    = (uint16_t)0x30A0;
472
  *(__IO uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD)    = (uint16_t)0x30A0;
424
 
473
 
425
  do
474
  do
426
  {
475
  {
427
    /* Wait till the Status = PCCARD_STATUS_OK */
476
    /* Wait till the Status = PCCARD_STATUS_OK */
428
    status =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
477
    status =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
429
    timeout--;
478
    timeout--;
430
  }while((status != PCCARD_STATUS_OK) && timeout);
479
  } while ((status != PCCARD_STATUS_OK) && timeout);
431
 
480
 
432
  if(timeout == 0U)
481
  if (timeout == 0U)
433
  {
482
  {
434
    *pStatus = PCCARD_TIMEOUT_ERROR;
483
    *pStatus = PCCARD_TIMEOUT_ERROR;
435
  }
484
  }
436
 
485
 
437
  /* Write bytes */
486
  /* Write bytes */
438
  for(; index < PCCARD_SECTOR_SIZE; index++)
487
  for (; index < PCCARD_SECTOR_SIZE; index++)
439
  {
488
  {
440
    *(uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR) = *(uint16_t *)pBuffer++;
489
    *(uint16_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR) = *(uint16_t *)pBuffer++;
441
  }
490
  }
442
 
491
 
443
  do
492
  do
444
  {
493
  {
445
    /* Wait till the Status = PCCARD_STATUS_WRITE_OK */
494
    /* Wait till the Status = PCCARD_STATUS_WRITE_OK */
446
    status =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
495
    status =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
447
    timeout--;
496
    timeout--;
448
  }while((status != PCCARD_STATUS_WRITE_OK) && timeout);
497
  } while ((status != PCCARD_STATUS_WRITE_OK) && timeout);
449
 
498
 
450
  if(timeout == 0U)
499
  if (timeout == 0U)
451
  {
500
  {
452
    *pStatus = PCCARD_TIMEOUT_ERROR;
501
    *pStatus = PCCARD_TIMEOUT_ERROR;
453
  }  
502
  }
454
 
503
 
455
  /* Update the PCCARD controller state */
504
  /* Update the PCCARD controller state */
456
  hpccard->State = HAL_PCCARD_STATE_READY;
505
  hpccard->State = HAL_PCCARD_STATE_READY;
457
 
506
 
458
  /* Process unlocked */
507
  /* Process unlocked */
459
  __HAL_UNLOCK(hpccard);  
508
  __HAL_UNLOCK(hpccard);
460
 
509
 
461
  return HAL_OK;
510
  return HAL_OK;
462
}
511
}
463
 
512
 
464
 
513
 
465
/**
514
/**
466
  * @brief  Erase sector from PCCARD memory
515
  * @brief  Erase sector from PCCARD memory
467
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
516
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
468
  *                the configuration information for PCCARD module.
517
  *                the configuration information for PCCARD module.
469
  * @param  SectorAddress: Sector address to erase
518
  * @param  SectorAddress Sector address to erase
470
  * @param  pStatus: pointer to CF status
519
  * @param  pStatus pointer to PCCARD status
471
  * @retval HAL status
520
  * @retval HAL status
472
  */
521
  */
473
HAL_StatusTypeDef  HAL_PCCARD_Erase_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t SectorAddress, uint8_t *pStatus)
522
HAL_StatusTypeDef  HAL_PCCARD_Erase_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t SectorAddress, uint8_t *pStatus)
474
{
523
{
475
  uint32_t timeout = 0x400U;
524
  uint32_t timeout = PCCARD_TIMEOUT_ERASE_SECTOR;
476
  uint8_t status = 0;
525
  uint8_t status = 0;
477
 
526
 
478
  /* Process Locked */
527
  /* Process Locked */
479
  __HAL_LOCK(hpccard);  
528
  __HAL_LOCK(hpccard);
480
 
529
 
481
  /* Check the PCCARD controller state */
530
  /* Check the PCCARD controller state */
482
  if(hpccard->State == HAL_PCCARD_STATE_BUSY)
531
  if (hpccard->State == HAL_PCCARD_STATE_BUSY)
483
  {
532
  {
484
     return HAL_BUSY;
533
    return HAL_BUSY;
485
  }
534
  }
486
 
535
 
487
  /* Update the PCCARD controller state */
536
  /* Update the PCCARD controller state */
488
  hpccard->State = HAL_PCCARD_STATE_BUSY;
537
  hpccard->State = HAL_PCCARD_STATE_BUSY;
489
 
538
 
490
  /* Initialize CF status */
539
  /* Initialize PCCARD status */
491
  *pStatus = PCCARD_READY;
540
  *pStatus = PCCARD_READY;
492
   
541
 
493
  /* Set the parameters to write a sector */
542
  /* Set the parameters to write a sector */
494
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_CYLINDER_LOW)  = 0x00;
543
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_CYLINDER_LOW)  = 0x00;
495
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_CYLINDER_HIGH) = 0x00;
544
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_CYLINDER_HIGH) = 0x00;
496
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_SECTOR_NUMBER) = SectorAddress;
545
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_SECTOR_NUMBER) = SectorAddress;
497
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_SECTOR_COUNT)  = 0x01;
546
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_SECTOR_COUNT)  = 0x01;
498
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_CARD_HEAD)     = 0xA0;
547
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_CARD_HEAD)     = 0xA0;
499
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD)    = ATA_ERASE_SECTOR_CMD;
548
  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD)    = ATA_ERASE_SECTOR_CMD;
500
 
549
 
501
  /* wait till the CF is ready */
550
  /* wait till the PCCARD is ready */
502
  status =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
551
  status =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
503
 
552
 
504
  while((status != PCCARD_STATUS_WRITE_OK) && timeout)
553
  while ((status != PCCARD_STATUS_WRITE_OK) && timeout)
505
  {
554
  {
506
    status =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
555
    status =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
507
    timeout--;
556
    timeout--;
508
  }
557
  }
509
 
558
 
510
  if(timeout == 0U)
559
  if (timeout == 0U)
511
  {
560
  {
512
    *pStatus = PCCARD_TIMEOUT_ERROR;
561
    *pStatus = PCCARD_TIMEOUT_ERROR;
513
  }
562
  }
514
 
563
 
515
  /* Check the PCCARD controller state */
564
  /* Check the PCCARD controller state */
516
  hpccard->State = HAL_PCCARD_STATE_READY;
565
  hpccard->State = HAL_PCCARD_STATE_READY;
517
 
566
 
518
  /* Process unlocked */
567
  /* Process unlocked */
519
  __HAL_UNLOCK(hpccard);  
568
  __HAL_UNLOCK(hpccard);
520
 
569
 
521
  return HAL_OK;
570
  return HAL_OK;
522
}
571
}
523
 
572
 
524
/**
573
/**
525
  * @brief  Reset the PCCARD memory
574
  * @brief  Reset the PCCARD memory
526
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
575
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
527
  *                the configuration information for PCCARD module.
576
  *                the configuration information for PCCARD module.
528
  * @retval HAL status
577
  * @retval HAL status
529
  */
578
  */
530
HAL_StatusTypeDef HAL_PCCARD_Reset(PCCARD_HandleTypeDef *hpccard)
579
HAL_StatusTypeDef HAL_PCCARD_Reset(PCCARD_HandleTypeDef *hpccard)
531
{
580
{
532
  /* Process Locked */
581
  /* Process Locked */
533
  __HAL_LOCK(hpccard);  
582
  __HAL_LOCK(hpccard);
534
 
583
 
535
  /* Check the PCCARD controller state */
584
  /* Check the PCCARD controller state */
536
  if(hpccard->State == HAL_PCCARD_STATE_BUSY)
585
  if (hpccard->State == HAL_PCCARD_STATE_BUSY)
537
  {
586
  {
538
     return HAL_BUSY;
587
    return HAL_BUSY;
539
  }
588
  }
540
 
589
 
541
  /* Provide an SW reset and Read and verify the:
590
  /* Provide a SW reset and Read and verify the:
542
   - CF Configuration Option Register at address 0x98000200 --> 0x80
591
   - PCCard Configuration Option Register at address 0x98000200 --> 0x80
543
   - Card Configuration and Status Register at address 0x98000202 --> 0x00
592
   - Card Configuration and Status Register at address 0x98000202 --> 0x00
544
   - Pin Replacement Register  at address 0x98000204 --> 0x0C
593
   - Pin Replacement Register at address 0x98000204 --> 0x0C
545
   - Socket and Copy Register at address 0x98000206 --> 0x00
594
   - Socket and Copy Register at address 0x98000206 --> 0x00
546
  */
595
  */
547
 
596
 
548
  /* Check the PCCARD controller state */
597
  /* Check the PCCARD controller state */
549
  hpccard->State = HAL_PCCARD_STATE_BUSY;
598
  hpccard->State = HAL_PCCARD_STATE_BUSY;
550
 
599
 
551
  *(__IO uint8_t *)(PCCARD_ATTRIBUTE_SPACE_ADDRESS | ATA_CARD_CONFIGURATION) = 0x01;
600
  *(__IO uint8_t *)(PCCARD_ATTRIBUTE_SPACE_ADDRESS | ATA_CARD_CONFIGURATION) = 0x01;
552
   
601
 
553
  /* Check the PCCARD controller state */
602
  /* Check the PCCARD controller state */
554
  hpccard->State = HAL_PCCARD_STATE_READY;
603
  hpccard->State = HAL_PCCARD_STATE_READY;
555
 
604
 
556
  /* Process unlocked */
605
  /* Process unlocked */
557
  __HAL_UNLOCK(hpccard);  
606
  __HAL_UNLOCK(hpccard);
558
 
607
 
559
  return HAL_OK;
608
  return HAL_OK;
560
}
609
}
561
 
610
 
562
/**
611
/**
563
  * @brief  This function handles PCCARD device interrupt request.
612
  * @brief  This function handles PCCARD device interrupt request.
564
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
613
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
565
  *                the configuration information for PCCARD module.
614
  *                the configuration information for PCCARD module.
566
  * @retval HAL status
615
  * @retval HAL status
567
*/
616
  */
568
void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef *hpccard)
617
void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef *hpccard)
569
{
618
{
570
  /* Check PCCARD interrupt Rising edge flag */
619
  /* Check PCCARD interrupt Rising edge flag */
571
  if(__FSMC_PCCARD_GET_FLAG(hpccard->Instance, FSMC_FLAG_RISING_EDGE))
620
  if (__FSMC_PCCARD_GET_FLAG(hpccard->Instance, FSMC_FLAG_RISING_EDGE))
572
  {
621
  {
573
    /* PCCARD interrupt callback*/
622
    /* PCCARD interrupt callback*/
-
 
623
#if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
-
 
624
    hpccard->ItCallback(hpccard);
-
 
625
#else
574
    HAL_PCCARD_ITCallback(hpccard);
626
    HAL_PCCARD_ITCallback(hpccard);
-
 
627
#endif
575
 
628
 
576
    /* Clear PCCARD interrupt Rising edge pending bit */
629
    /* Clear PCCARD interrupt Rising edge pending bit */
577
    __FSMC_PCCARD_CLEAR_FLAG(hpccard->Instance, FSMC_FLAG_RISING_EDGE);
630
    __FSMC_PCCARD_CLEAR_FLAG(hpccard->Instance, FSMC_FLAG_RISING_EDGE);
578
  }
631
  }
579
 
632
 
580
  /* Check PCCARD interrupt Level flag */
633
  /* Check PCCARD interrupt Level flag */
581
  if(__FSMC_PCCARD_GET_FLAG(hpccard->Instance, FSMC_FLAG_LEVEL))
634
  if (__FSMC_PCCARD_GET_FLAG(hpccard->Instance, FSMC_FLAG_LEVEL))
582
  {
635
  {
583
    /* PCCARD interrupt callback*/
636
    /* PCCARD interrupt callback*/
-
 
637
#if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
-
 
638
    hpccard->ItCallback(hpccard);
-
 
639
#else
584
    HAL_PCCARD_ITCallback(hpccard);
640
    HAL_PCCARD_ITCallback(hpccard);
-
 
641
#endif
585
 
642
 
586
    /* Clear PCCARD interrupt Level pending bit */
643
    /* Clear PCCARD interrupt Level pending bit */
587
    __FSMC_PCCARD_CLEAR_FLAG(hpccard->Instance, FSMC_FLAG_LEVEL);
644
    __FSMC_PCCARD_CLEAR_FLAG(hpccard->Instance, FSMC_FLAG_LEVEL);
588
  }
645
  }
589
 
646
 
590
  /* Check PCCARD interrupt Falling edge flag */
647
  /* Check PCCARD interrupt Falling edge flag */
591
  if(__FSMC_PCCARD_GET_FLAG(hpccard->Instance, FSMC_FLAG_FALLING_EDGE))
648
  if (__FSMC_PCCARD_GET_FLAG(hpccard->Instance, FSMC_FLAG_FALLING_EDGE))
592
  {
649
  {
593
    /* PCCARD interrupt callback*/
650
    /* PCCARD interrupt callback*/
-
 
651
#if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
-
 
652
    hpccard->ItCallback(hpccard);
-
 
653
#else
594
    HAL_PCCARD_ITCallback(hpccard);
654
    HAL_PCCARD_ITCallback(hpccard);
-
 
655
#endif
595
 
656
 
596
    /* Clear PCCARD interrupt Falling edge pending bit */
657
    /* Clear PCCARD interrupt Falling edge pending bit */
597
    __FSMC_PCCARD_CLEAR_FLAG(hpccard->Instance, FSMC_FLAG_FALLING_EDGE);
658
    __FSMC_PCCARD_CLEAR_FLAG(hpccard->Instance, FSMC_FLAG_FALLING_EDGE);
598
  }
659
  }
599
 
660
 
600
  /* Check PCCARD interrupt FIFO empty flag */
661
  /* Check PCCARD interrupt FIFO empty flag */
601
  if(__FSMC_PCCARD_GET_FLAG(hpccard->Instance, FSMC_FLAG_FEMPT))
662
  if (__FSMC_PCCARD_GET_FLAG(hpccard->Instance, FSMC_FLAG_FEMPT))
602
  {
663
  {
603
    /* PCCARD interrupt callback*/
664
    /* PCCARD interrupt callback*/
-
 
665
#if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
-
 
666
    hpccard->ItCallback(hpccard);
-
 
667
#else
604
    HAL_PCCARD_ITCallback(hpccard);
668
    HAL_PCCARD_ITCallback(hpccard);
-
 
669
#endif
605
 
670
 
606
    /* Clear PCCARD interrupt FIFO empty pending bit */
671
    /* Clear PCCARD interrupt FIFO empty pending bit */
607
    __FSMC_PCCARD_CLEAR_FLAG(hpccard->Instance, FSMC_FLAG_FEMPT);
672
    __FSMC_PCCARD_CLEAR_FLAG(hpccard->Instance, FSMC_FLAG_FEMPT);
608
  }  
673
  }
609
 
-
 
610
}
674
}
611
 
675
 
612
/**
676
/**
613
  * @brief  PCCARD interrupt feature callback
677
  * @brief  PCCARD interrupt feature callback
614
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
678
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
615
  *                the configuration information for PCCARD module.
679
  *                the configuration information for PCCARD module.
616
  * @retval None
680
  * @retval None
617
  */
681
  */
618
__weak void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard)
682
__weak void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard)
619
{
683
{
Line 621... Line 685...
621
  UNUSED(hpccard);
685
  UNUSED(hpccard);
622
  /* NOTE : This function Should not be modified, when the callback is needed,
686
  /* NOTE : This function Should not be modified, when the callback is needed,
623
            the HAL_PCCARD_ITCallback could be implemented in the user file
687
            the HAL_PCCARD_ITCallback could be implemented in the user file
624
   */
688
   */
625
}
689
}
-
 
690
 
-
 
691
#if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
-
 
692
/**
-
 
693
  * @brief  Register a User PCCARD Callback
-
 
694
  *         To be used instead of the weak (surcharged) predefined callback
-
 
695
  * @param hpccard : PCCARD handle
-
 
696
  * @param CallbackId : ID of the callback to be registered
-
 
697
  *        This parameter can be one of the following values:
-
 
698
  *          @arg @ref HAL_PCCARD_MSP_INIT_CB_ID       PCCARD MspInit callback ID
-
 
699
  *          @arg @ref HAL_PCCARD_MSP_DEINIT_CB_ID     PCCARD MspDeInit callback ID
-
 
700
  *          @arg @ref HAL_PCCARD_IT_CB_ID             PCCARD IT callback ID
-
 
701
  * @param pCallback : pointer to the Callback function
-
 
702
  * @retval status
-
 
703
  */
-
 
704
HAL_StatusTypeDef HAL_PCCARD_RegisterCallback(PCCARD_HandleTypeDef *hpccard, HAL_PCCARD_CallbackIDTypeDef CallbackId,
-
 
705
                                              pPCCARD_CallbackTypeDef pCallback)
-
 
706
{
-
 
707
  HAL_StatusTypeDef status = HAL_OK;
-
 
708
 
-
 
709
  if (pCallback == NULL)
-
 
710
  {
-
 
711
    return HAL_ERROR;
-
 
712
  }
-
 
713
 
-
 
714
  /* Process locked */
-
 
715
  __HAL_LOCK(hpccard);
-
 
716
 
-
 
717
  if (hpccard->State == HAL_PCCARD_STATE_READY)
-
 
718
  {
-
 
719
    switch (CallbackId)
-
 
720
    {
-
 
721
      case HAL_PCCARD_MSP_INIT_CB_ID :
-
 
722
        hpccard->MspInitCallback = pCallback;
-
 
723
        break;
-
 
724
      case HAL_PCCARD_MSP_DEINIT_CB_ID :
-
 
725
        hpccard->MspDeInitCallback = pCallback;
-
 
726
        break;
-
 
727
      case HAL_PCCARD_IT_CB_ID :
-
 
728
        hpccard->ItCallback = pCallback;
-
 
729
        break;
-
 
730
      default :
-
 
731
        /* update return status */
-
 
732
        status =  HAL_ERROR;
-
 
733
        break;
-
 
734
    }
-
 
735
  }
-
 
736
  else if (hpccard->State == HAL_PCCARD_STATE_RESET)
-
 
737
  {
-
 
738
    switch (CallbackId)
-
 
739
    {
-
 
740
      case HAL_PCCARD_MSP_INIT_CB_ID :
-
 
741
        hpccard->MspInitCallback = pCallback;
-
 
742
        break;
-
 
743
      case HAL_PCCARD_MSP_DEINIT_CB_ID :
-
 
744
        hpccard->MspDeInitCallback = pCallback;
-
 
745
        break;
-
 
746
      default :
-
 
747
        /* update return status */
-
 
748
        status =  HAL_ERROR;
-
 
749
        break;
-
 
750
    }
-
 
751
  }
-
 
752
  else
-
 
753
  {
-
 
754
    /* update return status */
-
 
755
    status =  HAL_ERROR;
-
 
756
  }
-
 
757
 
-
 
758
  /* Release Lock */
-
 
759
  __HAL_UNLOCK(hpccard);
-
 
760
  return status;
-
 
761
}
-
 
762
 
-
 
763
/**
-
 
764
  * @brief  Unregister a User PCCARD Callback
-
 
765
  *         PCCARD Callback is redirected to the weak (surcharged) predefined callback
-
 
766
  * @param hpccard : PCCARD handle
-
 
767
  * @param CallbackId : ID of the callback to be unregistered
-
 
768
  *        This parameter can be one of the following values:
-
 
769
  *          @arg @ref HAL_PCCARD_MSP_INIT_CB_ID       PCCARD MspInit callback ID
-
 
770
  *          @arg @ref HAL_PCCARD_MSP_DEINIT_CB_ID     PCCARD MspDeInit callback ID
-
 
771
  *          @arg @ref HAL_PCCARD_IT_CB_ID             PCCARD IT callback ID
-
 
772
  * @retval status
-
 
773
  */
-
 
774
HAL_StatusTypeDef HAL_PCCARD_UnRegisterCallback(PCCARD_HandleTypeDef *hpccard, HAL_PCCARD_CallbackIDTypeDef CallbackId)
-
 
775
{
-
 
776
  HAL_StatusTypeDef status = HAL_OK;
-
 
777
 
-
 
778
  /* Process locked */
-
 
779
  __HAL_LOCK(hpccard);
-
 
780
 
-
 
781
  if (hpccard->State == HAL_PCCARD_STATE_READY)
-
 
782
  {
-
 
783
    switch (CallbackId)
-
 
784
    {
-
 
785
      case HAL_PCCARD_MSP_INIT_CB_ID :
-
 
786
        hpccard->MspInitCallback = HAL_PCCARD_MspInit;
-
 
787
        break;
-
 
788
      case HAL_PCCARD_MSP_DEINIT_CB_ID :
-
 
789
        hpccard->MspDeInitCallback = HAL_PCCARD_MspDeInit;
-
 
790
        break;
-
 
791
      case HAL_PCCARD_IT_CB_ID :
-
 
792
        hpccard->ItCallback = HAL_PCCARD_ITCallback;
-
 
793
        break;
-
 
794
      default :
-
 
795
        /* update return status */
-
 
796
        status =  HAL_ERROR;
-
 
797
        break;
-
 
798
    }
-
 
799
  }
-
 
800
  else if (hpccard->State == HAL_PCCARD_STATE_RESET)
-
 
801
  {
-
 
802
    switch (CallbackId)
-
 
803
    {
-
 
804
      case HAL_PCCARD_MSP_INIT_CB_ID :
-
 
805
        hpccard->MspInitCallback = HAL_PCCARD_MspInit;
-
 
806
        break;
-
 
807
      case HAL_PCCARD_MSP_DEINIT_CB_ID :
-
 
808
        hpccard->MspDeInitCallback = HAL_PCCARD_MspDeInit;
-
 
809
        break;
-
 
810
      default :
-
 
811
        /* update return status */
-
 
812
        status =  HAL_ERROR;
-
 
813
        break;
-
 
814
    }
-
 
815
  }
-
 
816
  else
-
 
817
  {
-
 
818
    /* update return status */
-
 
819
    status =  HAL_ERROR;
626
 
820
  }
-
 
821
 
-
 
822
  /* Release Lock */
-
 
823
  __HAL_UNLOCK(hpccard);
-
 
824
  return status;
-
 
825
}
-
 
826
#endif
-
 
827
 
627
/**
828
/**
628
  * @}
829
  * @}
629
  */
830
  */
630
 
831
 
631
/** @defgroup PCCARD_Exported_Functions_Group3 Peripheral State functions
832
/** @defgroup PCCARD_Exported_Functions_Group3 State functions
632
 *  @brief   Peripheral State functions
833
  *  @brief   Peripheral State functions
633
 *
834
  *
634
@verbatim  
835
@verbatim
-
 
836
  ==============================================================================
-
 
837
                      ##### PCCARD State functions #####
635
  ==============================================================================
838
  ==============================================================================
636
                   ##### PCCARD Peripheral State functions #####
-
 
637
  ==============================================================================  
-
 
638
  [..]
839
  [..]
639
    This subsection permits to get in run-time the status of the PCCARD controller
840
    This subsection permits to get in run-time the status of the PCCARD controller
640
    and the data flow.
841
    and the data flow.
641
 
842
 
642
@endverbatim
843
@endverbatim
643
  * @{
844
  * @{
644
  */
845
  */
645
 
846
 
646
/**
847
/**
647
  * @brief  return the PCCARD controller state
848
  * @brief  return the PCCARD controller state
648
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
849
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
649
  *                the configuration information for PCCARD module.
850
  *                the configuration information for PCCARD module.
650
  * @retval HAL state
851
  * @retval HAL state
651
  */
852
  */
652
HAL_PCCARD_StateTypeDef HAL_PCCARD_GetState(PCCARD_HandleTypeDef *hpccard)
853
HAL_PCCARD_StateTypeDef HAL_PCCARD_GetState(PCCARD_HandleTypeDef *hpccard)
653
{
854
{
654
  return hpccard->State;
855
  return hpccard->State;
655
}  
856
}
656
 
857
 
657
/**
858
/**
658
  * @brief  Get the compact flash memory status
859
  * @brief  Get the compact flash memory status
659
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
860
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
660
  *                the configuration information for PCCARD module.      
861
  *                the configuration information for PCCARD module.
661
  * @retval New status of the CF operation. This parameter can be:
862
  * @retval New status of the PCCARD operation. This parameter can be:
662
  *          - CompactFlash_TIMEOUT_ERROR: when the previous operation generate
863
  *          - CompactFlash_TIMEOUT_ERROR: when the previous operation generate
663
  *            a Timeout error
864
  *            a Timeout error
664
  *          - CompactFlash_READY: when memory is ready for the next operation    
865
  *          - CompactFlash_READY: when memory is ready for the next operation
665
  *                
-
 
666
  */
866
  */
667
HAL_PCCARD_StatusTypeDef HAL_PCCARD_GetStatus(PCCARD_HandleTypeDef *hpccard)
867
HAL_PCCARD_StatusTypeDef HAL_PCCARD_GetStatus(PCCARD_HandleTypeDef *hpccard)
668
{
868
{
669
  uint32_t timeout = PCCARD_TIMEOUT_STATUS, status_cf = 0;  
869
  uint32_t timeout = PCCARD_TIMEOUT_STATUS, status_pccard = 0U;
670
 
870
 
671
  /* Check the PCCARD controller state */
871
  /* Check the PCCARD controller state */
672
  if(hpccard->State == HAL_PCCARD_STATE_BUSY)
872
  if (hpccard->State == HAL_PCCARD_STATE_BUSY)
673
  {
873
  {
674
     return HAL_PCCARD_STATUS_ONGOING;
874
    return HAL_PCCARD_STATUS_ONGOING;
675
  }
875
  }
676
 
876
 
677
  status_cf =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
877
  status_pccard =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
678
 
878
 
679
  while((status_cf == PCCARD_BUSY) && timeout)
879
  while ((status_pccard == PCCARD_BUSY) && timeout)
680
  {
880
  {
681
    status_cf =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
881
    status_pccard =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
682
    timeout--;
882
    timeout--;
683
  }
883
  }
684
 
884
 
685
  if(timeout == 0U)
885
  if (timeout == 0U)
686
  {          
886
  {
687
    status_cf =  PCCARD_TIMEOUT_ERROR;      
887
    status_pccard =  PCCARD_TIMEOUT_ERROR;
688
  }  
888
  }
689
 
889
 
690
  /* Return the operation status */
890
  /* Return the operation status */
691
  return (HAL_PCCARD_StatusTypeDef) status_cf;      
891
  return (HAL_PCCARD_StatusTypeDef) status_pccard;
692
}
892
}
693
 
893
 
694
/**
894
/**
695
  * @brief  Reads the Compact Flash memory status using the Read status command
895
  * @brief  Reads the Compact Flash memory status using the Read status command
696
  * @param  hpccard: pointer to a PCCARD_HandleTypeDef structure that contains
896
  * @param  hpccard pointer to a PCCARD_HandleTypeDef structure that contains
697
  *                the configuration information for PCCARD module.      
897
  *                the configuration information for PCCARD module.
698
  * @retval The status of the Compact Flash memory. This parameter can be:
898
  * @retval The status of the Compact Flash memory. This parameter can be:
699
  *          - CompactFlash_BUSY: when memory is busy
899
  *          - CompactFlash_BUSY: when memory is busy
700
  *          - CompactFlash_READY: when memory is ready for the next operation    
900
  *          - CompactFlash_READY: when memory is ready for the next operation
701
  *          - CompactFlash_ERROR: when the previous operation gererates error                
901
  *          - CompactFlash_ERROR: when the previous operation generates error
702
  */
902
  */
703
HAL_PCCARD_StatusTypeDef HAL_PCCARD_ReadStatus(PCCARD_HandleTypeDef *hpccard)
903
HAL_PCCARD_StatusTypeDef HAL_PCCARD_ReadStatus(PCCARD_HandleTypeDef *hpccard)
704
{
904
{
705
  uint8_t data = 0U, status_cf = PCCARD_BUSY;
905
  uint8_t data = 0U, status_pccard = PCCARD_BUSY;
706
 
906
 
707
  /* Check the PCCARD controller state */
907
  /* Check the PCCARD controller state */
708
  if(hpccard->State == HAL_PCCARD_STATE_BUSY)
908
  if (hpccard->State == HAL_PCCARD_STATE_BUSY)
709
  {
909
  {
710
     return HAL_PCCARD_STATUS_ONGOING;
910
    return HAL_PCCARD_STATUS_ONGOING;
711
  }
911
  }
712
 
912
 
713
  /* Read status operation */
913
  /* Read status operation */
714
  data =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
914
  data =  *(__IO uint8_t *)(PCCARD_IO_SPACE_PRIMARY_ADDR | ATA_STATUS_CMD_ALTERNATE);
715
 
915
 
716
  if((data & PCCARD_TIMEOUT_ERROR) == PCCARD_TIMEOUT_ERROR)
916
  if ((data & PCCARD_TIMEOUT_ERROR) == PCCARD_TIMEOUT_ERROR)
-
 
917
  {
-
 
918
    status_pccard = PCCARD_TIMEOUT_ERROR;
-
 
919
  }
-
 
920
  else if ((data & PCCARD_READY) == PCCARD_READY)
717
  {
921
  {
718
    status_cf = PCCARD_TIMEOUT_ERROR;
-
 
719
  }
-
 
720
  else if((data & PCCARD_READY) == PCCARD_READY)
-
 
721
  {
-
 
722
    status_cf = PCCARD_READY;
922
    status_pccard = PCCARD_READY;
723
  }
923
  }
724
 
924
 
725
  return (HAL_PCCARD_StatusTypeDef) status_cf;
925
  return (HAL_PCCARD_StatusTypeDef) status_pccard;
726
}  
926
}
727
 
927
 
728
/**
928
/**
729
  * @}
929
  * @}
730
  */
930
  */
731
 
931
 
732
/**
932
/**
733
  * @}
933
  * @}
734
  */
934
  */
-
 
935
 
735
/**
936
/**
736
  * @}
937
  * @}
737
  */
938
  */
738
 
939
 
739
#endif /* STM32F101xE || STM32F103xE || STM32F101xG || STM32F103xG */
-
 
740
#endif /* HAL_PCCARD_MODULE_ENABLED */  
940
#endif /* HAL_PCCARD_MODULE_ENABLED */
741
 
941
 
742
/**
942
/**
743
  * @}
943
  * @}
744
  */
944
  */
745
 
945
 
-
 
946
#endif /* FSMC_BANK4 */
-
 
947
 
746
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
948
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/