Rev 61 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 61 | Rev 77 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | /** |
1 | /** |
2 | ****************************************************************************** |
2 | ****************************************************************************** |
3 | * @file stm32l1xx_hal_sd.h |
3 | * @file stm32l1xx_hal_sd.h |
4 | * @author MCD Application Team |
4 | * @author MCD Application Team |
5 | * @brief Header file of SD HAL module. |
5 | * @brief Header file of SD HAL module. |
6 | ****************************************************************************** |
6 | ****************************************************************************** |
7 | * @attention |
7 | * @attention |
8 | * |
8 | * |
9 | * <h2><center>© Copyright (c) 2018 STMicroelectronics. |
9 | * Copyright (c) 2016 STMicroelectronics. |
10 | * All rights reserved.</center></h2> |
10 | * All rights reserved. |
11 | * |
11 | * |
12 | * This software component is licensed by ST under BSD 3-Clause license, |
12 | * This software is licensed under terms that can be found in the LICENSE file |
13 | * the "License"; You may not use this file except in compliance with the |
13 | * in the root directory of this software component. |
14 | * License. You may obtain a copy of the License at: |
14 | * If no LICENSE file comes with this software, it is provided AS-IS. |
15 | * opensource.org/licenses/BSD-3-Clause |
15 | * |
16 | * |
16 | ****************************************************************************** |
17 | ****************************************************************************** |
17 | */ |
18 | */ |
18 | |
19 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ |
|
20 | /* Define to prevent recursive inclusion -------------------------------------*/ |
20 | #ifndef STM32L1xx_HAL_SD_H |
21 | #ifndef STM32L1xx_HAL_SD_H |
21 | #define STM32L1xx_HAL_SD_H |
22 | #define STM32L1xx_HAL_SD_H |
22 | |
23 | 23 | #ifdef __cplusplus |
|
24 | #ifdef __cplusplus |
24 | extern "C" { |
25 | extern "C" { |
25 | #endif |
26 | #endif |
26 | |
27 | 27 | #if defined(SDIO) |
|
28 | #if defined(SDIO) |
28 | |
29 | 29 | /* Includes ------------------------------------------------------------------*/ |
|
30 | /* Includes ------------------------------------------------------------------*/ |
30 | #include "stm32l1xx_ll_sdmmc.h" |
31 | #include "stm32l1xx_ll_sdmmc.h" |
31 | |
32 | 32 | /** @addtogroup STM32L1xx_HAL_Driver |
|
33 | /** @addtogroup STM32L1xx_HAL_Driver |
33 | * @{ |
34 | * @{ |
34 | */ |
35 | */ |
35 | |
36 | 36 | /** @defgroup SD SD |
|
37 | /** @defgroup SD SD |
37 | * @brief SD HAL module driver |
38 | * @brief SD HAL module driver |
38 | * @{ |
39 | * @{ |
39 | */ |
40 | */ |
40 | |
41 | 41 | /* Exported types ------------------------------------------------------------*/ |
|
42 | /* Exported types ------------------------------------------------------------*/ |
42 | /** @defgroup SD_Exported_Types SD Exported Types |
43 | /** @defgroup SD_Exported_Types SD Exported Types |
43 | * @{ |
44 | * @{ |
44 | */ |
45 | */ |
45 | |
46 | 46 | /** @defgroup SD_Exported_Types_Group1 SD State enumeration structure |
|
47 | /** @defgroup SD_Exported_Types_Group1 SD State enumeration structure |
47 | * @{ |
48 | * @{ |
48 | */ |
49 | */ |
49 | typedef enum |
50 | typedef enum |
50 | { |
51 | { |
51 | HAL_SD_STATE_RESET = 0x00000000U, /*!< SD not yet initialized or disabled */ |
52 | HAL_SD_STATE_RESET = 0x00000000U, /*!< SD not yet initialized or disabled */ |
52 | HAL_SD_STATE_READY = 0x00000001U, /*!< SD initialized and ready for use */ |
53 | HAL_SD_STATE_READY = 0x00000001U, /*!< SD initialized and ready for use */ |
53 | HAL_SD_STATE_TIMEOUT = 0x00000002U, /*!< SD Timeout state */ |
54 | HAL_SD_STATE_TIMEOUT = 0x00000002U, /*!< SD Timeout state */ |
54 | HAL_SD_STATE_BUSY = 0x00000003U, /*!< SD process ongoing */ |
55 | HAL_SD_STATE_BUSY = 0x00000003U, /*!< SD process ongoing */ |
55 | HAL_SD_STATE_PROGRAMMING = 0x00000004U, /*!< SD Programming State */ |
56 | HAL_SD_STATE_PROGRAMMING = 0x00000004U, /*!< SD Programming State */ |
56 | HAL_SD_STATE_RECEIVING = 0x00000005U, /*!< SD Receiving State */ |
57 | HAL_SD_STATE_RECEIVING = 0x00000005U, /*!< SD Receiving State */ |
57 | HAL_SD_STATE_TRANSFER = 0x00000006U, /*!< SD Transfer State */ |
58 | HAL_SD_STATE_TRANSFER = 0x00000006U, /*!< SD Transfer State */ |
58 | HAL_SD_STATE_ERROR = 0x0000000FU /*!< SD is in error state */ |
59 | HAL_SD_STATE_ERROR = 0x0000000FU /*!< SD is in error state */ |
59 | }HAL_SD_StateTypeDef; |
60 | }HAL_SD_StateTypeDef; |
60 | /** |
61 | /** |
61 | * @} |
62 | * @} |
62 | */ |
63 | */ |
63 | |
64 | 64 | /** @defgroup SD_Exported_Types_Group2 SD Card State enumeration structure |
|
65 | /** @defgroup SD_Exported_Types_Group2 SD Card State enumeration structure |
65 | * @{ |
66 | * @{ |
66 | */ |
67 | */ |
67 | typedef uint32_t HAL_SD_CardStateTypeDef; |
68 | typedef uint32_t HAL_SD_CardStateTypeDef; |
68 | |
69 | 69 | #define HAL_SD_CARD_READY 0x00000001U /*!< Card state is ready */ |
|
70 | #define HAL_SD_CARD_READY 0x00000001U /*!< Card state is ready */ |
70 | #define HAL_SD_CARD_IDENTIFICATION 0x00000002U /*!< Card is in identification state */ |
71 | #define HAL_SD_CARD_IDENTIFICATION 0x00000002U /*!< Card is in identification state */ |
71 | #define HAL_SD_CARD_STANDBY 0x00000003U /*!< Card is in standby state */ |
72 | #define HAL_SD_CARD_STANDBY 0x00000003U /*!< Card is in standby state */ |
72 | #define HAL_SD_CARD_TRANSFER 0x00000004U /*!< Card is in transfer state */ |
73 | #define HAL_SD_CARD_TRANSFER 0x00000004U /*!< Card is in transfer state */ |
73 | #define HAL_SD_CARD_SENDING 0x00000005U /*!< Card is sending an operation */ |
74 | #define HAL_SD_CARD_SENDING 0x00000005U /*!< Card is sending an operation */ |
74 | #define HAL_SD_CARD_RECEIVING 0x00000006U /*!< Card is receiving operation information */ |
75 | #define HAL_SD_CARD_RECEIVING 0x00000006U /*!< Card is receiving operation information */ |
75 | #define HAL_SD_CARD_PROGRAMMING 0x00000007U /*!< Card is in programming state */ |
76 | #define HAL_SD_CARD_PROGRAMMING 0x00000007U /*!< Card is in programming state */ |
76 | #define HAL_SD_CARD_DISCONNECTED 0x00000008U /*!< Card is disconnected */ |
77 | #define HAL_SD_CARD_DISCONNECTED 0x00000008U /*!< Card is disconnected */ |
77 | #define HAL_SD_CARD_ERROR 0x000000FFU /*!< Card response Error */ |
78 | #define HAL_SD_CARD_ERROR 0x000000FFU /*!< Card response Error */ |
78 | /** |
79 | /** |
79 | * @} |
80 | * @} |
80 | */ |
81 | */ |
81 | |
82 | 82 | /** @defgroup SD_Exported_Types_Group3 SD Handle Structure definition |
|
83 | /** @defgroup SD_Exported_Types_Group3 SD Handle Structure definition |
83 | * @{ |
84 | * @{ |
84 | */ |
85 | */ |
85 | #define SD_InitTypeDef SDIO_InitTypeDef |
86 | #define SD_InitTypeDef SDIO_InitTypeDef |
86 | #define SD_TypeDef SDIO_TypeDef |
87 | #define SD_TypeDef SDIO_TypeDef |
87 | |
88 | 88 | /** |
|
89 | /** |
89 | * @brief SD Card Information Structure definition |
90 | * @brief SD Card Information Structure definition |
90 | */ |
91 | */ |
91 | typedef struct |
92 | typedef struct |
92 | { |
93 | { |
93 | uint32_t CardType; /*!< Specifies the card Type */ |
94 | uint32_t CardType; /*!< Specifies the card Type */ |
94 | |
95 | 95 | uint32_t CardVersion; /*!< Specifies the card version */ |
|
96 | uint32_t CardVersion; /*!< Specifies the card version */ |
96 | |
97 | 97 | uint32_t Class; /*!< Specifies the class of the card class */ |
|
98 | uint32_t Class; /*!< Specifies the class of the card class */ |
98 | |
99 | 99 | uint32_t RelCardAdd; /*!< Specifies the Relative Card Address */ |
|
100 | uint32_t RelCardAdd; /*!< Specifies the Relative Card Address */ |
100 | |
101 | 101 | uint32_t BlockNbr; /*!< Specifies the Card Capacity in blocks */ |
|
102 | uint32_t BlockNbr; /*!< Specifies the Card Capacity in blocks */ |
102 | |
103 | 103 | uint32_t BlockSize; /*!< Specifies one block size in bytes */ |
|
104 | uint32_t BlockSize; /*!< Specifies one block size in bytes */ |
104 | |
105 | 105 | uint32_t LogBlockNbr; /*!< Specifies the Card logical Capacity in blocks */ |
|
106 | uint32_t LogBlockNbr; /*!< Specifies the Card logical Capacity in blocks */ |
106 | |
107 | 107 | uint32_t LogBlockSize; /*!< Specifies logical block size in bytes */ |
|
108 | uint32_t LogBlockSize; /*!< Specifies logical block size in bytes */ |
108 | |
109 | 109 | }HAL_SD_CardInfoTypeDef; |
|
110 | }HAL_SD_CardInfoTypeDef; |
110 | |
111 | 111 | /** |
|
112 | /** |
112 | * @brief SD handle Structure definition |
113 | * @brief SD handle Structure definition |
113 | */ |
114 | */ |
114 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
115 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
115 | typedef struct __SD_HandleTypeDef |
116 | typedef struct __SD_HandleTypeDef |
116 | #else |
117 | #else |
117 | typedef struct |
118 | typedef struct |
118 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
119 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
119 | { |
120 | { |
120 | SD_TypeDef *Instance; /*!< SD registers base address */ |
121 | SD_TypeDef *Instance; /*!< SD registers base address */ |
121 | |
122 | 122 | SD_InitTypeDef Init; /*!< SD required parameters */ |
|
123 | SD_InitTypeDef Init; /*!< SD required parameters */ |
123 | |
124 | 124 | HAL_LockTypeDef Lock; /*!< SD locking object */ |
|
125 | HAL_LockTypeDef Lock; /*!< SD locking object */ |
125 | |
126 | 126 | uint8_t *pTxBuffPtr; /*!< Pointer to SD Tx transfer Buffer */ |
|
127 | uint8_t *pTxBuffPtr; /*!< Pointer to SD Tx transfer Buffer */ |
127 | |
128 | 128 | uint32_t TxXferSize; /*!< SD Tx Transfer size */ |
|
129 | uint32_t TxXferSize; /*!< SD Tx Transfer size */ |
129 | |
130 | 130 | uint8_t *pRxBuffPtr; /*!< Pointer to SD Rx transfer Buffer */ |
|
131 | uint8_t *pRxBuffPtr; /*!< Pointer to SD Rx transfer Buffer */ |
131 | |
132 | 132 | uint32_t RxXferSize; /*!< SD Rx Transfer size */ |
|
133 | uint32_t RxXferSize; /*!< SD Rx Transfer size */ |
133 | |
134 | 134 | __IO uint32_t Context; /*!< SD transfer context */ |
|
135 | __IO uint32_t Context; /*!< SD transfer context */ |
135 | |
136 | 136 | __IO HAL_SD_StateTypeDef State; /*!< SD card State */ |
|
137 | __IO HAL_SD_StateTypeDef State; /*!< SD card State */ |
137 | |
138 | 138 | __IO uint32_t ErrorCode; /*!< SD Card Error codes */ |
|
139 | __IO uint32_t ErrorCode; /*!< SD Card Error codes */ |
139 | |
140 | 140 | DMA_HandleTypeDef *hdmatx; /*!< SD Tx DMA handle parameters */ |
|
141 | DMA_HandleTypeDef *hdmatx; /*!< SD Tx DMA handle parameters */ |
141 | |
142 | 142 | DMA_HandleTypeDef *hdmarx; /*!< SD Rx DMA handle parameters */ |
|
143 | DMA_HandleTypeDef *hdmarx; /*!< SD Rx DMA handle parameters */ |
143 | |
144 | 144 | HAL_SD_CardInfoTypeDef SdCard; /*!< SD Card information */ |
|
145 | HAL_SD_CardInfoTypeDef SdCard; /*!< SD Card information */ |
145 | |
146 | 146 | uint32_t CSD[4]; /*!< SD card specific data table */ |
|
147 | uint32_t CSD[4]; /*!< SD card specific data table */ |
147 | |
148 | 148 | uint32_t CID[4]; /*!< SD card identification number table */ |
|
149 | uint32_t CID[4]; /*!< SD card identification number table */ |
149 | |
150 | 150 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
|
151 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
151 | void (* TxCpltCallback) (struct __SD_HandleTypeDef *hsd); |
152 | void (* TxCpltCallback) (struct __SD_HandleTypeDef *hsd); |
152 | void (* RxCpltCallback) (struct __SD_HandleTypeDef *hsd); |
153 | void (* RxCpltCallback) (struct __SD_HandleTypeDef *hsd); |
153 | void (* ErrorCallback) (struct __SD_HandleTypeDef *hsd); |
154 | void (* ErrorCallback) (struct __SD_HandleTypeDef *hsd); |
154 | void (* AbortCpltCallback) (struct __SD_HandleTypeDef *hsd); |
155 | void (* AbortCpltCallback) (struct __SD_HandleTypeDef *hsd); |
155 | |
156 | 156 | void (* MspInitCallback) (struct __SD_HandleTypeDef *hsd); |
|
157 | void (* MspInitCallback) (struct __SD_HandleTypeDef *hsd); |
157 | void (* MspDeInitCallback) (struct __SD_HandleTypeDef *hsd); |
158 | void (* MspDeInitCallback) (struct __SD_HandleTypeDef *hsd); |
158 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
159 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
159 | }SD_HandleTypeDef; |
160 | }SD_HandleTypeDef; |
160 | |
161 | 161 | /** |
|
162 | /** |
162 | * @} |
163 | * @} |
163 | */ |
164 | */ |
164 | |
165 | 165 | /** @defgroup SD_Exported_Types_Group4 Card Specific Data: CSD Register |
|
166 | /** @defgroup SD_Exported_Types_Group4 Card Specific Data: CSD Register |
166 | * @{ |
167 | * @{ |
167 | */ |
168 | */ |
168 | typedef struct |
169 | typedef struct |
169 | { |
170 | { |
170 | __IO uint8_t CSDStruct; /*!< CSD structure */ |
171 | __IO uint8_t CSDStruct; /*!< CSD structure */ |
171 | __IO uint8_t SysSpecVersion; /*!< System specification version */ |
172 | __IO uint8_t SysSpecVersion; /*!< System specification version */ |
172 | __IO uint8_t Reserved1; /*!< Reserved */ |
173 | __IO uint8_t Reserved1; /*!< Reserved */ |
173 | __IO uint8_t TAAC; /*!< Data read access time 1 */ |
174 | __IO uint8_t TAAC; /*!< Data read access time 1 */ |
174 | __IO uint8_t NSAC; /*!< Data read access time 2 in CLK cycles */ |
175 | __IO uint8_t NSAC; /*!< Data read access time 2 in CLK cycles */ |
175 | __IO uint8_t MaxBusClkFrec; /*!< Max. bus clock frequency */ |
176 | __IO uint8_t MaxBusClkFrec; /*!< Max. bus clock frequency */ |
176 | __IO uint16_t CardComdClasses; /*!< Card command classes */ |
177 | __IO uint16_t CardComdClasses; /*!< Card command classes */ |
177 | __IO uint8_t RdBlockLen; /*!< Max. read data block length */ |
178 | __IO uint8_t RdBlockLen; /*!< Max. read data block length */ |
178 | __IO uint8_t PartBlockRead; /*!< Partial blocks for read allowed */ |
179 | __IO uint8_t PartBlockRead; /*!< Partial blocks for read allowed */ |
179 | __IO uint8_t WrBlockMisalign; /*!< Write block misalignment */ |
180 | __IO uint8_t WrBlockMisalign; /*!< Write block misalignment */ |
180 | __IO uint8_t RdBlockMisalign; /*!< Read block misalignment */ |
181 | __IO uint8_t RdBlockMisalign; /*!< Read block misalignment */ |
181 | __IO uint8_t DSRImpl; /*!< DSR implemented */ |
182 | __IO uint8_t DSRImpl; /*!< DSR implemented */ |
182 | __IO uint8_t Reserved2; /*!< Reserved */ |
183 | __IO uint8_t Reserved2; /*!< Reserved */ |
183 | __IO uint32_t DeviceSize; /*!< Device Size */ |
184 | __IO uint32_t DeviceSize; /*!< Device Size */ |
184 | __IO uint8_t MaxRdCurrentVDDMin; /*!< Max. read current @ VDD min */ |
185 | __IO uint8_t MaxRdCurrentVDDMin; /*!< Max. read current @ VDD min */ |
185 | __IO uint8_t MaxRdCurrentVDDMax; /*!< Max. read current @ VDD max */ |
186 | __IO uint8_t MaxRdCurrentVDDMax; /*!< Max. read current @ VDD max */ |
186 | __IO uint8_t MaxWrCurrentVDDMin; /*!< Max. write current @ VDD min */ |
187 | __IO uint8_t MaxWrCurrentVDDMin; /*!< Max. write current @ VDD min */ |
187 | __IO uint8_t MaxWrCurrentVDDMax; /*!< Max. write current @ VDD max */ |
188 | __IO uint8_t MaxWrCurrentVDDMax; /*!< Max. write current @ VDD max */ |
188 | __IO uint8_t DeviceSizeMul; /*!< Device size multiplier */ |
189 | __IO uint8_t DeviceSizeMul; /*!< Device size multiplier */ |
189 | __IO uint8_t EraseGrSize; /*!< Erase group size */ |
190 | __IO uint8_t EraseGrSize; /*!< Erase group size */ |
190 | __IO uint8_t EraseGrMul; /*!< Erase group size multiplier */ |
191 | __IO uint8_t EraseGrMul; /*!< Erase group size multiplier */ |
191 | __IO uint8_t WrProtectGrSize; /*!< Write protect group size */ |
192 | __IO uint8_t WrProtectGrSize; /*!< Write protect group size */ |
192 | __IO uint8_t WrProtectGrEnable; /*!< Write protect group enable */ |
193 | __IO uint8_t WrProtectGrEnable; /*!< Write protect group enable */ |
193 | __IO uint8_t ManDeflECC; /*!< Manufacturer default ECC */ |
194 | __IO uint8_t ManDeflECC; /*!< Manufacturer default ECC */ |
194 | __IO uint8_t WrSpeedFact; /*!< Write speed factor */ |
195 | __IO uint8_t WrSpeedFact; /*!< Write speed factor */ |
195 | __IO uint8_t MaxWrBlockLen; /*!< Max. write data block length */ |
196 | __IO uint8_t MaxWrBlockLen; /*!< Max. write data block length */ |
196 | __IO uint8_t WriteBlockPaPartial; /*!< Partial blocks for write allowed */ |
197 | __IO uint8_t WriteBlockPaPartial; /*!< Partial blocks for write allowed */ |
197 | __IO uint8_t Reserved3; /*!< Reserved */ |
198 | __IO uint8_t Reserved3; /*!< Reserved */ |
198 | __IO uint8_t ContentProtectAppli; /*!< Content protection application */ |
199 | __IO uint8_t ContentProtectAppli; /*!< Content protection application */ |
199 | __IO uint8_t FileFormatGroup; /*!< File format group */ |
200 | __IO uint8_t FileFormatGroup; /*!< File format group */ |
200 | __IO uint8_t CopyFlag; /*!< Copy flag (OTP) */ |
201 | __IO uint8_t CopyFlag; /*!< Copy flag (OTP) */ |
201 | __IO uint8_t PermWrProtect; /*!< Permanent write protection */ |
202 | __IO uint8_t PermWrProtect; /*!< Permanent write protection */ |
202 | __IO uint8_t TempWrProtect; /*!< Temporary write protection */ |
203 | __IO uint8_t TempWrProtect; /*!< Temporary write protection */ |
203 | __IO uint8_t FileFormat; /*!< File format */ |
204 | __IO uint8_t FileFormat; /*!< File format */ |
204 | __IO uint8_t ECC; /*!< ECC code */ |
205 | __IO uint8_t ECC; /*!< ECC code */ |
205 | __IO uint8_t CSD_CRC; /*!< CSD CRC */ |
206 | __IO uint8_t CSD_CRC; /*!< CSD CRC */ |
206 | __IO uint8_t Reserved4; /*!< Always 1 */ |
207 | __IO uint8_t Reserved4; /*!< Always 1 */ |
207 | }HAL_SD_CardCSDTypeDef; |
208 | }HAL_SD_CardCSDTypeDef; |
208 | /** |
209 | /** |
209 | * @} |
210 | * @} |
210 | */ |
211 | */ |
211 | |
212 | 212 | /** @defgroup SD_Exported_Types_Group5 Card Identification Data: CID Register |
|
213 | /** @defgroup SD_Exported_Types_Group5 Card Identification Data: CID Register |
213 | * @{ |
214 | * @{ |
214 | */ |
215 | */ |
215 | typedef struct |
216 | typedef struct |
216 | { |
217 | { |
217 | __IO uint8_t ManufacturerID; /*!< Manufacturer ID */ |
218 | __IO uint8_t ManufacturerID; /*!< Manufacturer ID */ |
218 | __IO uint16_t OEM_AppliID; /*!< OEM/Application ID */ |
219 | __IO uint16_t OEM_AppliID; /*!< OEM/Application ID */ |
219 | __IO uint32_t ProdName1; /*!< Product Name part1 */ |
220 | __IO uint32_t ProdName1; /*!< Product Name part1 */ |
220 | __IO uint8_t ProdName2; /*!< Product Name part2 */ |
221 | __IO uint8_t ProdName2; /*!< Product Name part2 */ |
221 | __IO uint8_t ProdRev; /*!< Product Revision */ |
222 | __IO uint8_t ProdRev; /*!< Product Revision */ |
222 | __IO uint32_t ProdSN; /*!< Product Serial Number */ |
223 | __IO uint32_t ProdSN; /*!< Product Serial Number */ |
223 | __IO uint8_t Reserved1; /*!< Reserved1 */ |
224 | __IO uint8_t Reserved1; /*!< Reserved1 */ |
224 | __IO uint16_t ManufactDate; /*!< Manufacturing Date */ |
225 | __IO uint16_t ManufactDate; /*!< Manufacturing Date */ |
225 | __IO uint8_t CID_CRC; /*!< CID CRC */ |
226 | __IO uint8_t CID_CRC; /*!< CID CRC */ |
226 | __IO uint8_t Reserved2; /*!< Always 1 */ |
227 | __IO uint8_t Reserved2; /*!< Always 1 */ |
227 | |
228 | 228 | }HAL_SD_CardCIDTypeDef; |
|
229 | }HAL_SD_CardCIDTypeDef; |
229 | /** |
230 | /** |
230 | * @} |
231 | * @} |
231 | */ |
232 | */ |
232 | |
233 | 233 | /** @defgroup SD_Exported_Types_Group6 SD Card Status returned by ACMD13 |
|
234 | /** @defgroup SD_Exported_Types_Group6 SD Card Status returned by ACMD13 |
234 | * @{ |
235 | * @{ |
235 | */ |
236 | */ |
236 | typedef struct |
237 | typedef struct |
237 | { |
238 | { |
238 | __IO uint8_t DataBusWidth; /*!< Shows the currently defined data bus width */ |
239 | __IO uint8_t DataBusWidth; /*!< Shows the currently defined data bus width */ |
239 | __IO uint8_t SecuredMode; /*!< Card is in secured mode of operation */ |
240 | __IO uint8_t SecuredMode; /*!< Card is in secured mode of operation */ |
240 | __IO uint16_t CardType; /*!< Carries information about card type */ |
241 | __IO uint16_t CardType; /*!< Carries information about card type */ |
241 | __IO uint32_t ProtectedAreaSize; /*!< Carries information about the capacity of protected area */ |
242 | __IO uint32_t ProtectedAreaSize; /*!< Carries information about the capacity of protected area */ |
242 | __IO uint8_t SpeedClass; /*!< Carries information about the speed class of the card */ |
243 | __IO uint8_t SpeedClass; /*!< Carries information about the speed class of the card */ |
243 | __IO uint8_t PerformanceMove; /*!< Carries information about the card's performance move */ |
244 | __IO uint8_t PerformanceMove; /*!< Carries information about the card's performance move */ |
244 | __IO uint8_t AllocationUnitSize; /*!< Carries information about the card's allocation unit size */ |
245 | __IO uint8_t AllocationUnitSize; /*!< Carries information about the card's allocation unit size */ |
245 | __IO uint16_t EraseSize; /*!< Determines the number of AUs to be erased in one operation */ |
246 | __IO uint16_t EraseSize; /*!< Determines the number of AUs to be erased in one operation */ |
246 | __IO uint8_t EraseTimeout; /*!< Determines the timeout for any number of AU erase */ |
247 | __IO uint8_t EraseTimeout; /*!< Determines the timeout for any number of AU erase */ |
247 | __IO uint8_t EraseOffset; /*!< Carries information about the erase offset */ |
248 | __IO uint8_t EraseOffset; /*!< Carries information about the erase offset */ |
248 | |
249 | 249 | }HAL_SD_CardStatusTypeDef; |
|
250 | }HAL_SD_CardStatusTypeDef; |
250 | /** |
251 | /** |
251 | * @} |
252 | * @} |
252 | */ |
253 | */ |
253 | |
254 | 254 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
|
255 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
255 | /** @defgroup SD_Exported_Types_Group7 SD Callback ID enumeration definition |
256 | /** @defgroup SD_Exported_Types_Group7 SD Callback ID enumeration definition |
256 | * @{ |
257 | * @{ |
257 | */ |
258 | */ |
258 | typedef enum |
259 | typedef enum |
259 | { |
260 | { |
260 | HAL_SD_TX_CPLT_CB_ID = 0x00U, /*!< SD Tx Complete Callback ID */ |
261 | HAL_SD_TX_CPLT_CB_ID = 0x00U, /*!< SD Tx Complete Callback ID */ |
261 | HAL_SD_RX_CPLT_CB_ID = 0x01U, /*!< SD Rx Complete Callback ID */ |
262 | HAL_SD_RX_CPLT_CB_ID = 0x01U, /*!< SD Rx Complete Callback ID */ |
262 | HAL_SD_ERROR_CB_ID = 0x02U, /*!< SD Error Callback ID */ |
263 | HAL_SD_ERROR_CB_ID = 0x02U, /*!< SD Error Callback ID */ |
263 | HAL_SD_ABORT_CB_ID = 0x03U, /*!< SD Abort Callback ID */ |
264 | HAL_SD_ABORT_CB_ID = 0x03U, /*!< SD Abort Callback ID */ |
264 | |
265 | 265 | HAL_SD_MSP_INIT_CB_ID = 0x10U, /*!< SD MspInit Callback ID */ |
|
266 | HAL_SD_MSP_INIT_CB_ID = 0x10U, /*!< SD MspInit Callback ID */ |
266 | HAL_SD_MSP_DEINIT_CB_ID = 0x11U /*!< SD MspDeInit Callback ID */ |
267 | HAL_SD_MSP_DEINIT_CB_ID = 0x11U /*!< SD MspDeInit Callback ID */ |
267 | }HAL_SD_CallbackIDTypeDef; |
268 | }HAL_SD_CallbackIDTypeDef; |
268 | /** |
269 | /** |
269 | * @} |
270 | * @} |
270 | */ |
271 | */ |
271 | |
272 | 272 | /** @defgroup SD_Exported_Types_Group8 SD Callback pointer definition |
|
273 | /** @defgroup SD_Exported_Types_Group8 SD Callback pointer definition |
273 | * @{ |
274 | * @{ |
274 | */ |
275 | */ |
275 | typedef void (*pSD_CallbackTypeDef) (SD_HandleTypeDef *hsd); |
276 | typedef void (*pSD_CallbackTypeDef) (SD_HandleTypeDef *hsd); |
276 | /** |
277 | /** |
277 | * @} |
278 | * @} |
278 | */ |
279 | */ |
279 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
280 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
280 | /** |
281 | /** |
281 | * @} |
282 | * @} |
282 | */ |
283 | */ |
283 | |
284 | 284 | /* Exported constants --------------------------------------------------------*/ |
|
285 | /* Exported constants --------------------------------------------------------*/ |
285 | /** @defgroup SD_Exported_Constants Exported Constants |
286 | /** @defgroup SD_Exported_Constants Exported Constants |
286 | * @{ |
287 | * @{ |
287 | */ |
288 | */ |
288 | |
289 | 289 | #define BLOCKSIZE 512U /*!< Block size is 512 bytes */ |
|
290 | #define BLOCKSIZE 512U /*!< Block size is 512 bytes */ |
290 | |
291 | 291 | /** @defgroup SD_Exported_Constansts_Group1 SD Error status enumeration Structure definition |
|
292 | /** @defgroup SD_Exported_Constansts_Group1 SD Error status enumeration Structure definition |
292 | * @{ |
293 | * @{ |
293 | */ |
294 | */ |
294 | #define HAL_SD_ERROR_NONE SDMMC_ERROR_NONE /*!< No error */ |
295 | #define HAL_SD_ERROR_NONE SDMMC_ERROR_NONE /*!< No error */ |
295 | #define HAL_SD_ERROR_CMD_CRC_FAIL SDMMC_ERROR_CMD_CRC_FAIL /*!< Command response received (but CRC check failed) */ |
296 | #define HAL_SD_ERROR_CMD_CRC_FAIL SDMMC_ERROR_CMD_CRC_FAIL /*!< Command response received (but CRC check failed) */ |
296 | #define HAL_SD_ERROR_DATA_CRC_FAIL SDMMC_ERROR_DATA_CRC_FAIL /*!< Data block sent/received (CRC check failed) */ |
297 | #define HAL_SD_ERROR_DATA_CRC_FAIL SDMMC_ERROR_DATA_CRC_FAIL /*!< Data block sent/received (CRC check failed) */ |
297 | #define HAL_SD_ERROR_CMD_RSP_TIMEOUT SDMMC_ERROR_CMD_RSP_TIMEOUT /*!< Command response timeout */ |
298 | #define HAL_SD_ERROR_CMD_RSP_TIMEOUT SDMMC_ERROR_CMD_RSP_TIMEOUT /*!< Command response timeout */ |
298 | #define HAL_SD_ERROR_DATA_TIMEOUT SDMMC_ERROR_DATA_TIMEOUT /*!< Data timeout */ |
299 | #define HAL_SD_ERROR_DATA_TIMEOUT SDMMC_ERROR_DATA_TIMEOUT /*!< Data timeout */ |
299 | #define HAL_SD_ERROR_TX_UNDERRUN SDMMC_ERROR_TX_UNDERRUN /*!< Transmit FIFO underrun */ |
300 | #define HAL_SD_ERROR_TX_UNDERRUN SDMMC_ERROR_TX_UNDERRUN /*!< Transmit FIFO underrun */ |
300 | #define HAL_SD_ERROR_RX_OVERRUN SDMMC_ERROR_RX_OVERRUN /*!< Receive FIFO overrun */ |
301 | #define HAL_SD_ERROR_RX_OVERRUN SDMMC_ERROR_RX_OVERRUN /*!< Receive FIFO overrun */ |
301 | #define HAL_SD_ERROR_ADDR_MISALIGNED SDMMC_ERROR_ADDR_MISALIGNED /*!< Misaligned address */ |
302 | #define HAL_SD_ERROR_ADDR_MISALIGNED SDMMC_ERROR_ADDR_MISALIGNED /*!< Misaligned address */ |
302 | #define HAL_SD_ERROR_BLOCK_LEN_ERR SDMMC_ERROR_BLOCK_LEN_ERR /*!< Transferred block length is not allowed for the card or the |
303 | #define HAL_SD_ERROR_BLOCK_LEN_ERR SDMMC_ERROR_BLOCK_LEN_ERR /*!< Transferred block length is not allowed for the card or the |
303 | number of transferred bytes does not match the block length */ |
304 | number of transferred bytes does not match the block length */ |
304 | #define HAL_SD_ERROR_ERASE_SEQ_ERR SDMMC_ERROR_ERASE_SEQ_ERR /*!< An error in the sequence of erase command occurs */ |
305 | #define HAL_SD_ERROR_ERASE_SEQ_ERR SDMMC_ERROR_ERASE_SEQ_ERR /*!< An error in the sequence of erase command occurs */ |
305 | #define HAL_SD_ERROR_BAD_ERASE_PARAM SDMMC_ERROR_BAD_ERASE_PARAM /*!< An invalid selection for erase groups */ |
306 | #define HAL_SD_ERROR_BAD_ERASE_PARAM SDMMC_ERROR_BAD_ERASE_PARAM /*!< An invalid selection for erase groups */ |
306 | #define HAL_SD_ERROR_WRITE_PROT_VIOLATION SDMMC_ERROR_WRITE_PROT_VIOLATION /*!< Attempt to program a write protect block */ |
307 | #define HAL_SD_ERROR_WRITE_PROT_VIOLATION SDMMC_ERROR_WRITE_PROT_VIOLATION /*!< Attempt to program a write protect block */ |
307 | #define HAL_SD_ERROR_LOCK_UNLOCK_FAILED SDMMC_ERROR_LOCK_UNLOCK_FAILED /*!< Sequence or password error has been detected in unlock |
308 | #define HAL_SD_ERROR_LOCK_UNLOCK_FAILED SDMMC_ERROR_LOCK_UNLOCK_FAILED /*!< Sequence or password error has been detected in unlock |
308 | command or if there was an attempt to access a locked card */ |
309 | command or if there was an attempt to access a locked card */ |
309 | #define HAL_SD_ERROR_COM_CRC_FAILED SDMMC_ERROR_COM_CRC_FAILED /*!< CRC check of the previous command failed */ |
310 | #define HAL_SD_ERROR_COM_CRC_FAILED SDMMC_ERROR_COM_CRC_FAILED /*!< CRC check of the previous command failed */ |
310 | #define HAL_SD_ERROR_ILLEGAL_CMD SDMMC_ERROR_ILLEGAL_CMD /*!< Command is not legal for the card state */ |
311 | #define HAL_SD_ERROR_ILLEGAL_CMD SDMMC_ERROR_ILLEGAL_CMD /*!< Command is not legal for the card state */ |
311 | #define HAL_SD_ERROR_CARD_ECC_FAILED SDMMC_ERROR_CARD_ECC_FAILED /*!< Card internal ECC was applied but failed to correct the data */ |
312 | #define HAL_SD_ERROR_CARD_ECC_FAILED SDMMC_ERROR_CARD_ECC_FAILED /*!< Card internal ECC was applied but failed to correct the data */ |
312 | #define HAL_SD_ERROR_CC_ERR SDMMC_ERROR_CC_ERR /*!< Internal card controller error */ |
313 | #define HAL_SD_ERROR_CC_ERR SDMMC_ERROR_CC_ERR /*!< Internal card controller error */ |
313 | #define HAL_SD_ERROR_GENERAL_UNKNOWN_ERR SDMMC_ERROR_GENERAL_UNKNOWN_ERR /*!< General or unknown error */ |
314 | #define HAL_SD_ERROR_GENERAL_UNKNOWN_ERR SDMMC_ERROR_GENERAL_UNKNOWN_ERR /*!< General or unknown error */ |
314 | #define HAL_SD_ERROR_STREAM_READ_UNDERRUN SDMMC_ERROR_STREAM_READ_UNDERRUN /*!< The card could not sustain data reading in stream rmode */ |
315 | #define HAL_SD_ERROR_STREAM_READ_UNDERRUN SDMMC_ERROR_STREAM_READ_UNDERRUN /*!< The card could not sustain data reading in stream rmode */ |
315 | #define HAL_SD_ERROR_STREAM_WRITE_OVERRUN SDMMC_ERROR_STREAM_WRITE_OVERRUN /*!< The card could not sustain data programming in stream mode */ |
316 | #define HAL_SD_ERROR_STREAM_WRITE_OVERRUN SDMMC_ERROR_STREAM_WRITE_OVERRUN /*!< The card could not sustain data programming in stream mode */ |
316 | #define HAL_SD_ERROR_CID_CSD_OVERWRITE SDMMC_ERROR_CID_CSD_OVERWRITE /*!< CID/CSD overwrite error */ |
317 | #define HAL_SD_ERROR_CID_CSD_OVERWRITE SDMMC_ERROR_CID_CSD_OVERWRITE /*!< CID/CSD overwrite error */ |
317 | #define HAL_SD_ERROR_WP_ERASE_SKIP SDMMC_ERROR_WP_ERASE_SKIP /*!< Only partial address space was erased */ |
318 | #define HAL_SD_ERROR_WP_ERASE_SKIP SDMMC_ERROR_WP_ERASE_SKIP /*!< Only partial address space was erased */ |
318 | #define HAL_SD_ERROR_CARD_ECC_DISABLED SDMMC_ERROR_CARD_ECC_DISABLED /*!< Command has been executed without using internal ECC */ |
319 | #define HAL_SD_ERROR_CARD_ECC_DISABLED SDMMC_ERROR_CARD_ECC_DISABLED /*!< Command has been executed without using internal ECC */ |
319 | #define HAL_SD_ERROR_ERASE_RESET SDMMC_ERROR_ERASE_RESET /*!< Erase sequence was cleared before executing because an out |
320 | #define HAL_SD_ERROR_ERASE_RESET SDMMC_ERROR_ERASE_RESET /*!< Erase sequence was cleared before executing because an out |
320 | of erase sequence command was received */ |
321 | of erase sequence command was received */ |
321 | #define HAL_SD_ERROR_AKE_SEQ_ERR SDMMC_ERROR_AKE_SEQ_ERR /*!< Error in sequence of authentication */ |
322 | #define HAL_SD_ERROR_AKE_SEQ_ERR SDMMC_ERROR_AKE_SEQ_ERR /*!< Error in sequence of authentication */ |
322 | #define HAL_SD_ERROR_INVALID_VOLTRANGE SDMMC_ERROR_INVALID_VOLTRANGE /*!< Error in case of invalid voltage range */ |
323 | #define HAL_SD_ERROR_INVALID_VOLTRANGE SDMMC_ERROR_INVALID_VOLTRANGE /*!< Error in case of invalid voltage range */ |
323 | #define HAL_SD_ERROR_ADDR_OUT_OF_RANGE SDMMC_ERROR_ADDR_OUT_OF_RANGE /*!< Error when addressed block is out of range */ |
324 | #define HAL_SD_ERROR_ADDR_OUT_OF_RANGE SDMMC_ERROR_ADDR_OUT_OF_RANGE /*!< Error when addressed block is out of range */ |
324 | #define HAL_SD_ERROR_REQUEST_NOT_APPLICABLE SDMMC_ERROR_REQUEST_NOT_APPLICABLE /*!< Error when command request is not applicable */ |
325 | #define HAL_SD_ERROR_REQUEST_NOT_APPLICABLE SDMMC_ERROR_REQUEST_NOT_APPLICABLE /*!< Error when command request is not applicable */ |
325 | #define HAL_SD_ERROR_PARAM SDMMC_ERROR_INVALID_PARAMETER /*!< the used parameter is not valid */ |
326 | #define HAL_SD_ERROR_PARAM SDMMC_ERROR_INVALID_PARAMETER /*!< the used parameter is not valid */ |
326 | #define HAL_SD_ERROR_UNSUPPORTED_FEATURE SDMMC_ERROR_UNSUPPORTED_FEATURE /*!< Error when feature is not insupported */ |
327 | #define HAL_SD_ERROR_UNSUPPORTED_FEATURE SDMMC_ERROR_UNSUPPORTED_FEATURE /*!< Error when feature is not insupported */ |
327 | #define HAL_SD_ERROR_BUSY SDMMC_ERROR_BUSY /*!< Error when transfer process is busy */ |
328 | #define HAL_SD_ERROR_BUSY SDMMC_ERROR_BUSY /*!< Error when transfer process is busy */ |
328 | #define HAL_SD_ERROR_DMA SDMMC_ERROR_DMA /*!< Error while DMA transfer */ |
329 | #define HAL_SD_ERROR_DMA SDMMC_ERROR_DMA /*!< Error while DMA transfer */ |
329 | #define HAL_SD_ERROR_TIMEOUT SDMMC_ERROR_TIMEOUT /*!< Timeout error */ |
330 | #define HAL_SD_ERROR_TIMEOUT SDMMC_ERROR_TIMEOUT /*!< Timeout error */ |
330 | |
331 | 331 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
|
332 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
332 | #define HAL_SD_ERROR_INVALID_CALLBACK SDMMC_ERROR_INVALID_PARAMETER /*!< Invalid callback error */ |
333 | #define HAL_SD_ERROR_INVALID_CALLBACK SDMMC_ERROR_INVALID_PARAMETER /*!< Invalid callback error */ |
333 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
334 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
334 | /** |
335 | /** |
335 | * @} |
336 | * @} |
336 | */ |
337 | */ |
337 | |
338 | 338 | /** @defgroup SD_Exported_Constansts_Group2 SD context enumeration |
|
339 | /** @defgroup SD_Exported_Constansts_Group2 SD context enumeration |
339 | * @{ |
340 | * @{ |
340 | */ |
341 | */ |
341 | #define SD_CONTEXT_NONE 0x00000000U /*!< None */ |
342 | #define SD_CONTEXT_NONE 0x00000000U /*!< None */ |
342 | #define SD_CONTEXT_READ_SINGLE_BLOCK 0x00000001U /*!< Read single block operation */ |
343 | #define SD_CONTEXT_READ_SINGLE_BLOCK 0x00000001U /*!< Read single block operation */ |
343 | #define SD_CONTEXT_READ_MULTIPLE_BLOCK 0x00000002U /*!< Read multiple blocks operation */ |
344 | #define SD_CONTEXT_READ_MULTIPLE_BLOCK 0x00000002U /*!< Read multiple blocks operation */ |
344 | #define SD_CONTEXT_WRITE_SINGLE_BLOCK 0x00000010U /*!< Write single block operation */ |
345 | #define SD_CONTEXT_WRITE_SINGLE_BLOCK 0x00000010U /*!< Write single block operation */ |
345 | #define SD_CONTEXT_WRITE_MULTIPLE_BLOCK 0x00000020U /*!< Write multiple blocks operation */ |
346 | #define SD_CONTEXT_WRITE_MULTIPLE_BLOCK 0x00000020U /*!< Write multiple blocks operation */ |
346 | #define SD_CONTEXT_IT 0x00000008U /*!< Process in Interrupt mode */ |
347 | #define SD_CONTEXT_IT 0x00000008U /*!< Process in Interrupt mode */ |
347 | #define SD_CONTEXT_DMA 0x00000080U /*!< Process in DMA mode */ |
348 | #define SD_CONTEXT_DMA 0x00000080U /*!< Process in DMA mode */ |
348 | |
349 | 349 | /** |
|
350 | /** |
350 | * @} |
351 | * @} |
351 | */ |
352 | */ |
352 | |
353 | 353 | /** @defgroup SD_Exported_Constansts_Group3 SD Supported Memory Cards |
|
354 | /** @defgroup SD_Exported_Constansts_Group3 SD Supported Memory Cards |
354 | * @{ |
355 | * @{ |
355 | */ |
356 | */ |
356 | #define CARD_SDSC 0x00000000U /*!< SD Standard Capacity <2Go */ |
357 | #define CARD_SDSC 0x00000000U /*!< SD Standard Capacity <2Go */ |
357 | #define CARD_SDHC_SDXC 0x00000001U /*!< SD High Capacity <32Go, SD Extended Capacity <2To */ |
358 | #define CARD_SDHC_SDXC 0x00000001U /*!< SD High Capacity <32Go, SD Extended Capacity <2To */ |
358 | #define CARD_SECURED 0x00000003U |
359 | #define CARD_SECURED 0x00000003U |
359 | |
360 | 360 | /** |
|
361 | /** |
361 | * @} |
362 | * @} |
362 | */ |
363 | */ |
363 | |
364 | 364 | /** @defgroup SD_Exported_Constansts_Group4 SD Supported Version |
|
365 | /** @defgroup SD_Exported_Constansts_Group4 SD Supported Version |
365 | * @{ |
366 | * @{ |
366 | */ |
367 | */ |
367 | #define CARD_V1_X 0x00000000U |
368 | #define CARD_V1_X 0x00000000U |
368 | #define CARD_V2_X 0x00000001U |
369 | #define CARD_V2_X 0x00000001U |
369 | /** |
370 | /** |
370 | * @} |
371 | * @} |
371 | */ |
372 | */ |
372 | |
373 | 373 | /** |
|
374 | /** |
374 | * @} |
375 | * @} |
375 | */ |
376 | */ |
376 | |
377 | 377 | /* Exported macro ------------------------------------------------------------*/ |
|
378 | /* Exported macro ------------------------------------------------------------*/ |
378 | /** @defgroup SD_Exported_macros SD Exported Macros |
379 | /** @defgroup SD_Exported_macros SD Exported Macros |
379 | * @brief macros to handle interrupts and specific clock configurations |
380 | * @brief macros to handle interrupts and specific clock configurations |
380 | * @{ |
381 | * @{ |
381 | */ |
382 | */ |
382 | /** @brief Reset SD handle state. |
383 | /** @brief Reset SD handle state. |
383 | * @param __HANDLE__ : SD handle. |
384 | * @param __HANDLE__ : SD handle. |
384 | * @retval None |
385 | * @retval None |
385 | */ |
386 | */ |
386 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
387 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
387 | #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) do { \ |
388 | #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) do { \ |
388 | (__HANDLE__)->State = HAL_SD_STATE_RESET; \ |
389 | (__HANDLE__)->State = HAL_SD_STATE_RESET; \ |
389 | (__HANDLE__)->MspInitCallback = NULL; \ |
390 | (__HANDLE__)->MspInitCallback = NULL; \ |
390 | (__HANDLE__)->MspDeInitCallback = NULL; \ |
391 | (__HANDLE__)->MspDeInitCallback = NULL; \ |
391 | } while(0) |
392 | } while(0) |
392 | #else |
393 | #else |
393 | #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SD_STATE_RESET) |
394 | #define __HAL_SD_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_SD_STATE_RESET) |
394 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
395 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
395 | |
396 | 396 | /** |
|
397 | /** |
397 | * @brief Enable the SD device. |
398 | * @brief Enable the SD device. |
398 | * @retval None |
399 | * @retval None |
399 | */ |
400 | */ |
400 | #define __HAL_SD_ENABLE(__HANDLE__) __SDIO_ENABLE((__HANDLE__)->Instance) |
401 | #define __HAL_SD_ENABLE(__HANDLE__) __SDIO_ENABLE((__HANDLE__)->Instance) |
401 | |
402 | 402 | /** |
|
403 | /** |
403 | * @brief Disable the SD device. |
404 | * @brief Disable the SD device. |
404 | * @retval None |
405 | * @retval None |
405 | */ |
406 | */ |
406 | #define __HAL_SD_DISABLE(__HANDLE__) __SDIO_DISABLE((__HANDLE__)->Instance) |
407 | #define __HAL_SD_DISABLE(__HANDLE__) __SDIO_DISABLE((__HANDLE__)->Instance) |
407 | |
408 | 408 | /** |
|
409 | /** |
409 | * @brief Enable the SDMMC DMA transfer. |
410 | * @brief Enable the SDMMC DMA transfer. |
410 | * @retval None |
411 | * @retval None |
411 | */ |
412 | */ |
412 | #define __HAL_SD_DMA_ENABLE(__HANDLE__) __SDIO_DMA_ENABLE((__HANDLE__)->Instance) |
413 | #define __HAL_SD_DMA_ENABLE(__HANDLE__) __SDIO_DMA_ENABLE((__HANDLE__)->Instance) |
413 | |
414 | 414 | /** |
|
415 | /** |
415 | * @brief Disable the SDMMC DMA transfer. |
416 | * @brief Disable the SDMMC DMA transfer. |
416 | * @retval None |
417 | * @retval None |
417 | */ |
418 | */ |
418 | #define __HAL_SD_DMA_DISABLE(__HANDLE__) __SDIO_DMA_DISABLE((__HANDLE__)->Instance) |
419 | #define __HAL_SD_DMA_DISABLE(__HANDLE__) __SDIO_DMA_DISABLE((__HANDLE__)->Instance) |
419 | |
420 | 420 | /** |
|
421 | /** |
421 | * @brief Enable the SD device interrupt. |
422 | * @brief Enable the SD device interrupt. |
422 | * @param __HANDLE__: SD Handle |
423 | * @param __HANDLE__: SD Handle |
423 | * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be enabled. |
424 | * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be enabled. |
424 | * This parameter can be one or a combination of the following values: |
425 | * This parameter can be one or a combination of the following values: |
425 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt |
426 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt |
426 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt |
427 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt |
427 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt |
428 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt |
428 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt |
429 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt |
429 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt |
430 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt |
430 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt |
431 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt |
431 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt |
432 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt |
432 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt |
433 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt |
433 | * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt |
434 | * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt |
434 | * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt |
435 | * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt |
435 | * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt |
436 | * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt |
436 | * @arg SDIO_IT_TXACT: Data transmit in progress interrupt |
437 | * @arg SDIO_IT_TXACT: Data transmit in progress interrupt |
437 | * @arg SDIO_IT_RXACT: Data receive in progress interrupt |
438 | * @arg SDIO_IT_RXACT: Data receive in progress interrupt |
438 | * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt |
439 | * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt |
439 | * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt |
440 | * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt |
440 | * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt |
441 | * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt |
441 | * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt |
442 | * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt |
442 | * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt |
443 | * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt |
443 | * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt |
444 | * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt |
444 | * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt |
445 | * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt |
445 | * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt |
446 | * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt |
446 | * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt |
447 | * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt |
447 | * @retval None |
448 | * @retval None |
448 | */ |
449 | */ |
449 | #define __HAL_SD_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) |
450 | #define __HAL_SD_ENABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_ENABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) |
450 | |
451 | 451 | /** |
|
452 | /** |
452 | * @brief Disable the SD device interrupt. |
453 | * @brief Disable the SD device interrupt. |
453 | * @param __HANDLE__: SD Handle |
454 | * @param __HANDLE__: SD Handle |
454 | * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be disabled. |
455 | * @param __INTERRUPT__: specifies the SDMMC interrupt sources to be disabled. |
455 | * This parameter can be one or a combination of the following values: |
456 | * This parameter can be one or a combination of the following values: |
456 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt |
457 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt |
457 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt |
458 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt |
458 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt |
459 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt |
459 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt |
460 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt |
460 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt |
461 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt |
461 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt |
462 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt |
462 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt |
463 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt |
463 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt |
464 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt |
464 | * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt |
465 | * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt |
465 | * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt |
466 | * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt |
466 | * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt |
467 | * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt |
467 | * @arg SDIO_IT_TXACT: Data transmit in progress interrupt |
468 | * @arg SDIO_IT_TXACT: Data transmit in progress interrupt |
468 | * @arg SDIO_IT_RXACT: Data receive in progress interrupt |
469 | * @arg SDIO_IT_RXACT: Data receive in progress interrupt |
469 | * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt |
470 | * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt |
470 | * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt |
471 | * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt |
471 | * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt |
472 | * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt |
472 | * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt |
473 | * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt |
473 | * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt |
474 | * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt |
474 | * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt |
475 | * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt |
475 | * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt |
476 | * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt |
476 | * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt |
477 | * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt |
477 | * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt |
478 | * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt |
478 | * @retval None |
479 | * @retval None |
479 | */ |
480 | */ |
480 | #define __HAL_SD_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) |
481 | #define __HAL_SD_DISABLE_IT(__HANDLE__, __INTERRUPT__) __SDIO_DISABLE_IT((__HANDLE__)->Instance, (__INTERRUPT__)) |
481 | |
482 | 482 | /** |
|
483 | /** |
483 | * @brief Check whether the specified SD flag is set or not. |
484 | * @brief Check whether the specified SD flag is set or not. |
484 | * @param __HANDLE__: SD Handle |
485 | * @param __HANDLE__: SD Handle |
485 | * @param __FLAG__: specifies the flag to check. |
486 | * @param __FLAG__: specifies the flag to check. |
486 | * This parameter can be one of the following values: |
487 | * This parameter can be one of the following values: |
487 | * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) |
488 | * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) |
488 | * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) |
489 | * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) |
489 | * @arg SDIO_FLAG_CTIMEOUT: Command response timeout |
490 | * @arg SDIO_FLAG_CTIMEOUT: Command response timeout |
490 | * @arg SDIO_FLAG_DTIMEOUT: Data timeout |
491 | * @arg SDIO_FLAG_DTIMEOUT: Data timeout |
491 | * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error |
492 | * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error |
492 | * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error |
493 | * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error |
493 | * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) |
494 | * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) |
494 | * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) |
495 | * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) |
495 | * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) |
496 | * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) |
496 | * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) |
497 | * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) |
497 | * @arg SDIO_FLAG_CMDACT: Command transfer in progress |
498 | * @arg SDIO_FLAG_CMDACT: Command transfer in progress |
498 | * @arg SDIO_FLAG_TXACT: Data transmit in progress |
499 | * @arg SDIO_FLAG_TXACT: Data transmit in progress |
499 | * @arg SDIO_FLAG_RXACT: Data receive in progress |
500 | * @arg SDIO_FLAG_RXACT: Data receive in progress |
500 | * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty |
501 | * @arg SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty |
501 | * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full |
502 | * @arg SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full |
502 | * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full |
503 | * @arg SDIO_FLAG_TXFIFOF: Transmit FIFO full |
503 | * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full |
504 | * @arg SDIO_FLAG_RXFIFOF: Receive FIFO full |
504 | * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty |
505 | * @arg SDIO_FLAG_TXFIFOE: Transmit FIFO empty |
505 | * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty |
506 | * @arg SDIO_FLAG_RXFIFOE: Receive FIFO empty |
506 | * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO |
507 | * @arg SDIO_FLAG_TXDAVL: Data available in transmit FIFO |
507 | * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO |
508 | * @arg SDIO_FLAG_RXDAVL: Data available in receive FIFO |
508 | * @arg SDIO_FLAG_SDIOIT: SDIO interrupt received |
509 | * @arg SDIO_FLAG_SDIOIT: SDIO interrupt received |
509 | * @retval The new state of SD FLAG (SET or RESET). |
510 | * @retval The new state of SD FLAG (SET or RESET). |
510 | */ |
511 | */ |
511 | #define __HAL_SD_GET_FLAG(__HANDLE__, __FLAG__) __SDIO_GET_FLAG((__HANDLE__)->Instance, (__FLAG__)) |
512 | #define __HAL_SD_GET_FLAG(__HANDLE__, __FLAG__) __SDIO_GET_FLAG((__HANDLE__)->Instance, (__FLAG__)) |
512 | |
513 | 513 | /** |
|
514 | /** |
514 | * @brief Clear the SD's pending flags. |
515 | * @brief Clear the SD's pending flags. |
515 | * @param __HANDLE__: SD Handle |
516 | * @param __HANDLE__: SD Handle |
516 | * @param __FLAG__: specifies the flag to clear. |
517 | * @param __FLAG__: specifies the flag to clear. |
517 | * This parameter can be one or a combination of the following values: |
518 | * This parameter can be one or a combination of the following values: |
518 | * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) |
519 | * @arg SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed) |
519 | * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) |
520 | * @arg SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed) |
520 | * @arg SDIO_FLAG_CTIMEOUT: Command response timeout |
521 | * @arg SDIO_FLAG_CTIMEOUT: Command response timeout |
521 | * @arg SDIO_FLAG_DTIMEOUT: Data timeout |
522 | * @arg SDIO_FLAG_DTIMEOUT: Data timeout |
522 | * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error |
523 | * @arg SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error |
523 | * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error |
524 | * @arg SDIO_FLAG_RXOVERR: Received FIFO overrun error |
524 | * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) |
525 | * @arg SDIO_FLAG_CMDREND: Command response received (CRC check passed) |
525 | * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) |
526 | * @arg SDIO_FLAG_CMDSENT: Command sent (no response required) |
526 | * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) |
527 | * @arg SDIO_FLAG_DATAEND: Data end (data counter, DATACOUNT, is zero) |
527 | * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) |
528 | * @arg SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed) |
528 | * @arg SDIO_FLAG_SDIOIT: SDIO interrupt received |
529 | * @arg SDIO_FLAG_SDIOIT: SDIO interrupt received |
529 | * @retval None |
530 | * @retval None |
530 | */ |
531 | */ |
531 | #define __HAL_SD_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDIO_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__)) |
532 | #define __HAL_SD_CLEAR_FLAG(__HANDLE__, __FLAG__) __SDIO_CLEAR_FLAG((__HANDLE__)->Instance, (__FLAG__)) |
532 | |
533 | 533 | /** |
|
534 | /** |
534 | * @brief Check whether the specified SD interrupt has occurred or not. |
535 | * @brief Check whether the specified SD interrupt has occurred or not. |
535 | * @param __HANDLE__: SD Handle |
536 | * @param __HANDLE__: SD Handle |
536 | * @param __INTERRUPT__: specifies the SDMMC interrupt source to check. |
537 | * @param __INTERRUPT__: specifies the SDMMC interrupt source to check. |
537 | * This parameter can be one of the following values: |
538 | * This parameter can be one of the following values: |
538 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt |
539 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt |
539 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt |
540 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt |
540 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt |
541 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt |
541 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt |
542 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt |
542 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt |
543 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt |
543 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt |
544 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt |
544 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt |
545 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt |
545 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt |
546 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt |
546 | * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt |
547 | * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt |
547 | * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt |
548 | * @arg SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt |
548 | * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt |
549 | * @arg SDIO_IT_CMDACT: Command transfer in progress interrupt |
549 | * @arg SDIO_IT_TXACT: Data transmit in progress interrupt |
550 | * @arg SDIO_IT_TXACT: Data transmit in progress interrupt |
550 | * @arg SDIO_IT_RXACT: Data receive in progress interrupt |
551 | * @arg SDIO_IT_RXACT: Data receive in progress interrupt |
551 | * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt |
552 | * @arg SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt |
552 | * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt |
553 | * @arg SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt |
553 | * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt |
554 | * @arg SDIO_IT_TXFIFOF: Transmit FIFO full interrupt |
554 | * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt |
555 | * @arg SDIO_IT_RXFIFOF: Receive FIFO full interrupt |
555 | * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt |
556 | * @arg SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt |
556 | * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt |
557 | * @arg SDIO_IT_RXFIFOE: Receive FIFO empty interrupt |
557 | * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt |
558 | * @arg SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt |
558 | * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt |
559 | * @arg SDIO_IT_RXDAVL: Data available in receive FIFO interrupt |
559 | * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt |
560 | * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt |
560 | * @retval The new state of SD IT (SET or RESET). |
561 | * @retval The new state of SD IT (SET or RESET). |
561 | */ |
562 | */ |
562 | #define __HAL_SD_GET_IT(__HANDLE__, __INTERRUPT__) __SDIO_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__)) |
563 | #define __HAL_SD_GET_IT(__HANDLE__, __INTERRUPT__) __SDIO_GET_IT((__HANDLE__)->Instance, (__INTERRUPT__)) |
563 | |
564 | 564 | /** |
|
565 | /** |
565 | * @brief Clear the SD's interrupt pending bits. |
566 | * @brief Clear the SD's interrupt pending bits. |
566 | * @param __HANDLE__: SD Handle |
567 | * @param __HANDLE__: SD Handle |
567 | * @param __INTERRUPT__: specifies the interrupt pending bit to clear. |
568 | * @param __INTERRUPT__: specifies the interrupt pending bit to clear. |
568 | * This parameter can be one or a combination of the following values: |
569 | * This parameter can be one or a combination of the following values: |
569 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt |
570 | * @arg SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt |
570 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt |
571 | * @arg SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt |
571 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt |
572 | * @arg SDIO_IT_CTIMEOUT: Command response timeout interrupt |
572 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt |
573 | * @arg SDIO_IT_DTIMEOUT: Data timeout interrupt |
573 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt |
574 | * @arg SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt |
574 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt |
575 | * @arg SDIO_IT_RXOVERR: Received FIFO overrun error interrupt |
575 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt |
576 | * @arg SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt |
576 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt |
577 | * @arg SDIO_IT_CMDSENT: Command sent (no response required) interrupt |
577 | * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt |
578 | * @arg SDIO_IT_DATAEND: Data end (data counter, DATACOUNT, is zero) interrupt |
578 | * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt |
579 | * @arg SDIO_IT_SDIOIT: SDIO interrupt received interrupt |
579 | * @retval None |
580 | * @retval None |
580 | */ |
581 | */ |
581 | #define __HAL_SD_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDIO_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__)) |
582 | #define __HAL_SD_CLEAR_IT(__HANDLE__, __INTERRUPT__) __SDIO_CLEAR_IT((__HANDLE__)->Instance, (__INTERRUPT__)) |
582 | |
583 | 583 | /** |
|
584 | /** |
584 | * @} |
585 | * @} |
585 | */ |
586 | */ |
586 | |
587 | 587 | /* Exported functions --------------------------------------------------------*/ |
|
588 | /* Exported functions --------------------------------------------------------*/ |
588 | /** @defgroup SD_Exported_Functions SD Exported Functions |
589 | /** @defgroup SD_Exported_Functions SD Exported Functions |
589 | * @{ |
590 | * @{ |
590 | */ |
591 | */ |
591 | |
592 | 592 | /** @defgroup SD_Exported_Functions_Group1 Initialization and de-initialization functions |
|
593 | /** @defgroup SD_Exported_Functions_Group1 Initialization and de-initialization functions |
593 | * @{ |
594 | * @{ |
594 | */ |
595 | */ |
595 | HAL_StatusTypeDef HAL_SD_Init(SD_HandleTypeDef *hsd); |
596 | HAL_StatusTypeDef HAL_SD_Init(SD_HandleTypeDef *hsd); |
596 | HAL_StatusTypeDef HAL_SD_InitCard(SD_HandleTypeDef *hsd); |
597 | HAL_StatusTypeDef HAL_SD_InitCard(SD_HandleTypeDef *hsd); |
597 | HAL_StatusTypeDef HAL_SD_DeInit (SD_HandleTypeDef *hsd); |
598 | HAL_StatusTypeDef HAL_SD_DeInit (SD_HandleTypeDef *hsd); |
598 | void HAL_SD_MspInit(SD_HandleTypeDef *hsd); |
599 | void HAL_SD_MspInit(SD_HandleTypeDef *hsd); |
599 | void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd); |
600 | void HAL_SD_MspDeInit(SD_HandleTypeDef *hsd); |
600 | /** |
601 | /** |
601 | * @} |
602 | * @} |
602 | */ |
603 | */ |
603 | |
604 | 604 | /** @defgroup SD_Exported_Functions_Group2 Input and Output operation functions |
|
605 | /** @defgroup SD_Exported_Functions_Group2 Input and Output operation functions |
605 | * @{ |
606 | * @{ |
606 | */ |
607 | */ |
607 | /* Blocking mode: Polling */ |
608 | /* Blocking mode: Polling */ |
608 | HAL_StatusTypeDef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout); |
609 | HAL_StatusTypeDef HAL_SD_ReadBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout); |
609 | HAL_StatusTypeDef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout); |
610 | HAL_StatusTypeDef HAL_SD_WriteBlocks(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks, uint32_t Timeout); |
610 | HAL_StatusTypeDef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint32_t BlockStartAdd, uint32_t BlockEndAdd); |
611 | HAL_StatusTypeDef HAL_SD_Erase(SD_HandleTypeDef *hsd, uint32_t BlockStartAdd, uint32_t BlockEndAdd); |
611 | /* Non-Blocking mode: IT */ |
612 | /* Non-Blocking mode: IT */ |
612 | HAL_StatusTypeDef HAL_SD_ReadBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); |
613 | HAL_StatusTypeDef HAL_SD_ReadBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); |
613 | HAL_StatusTypeDef HAL_SD_WriteBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); |
614 | HAL_StatusTypeDef HAL_SD_WriteBlocks_IT(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); |
614 | /* Non-Blocking mode: DMA */ |
615 | /* Non-Blocking mode: DMA */ |
615 | HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); |
616 | HAL_StatusTypeDef HAL_SD_ReadBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); |
616 | HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); |
617 | HAL_StatusTypeDef HAL_SD_WriteBlocks_DMA(SD_HandleTypeDef *hsd, uint8_t *pData, uint32_t BlockAdd, uint32_t NumberOfBlocks); |
617 | |
618 | 618 | void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd); |
|
619 | void HAL_SD_IRQHandler(SD_HandleTypeDef *hsd); |
619 | |
620 | 620 | /* Callback in non blocking modes (DMA) */ |
|
621 | /* Callback in non blocking modes (DMA) */ |
621 | void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd); |
622 | void HAL_SD_TxCpltCallback(SD_HandleTypeDef *hsd); |
622 | void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd); |
623 | void HAL_SD_RxCpltCallback(SD_HandleTypeDef *hsd); |
623 | void HAL_SD_ErrorCallback(SD_HandleTypeDef *hsd); |
624 | void HAL_SD_ErrorCallback(SD_HandleTypeDef *hsd); |
624 | void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd); |
625 | void HAL_SD_AbortCallback(SD_HandleTypeDef *hsd); |
625 | |
626 | 626 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
|
627 | #if defined (USE_HAL_SD_REGISTER_CALLBACKS) && (USE_HAL_SD_REGISTER_CALLBACKS == 1U) |
627 | /* SD callback registering/unregistering */ |
628 | /* SD callback registering/unregistering */ |
628 | HAL_StatusTypeDef HAL_SD_RegisterCallback (SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackId, pSD_CallbackTypeDef pCallback); |
629 | HAL_StatusTypeDef HAL_SD_RegisterCallback (SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackId, pSD_CallbackTypeDef pCallback); |
629 | HAL_StatusTypeDef HAL_SD_UnRegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackId); |
630 | HAL_StatusTypeDef HAL_SD_UnRegisterCallback(SD_HandleTypeDef *hsd, HAL_SD_CallbackIDTypeDef CallbackId); |
630 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
631 | #endif /* USE_HAL_SD_REGISTER_CALLBACKS */ |
631 | |
632 | 632 | /** |
|
633 | /** |
633 | * @} |
634 | * @} |
634 | */ |
635 | */ |
635 | |
636 | 636 | /** @defgroup SD_Exported_Functions_Group3 Peripheral Control functions |
|
637 | /** @defgroup SD_Exported_Functions_Group3 Peripheral Control functions |
637 | * @{ |
638 | * @{ |
638 | */ |
639 | */ |
639 | HAL_StatusTypeDef HAL_SD_ConfigWideBusOperation(SD_HandleTypeDef *hsd, uint32_t WideMode); |
640 | HAL_StatusTypeDef HAL_SD_ConfigWideBusOperation(SD_HandleTypeDef *hsd, uint32_t WideMode); |
640 | /** |
641 | /** |
641 | * @} |
642 | * @} |
642 | */ |
643 | */ |
643 | |
644 | 644 | /** @defgroup SD_Exported_Functions_Group4 SD card related functions |
|
645 | /** @defgroup SD_Exported_Functions_Group4 SD card related functions |
645 | * @{ |
646 | * @{ |
646 | */ |
647 | */ |
647 | HAL_StatusTypeDef HAL_SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus); |
648 | HAL_StatusTypeDef HAL_SD_SendSDStatus(SD_HandleTypeDef *hsd, uint32_t *pSDstatus); |
648 | HAL_SD_CardStateTypeDef HAL_SD_GetCardState(SD_HandleTypeDef *hsd); |
649 | HAL_SD_CardStateTypeDef HAL_SD_GetCardState(SD_HandleTypeDef *hsd); |
649 | HAL_StatusTypeDef HAL_SD_GetCardCID(SD_HandleTypeDef *hsd, HAL_SD_CardCIDTypeDef *pCID); |
650 | HAL_StatusTypeDef HAL_SD_GetCardCID(SD_HandleTypeDef *hsd, HAL_SD_CardCIDTypeDef *pCID); |
650 | HAL_StatusTypeDef HAL_SD_GetCardCSD(SD_HandleTypeDef *hsd, HAL_SD_CardCSDTypeDef *pCSD); |
651 | HAL_StatusTypeDef HAL_SD_GetCardCSD(SD_HandleTypeDef *hsd, HAL_SD_CardCSDTypeDef *pCSD); |
651 | HAL_StatusTypeDef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusTypeDef *pStatus); |
652 | HAL_StatusTypeDef HAL_SD_GetCardStatus(SD_HandleTypeDef *hsd, HAL_SD_CardStatusTypeDef *pStatus); |
652 | HAL_StatusTypeDef HAL_SD_GetCardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo); |
653 | HAL_StatusTypeDef HAL_SD_GetCardInfo(SD_HandleTypeDef *hsd, HAL_SD_CardInfoTypeDef *pCardInfo); |
653 | /** |
654 | /** |
654 | * @} |
655 | * @} |
655 | */ |
656 | */ |
656 | |
657 | 657 | /** @defgroup SD_Exported_Functions_Group5 Peripheral State and Errors functions |
|
658 | /** @defgroup SD_Exported_Functions_Group5 Peripheral State and Errors functions |
658 | * @{ |
659 | * @{ |
659 | */ |
660 | */ |
660 | HAL_SD_StateTypeDef HAL_SD_GetState(SD_HandleTypeDef *hsd); |
661 | HAL_SD_StateTypeDef HAL_SD_GetState(SD_HandleTypeDef *hsd); |
661 | uint32_t HAL_SD_GetError(SD_HandleTypeDef *hsd); |
662 | uint32_t HAL_SD_GetError(SD_HandleTypeDef *hsd); |
662 | /** |
663 | /** |
663 | * @} |
664 | * @} |
664 | */ |
665 | */ |
665 | |
666 | 666 | /** @defgroup SD_Exported_Functions_Group6 Perioheral Abort management |
|
667 | /** @defgroup SD_Exported_Functions_Group6 Perioheral Abort management |
667 | * @{ |
668 | * @{ |
668 | */ |
669 | */ |
669 | HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd); |
670 | HAL_StatusTypeDef HAL_SD_Abort(SD_HandleTypeDef *hsd); |
670 | HAL_StatusTypeDef HAL_SD_Abort_IT(SD_HandleTypeDef *hsd); |
671 | HAL_StatusTypeDef HAL_SD_Abort_IT(SD_HandleTypeDef *hsd); |
671 | /** |
672 | /** |
672 | * @} |
673 | * @} |
673 | */ |
674 | */ |
674 | |
675 | 675 | /* Private types -------------------------------------------------------------*/ |
|
676 | /* Private types -------------------------------------------------------------*/ |
676 | /** @defgroup SD_Private_Types SD Private Types |
677 | /** @defgroup SD_Private_Types SD Private Types |
677 | * @{ |
678 | * @{ |
678 | */ |
679 | */ |
679 | |
680 | 680 | /** |
|
681 | /** |
681 | * @} |
682 | * @} |
682 | */ |
683 | */ |
683 | |
684 | 684 | /* Private defines -----------------------------------------------------------*/ |
|
685 | /* Private defines -----------------------------------------------------------*/ |
685 | /** @defgroup SD_Private_Defines SD Private Defines |
686 | /** @defgroup SD_Private_Defines SD Private Defines |
686 | * @{ |
687 | * @{ |
687 | */ |
688 | */ |
688 | |
689 | 689 | /** |
|
690 | /** |
690 | * @} |
691 | * @} |
691 | */ |
692 | */ |
692 | |
693 | 693 | /* Private variables ---------------------------------------------------------*/ |
|
694 | /* Private variables ---------------------------------------------------------*/ |
694 | /** @defgroup SD_Private_Variables SD Private Variables |
695 | /** @defgroup SD_Private_Variables SD Private Variables |
695 | * @{ |
696 | * @{ |
696 | */ |
697 | */ |
697 | |
698 | 698 | /** |
|
699 | /** |
699 | * @} |
700 | * @} |
700 | */ |
701 | */ |
701 | |
702 | 702 | /* Private constants ---------------------------------------------------------*/ |
|
703 | /* Private constants ---------------------------------------------------------*/ |
703 | /** @defgroup SD_Private_Constants SD Private Constants |
704 | /** @defgroup SD_Private_Constants SD Private Constants |
704 | * @{ |
705 | * @{ |
705 | */ |
706 | */ |
706 | |
707 | 707 | /** |
|
708 | /** |
708 | * @} |
709 | * @} |
709 | */ |
710 | */ |
710 | |
711 | 711 | /* Private macros ------------------------------------------------------------*/ |
|
712 | /* Private macros ------------------------------------------------------------*/ |
712 | /** @defgroup SD_Private_Macros SD Private Macros |
713 | /** @defgroup SD_Private_Macros SD Private Macros |
713 | * @{ |
714 | * @{ |
714 | */ |
715 | */ |
715 | |
716 | 716 | /** |
|
717 | /** |
717 | * @} |
718 | * @} |
718 | */ |
719 | */ |
719 | |
720 | 720 | /* Private functions prototypes ----------------------------------------------*/ |
|
721 | /* Private functions prototypes ----------------------------------------------*/ |
721 | /** @defgroup SD_Private_Functions_Prototypes SD Private Functions Prototypes |
722 | /** @defgroup SD_Private_Functions_Prototypes SD Private Functions Prototypes |
722 | * @{ |
723 | * @{ |
723 | */ |
724 | */ |
724 | |
725 | 725 | /** |
|
726 | /** |
726 | * @} |
727 | * @} |
727 | */ |
728 | */ |
728 | |
729 | 729 | /* Private functions ---------------------------------------------------------*/ |
|
730 | /* Private functions ---------------------------------------------------------*/ |
730 | /** @defgroup SD_Private_Functions SD Private Functions |
731 | /** @defgroup SD_Private_Functions SD Private Functions |
731 | * @{ |
732 | * @{ |
732 | */ |
733 | */ |
733 | |
734 | 734 | /** |
|
735 | /** |
735 | * @} |
736 | * @} |
736 | */ |
737 | */ |
737 | |
738 | 738 | ||
739 | 739 | /** |
|
740 | /** |
740 | * @} |
741 | * @} |
741 | */ |
742 | */ |
742 | |
743 | 743 | /** |
|
744 | /** |
744 | * @} |
745 | * @} |
745 | */ |
746 | */ |
746 | |
747 | 747 | /** |
|
748 | /** |
748 | * @} |
749 | * @} |
749 | */ |
750 | */ |
750 | |
751 | 751 | #endif /* SDIO */ |
|
752 | #endif /* SDIO */ |
752 | |
753 | 753 | #ifdef __cplusplus |
|
754 | #ifdef __cplusplus |
754 | } |
755 | } |
755 | #endif |
756 | #endif |
756 | |
757 | 757 | ||
758 | 758 | #endif /* STM32L1xx_HAL_SD_H */ |
|
759 | #endif /* STM32L1xx_HAL_SD_H */ |
- | |
760 | - | ||
761 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
- |