STM32F4 Standard Peripheral bibliotheek  1.0
ST Microelectronics bibliotheek documentatie voor de STM32F4 Standard Peripheral Library
 All Data Structures Files Functions Variables Enumerations Enumerator Groups

SDIO driver modules. More...

Modules

 SDIO_Exported_Constants
 
 SDIO_Private_Functions
 

Data Structures

struct  SDIO_InitTypeDef
 
struct  SDIO_CmdInitTypeDef
 
struct  SDIO_DataInitTypeDef
 

Macros

#define SDIO_OFFSET   (SDIO_BASE - PERIPH_BASE)
 
#define CLKCR_OFFSET   (SDIO_OFFSET + 0x04)
 
#define CLKEN_BitNumber   0x08
 
#define CLKCR_CLKEN_BB   (PERIPH_BB_BASE + (CLKCR_OFFSET * 32) + (CLKEN_BitNumber * 4))
 
#define CMD_OFFSET   (SDIO_OFFSET + 0x0C)
 
#define SDIOSUSPEND_BitNumber   0x0B
 
#define CMD_SDIOSUSPEND_BB   (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (SDIOSUSPEND_BitNumber * 4))
 
#define ENCMDCOMPL_BitNumber   0x0C
 
#define CMD_ENCMDCOMPL_BB   (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ENCMDCOMPL_BitNumber * 4))
 
#define NIEN_BitNumber   0x0D
 
#define CMD_NIEN_BB   (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (NIEN_BitNumber * 4))
 
#define ATACMD_BitNumber   0x0E
 
#define CMD_ATACMD_BB   (PERIPH_BB_BASE + (CMD_OFFSET * 32) + (ATACMD_BitNumber * 4))
 
#define DCTRL_OFFSET   (SDIO_OFFSET + 0x2C)
 
#define DMAEN_BitNumber   0x03
 
#define DCTRL_DMAEN_BB   (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (DMAEN_BitNumber * 4))
 
#define RWSTART_BitNumber   0x08
 
#define DCTRL_RWSTART_BB   (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTART_BitNumber * 4))
 
#define RWSTOP_BitNumber   0x09
 
#define DCTRL_RWSTOP_BB   (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWSTOP_BitNumber * 4))
 
#define RWMOD_BitNumber   0x0A
 
#define DCTRL_RWMOD_BB   (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (RWMOD_BitNumber * 4))
 
#define SDIOEN_BitNumber   0x0B
 
#define DCTRL_SDIOEN_BB   (PERIPH_BB_BASE + (DCTRL_OFFSET * 32) + (SDIOEN_BitNumber * 4))
 
#define CLKCR_CLEAR_MASK   ((uint32_t)0xFFFF8100)
 
#define PWR_PWRCTRL_MASK   ((uint32_t)0xFFFFFFFC)
 
#define DCTRL_CLEAR_MASK   ((uint32_t)0xFFFFFF08)
 
#define CMD_CLEAR_MASK   ((uint32_t)0xFFFFF800)
 
#define SDIO_RESP_ADDR   ((uint32_t)(SDIO_BASE + 0x14))
 

Functions

void SDIO_DeInit (void)
 Deinitializes the SDIO peripheral registers to their default reset values. More...
 
void SDIO_Init (SDIO_InitTypeDef *SDIO_InitStruct)
 Initializes the SDIO peripheral according to the specified parameters in the SDIO_InitStruct. More...
 
void SDIO_StructInit (SDIO_InitTypeDef *SDIO_InitStruct)
 Fills each SDIO_InitStruct member with its default value. More...
 
void SDIO_ClockCmd (FunctionalState NewState)
 Enables or disables the SDIO Clock. More...
 
void SDIO_SetPowerState (uint32_t SDIO_PowerState)
 Sets the power status of the controller. More...
 
uint32_t SDIO_GetPowerState (void)
 Gets the power status of the controller. More...
 
void SDIO_SendCommand (SDIO_CmdInitTypeDef *SDIO_CmdInitStruct)
 Initializes the SDIO Command according to the specified parameters in the SDIO_CmdInitStruct and send the command. More...
 
void SDIO_CmdStructInit (SDIO_CmdInitTypeDef *SDIO_CmdInitStruct)
 Fills each SDIO_CmdInitStruct member with its default value. More...
 
uint8_t SDIO_GetCommandResponse (void)
 Returns command index of last command for which response received. More...
 
uint32_t SDIO_GetResponse (uint32_t SDIO_RESP)
 Returns response received from the card for the last command. More...
 
void SDIO_DataConfig (SDIO_DataInitTypeDef *SDIO_DataInitStruct)
 Initializes the SDIO data path according to the specified parameters in the SDIO_DataInitStruct. More...
 
void SDIO_DataStructInit (SDIO_DataInitTypeDef *SDIO_DataInitStruct)
 Fills each SDIO_DataInitStruct member with its default value. More...
 
uint32_t SDIO_GetDataCounter (void)
 Returns number of remaining data bytes to be transferred. More...
 
uint32_t SDIO_ReadData (void)
 Read one data word from Rx FIFO. More...
 
void SDIO_WriteData (uint32_t Data)
 Write one data word to Tx FIFO. More...
 
uint32_t SDIO_GetFIFOCount (void)
 Returns the number of words left to be written to or read from FIFO. More...
 
void SDIO_StartSDIOReadWait (FunctionalState NewState)
 Starts the SD I/O Read Wait operation. More...
 
void SDIO_StopSDIOReadWait (FunctionalState NewState)
 Stops the SD I/O Read Wait operation. More...
 
void SDIO_SetSDIOReadWaitMode (uint32_t SDIO_ReadWaitMode)
 Sets one of the two options of inserting read wait interval. More...
 
void SDIO_SetSDIOOperation (FunctionalState NewState)
 Enables or disables the SD I/O Mode Operation. More...
 
void SDIO_SendSDIOSuspendCmd (FunctionalState NewState)
 Enables or disables the SD I/O Mode suspend command sending. More...
 
void SDIO_CommandCompletionCmd (FunctionalState NewState)
 Enables or disables the command completion signal. More...
 
void SDIO_CEATAITCmd (FunctionalState NewState)
 Enables or disables the CE-ATA interrupt. More...
 
void SDIO_SendCEATACmd (FunctionalState NewState)
 Sends CE-ATA command (CMD61). More...
 
void SDIO_DMACmd (FunctionalState NewState)
 Enables or disables the SDIO DMA request. More...
 
void SDIO_ITConfig (uint32_t SDIO_IT, FunctionalState NewState)
 Enables or disables the SDIO interrupts. More...
 
FlagStatus SDIO_GetFlagStatus (uint32_t SDIO_FLAG)
 Checks whether the specified SDIO flag is set or not. More...
 
void SDIO_ClearFlag (uint32_t SDIO_FLAG)
 Clears the SDIO's pending flags. More...
 
ITStatus SDIO_GetITStatus (uint32_t SDIO_IT)
 Checks whether the specified SDIO interrupt has occurred or not. More...
 
void SDIO_ClearITPendingBit (uint32_t SDIO_IT)
 Clears the SDIO's interrupt pending bits. More...
 

Detailed Description

SDIO driver modules.

Function Documentation

void SDIO_CEATAITCmd ( FunctionalState  NewState)

Enables or disables the CE-ATA interrupt.

Parameters
NewState,:new state of CE-ATA interrupt. This parameter can be: ENABLE or DISABLE.
Return values
None
void SDIO_ClearFlag ( uint32_t  SDIO_FLAG)

Clears the SDIO's pending flags.

Parameters
SDIO_FLAG,:specifies the flag to clear. This parameter can be one or a combination of the following values:
  • SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed)
  • SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
  • SDIO_FLAG_CTIMEOUT: Command response timeout
  • SDIO_FLAG_DTIMEOUT: Data timeout
  • SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
  • SDIO_FLAG_RXOVERR: Received FIFO overrun error
  • SDIO_FLAG_CMDREND: Command response received (CRC check passed)
  • SDIO_FLAG_CMDSENT: Command sent (no response required)
  • SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero)
  • SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide bus mode
  • SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed)
  • SDIO_FLAG_SDIOIT: SD I/O interrupt received
  • SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61
Return values
None
void SDIO_ClearITPendingBit ( uint32_t  SDIO_IT)

Clears the SDIO's interrupt pending bits.

Parameters
SDIO_IT,:specifies the interrupt pending bit to clear. This parameter can be one or a combination of the following values:
  • SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  • SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  • SDIO_IT_CTIMEOUT: Command response timeout interrupt
  • SDIO_IT_DTIMEOUT: Data timeout interrupt
  • SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  • SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
  • SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt
  • SDIO_IT_CMDSENT: Command sent (no response required) interrupt
  • SDIO_IT_DATAEND: Data end (data counter, SDIO_DCOUNT, is zero) interrupt
  • SDIO_IT_STBITERR: Start bit not detected on all data signals in wide bus mode interrupt
  • SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
  • SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61
Return values
None
void SDIO_ClockCmd ( FunctionalState  NewState)

Enables or disables the SDIO Clock.

Parameters
NewState,:new state of the SDIO Clock. This parameter can be: ENABLE or DISABLE.
Return values
None
void SDIO_CmdStructInit ( SDIO_CmdInitTypeDef SDIO_CmdInitStruct)

Fills each SDIO_CmdInitStruct member with its default value.

Parameters
SDIO_CmdInitStruct,:pointer to an SDIO_CmdInitTypeDef structure which will be initialized.
Return values
None
void SDIO_CommandCompletionCmd ( FunctionalState  NewState)

Enables or disables the command completion signal.

Parameters
NewState,:new state of command completion signal. This parameter can be: ENABLE or DISABLE.
Return values
None
void SDIO_DataConfig ( SDIO_DataInitTypeDef SDIO_DataInitStruct)

Initializes the SDIO data path according to the specified parameters in the SDIO_DataInitStruct.

Parameters
SDIO_DataInitStruct: pointer to a SDIO_DataInitTypeDef structure that contains the configuration information for the SDIO command.
Return values
None
void SDIO_DataStructInit ( SDIO_DataInitTypeDef SDIO_DataInitStruct)

Fills each SDIO_DataInitStruct member with its default value.

Parameters
SDIO_DataInitStruct,:pointer to an SDIO_DataInitTypeDef structure which will be initialized.
Return values
None
void SDIO_DeInit ( void  )

Deinitializes the SDIO peripheral registers to their default reset values.

Parameters
None
Return values
None
void SDIO_DMACmd ( FunctionalState  NewState)

Enables or disables the SDIO DMA request.

Parameters
NewState,:new state of the selected SDIO DMA request. This parameter can be: ENABLE or DISABLE.
Return values
None
uint8_t SDIO_GetCommandResponse ( void  )

Returns command index of last command for which response received.

Parameters
None
Return values
Returnsthe command index of the last command response received.
uint32_t SDIO_GetDataCounter ( void  )

Returns number of remaining data bytes to be transferred.

Parameters
None
Return values
Numberof remaining data bytes to be transferred
uint32_t SDIO_GetFIFOCount ( void  )

Returns the number of words left to be written to or read from FIFO.

Parameters
None
Return values
Remainingnumber of words.
FlagStatus SDIO_GetFlagStatus ( uint32_t  SDIO_FLAG)

Checks whether the specified SDIO flag is set or not.

Parameters
SDIO_FLAG,:specifies the flag to check. This parameter can be one of the following values:
  • SDIO_FLAG_CCRCFAIL: Command response received (CRC check failed)
  • SDIO_FLAG_DCRCFAIL: Data block sent/received (CRC check failed)
  • SDIO_FLAG_CTIMEOUT: Command response timeout
  • SDIO_FLAG_DTIMEOUT: Data timeout
  • SDIO_FLAG_TXUNDERR: Transmit FIFO underrun error
  • SDIO_FLAG_RXOVERR: Received FIFO overrun error
  • SDIO_FLAG_CMDREND: Command response received (CRC check passed)
  • SDIO_FLAG_CMDSENT: Command sent (no response required)
  • SDIO_FLAG_DATAEND: Data end (data counter, SDIDCOUNT, is zero)
  • SDIO_FLAG_STBITERR: Start bit not detected on all data signals in wide bus mode.
  • SDIO_FLAG_DBCKEND: Data block sent/received (CRC check passed)
  • SDIO_FLAG_CMDACT: Command transfer in progress
  • SDIO_FLAG_TXACT: Data transmit in progress
  • SDIO_FLAG_RXACT: Data receive in progress
  • SDIO_FLAG_TXFIFOHE: Transmit FIFO Half Empty
  • SDIO_FLAG_RXFIFOHF: Receive FIFO Half Full
  • SDIO_FLAG_TXFIFOF: Transmit FIFO full
  • SDIO_FLAG_RXFIFOF: Receive FIFO full
  • SDIO_FLAG_TXFIFOE: Transmit FIFO empty
  • SDIO_FLAG_RXFIFOE: Receive FIFO empty
  • SDIO_FLAG_TXDAVL: Data available in transmit FIFO
  • SDIO_FLAG_RXDAVL: Data available in receive FIFO
  • SDIO_FLAG_SDIOIT: SD I/O interrupt received
  • SDIO_FLAG_CEATAEND: CE-ATA command completion signal received for CMD61
Return values
Thenew state of SDIO_FLAG (SET or RESET).
ITStatus SDIO_GetITStatus ( uint32_t  SDIO_IT)

Checks whether the specified SDIO interrupt has occurred or not.

Parameters
SDIO_IT,:specifies the SDIO interrupt source to check. This parameter can be one of the following values:
  • SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  • SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  • SDIO_IT_CTIMEOUT: Command response timeout interrupt
  • SDIO_IT_DTIMEOUT: Data timeout interrupt
  • SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  • SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
  • SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt
  • SDIO_IT_CMDSENT: Command sent (no response required) interrupt
  • SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt
  • SDIO_IT_STBITERR: Start bit not detected on all data signals in wide bus mode interrupt
  • SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
  • SDIO_IT_CMDACT: Command transfer in progress interrupt
  • SDIO_IT_TXACT: Data transmit in progress interrupt
  • SDIO_IT_RXACT: Data receive in progress interrupt
  • SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
  • SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
  • SDIO_IT_TXFIFOF: Transmit FIFO full interrupt
  • SDIO_IT_RXFIFOF: Receive FIFO full interrupt
  • SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt
  • SDIO_IT_RXFIFOE: Receive FIFO empty interrupt
  • SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt
  • SDIO_IT_RXDAVL: Data available in receive FIFO interrupt
  • SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
  • SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt
Return values
Thenew state of SDIO_IT (SET or RESET).
uint32_t SDIO_GetPowerState ( void  )

Gets the power status of the controller.

Parameters
None
Return values
Powerstatus of the controller. The returned value can be one of the following values:
  • 0x00: Power OFF
  • 0x02: Power UP
  • 0x03: Power ON
uint32_t SDIO_GetResponse ( uint32_t  SDIO_RESP)

Returns response received from the card for the last command.

Parameters
SDIO_RESP,:Specifies the SDIO response register. This parameter can be one of the following values:
  • SDIO_RESP1: Response Register 1
  • SDIO_RESP2: Response Register 2
  • SDIO_RESP3: Response Register 3
  • SDIO_RESP4: Response Register 4
Return values
TheCorresponding response register value.
void SDIO_Init ( SDIO_InitTypeDef SDIO_InitStruct)

Initializes the SDIO peripheral according to the specified parameters in the SDIO_InitStruct.

Parameters
SDIO_InitStruct: pointer to a SDIO_InitTypeDef structure that contains the configuration information for the SDIO peripheral.
Return values
None
void SDIO_ITConfig ( uint32_t  SDIO_IT,
FunctionalState  NewState 
)

Enables or disables the SDIO interrupts.

Parameters
SDIO_IT,:specifies the SDIO interrupt sources to be enabled or disabled. This parameter can be one or a combination of the following values:
  • SDIO_IT_CCRCFAIL: Command response received (CRC check failed) interrupt
  • SDIO_IT_DCRCFAIL: Data block sent/received (CRC check failed) interrupt
  • SDIO_IT_CTIMEOUT: Command response timeout interrupt
  • SDIO_IT_DTIMEOUT: Data timeout interrupt
  • SDIO_IT_TXUNDERR: Transmit FIFO underrun error interrupt
  • SDIO_IT_RXOVERR: Received FIFO overrun error interrupt
  • SDIO_IT_CMDREND: Command response received (CRC check passed) interrupt
  • SDIO_IT_CMDSENT: Command sent (no response required) interrupt
  • SDIO_IT_DATAEND: Data end (data counter, SDIDCOUNT, is zero) interrupt
  • SDIO_IT_STBITERR: Start bit not detected on all data signals in wide bus mode interrupt
  • SDIO_IT_DBCKEND: Data block sent/received (CRC check passed) interrupt
  • SDIO_IT_CMDACT: Command transfer in progress interrupt
  • SDIO_IT_TXACT: Data transmit in progress interrupt
  • SDIO_IT_RXACT: Data receive in progress interrupt
  • SDIO_IT_TXFIFOHE: Transmit FIFO Half Empty interrupt
  • SDIO_IT_RXFIFOHF: Receive FIFO Half Full interrupt
  • SDIO_IT_TXFIFOF: Transmit FIFO full interrupt
  • SDIO_IT_RXFIFOF: Receive FIFO full interrupt
  • SDIO_IT_TXFIFOE: Transmit FIFO empty interrupt
  • SDIO_IT_RXFIFOE: Receive FIFO empty interrupt
  • SDIO_IT_TXDAVL: Data available in transmit FIFO interrupt
  • SDIO_IT_RXDAVL: Data available in receive FIFO interrupt
  • SDIO_IT_SDIOIT: SD I/O interrupt received interrupt
  • SDIO_IT_CEATAEND: CE-ATA command completion signal received for CMD61 interrupt
NewState,:new state of the specified SDIO interrupts. This parameter can be: ENABLE or DISABLE.
Return values
None
uint32_t SDIO_ReadData ( void  )

Read one data word from Rx FIFO.

Parameters
None
Return values
Datareceived
void SDIO_SendCEATACmd ( FunctionalState  NewState)

Sends CE-ATA command (CMD61).

Parameters
NewState,:new state of CE-ATA command. This parameter can be: ENABLE or DISABLE.
Return values
None
void SDIO_SendCommand ( SDIO_CmdInitTypeDef SDIO_CmdInitStruct)

Initializes the SDIO Command according to the specified parameters in the SDIO_CmdInitStruct and send the command.

Parameters
SDIO_CmdInitStruct: pointer to a SDIO_CmdInitTypeDef structure that contains the configuration information for the SDIO command.
Return values
None
void SDIO_SendSDIOSuspendCmd ( FunctionalState  NewState)

Enables or disables the SD I/O Mode suspend command sending.

Parameters
NewState,:new state of the SD I/O Mode suspend command. This parameter can be: ENABLE or DISABLE.
Return values
None
void SDIO_SetPowerState ( uint32_t  SDIO_PowerState)

Sets the power status of the controller.

Parameters
SDIO_PowerState,:new state of the Power state. This parameter can be one of the following values:
  • SDIO_PowerState_OFF: SDIO Power OFF
  • SDIO_PowerState_ON: SDIO Power ON
Return values
None
void SDIO_SetSDIOOperation ( FunctionalState  NewState)

Enables or disables the SD I/O Mode Operation.

Parameters
NewState,:new state of SDIO specific operation. This parameter can be: ENABLE or DISABLE.
Return values
None
void SDIO_SetSDIOReadWaitMode ( uint32_t  SDIO_ReadWaitMode)

Sets one of the two options of inserting read wait interval.

Parameters
SDIO_ReadWaitMode,:SD I/O Read Wait operation mode. This parameter can be:
  • SDIO_ReadWaitMode_CLK: Read Wait control by stopping SDIOCLK
  • SDIO_ReadWaitMode_DATA2: Read Wait control using SDIO_DATA2
Return values
None
void SDIO_StartSDIOReadWait ( FunctionalState  NewState)

Starts the SD I/O Read Wait operation.

Parameters
NewState,:new state of the Start SDIO Read Wait operation. This parameter can be: ENABLE or DISABLE.
Return values
None
void SDIO_StopSDIOReadWait ( FunctionalState  NewState)

Stops the SD I/O Read Wait operation.

Parameters
NewState,:new state of the Stop SDIO Read Wait operation. This parameter can be: ENABLE or DISABLE.
Return values
None
void SDIO_StructInit ( SDIO_InitTypeDef SDIO_InitStruct)

Fills each SDIO_InitStruct member with its default value.

Parameters
SDIO_InitStruct,:pointer to an SDIO_InitTypeDef structure which will be initialized.
Return values
None
void SDIO_WriteData ( uint32_t  Data)

Write one data word to Tx FIFO.

Parameters
Data,:32-bit data word to write.
Return values
None