2 ******************************************************************************
3 * @file stm32f4xx_hal_pccard.h
4 * @author MCD Application Team
7 * @brief Header file of PCCARD HAL module.
8 ******************************************************************************
11 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F4xx_HAL_PCCARD_H
40 #define __STM32F4xx_HAL_PCCARD_H
46 /* Includes ------------------------------------------------------------------*/
47 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
48 #include "stm32f4xx_ll_fsmc.h"
49 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
51 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
52 #include "stm32f4xx_ll_fmc.h"
53 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
55 /** @addtogroup STM32F4xx_HAL_Driver
59 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
60 defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
62 /** @addtogroup PCCARD
66 /* Exported typedef ----------------------------------------------------------*/
67 /** @defgroup PCCARD_Exported_Types PCCARD Exported Types
72 * @brief HAL PCCARD State structures definition
76 HAL_PCCARD_STATE_RESET
= 0x00U
, /*!< PCCARD peripheral not yet initialized or disabled */
77 HAL_PCCARD_STATE_READY
= 0x01U
, /*!< PCCARD peripheral ready */
78 HAL_PCCARD_STATE_BUSY
= 0x02U
, /*!< PCCARD peripheral busy */
79 HAL_PCCARD_STATE_ERROR
= 0x04U
/*!< PCCARD peripheral error */
80 }HAL_PCCARD_StateTypeDef
;
84 HAL_PCCARD_STATUS_SUCCESS
= 0U,
85 HAL_PCCARD_STATUS_ONGOING
,
86 HAL_PCCARD_STATUS_ERROR
,
87 HAL_PCCARD_STATUS_TIMEOUT
88 }HAL_PCCARD_StatusTypeDef
;
91 * @brief FMC_PCCARD handle Structure definition
95 FMC_PCCARD_TypeDef
*Instance
; /*!< Register base address for PCCARD device */
97 FMC_PCCARD_InitTypeDef Init
; /*!< PCCARD device control configuration parameters */
99 __IO HAL_PCCARD_StateTypeDef State
; /*!< PCCARD device access state */
101 HAL_LockTypeDef Lock
; /*!< PCCARD Lock */
103 }PCCARD_HandleTypeDef
;
108 /* Exported constants --------------------------------------------------------*/
109 /* Exported macro ------------------------------------------------------------*/
110 /** @defgroup PCCARD_Exported_Macros PCCARD Exported Macros
113 /** @brief Reset PCCARD handle state
114 * @param __HANDLE__: specifies the PCCARD handle.
117 #define __HAL_PCCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_PCCARD_STATE_RESET)
122 /* Exported functions --------------------------------------------------------*/
123 /** @addtogroup PCCARD_Exported_Functions
127 /** @addtogroup PCCARD_Exported_Functions_Group1
130 /* Initialization/de-initialization functions **********************************/
131 HAL_StatusTypeDef
HAL_PCCARD_Init(PCCARD_HandleTypeDef
*hpccard
, FMC_NAND_PCC_TimingTypeDef
*ComSpaceTiming
, FMC_NAND_PCC_TimingTypeDef
*AttSpaceTiming
, FMC_NAND_PCC_TimingTypeDef
*IOSpaceTiming
);
132 HAL_StatusTypeDef
HAL_PCCARD_DeInit(PCCARD_HandleTypeDef
*hpccard
);
133 void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef
*hpccard
);
134 void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef
*hpccard
);
139 /** @addtogroup PCCARD_Exported_Functions_Group2
142 /* IO operation functions *****************************************************/
143 HAL_StatusTypeDef
HAL_PCCARD_Read_ID(PCCARD_HandleTypeDef
*hpccard
, uint8_t CompactFlash_ID
[], uint8_t *pStatus
);
144 HAL_StatusTypeDef
HAL_PCCARD_Write_Sector(PCCARD_HandleTypeDef
*hpccard
, uint16_t *pBuffer
, uint16_t SectorAddress
, uint8_t *pStatus
);
145 HAL_StatusTypeDef
HAL_PCCARD_Read_Sector(PCCARD_HandleTypeDef
*hpccard
, uint16_t *pBuffer
, uint16_t SectorAddress
, uint8_t *pStatus
);
146 HAL_StatusTypeDef
HAL_PCCARD_Erase_Sector(PCCARD_HandleTypeDef
*hpccard
, uint16_t SectorAddress
, uint8_t *pStatus
);
147 HAL_StatusTypeDef
HAL_PCCARD_Reset(PCCARD_HandleTypeDef
*hpccard
);
148 void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef
*hpccard
);
149 void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef
*hpccard
);
155 /** @addtogroup PCCARD_Exported_Functions_Group3
158 /* PCCARD State functions *******************************************************/
159 HAL_PCCARD_StateTypeDef
HAL_PCCARD_GetState(PCCARD_HandleTypeDef
*hpccard
);
160 HAL_PCCARD_StatusTypeDef
HAL_PCCARD_GetStatus(PCCARD_HandleTypeDef
*hpccard
);
161 HAL_PCCARD_StatusTypeDef
HAL_PCCARD_ReadStatus(PCCARD_HandleTypeDef
*hpccard
);
169 /* Private types -------------------------------------------------------------*/
170 /* Private variables ---------------------------------------------------------*/
171 /* Private constants ---------------------------------------------------------*/
172 /** @defgroup PCCARD_Private_Constants PCCARD Private Constants
175 #define PCCARD_DEVICE_ADDRESS 0x90000000U
176 #define PCCARD_ATTRIBUTE_SPACE_ADDRESS 0x98000000U /* Attribute space size to @0x9BFF FFFF */
177 #define PCCARD_COMMON_SPACE_ADDRESS PCCARD_DEVICE_ADDRESS /* Common space size to @0x93FF FFFF */
178 #define PCCARD_IO_SPACE_ADDRESS 0x9C000000U /* IO space size to @0x9FFF FFFF */
179 #define PCCARD_IO_SPACE_PRIMARY_ADDR 0x9C0001F0U /* IO space size to @0x9FFF FFFF */
181 /* Flash-ATA registers description */
182 #define ATA_DATA ((uint8_t)0x00) /* Data register */
183 #define ATA_SECTOR_COUNT ((uint8_t)0x02) /* Sector Count register */
184 #define ATA_SECTOR_NUMBER ((uint8_t)0x03) /* Sector Number register */
185 #define ATA_CYLINDER_LOW ((uint8_t)0x04) /* Cylinder low register */
186 #define ATA_CYLINDER_HIGH ((uint8_t)0x05) /* Cylinder high register */
187 #define ATA_CARD_HEAD ((uint8_t)0x06) /* Card/Head register */
188 #define ATA_STATUS_CMD ((uint8_t)0x07) /* Status(read)/Command(write) register */
189 #define ATA_STATUS_CMD_ALTERNATE ((uint8_t)0x0E) /* Alternate Status(read)/Command(write) register */
190 #define ATA_COMMON_DATA_AREA ((uint16_t)0x0400) /* Start of data area (for Common access only!) */
191 #define ATA_CARD_CONFIGURATION ((uint16_t)0x0202) /* Card Configuration and Status Register */
193 /* Flash-ATA commands */
194 #define ATA_READ_SECTOR_CMD ((uint8_t)0x20)
195 #define ATA_WRITE_SECTOR_CMD ((uint8_t)0x30)
196 #define ATA_ERASE_SECTOR_CMD ((uint8_t)0xC0)
197 #define ATA_IDENTIFY_CMD ((uint8_t)0xEC)
199 /* PC Card/Compact Flash status */
200 #define PCCARD_TIMEOUT_ERROR ((uint8_t)0x60)
201 #define PCCARD_BUSY ((uint8_t)0x80)
202 #define PCCARD_PROGR ((uint8_t)0x01)
203 #define PCCARD_READY ((uint8_t)0x40)
205 #define PCCARD_SECTOR_SIZE 255U /* In half words */
210 /* Compact Flash redefinition */
211 #define HAL_CF_Init HAL_PCCARD_Init
212 #define HAL_CF_DeInit HAL_PCCARD_DeInit
213 #define HAL_CF_MspInit HAL_PCCARD_MspInit
214 #define HAL_CF_MspDeInit HAL_PCCARD_MspDeInit
216 #define HAL_CF_Read_ID HAL_PCCARD_Read_ID
217 #define HAL_CF_Write_Sector HAL_PCCARD_Write_Sector
218 #define HAL_CF_Read_Sector HAL_PCCARD_Read_Sector
219 #define HAL_CF_Erase_Sector HAL_PCCARD_Erase_Sector
220 #define HAL_CF_Reset HAL_PCCARD_Reset
221 #define HAL_CF_IRQHandler HAL_PCCARD_IRQHandler
222 #define HAL_CF_ITCallback HAL_PCCARD_ITCallback
224 #define HAL_CF_GetState HAL_PCCARD_GetState
225 #define HAL_CF_GetStatus HAL_PCCARD_GetStatus
226 #define HAL_CF_ReadStatus HAL_PCCARD_ReadStatus
228 #define HAL_CF_STATUS_SUCCESS HAL_PCCARD_STATUS_SUCCESS
229 #define HAL_CF_STATUS_ONGOING HAL_PCCARD_STATUS_ONGOING
230 #define HAL_CF_STATUS_ERROR HAL_PCCARD_STATUS_ERROR
231 #define HAL_CF_STATUS_TIMEOUT HAL_PCCARD_STATUS_TIMEOUT
232 #define HAL_CF_StatusTypeDef HAL_PCCARD_StatusTypeDef
234 #define CF_DEVICE_ADDRESS PCCARD_DEVICE_ADDRESS
235 #define CF_ATTRIBUTE_SPACE_ADDRESS PCCARD_ATTRIBUTE_SPACE_ADDRESS
236 #define CF_COMMON_SPACE_ADDRESS PCCARD_COMMON_SPACE_ADDRESS
237 #define CF_IO_SPACE_ADDRESS PCCARD_IO_SPACE_ADDRESS
238 #define CF_IO_SPACE_PRIMARY_ADDR PCCARD_IO_SPACE_PRIMARY_ADDR
240 #define CF_TIMEOUT_ERROR PCCARD_TIMEOUT_ERROR
241 #define CF_BUSY PCCARD_BUSY
242 #define CF_PROGR PCCARD_PROGR
243 #define CF_READY PCCARD_READY
245 #define CF_SECTOR_SIZE PCCARD_SECTOR_SIZE
247 /* Private macros ------------------------------------------------------------*/
252 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx ||\
253 STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
264 #endif /* __STM32F4xx_HAL_PCCARD_H */
266 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/