30 #ifndef __STM32F4_SDIO_SD_H__
31 #define __STM32F4_SDIO_SD_H__
79 SD_INVALID_VOLTRANGE = (27),
80 SD_ADDR_OUT_OF_RANGE = (28),
81 SD_SWITCH_ERROR = (29),
82 SD_SDIO_DISABLED = (30),
83 SD_SDIO_FUNCTION_BUSY = (31),
84 SD_SDIO_FUNCTION_FAILED = (32),
85 SD_SDIO_UNKNOWN_FUNCTION = (33),
93 SD_REQUEST_NOT_APPLICABLE,
95 SD_UNSUPPORTED_FEATURE,
107 SD_TRANSFER_BUSY = 1,
116 SD_CARD_READY = ((uint32_t)0x00000001),
117 SD_CARD_IDENTIFICATION = ((uint32_t)0x00000002),
118 SD_CARD_STANDBY = ((uint32_t)0x00000003),
119 SD_CARD_TRANSFER = ((uint32_t)0x00000004),
120 SD_CARD_SENDING = ((uint32_t)0x00000005),
121 SD_CARD_RECEIVING = ((uint32_t)0x00000006),
122 SD_CARD_PROGRAMMING = ((uint32_t)0x00000007),
123 SD_CARD_DISCONNECTED = ((uint32_t)0x00000008),
124 SD_CARD_ERROR = ((uint32_t)0x000000FF)
194 __IO uint8_t DAT_BUS_WIDTH;
195 __IO uint8_t SECURED_MODE;
196 __IO uint16_t SD_CARD_TYPE;
197 __IO uint32_t SIZE_OF_PROTECTED_AREA;
198 __IO uint8_t SPEED_CLASS;
199 __IO uint8_t PERFORMANCE_MOVE;
200 __IO uint8_t AU_SIZE;
201 __IO uint16_t ERASE_SIZE;
202 __IO uint8_t ERASE_TIMEOUT;
203 __IO uint8_t ERASE_OFFSET;
223 #define SD_CMD_GO_IDLE_STATE ((uint8_t)0)
224 #define SD_CMD_SEND_OP_COND ((uint8_t)1)
225 #define SD_CMD_ALL_SEND_CID ((uint8_t)2)
226 #define SD_CMD_SET_REL_ADDR ((uint8_t)3)
227 #define SD_CMD_SET_DSR ((uint8_t)4)
228 #define SD_CMD_SDIO_SEN_OP_COND ((uint8_t)5)
229 #define SD_CMD_HS_SWITCH ((uint8_t)6)
230 #define SD_CMD_SEL_DESEL_CARD ((uint8_t)7)
231 #define SD_CMD_HS_SEND_EXT_CSD ((uint8_t)8)
232 #define SD_CMD_SEND_CSD ((uint8_t)9)
233 #define SD_CMD_SEND_CID ((uint8_t)10)
234 #define SD_CMD_READ_DAT_UNTIL_STOP ((uint8_t)11)
235 #define SD_CMD_STOP_TRANSMISSION ((uint8_t)12)
236 #define SD_CMD_SEND_STATUS ((uint8_t)13)
237 #define SD_CMD_HS_BUSTEST_READ ((uint8_t)14)
238 #define SD_CMD_GO_INACTIVE_STATE ((uint8_t)15)
239 #define SD_CMD_SET_BLOCKLEN ((uint8_t)16)
240 #define SD_CMD_READ_SINGLE_BLOCK ((uint8_t)17)
241 #define SD_CMD_READ_MULT_BLOCK ((uint8_t)18)
242 #define SD_CMD_HS_BUSTEST_WRITE ((uint8_t)19)
243 #define SD_CMD_WRITE_DAT_UNTIL_STOP ((uint8_t)20)
244 #define SD_CMD_SET_BLOCK_COUNT ((uint8_t)23)
245 #define SD_CMD_WRITE_SINGLE_BLOCK ((uint8_t)24)
246 #define SD_CMD_WRITE_MULT_BLOCK ((uint8_t)25)
247 #define SD_CMD_PROG_CID ((uint8_t)26)
248 #define SD_CMD_PROG_CSD ((uint8_t)27)
249 #define SD_CMD_SET_WRITE_PROT ((uint8_t)28)
250 #define SD_CMD_CLR_WRITE_PROT ((uint8_t)29)
251 #define SD_CMD_SEND_WRITE_PROT ((uint8_t)30)
252 #define SD_CMD_SD_ERASE_GRP_START ((uint8_t)32)
254 #define SD_CMD_SD_ERASE_GRP_END ((uint8_t)33)
256 #define SD_CMD_ERASE_GRP_START ((uint8_t)35)
259 #define SD_CMD_ERASE_GRP_END ((uint8_t)36)
262 #define SD_CMD_ERASE ((uint8_t)38)
263 #define SD_CMD_FAST_IO ((uint8_t)39)
264 #define SD_CMD_GO_IRQ_STATE ((uint8_t)40)
265 #define SD_CMD_LOCK_UNLOCK ((uint8_t)42)
266 #define SD_CMD_APP_CMD ((uint8_t)55)
267 #define SD_CMD_GEN_CMD ((uint8_t)56)
268 #define SD_CMD_NO_CMD ((uint8_t)64)
274 #define SD_CMD_APP_SD_SET_BUSWIDTH ((uint8_t)6)
275 #define SD_CMD_SD_APP_STAUS ((uint8_t)13)
276 #define SD_CMD_SD_APP_SEND_NUM_WRITE_BLOCKS ((uint8_t)22)
277 #define SD_CMD_SD_APP_OP_COND ((uint8_t)41)
278 #define SD_CMD_SD_APP_SET_CLR_CARD_DETECT ((uint8_t)42)
279 #define SD_CMD_SD_APP_SEND_SCR ((uint8_t)51)
280 #define SD_CMD_SDIO_RW_DIRECT ((uint8_t)52)
281 #define SD_CMD_SDIO_RW_EXTENDED ((uint8_t)53)
287 #define SD_CMD_SD_APP_GET_MKB ((uint8_t)43)
288 #define SD_CMD_SD_APP_GET_MID ((uint8_t)44)
289 #define SD_CMD_SD_APP_SET_CER_RN1 ((uint8_t)45)
290 #define SD_CMD_SD_APP_GET_CER_RN2 ((uint8_t)46)
291 #define SD_CMD_SD_APP_SET_CER_RES2 ((uint8_t)47)
292 #define SD_CMD_SD_APP_GET_CER_RES1 ((uint8_t)48)
293 #define SD_CMD_SD_APP_SECURE_READ_MULTIPLE_BLOCK ((uint8_t)18)
294 #define SD_CMD_SD_APP_SECURE_WRITE_MULTIPLE_BLOCK ((uint8_t)25)
295 #define SD_CMD_SD_APP_SECURE_ERASE ((uint8_t)38)
296 #define SD_CMD_SD_APP_CHANGE_SECURE_AREA ((uint8_t)49)
297 #define SD_CMD_SD_APP_SECURE_WRITE_MKB ((uint8_t)48)
300 #if !defined (SD_DMA_MODE) && !defined (SD_POLLING_MODE)
301 #define SD_DMA_MODE ((uint32_t)0x00000000)
308 #define SD_PRESENT ((uint8_t)0x01)
309 #define SD_NOT_PRESENT ((uint8_t)0x00)
314 #define SDIO_STD_CAPACITY_SD_CARD_V1_1 ((uint32_t)0x00000000)
315 #define SDIO_STD_CAPACITY_SD_CARD_V2_0 ((uint32_t)0x00000001)
316 #define SDIO_HIGH_CAPACITY_SD_CARD ((uint32_t)0x00000002)
317 #define SDIO_MULTIMEDIA_CARD ((uint32_t)0x00000003)
318 #define SDIO_SECURE_DIGITAL_IO_CARD ((uint32_t)0x00000004)
319 #define SDIO_HIGH_SPEED_MULTIMEDIA_CARD ((uint32_t)0x00000005)
320 #define SDIO_SECURE_DIGITAL_IO_COMBO_CARD ((uint32_t)0x00000006)
321 #define SDIO_HIGH_CAPACITY_MMC_CARD ((uint32_t)0x00000007)
345 SD_Error SD_WriteMultiBlocksFIXED(uint8_t *writebuff, uint32_t WriteAddr, uint32_t BlockSize, uint32_t NumberOfBlocks);
__IO uint8_t RdBlockMisalign
SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
Allows to read blocks from a specified address in a card. The Data transfer can be managed by DMA mod...
SD_Error SD_Erase(uint32_t startaddr, uint32_t endaddr)
Allows to erase memory area specified for the given card.
SD_Error SD_Init(void)
Initializes the SD Card and put it into StandBy State (Ready for data transfer).
__IO uint8_t WriteBlockPaPartial
__IO uint8_t PermWrProtect
__IO uint8_t MaxBusClkFrec
SD_Error SD_WriteBlock(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize)
Allows to write one block starting from a specified address in a card. The Data transfer can be manag...
__IO uint8_t WrProtectGrSize
__IO uint8_t MaxRdCurrentVDDMax
__IO uint8_t TempWrProtect
SD_Error SD_WaitWriteOperation(void)
This function waits until the SDIO DMA data transfer is finished. This function should be called afte...
__IO uint16_t OEM_AppliID
SD_Error SD_EnableWideBusOperation(uint32_t WideMode)
Enables wide bus opeartion for the requeseted card if supported by card.
SD_Error SD_WaitReadOperation(void)
This function waits until the SDIO DMA data transfer is finished. This function should be called afte...
__IO uint8_t FileFormatGrouop
SD_Error SD_PowerOFF(void)
Turns the SDIO output signals off.
__IO uint8_t SysSpecVersion
SD_Error SD_PowerON(void)
Enquires cards about their operating voltage and configures clock controls.
SD_Error SD_InitializeCards(void)
Intialises all cards or single card as the case may be Card(s) come into standby state.
__IO uint8_t MaxWrCurrentVDDMax
__IO uint8_t WrProtectGrEnable
__IO uint8_t MaxRdCurrentVDDMin
SD_Error SD_ReadMultiBlocksFIXED(uint8_t *readbuff, uint32_t ReadAddr, uint32_t BlockSize, uint32_t NumberOfBlocks)
SDCardState SD_GetState(void)
Returns the current card's state.
SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
Allows to write blocks starting from a specified address in a card. The Data transfer can be managed ...
SD_Error SD_SendStatus(uint32_t *pcardstatus)
Returns the current card's status.
__IO uint16_t CardComdClasses
__IO uint8_t ContentProtectAppli
SDIO specific error defines.
Card Specific Data: CSD Register.
__IO uint8_t DeviceSizeMul
SDTransferState SD_GetStatus(void)
Gets the cuurent sd card data transfer status.
Card Identification Data: CID Register.
SD_Error SD_ReadBlock(uint8_t *readbuff, uint32_t ReadAddr, uint16_t BlockSize)
Allows to read one block from a specified address in a card. The Data transfer can be managed by DMA ...
__IO uint8_t ManufacturerID
__IO uint8_t MaxWrBlockLen
SD_Error SD_GetCardStatus(SD_CardStatus *cardstatus)
Enables wide bus opeartion for the requeseted card if supported by card.
__IO uint16_t ManufactDate
SD_Error SD_StopTransfer(void)
Aborts an ongoing data transfer.
__IO uint8_t MaxWrCurrentVDDMin
SDTransferState
SDIO Transfer state.
SD_Error SD_GetCardInfo(SD_CardInfo *cardinfo)
Returns information about specific card.
SDCardState
SD Card States.
uint8_t SD_Detect(void)
Detect if SD card is correctly plugged in the memory slot.
SD_Error SD_SendSDStatus(uint32_t *psdstatus)
Returns the current SD card's status.
SDTransferState SD_GetTransferState(void)
Gets the cuurent data transfer state.
void SD_DeInit(void)
DeInitializes the SDIO interface.
SD_Error SD_ProcessIRQSrc(void)
Allows to process all the interrupts that are high.
__IO uint8_t WrBlockMisalign
__IO uint8_t PartBlockRead
void SD_ProcessDMAIRQ(void)
This function waits until the SDIO DMA data transfer is finished.
SD_Error SD_SelectDeselect(uint32_t addr)
Selects od Deselects the corresponding card.