1 | /**
|
---|
2 | ******************************************************************************
|
---|
3 | * @file stm32f4xx_hal_pccard.h
|
---|
4 | * @author MCD Application Team
|
---|
5 | * @brief Header file of PCCARD HAL module.
|
---|
6 | ******************************************************************************
|
---|
7 | * @attention
|
---|
8 | *
|
---|
9 | * <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
---|
10 | * All rights reserved.</center></h2>
|
---|
11 | *
|
---|
12 | * This software component is licensed by ST under BSD 3-Clause license,
|
---|
13 | * the "License"; You may not use this file except in compliance with the
|
---|
14 | * License. You may obtain a copy of the License at:
|
---|
15 | * opensource.org/licenses/BSD-3-Clause
|
---|
16 | *
|
---|
17 | ******************************************************************************
|
---|
18 | */
|
---|
19 |
|
---|
20 | /* Define to prevent recursive inclusion -------------------------------------*/
|
---|
21 | #ifndef __STM32F4xx_HAL_PCCARD_H
|
---|
22 | #define __STM32F4xx_HAL_PCCARD_H
|
---|
23 |
|
---|
24 | #ifdef __cplusplus
|
---|
25 | extern "C" {
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | /* Includes ------------------------------------------------------------------*/
|
---|
29 | #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
|
---|
30 | #include "stm32f4xx_ll_fsmc.h"
|
---|
31 | #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
|
---|
32 |
|
---|
33 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
|
---|
34 | #include "stm32f4xx_ll_fmc.h"
|
---|
35 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
|
---|
36 |
|
---|
37 | /** @addtogroup STM32F4xx_HAL_Driver
|
---|
38 | * @{
|
---|
39 | */
|
---|
40 |
|
---|
41 | #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
|
---|
42 | defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
|
---|
43 |
|
---|
44 | /** @addtogroup PCCARD
|
---|
45 | * @{
|
---|
46 | */
|
---|
47 |
|
---|
48 | /* Exported typedef ----------------------------------------------------------*/
|
---|
49 | /** @defgroup PCCARD_Exported_Types PCCARD Exported Types
|
---|
50 | * @{
|
---|
51 | */
|
---|
52 |
|
---|
53 | /**
|
---|
54 | * @brief HAL PCCARD State structures definition
|
---|
55 | */
|
---|
56 | typedef enum
|
---|
57 | {
|
---|
58 | HAL_PCCARD_STATE_RESET = 0x00U, /*!< PCCARD peripheral not yet initialized or disabled */
|
---|
59 | HAL_PCCARD_STATE_READY = 0x01U, /*!< PCCARD peripheral ready */
|
---|
60 | HAL_PCCARD_STATE_BUSY = 0x02U, /*!< PCCARD peripheral busy */
|
---|
61 | HAL_PCCARD_STATE_ERROR = 0x04U /*!< PCCARD peripheral error */
|
---|
62 | }HAL_PCCARD_StateTypeDef;
|
---|
63 |
|
---|
64 | typedef enum
|
---|
65 | {
|
---|
66 | HAL_PCCARD_STATUS_SUCCESS = 0U,
|
---|
67 | HAL_PCCARD_STATUS_ONGOING,
|
---|
68 | HAL_PCCARD_STATUS_ERROR,
|
---|
69 | HAL_PCCARD_STATUS_TIMEOUT
|
---|
70 | }HAL_PCCARD_StatusTypeDef;
|
---|
71 |
|
---|
72 | /**
|
---|
73 | * @brief FMC_PCCARD handle Structure definition
|
---|
74 | */
|
---|
75 | #if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
|
---|
76 | typedef struct __PCCARD_HandleTypeDef
|
---|
77 | #else
|
---|
78 | typedef struct
|
---|
79 | #endif /* USE_HAL_PCCARD_REGISTER_CALLBACKS */
|
---|
80 | {
|
---|
81 | FMC_PCCARD_TypeDef *Instance; /*!< Register base address for PCCARD device */
|
---|
82 |
|
---|
83 | FMC_PCCARD_InitTypeDef Init; /*!< PCCARD device control configuration parameters */
|
---|
84 |
|
---|
85 | __IO HAL_PCCARD_StateTypeDef State; /*!< PCCARD device access state */
|
---|
86 |
|
---|
87 | HAL_LockTypeDef Lock; /*!< PCCARD Lock */
|
---|
88 |
|
---|
89 | #if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
|
---|
90 | void (* MspInitCallback) ( struct __PCCARD_HandleTypeDef * hpccard); /*!< PCCARD Msp Init callback */
|
---|
91 | void (* MspDeInitCallback) ( struct __PCCARD_HandleTypeDef * hpccard); /*!< PCCARD Msp DeInit callback */
|
---|
92 | void (* ItCallback) ( struct __PCCARD_HandleTypeDef * hpccard); /*!< PCCARD IT callback */
|
---|
93 | #endif
|
---|
94 | } PCCARD_HandleTypeDef;
|
---|
95 |
|
---|
96 | #if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
|
---|
97 | /**
|
---|
98 | * @brief HAL PCCARD Callback ID enumeration definition
|
---|
99 | */
|
---|
100 | typedef enum
|
---|
101 | {
|
---|
102 | HAL_PCCARD_MSP_INIT_CB_ID = 0x00U, /*!< PCCARD MspInit Callback ID */
|
---|
103 | HAL_PCCARD_MSP_DEINIT_CB_ID = 0x01U, /*!< PCCARD MspDeInit Callback ID */
|
---|
104 | HAL_PCCARD_IT_CB_ID = 0x02U /*!< PCCARD IT Callback ID */
|
---|
105 | }HAL_PCCARD_CallbackIDTypeDef;
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * @brief HAL PCCARD Callback pointer definition
|
---|
109 | */
|
---|
110 | typedef void (*pPCCARD_CallbackTypeDef)(PCCARD_HandleTypeDef *hpccard);
|
---|
111 | #endif
|
---|
112 | /**
|
---|
113 | * @}
|
---|
114 | */
|
---|
115 |
|
---|
116 | /* Exported constants --------------------------------------------------------*/
|
---|
117 | /* Exported macro ------------------------------------------------------------*/
|
---|
118 | /** @defgroup PCCARD_Exported_Macros PCCARD Exported Macros
|
---|
119 | * @{
|
---|
120 | */
|
---|
121 | /** @brief Reset PCCARD handle state
|
---|
122 | * @param __HANDLE__ specifies the PCCARD handle.
|
---|
123 | * @retval None
|
---|
124 | */
|
---|
125 | #if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
|
---|
126 | #define __HAL_PCCARD_RESET_HANDLE_STATE(__HANDLE__) do { \
|
---|
127 | (__HANDLE__)->State = HAL_PCCARD_STATE_RESET; \
|
---|
128 | (__HANDLE__)->MspInitCallback = NULL; \
|
---|
129 | (__HANDLE__)->MspDeInitCallback = NULL; \
|
---|
130 | } while(0)
|
---|
131 | #else
|
---|
132 | #define __HAL_PCCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_PCCARD_STATE_RESET)
|
---|
133 | #endif
|
---|
134 | /**
|
---|
135 | * @}
|
---|
136 | */
|
---|
137 |
|
---|
138 | /* Exported functions --------------------------------------------------------*/
|
---|
139 | /** @addtogroup PCCARD_Exported_Functions
|
---|
140 | * @{
|
---|
141 | */
|
---|
142 |
|
---|
143 | /** @addtogroup PCCARD_Exported_Functions_Group1
|
---|
144 | * @{
|
---|
145 | */
|
---|
146 | /* Initialization/de-initialization functions **********************************/
|
---|
147 | HAL_StatusTypeDef HAL_PCCARD_Init(PCCARD_HandleTypeDef *hpccard, FMC_NAND_PCC_TimingTypeDef *ComSpaceTiming, FMC_NAND_PCC_TimingTypeDef *AttSpaceTiming, FMC_NAND_PCC_TimingTypeDef *IOSpaceTiming);
|
---|
148 | HAL_StatusTypeDef HAL_PCCARD_DeInit(PCCARD_HandleTypeDef *hpccard);
|
---|
149 | void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef *hpccard);
|
---|
150 | void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef *hpccard);
|
---|
151 | /**
|
---|
152 | * @}
|
---|
153 | */
|
---|
154 |
|
---|
155 | /** @addtogroup PCCARD_Exported_Functions_Group2
|
---|
156 | * @{
|
---|
157 | */
|
---|
158 | /* IO operation functions *****************************************************/
|
---|
159 | HAL_StatusTypeDef HAL_PCCARD_Read_ID(PCCARD_HandleTypeDef *hpccard, uint8_t CompactFlash_ID[], uint8_t *pStatus);
|
---|
160 | HAL_StatusTypeDef HAL_PCCARD_Write_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress, uint8_t *pStatus);
|
---|
161 | HAL_StatusTypeDef HAL_PCCARD_Read_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress, uint8_t *pStatus);
|
---|
162 | HAL_StatusTypeDef HAL_PCCARD_Erase_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t SectorAddress, uint8_t *pStatus);
|
---|
163 | HAL_StatusTypeDef HAL_PCCARD_Reset(PCCARD_HandleTypeDef *hpccard);
|
---|
164 | void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef *hpccard);
|
---|
165 | void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard);
|
---|
166 |
|
---|
167 | #if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
|
---|
168 | /* PCCARD callback registering/unregistering */
|
---|
169 | HAL_StatusTypeDef HAL_PCCARD_RegisterCallback(PCCARD_HandleTypeDef *hpccard, HAL_PCCARD_CallbackIDTypeDef CallbackId, pPCCARD_CallbackTypeDef pCallback);
|
---|
170 | HAL_StatusTypeDef HAL_PCCARD_UnRegisterCallback(PCCARD_HandleTypeDef *hpccard, HAL_PCCARD_CallbackIDTypeDef CallbackId);
|
---|
171 | #endif
|
---|
172 | /**
|
---|
173 | * @}
|
---|
174 | */
|
---|
175 |
|
---|
176 | /** @addtogroup PCCARD_Exported_Functions_Group3
|
---|
177 | * @{
|
---|
178 | */
|
---|
179 | /* PCCARD State functions *******************************************************/
|
---|
180 | HAL_PCCARD_StateTypeDef HAL_PCCARD_GetState(PCCARD_HandleTypeDef *hpccard);
|
---|
181 | HAL_PCCARD_StatusTypeDef HAL_PCCARD_GetStatus(PCCARD_HandleTypeDef *hpccard);
|
---|
182 | HAL_PCCARD_StatusTypeDef HAL_PCCARD_ReadStatus(PCCARD_HandleTypeDef *hpccard);
|
---|
183 | /**
|
---|
184 | * @}
|
---|
185 | */
|
---|
186 |
|
---|
187 | /**
|
---|
188 | * @}
|
---|
189 | */
|
---|
190 | /* Private types -------------------------------------------------------------*/
|
---|
191 | /* Private variables ---------------------------------------------------------*/
|
---|
192 | /* Private constants ---------------------------------------------------------*/
|
---|
193 | /** @defgroup PCCARD_Private_Constants PCCARD Private Constants
|
---|
194 | * @{
|
---|
195 | */
|
---|
196 | #define PCCARD_DEVICE_ADDRESS 0x90000000U
|
---|
197 | #define PCCARD_ATTRIBUTE_SPACE_ADDRESS 0x98000000U /* Attribute space size to @0x9BFF FFFF */
|
---|
198 | #define PCCARD_COMMON_SPACE_ADDRESS PCCARD_DEVICE_ADDRESS /* Common space size to @0x93FF FFFF */
|
---|
199 | #define PCCARD_IO_SPACE_ADDRESS 0x9C000000U /* IO space size to @0x9FFF FFFF */
|
---|
200 | #define PCCARD_IO_SPACE_PRIMARY_ADDR 0x9C0001F0U /* IO space size to @0x9FFF FFFF */
|
---|
201 |
|
---|
202 | /* Flash-ATA registers description */
|
---|
203 | #define ATA_DATA ((uint8_t)0x00) /* Data register */
|
---|
204 | #define ATA_SECTOR_COUNT ((uint8_t)0x02) /* Sector Count register */
|
---|
205 | #define ATA_SECTOR_NUMBER ((uint8_t)0x03) /* Sector Number register */
|
---|
206 | #define ATA_CYLINDER_LOW ((uint8_t)0x04) /* Cylinder low register */
|
---|
207 | #define ATA_CYLINDER_HIGH ((uint8_t)0x05) /* Cylinder high register */
|
---|
208 | #define ATA_CARD_HEAD ((uint8_t)0x06) /* Card/Head register */
|
---|
209 | #define ATA_STATUS_CMD ((uint8_t)0x07) /* Status(read)/Command(write) register */
|
---|
210 | #define ATA_STATUS_CMD_ALTERNATE ((uint8_t)0x0E) /* Alternate Status(read)/Command(write) register */
|
---|
211 | #define ATA_COMMON_DATA_AREA ((uint16_t)0x0400) /* Start of data area (for Common access only!) */
|
---|
212 | #define ATA_CARD_CONFIGURATION ((uint16_t)0x0202) /* Card Configuration and Status Register */
|
---|
213 |
|
---|
214 | /* Flash-ATA commands */
|
---|
215 | #define ATA_READ_SECTOR_CMD ((uint8_t)0x20)
|
---|
216 | #define ATA_WRITE_SECTOR_CMD ((uint8_t)0x30)
|
---|
217 | #define ATA_ERASE_SECTOR_CMD ((uint8_t)0xC0)
|
---|
218 | #define ATA_IDENTIFY_CMD ((uint8_t)0xEC)
|
---|
219 |
|
---|
220 | /* PC Card/Compact Flash status */
|
---|
221 | #define PCCARD_TIMEOUT_ERROR ((uint8_t)0x60)
|
---|
222 | #define PCCARD_BUSY ((uint8_t)0x80)
|
---|
223 | #define PCCARD_PROGR ((uint8_t)0x01)
|
---|
224 | #define PCCARD_READY ((uint8_t)0x40)
|
---|
225 |
|
---|
226 | #define PCCARD_SECTOR_SIZE 255U /* In half words */
|
---|
227 |
|
---|
228 | /**
|
---|
229 | * @}
|
---|
230 | */
|
---|
231 | /* Compact Flash redefinition */
|
---|
232 | #define HAL_CF_Init HAL_PCCARD_Init
|
---|
233 | #define HAL_CF_DeInit HAL_PCCARD_DeInit
|
---|
234 | #define HAL_CF_MspInit HAL_PCCARD_MspInit
|
---|
235 | #define HAL_CF_MspDeInit HAL_PCCARD_MspDeInit
|
---|
236 |
|
---|
237 | #define HAL_CF_Read_ID HAL_PCCARD_Read_ID
|
---|
238 | #define HAL_CF_Write_Sector HAL_PCCARD_Write_Sector
|
---|
239 | #define HAL_CF_Read_Sector HAL_PCCARD_Read_Sector
|
---|
240 | #define HAL_CF_Erase_Sector HAL_PCCARD_Erase_Sector
|
---|
241 | #define HAL_CF_Reset HAL_PCCARD_Reset
|
---|
242 | #define HAL_CF_IRQHandler HAL_PCCARD_IRQHandler
|
---|
243 | #define HAL_CF_ITCallback HAL_PCCARD_ITCallback
|
---|
244 |
|
---|
245 | #define HAL_CF_GetState HAL_PCCARD_GetState
|
---|
246 | #define HAL_CF_GetStatus HAL_PCCARD_GetStatus
|
---|
247 | #define HAL_CF_ReadStatus HAL_PCCARD_ReadStatus
|
---|
248 |
|
---|
249 | #define HAL_CF_STATUS_SUCCESS HAL_PCCARD_STATUS_SUCCESS
|
---|
250 | #define HAL_CF_STATUS_ONGOING HAL_PCCARD_STATUS_ONGOING
|
---|
251 | #define HAL_CF_STATUS_ERROR HAL_PCCARD_STATUS_ERROR
|
---|
252 | #define HAL_CF_STATUS_TIMEOUT HAL_PCCARD_STATUS_TIMEOUT
|
---|
253 | #define HAL_CF_StatusTypeDef HAL_PCCARD_StatusTypeDef
|
---|
254 |
|
---|
255 | #define CF_DEVICE_ADDRESS PCCARD_DEVICE_ADDRESS
|
---|
256 | #define CF_ATTRIBUTE_SPACE_ADDRESS PCCARD_ATTRIBUTE_SPACE_ADDRESS
|
---|
257 | #define CF_COMMON_SPACE_ADDRESS PCCARD_COMMON_SPACE_ADDRESS
|
---|
258 | #define CF_IO_SPACE_ADDRESS PCCARD_IO_SPACE_ADDRESS
|
---|
259 | #define CF_IO_SPACE_PRIMARY_ADDR PCCARD_IO_SPACE_PRIMARY_ADDR
|
---|
260 |
|
---|
261 | #define CF_TIMEOUT_ERROR PCCARD_TIMEOUT_ERROR
|
---|
262 | #define CF_BUSY PCCARD_BUSY
|
---|
263 | #define CF_PROGR PCCARD_PROGR
|
---|
264 | #define CF_READY PCCARD_READY
|
---|
265 |
|
---|
266 | #define CF_SECTOR_SIZE PCCARD_SECTOR_SIZE
|
---|
267 |
|
---|
268 | /* Private macros ------------------------------------------------------------*/
|
---|
269 | /**
|
---|
270 | * @}
|
---|
271 | */
|
---|
272 |
|
---|
273 | #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx ||\
|
---|
274 | STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
|
---|
275 |
|
---|
276 |
|
---|
277 | /**
|
---|
278 | * @}
|
---|
279 | */
|
---|
280 |
|
---|
281 | #ifdef __cplusplus
|
---|
282 | }
|
---|
283 | #endif
|
---|
284 |
|
---|
285 | #endif /* __STM32F4xx_HAL_PCCARD_H */
|
---|
286 |
|
---|
287 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
---|