SDIO Library
The SD/SDIO MMC card host interface (SDIO) provides an interface between the APB2 peripheral bus and MultiMediaCards (MMCs), SD memory cards, SDIO cards and CE-ATA devices. It is available only for the Cortex M4 devices.
The MultiMediaCard/SD bus connects cards to the controller.
The SDIO features include the following :
- Full compliance with MultiMediaCard System Specification Version 4.2 Card support for three different databus modes: 1-bit (default), 4-bit and 8-bit.
- Full compatibility with previous versions of MultiMediaCards (forward compatibility).
- Full compliance with SD Memory Card Specifications Version 2.0.
- Full compliance with SD I/O Card Specification Version 2.0: card support for two different databus modes: 1-bit (default) and 4-bit.
- Full support of the CE-ATA features (full compliance with CE-ATA digital protocol Rev1.1).
- Data transfer up to 48 MHz for the 8 bit mode.
- Data and command output enable signals to control external bidirectional drivers.
Library Routines
- SDIO_Reset
- SDIO_Init
- SDIO_ClockCmd
- SDIO_SetPowerState
- SDIO_GetPowerState
- SDIO_SendCommand
- SDIO_GetCommandResponse
- SDIO_DataConfig
- SDIO_GetDataCounter
- SDIO_ReadData
- SDIO_WriteData
- SDIO_GetFIFOCount
- SDIO_StartSDIOReadWait
- SDIO_StopSDIOReadWait
- SDIO_SetSDIOReadWaitMode
- SDIO_SetSDIOOperation
- SDIO_SendSDIOSuspendCmd
- SDIO_CommandCompletionCmd
- SDIO_CEATAITCmd
- SDIO_SendCEATACmd
- SDIO_DMACmd
- SDIO_ITConfig
- SDIO_GetFlagStatus
- SDIO_ClearFlag
- SDIO_GetITStatus
- SDIO_ClearITPendingBit
SDIO_Reset
Prototype |
procedure SDIO_Reset(); |
---|---|
Description |
Deinitializes the SD I/O peripheral registers to their default reset values. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDIO_Init
Prototype |
procedure SDIO_Init(cfg : dword; clockDiv : byte; module : ^const Module_Struct); |
||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Initializes the SD I/O peripheral according to the specified parameters. |
||||||||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||
Notes |
None. |
SDIO_ClockCmd
Prototype |
procedure SDIO_ClockCmd(newState : byte); |
||||||
---|---|---|---|---|---|---|---|
Description |
Enables or disables the SD I/O Clock. |
||||||
Parameters |
|
||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDIO_SetPowerState
Prototype |
procedure SDIO_SetPowerState(powerState : byte); |
||||||||
---|---|---|---|---|---|---|---|---|---|
Description |
Sets the power status of the controller. |
||||||||
Parameters |
|
||||||||
Returns |
Nothing. |
||||||||
Requires |
Nothing. |
||||||||
Notes |
None. |
SDIO_GetPowerState
Prototype |
function SDIO_GetPowerState() : dword; |
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Returns the power status of the controller. |
||||||||||||
Parameters |
None. |
||||||||||||
Returns |
Power status of the controller. The returned value can be one of the following values :
|
||||||||||||
Requires |
Nothing. |
||||||||||||
Notes |
None. |
SDIO_SendCommand
Prototype |
procedure SDIO_SendCommand(var SDIO_CmdInitStruct : SDIO_CmdInitTypeDef); |
||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Initializes the SD I/O Command according to the specified parameters in the |
||||||||||||||||
Parameters |
|
||||||||||||||||
Returns |
None. |
||||||||||||||||
Requires |
Nothing. |
||||||||||||||||
Notes |
None. |
SDIO_GetCommandResponse
Prototype |
function SDIO_GetCommandResponse() : byte; |
---|---|
Description |
Returns command index of last command for which response received. |
Parameters | |
Returns |
Command index of the last command response received. |
Requires |
Nothing. |
Notes |
None. |
SDIO_DataConfig
Prototype |
procedure SDIO_DataConfig(var SDIO_DataInitStruct : SDIO_DataInitTypeDef); |
||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Initializes the SD I/O data path according to the specified parameters in the |
||||||||||||||||||||||||||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||||||||||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||||||
Notes |
None. |
SDIO_GetDataCounter
Prototype |
function SDIO_GetDataCounter() : dword; |
---|---|
Description |
Returns number of remaining data bytes to be transferred. |
Parameters |
None. |
Returns |
Number of remaining data bytes to be transferred. |
Requires |
Nothing. |
Notes |
None. |
SDIO_ReadData
Prototype |
function SDIO_ReadData() : dword; |
---|---|
Description |
Read one data word from Rx FIFO. |
Parameters |
None. |
Returns |
One data word from Rx FIFO. |
Requires |
Nothing. |
Notes |
None. |
SDIO_WriteData
Prototype |
procedure SDIO_WriteData(dat : dword); |
---|---|
Description |
Write one data word to Tx FIFO. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDIO_GetFIFOCount
Prototype |
function SDIO_GetFIFOCount() : dword; |
---|---|
Description |
Returns the number of words left to be written to or read from FIFO. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Remaining number of words. |
Notes |
None. |
SDIO_StartSDIOReadWait
Prototype |
procedure SDIO_StartSDIOReadWait(newState : byte); |
||||||
---|---|---|---|---|---|---|---|
Description |
Starts the SD I/O Read Wait operation. |
||||||
Parameters |
| ||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDIO_StopSDIOReadWait
Prototype |
procedure SDIO_StopSDIOReadWait(newState : byte); |
||||||
---|---|---|---|---|---|---|---|
Description |
Stops the SD I/O Read Wait operation. |
||||||
Parameters |
| ||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDIO_SetSDIOReadWaitMode
Prototype |
procedure SDIO_SetSDIOReadWaitMode(readWaitMode : byte); |
||||||
---|---|---|---|---|---|---|---|
Description |
Sets one of the two options of inserting read wait interval. |
||||||
Parameters |
| ||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDIO_SetSDIOOperation
Prototype |
procedure SDIO_SetSDIOOperation(newState : byte); |
||||||
---|---|---|---|---|---|---|---|
Description |
Enables or disables the SD I/O Mode Operation. |
||||||
Parameters |
| ||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDIO_SendSDIOSuspendCmd
Prototype |
procedure SDIO_SendSDIOSuspendCmd(newState : byte); |
||||||
---|---|---|---|---|---|---|---|
Description |
Enables or disables the SD I/O Mode suspend command sending. |
||||||
Parameters |
| ||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDIO_CommandCompletionCmd
Prototype |
procedure SDIO_CommandCompletionCmd(newState : byte); |
||||||
---|---|---|---|---|---|---|---|
Description |
Enables or disables the command completion signal. |
||||||
Parameters |
| ||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDIO_CEATAITCmd
Prototype |
procedure SDIO_CEATAITCmd(newState : byte); |
||||||
---|---|---|---|---|---|---|---|
Description |
Enables or disables the CE-ATA interrupt. |
||||||
Parameters |
| ||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDIO_SendCEATACmd
Prototype |
procedure SDIO_SendCEATACmd(newState : byte); |
||||||
---|---|---|---|---|---|---|---|
Description |
Enables or disables CE-ATA (CMD61) command sending. |
||||||
Parameters |
| ||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDIO_DMACmd
Prototype |
procedure SDIO_DMACmd(newState : byte); |
||||||
---|---|---|---|---|---|---|---|
Description |
Enables or disables the SD I/O DMA request. |
||||||
Parameters |
| ||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDIO_ITConfig
Prototype |
procedure SDIO_ITConfig(it : dword; newState : byte); |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Enables or disables the SD I/O interrupts. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Parameters |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Notes |
None. |
SDIO_GetFlagStatus
Prototype |
function SDIO_GetFlagStatus(flag : dword) : byte; |
||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Checks whether the specified SD I/O flag is set or not. |
||||||||||||||||||||||||||||||||||||||||||||||||||
Parameters |
| ||||||||||||||||||||||||||||||||||||||||||||||||||
Returns |
The new state of SDIO_FLAG. |
||||||||||||||||||||||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||||||||
Notes |
None. |
SDIO_ClearFlag
Prototype |
procedure SDIO_ClearFlag(flags : dword); |
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Clears the SD I/O's pending flags. |
||||||||||||||||||||||||||||
Parameters |
| ||||||||||||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||
Notes |
None. |
SDIO_GetITStatus
Prototype |
function SDIO_GetITStatus(it : dword) : byte; |
||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Checks whether the specified SD I/O interrupt has occurred or not. |
||||||||||||||||||||||||||||||||||||||||||||||||||
Parameters |
| ||||||||||||||||||||||||||||||||||||||||||||||||||
Returns |
The new state of SDIO_IT. |
||||||||||||||||||||||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||||||||
Notes |
None. |
SDIO_ClearITPendingBit
Prototype |
procedure SDIO_ClearITPendingBit(it : dword); |
||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
Clears the SD I/O's interrupt pending bits. |
||||||||||||||||||||||||||||
Parameters |
| ||||||||||||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||
Notes |
None. |