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