38
|
1 /**
|
|
2 ******************************************************************************
|
|
3 * @file stm32f4xx_hal_pccard.h
|
|
4 * @author MCD Application Team
|
|
5 * @version V1.2.0
|
|
6 * @date 26-December-2014
|
|
7 * @brief Header file of PCCARD HAL module.
|
|
8 ******************************************************************************
|
|
9 * @attention
|
|
10 *
|
|
11 * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
|
|
12 *
|
|
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.
|
|
23 *
|
|
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.
|
|
34 *
|
|
35 ******************************************************************************
|
|
36 */
|
|
37
|
|
38 /* Define to prevent recursive inclusion -------------------------------------*/
|
|
39 #ifndef __STM32F4xx_HAL_PCCARD_H
|
|
40 #define __STM32F4xx_HAL_PCCARD_H
|
|
41
|
|
42 #ifdef __cplusplus
|
|
43 extern "C" {
|
|
44 #endif
|
|
45
|
|
46 /* Includes ------------------------------------------------------------------*/
|
|
47 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx)
|
|
48 #include "stm32f4xx_ll_fsmc.h"
|
|
49 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
|
|
50
|
|
51 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx)
|
|
52 #include "stm32f4xx_ll_fmc.h"
|
|
53 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
|
|
54
|
|
55 /** @addtogroup STM32F4xx_HAL_Driver
|
|
56 * @{
|
|
57 */
|
|
58
|
|
59 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx)
|
|
60 /** @addtogroup PCCARD
|
|
61 * @{
|
|
62 */
|
|
63
|
|
64 /* Exported typedef ----------------------------------------------------------*/
|
|
65 /** @defgroup PCCARD_Exported_Types PCCARD Exported Types
|
|
66 * @{
|
|
67 */
|
|
68
|
|
69 /**
|
|
70 * @brief HAL PCCARD State structures definition
|
|
71 */
|
|
72 typedef enum
|
|
73 {
|
|
74 HAL_PCCARD_STATE_RESET = 0x00, /*!< PCCARD peripheral not yet initialized or disabled */
|
|
75 HAL_PCCARD_STATE_READY = 0x01, /*!< PCCARD peripheral ready */
|
|
76 HAL_PCCARD_STATE_BUSY = 0x02, /*!< PCCARD peripheral busy */
|
|
77 HAL_PCCARD_STATE_ERROR = 0x04 /*!< PCCARD peripheral error */
|
|
78 }HAL_PCCARD_StateTypeDef;
|
|
79
|
|
80 typedef enum
|
|
81 {
|
|
82 HAL_PCCARD_STATUS_SUCCESS = 0,
|
|
83 HAL_PCCARD_STATUS_ONGOING,
|
|
84 HAL_PCCARD_STATUS_ERROR,
|
|
85 HAL_PCCARD_STATUS_TIMEOUT
|
|
86 }HAL_PCCARD_StatusTypeDef;
|
|
87
|
|
88 /**
|
|
89 * @brief FMC_PCCARD handle Structure definition
|
|
90 */
|
|
91 typedef struct
|
|
92 {
|
|
93 FMC_PCCARD_TypeDef *Instance; /*!< Register base address for PCCARD device */
|
|
94
|
|
95 FMC_PCCARD_InitTypeDef Init; /*!< PCCARD device control configuration parameters */
|
|
96
|
|
97 __IO HAL_PCCARD_StateTypeDef State; /*!< PCCARD device access state */
|
|
98
|
|
99 HAL_LockTypeDef Lock; /*!< PCCARD Lock */
|
|
100
|
|
101 }PCCARD_HandleTypeDef;
|
|
102 /**
|
|
103 * @}
|
|
104 */
|
|
105
|
|
106 /* Exported constants --------------------------------------------------------*/
|
|
107 /* Exported macro ------------------------------------------------------------*/
|
|
108 /** @defgroup PCCARD_Exported_Macros PCCARD Exported Macros
|
|
109 * @{
|
|
110 */
|
|
111 /** @brief Reset PCCARD handle state
|
|
112 * @param __HANDLE__: specifies the PCCARD handle.
|
|
113 * @retval None
|
|
114 */
|
|
115 #define __HAL_PCCARD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_PCCARD_STATE_RESET)
|
|
116 /**
|
|
117 * @}
|
|
118 */
|
|
119
|
|
120 /* Exported functions --------------------------------------------------------*/
|
|
121 /** @addtogroup PCCARD_Exported_Functions
|
|
122 * @{
|
|
123 */
|
|
124
|
|
125 /** @addtogroup PCCARD_Exported_Functions_Group1
|
|
126 * @{
|
|
127 */
|
|
128 /* Initialization/de-initialization functions **********************************/
|
|
129 HAL_StatusTypeDef HAL_PCCARD_Init(PCCARD_HandleTypeDef *hpccard, FMC_NAND_PCC_TimingTypeDef *ComSpaceTiming, FMC_NAND_PCC_TimingTypeDef *AttSpaceTiming, FMC_NAND_PCC_TimingTypeDef *IOSpaceTiming);
|
|
130 HAL_StatusTypeDef HAL_PCCARD_DeInit(PCCARD_HandleTypeDef *hpccard);
|
|
131 void HAL_PCCARD_MspInit(PCCARD_HandleTypeDef *hpccard);
|
|
132 void HAL_PCCARD_MspDeInit(PCCARD_HandleTypeDef *hpccard);
|
|
133 /**
|
|
134 * @}
|
|
135 */
|
|
136
|
|
137 /** @addtogroup PCCARD_Exported_Functions_Group2
|
|
138 * @{
|
|
139 */
|
|
140 /* IO operation functions *****************************************************/
|
|
141 HAL_StatusTypeDef HAL_PCCARD_Read_ID(PCCARD_HandleTypeDef *hpccard, uint8_t CompactFlash_ID[], uint8_t *pStatus);
|
|
142 HAL_StatusTypeDef HAL_PCCARD_Write_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress, uint8_t *pStatus);
|
|
143 HAL_StatusTypeDef HAL_PCCARD_Read_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t *pBuffer, uint16_t SectorAddress, uint8_t *pStatus);
|
|
144 HAL_StatusTypeDef HAL_PCCARD_Erase_Sector(PCCARD_HandleTypeDef *hpccard, uint16_t SectorAddress, uint8_t *pStatus);
|
|
145 HAL_StatusTypeDef HAL_PCCARD_Reset(PCCARD_HandleTypeDef *hpccard);
|
|
146 void HAL_PCCARD_IRQHandler(PCCARD_HandleTypeDef *hpccard);
|
|
147 void HAL_PCCARD_ITCallback(PCCARD_HandleTypeDef *hpccard);
|
|
148
|
|
149 /**
|
|
150 * @}
|
|
151 */
|
|
152
|
|
153 /** @addtogroup PCCARD_Exported_Functions_Group3
|
|
154 * @{
|
|
155 */
|
|
156 /* PCCARD State functions *******************************************************/
|
|
157 HAL_PCCARD_StateTypeDef HAL_PCCARD_GetState(PCCARD_HandleTypeDef *hpccard);
|
|
158 HAL_PCCARD_StatusTypeDef HAL_PCCARD_GetStatus(PCCARD_HandleTypeDef *hpccard);
|
|
159 HAL_PCCARD_StatusTypeDef HAL_PCCARD_ReadStatus(PCCARD_HandleTypeDef *hpccard);
|
|
160 /**
|
|
161 * @}
|
|
162 */
|
|
163
|
|
164 /**
|
|
165 * @}
|
|
166 */
|
|
167 /* Private types -------------------------------------------------------------*/
|
|
168 /* Private variables ---------------------------------------------------------*/
|
|
169 /* Private constants ---------------------------------------------------------*/
|
|
170 /** @defgroup PCCARD_Private_Constants PCCARD Private Constants
|
|
171 * @{
|
|
172 */
|
|
173 #define PCCARD_DEVICE_ADDRESS ((uint32_t)0x90000000)
|
|
174 #define PCCARD_ATTRIBUTE_SPACE_ADDRESS ((uint32_t)0x98000000) /* Attribute space size to @0x9BFF FFFF */
|
|
175 #define PCCARD_COMMON_SPACE_ADDRESS PCCARD_DEVICE_ADDRESS /* Common space size to @0x93FF FFFF */
|
|
176 #define PCCARD_IO_SPACE_ADDRESS ((uint32_t)0x9C000000) /* IO space size to @0x9FFF FFFF */
|
|
177 #define PCCARD_IO_SPACE_PRIMARY_ADDR ((uint32_t)0x9C0001F0) /* IO space size to @0x9FFF FFFF */
|
|
178
|
|
179 /* Flash-ATA registers description */
|
|
180 #define ATA_DATA ((uint8_t)0x00) /* Data register */
|
|
181 #define ATA_SECTOR_COUNT ((uint8_t)0x02) /* Sector Count register */
|
|
182 #define ATA_SECTOR_NUMBER ((uint8_t)0x03) /* Sector Number register */
|
|
183 #define ATA_CYLINDER_LOW ((uint8_t)0x04) /* Cylinder low register */
|
|
184 #define ATA_CYLINDER_HIGH ((uint8_t)0x05) /* Cylinder high register */
|
|
185 #define ATA_CARD_HEAD ((uint8_t)0x06) /* Card/Head register */
|
|
186 #define ATA_STATUS_CMD ((uint8_t)0x07) /* Status(read)/Command(write) register */
|
|
187 #define ATA_STATUS_CMD_ALTERNATE ((uint8_t)0x0E) /* Alternate Status(read)/Command(write) register */
|
|
188 #define ATA_COMMON_DATA_AREA ((uint16_t)0x0400) /* Start of data area (for Common access only!) */
|
|
189
|
|
190 /* Flash-ATA commands */
|
|
191 #define ATA_READ_SECTOR_CMD ((uint8_t)0x20)
|
|
192 #define ATA_WRITE_SECTOR_CMD ((uint8_t)0x30)
|
|
193 #define ATA_ERASE_SECTOR_CMD ((uint8_t)0xC0)
|
|
194 #define ATA_IDENTIFY_CMD ((uint8_t)0xEC)
|
|
195
|
|
196 /* PC Card/Compact Flash status */
|
|
197 #define PCCARD_TIMEOUT_ERROR ((uint8_t)0x60)
|
|
198 #define PCCARD_BUSY ((uint8_t)0x80)
|
|
199 #define PCCARD_PROGR ((uint8_t)0x01)
|
|
200 #define PCCARD_READY ((uint8_t)0x40)
|
|
201
|
|
202 #define PCCARD_SECTOR_SIZE ((uint32_t)255) /* In half words */
|
|
203
|
|
204 /**
|
|
205 * @}
|
|
206 */
|
|
207 /* Compact Flash redefinition */
|
|
208 #define HAL_CF_Init HAL_PCCARD_Init
|
|
209 #define HAL_CF_DeInit HAL_PCCARD_DeInit
|
|
210 #define HAL_CF_MspInit HAL_PCCARD_MspInit
|
|
211 #define HAL_CF_MspDeInit HAL_PCCARD_MspDeInit
|
|
212
|
|
213 #define HAL_CF_Read_ID HAL_PCCARD_Read_ID
|
|
214 #define HAL_CF_Write_Sector HAL_PCCARD_Write_Sector
|
|
215 #define HAL_CF_Read_Sector HAL_PCCARD_Read_Sector
|
|
216 #define HAL_CF_Erase_Sector HAL_PCCARD_Erase_Sector
|
|
217 #define HAL_CF_Reset HAL_PCCARD_Reset
|
|
218 #define HAL_CF_IRQHandler HAL_PCCARD_IRQHandler
|
|
219 #define HAL_CF_ITCallback HAL_PCCARD_ITCallback
|
|
220
|
|
221 #define HAL_CF_GetState HAL_PCCARD_GetState
|
|
222 #define HAL_CF_GetStatus HAL_PCCARD_GetStatus
|
|
223 #define HAL_CF_ReadStatus HAL_PCCARD_ReadStatus
|
|
224
|
|
225 #define HAL_CF_STATUS_SUCCESS HAL_PCCARD_STATUS_SUCCESS
|
|
226 #define HAL_CF_STATUS_ONGOING HAL_PCCARD_STATUS_ONGOING
|
|
227 #define HAL_CF_STATUS_ERROR HAL_PCCARD_STATUS_ERROR
|
|
228 #define HAL_CF_STATUS_TIMEOUT HAL_PCCARD_STATUS_TIMEOUT
|
|
229 #define HAL_CF_StatusTypeDef HAL_PCCARD_StatusTypeDef
|
|
230
|
|
231
|
|
232 #define CF_DEVICE_ADDRESS PCCARD_DEVICE_ADDRESS
|
|
233 #define CF_ATTRIBUTE_SPACE_ADDRESS PCCARD_ATTRIBUTE_SPACE_ADDRESS
|
|
234 #define CF_COMMON_SPACE_ADDRESS PCCARD_COMMON_SPACE_ADDRESS
|
|
235 #define CF_IO_SPACE_ADDRESS PCCARD_IO_SPACE_ADDRESS
|
|
236 #define CF_IO_SPACE_PRIMARY_ADDR PCCARD_IO_SPACE_PRIMARY_ADDR
|
|
237
|
|
238 #define CF_TIMEOUT_ERROR PCCARD_TIMEOUT_ERROR
|
|
239 #define CF_BUSY PCCARD_BUSY
|
|
240 #define CF_PROGR PCCARD_PROGR
|
|
241 #define CF_READY PCCARD_READY
|
|
242
|
|
243 #define CF_SECTOR_SIZE PCCARD_SECTOR_SIZE
|
|
244
|
|
245 /* Private macros ------------------------------------------------------------*/
|
|
246 /**
|
|
247 * @}
|
|
248 */
|
|
249
|
|
250 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
|
|
251
|
|
252
|
|
253 /**
|
|
254 * @}
|
|
255 */
|
|
256
|
|
257 #ifdef __cplusplus
|
|
258 }
|
|
259 #endif
|
|
260
|
|
261 #endif /* __STM32F4xx_HAL_PCCARD_H */
|
|
262
|
|
263 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|