21 #ifndef __STM32F4xx_HAL_PCCARD_H
22 #define __STM32F4xx_HAL_PCCARD_H
29 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
30 #include "stm32f4xx_ll_fsmc.h"
33 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
34 #include "stm32f4xx_ll_fmc.h"
41 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
42 defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
58 HAL_PCCARD_STATE_RESET = 0x00U,
59 HAL_PCCARD_STATE_READY = 0x01U,
60 HAL_PCCARD_STATE_BUSY = 0x02U,
61 HAL_PCCARD_STATE_ERROR = 0x04U
62 }HAL_PCCARD_StateTypeDef;
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;
75 #if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
76 typedef struct __PCCARD_HandleTypeDef
81 FMC_PCCARD_TypeDef *Instance;
83 FMC_PCCARD_InitTypeDef
Init;
85 __IO HAL_PCCARD_StateTypeDef State;
89 #if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
90 void (* MspInitCallback) (
struct __PCCARD_HandleTypeDef * hpccard);
91 void (* MspDeInitCallback) (
struct __PCCARD_HandleTypeDef * hpccard);
92 void (* ItCallback) (
struct __PCCARD_HandleTypeDef * hpccard);
94 } PCCARD_HandleTypeDef;
96 #if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
102 HAL_PCCARD_MSP_INIT_CB_ID = 0x00U,
103 HAL_PCCARD_MSP_DEINIT_CB_ID = 0x01U,
104 HAL_PCCARD_IT_CB_ID = 0x02U
105 }HAL_PCCARD_CallbackIDTypeDef;
110 typedef void (*pPCCARD_CallbackTypeDef)(PCCARD_HandleTypeDef *hpccard);
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; \
132 #define __HAL_PCCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_PCCARD_STATE_RESET)
149 void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef *hpccard);
150 void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef *hpccard);
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);
164 void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef *hpccard);
165 void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard);
167 #if (USE_HAL_PCCARD_REGISTER_CALLBACKS == 1)
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);
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);
196 #define PCCARD_DEVICE_ADDRESS 0x90000000U
197 #define PCCARD_ATTRIBUTE_SPACE_ADDRESS 0x98000000U
198 #define PCCARD_COMMON_SPACE_ADDRESS PCCARD_DEVICE_ADDRESS
199 #define PCCARD_IO_SPACE_ADDRESS 0x9C000000U
200 #define PCCARD_IO_SPACE_PRIMARY_ADDR 0x9C0001F0U
203 #define ATA_DATA ((uint8_t)0x00)
204 #define ATA_SECTOR_COUNT ((uint8_t)0x02)
205 #define ATA_SECTOR_NUMBER ((uint8_t)0x03)
206 #define ATA_CYLINDER_LOW ((uint8_t)0x04)
207 #define ATA_CYLINDER_HIGH ((uint8_t)0x05)
208 #define ATA_CARD_HEAD ((uint8_t)0x06)
209 #define ATA_STATUS_CMD ((uint8_t)0x07)
210 #define ATA_STATUS_CMD_ALTERNATE ((uint8_t)0x0E)
211 #define ATA_COMMON_DATA_AREA ((uint16_t)0x0400)
212 #define ATA_CARD_CONFIGURATION ((uint16_t)0x0202)
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)
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)
226 #define PCCARD_SECTOR_SIZE 255U
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
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
245 #define HAL_CF_GetState HAL_PCCARD_GetState
246 #define HAL_CF_GetStatus HAL_PCCARD_GetStatus
247 #define HAL_CF_ReadStatus HAL_PCCARD_ReadStatus
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
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
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
266 #define CF_SECTOR_SIZE PCCARD_SECTOR_SIZE