MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Overview

The SDIO card driver provide card initialization/IO direct and extend command interface.

SDIO CARD Operation

error log support

Not support yet

User configuable

Board dependency

Typical use case

Data Structures

struct  sdio_card_t
 SDIO card state. More...
 

Macros

#define FSL_SDIO_DRIVER_VERSION   (MAKE_VERSION(2U, 2U, 13U)) /*2.2.13*/
 Middleware version. More...
 
#define FSL_SDIO_MAX_IO_NUMS   (7U)
 sdio device support maximum IO number
 

Typedefs

typedef void(* sdio_io_irq_handler_t )(sdio_card_t *card, uint32_t func)
 sdio io handler
 

Enumerations

enum  sdio_io_direction_t {
  kSDIO_IORead = 0U,
  kSDIO_IOWrite = 1U
}
 sdio io read/write direction More...
 

Variables

SDMMCHOST_CONFIG sdio_card_t::host
 Host information.
 
sdiocard_usr_param_t sdio_card_t::usrParam
 user parameter
 
bool sdio_card_t::noInternalAlign
 use this flag to disable sdmmc align. More...
 
bool sdio_card_t::isHostReady
 use this flag to indicate if need host re-init or not
 
bool sdio_card_t::memPresentFlag
 indicate if memory present
 
uint32_t sdio_card_t::busClock_Hz
 SD bus clock frequency united in Hz.
 
uint32_t sdio_card_t::relativeAddress
 Relative address of the card.
 
uint8_t sdio_card_t::sdVersion
 SD version.
 
sd_timing_mode_t sdio_card_t::currentTiming
 current timing mode
 
sd_driver_strength_t sdio_card_t::driverStrength
 driver strength
 
sd_max_current_t sdio_card_t::maxCurrent
 card current limit
 
sdmmc_operation_voltage_t sdio_card_t::operationVoltage
 card operation voltage
 
uint8_t sdio_card_t::sdioVersion
 SDIO version.
 
uint8_t sdio_card_t::cccrVersioin
 CCCR version.
 
uint8_t sdio_card_t::ioTotalNumber
 total number of IO function
 
uint32_t sdio_card_t::cccrflags
 Flags in _sd_card_flag.
 
uint32_t sdio_card_t::io0blockSize
 record the io0 block size
 
uint32_t sdio_card_t::ocr
 Raw OCR content, only 24bit avalible for SDIO card.
 
uint32_t sdio_card_t::commonCISPointer
 point to common CIS
 
sdio_common_cis_t sdio_card_t::commonCIS
 CIS table.
 
sdio_fbr_t sdio_card_t::ioFBR [FSL_SDIO_MAX_IO_NUMS]
 FBR table.
 
sdio_func_cis_t sdio_card_t::funcCIS [FSL_SDIO_MAX_IO_NUMS]
 function CIS table
 
sdio_io_irq_handler_t sdio_card_t::ioIRQHandler [FSL_SDIO_MAX_IO_NUMS]
 io IRQ handler
 
uint8_t sdio_card_t::ioIntIndex
 used to record current enabled io interrupt index
 
uint8_t sdio_card_t::ioIntNums
 used to record total enabled io interrupt numbers
 

Initialization and deinitialization

status_t SDIO_Init (sdio_card_t *card)
 SDIO card init function. More...
 
void SDIO_Deinit (sdio_card_t *card)
 SDIO card deinit, include card and host deinit. More...
 
status_t SDIO_CardInit (sdio_card_t *card)
 Initializes the card. More...
 
void SDIO_CardDeinit (sdio_card_t *card)
 Deinitializes the card. More...
 
status_t SDIO_HostInit (sdio_card_t *card)
 initialize the host. More...
 
void SDIO_HostDeinit (sdio_card_t *card)
 Deinitializes the host. More...
 
void SDIO_HostReset (SDMMCHOST_CONFIG *host)
 reset the host. More...
 
void SDIO_PowerOnCard (SDMMCHOST_TYPE *base, const sdmmchost_pwr_card_t *pwr)
 power on card. More...
 
void SDIO_PowerOffCard (SDMMCHOST_TYPE *base, const sdmmchost_pwr_card_t *pwr)
 power on card. More...
 
status_t SDIO_CardInActive (sdio_card_t *card)
 set SDIO card to inactive state More...
 
status_t SDIO_GetCardCapability (sdio_card_t *card, sdio_func_num_t func)
 get SDIO card capability More...
 
status_t SDIO_SetBlockSize (sdio_card_t *card, sdio_func_num_t func, uint32_t blockSize)
 set SDIO card block size More...
 
status_t SDIO_CardReset (sdio_card_t *card)
 set SDIO card reset More...
 
status_t SDIO_SetDataBusWidth (sdio_card_t *card, sdio_bus_width_t busWidth)
 set SDIO card data bus width More...
 
status_t SDIO_SwitchToHighSpeed (sdio_card_t *card)
 switch the card to high speed More...
 
status_t SDIO_ReadCIS (sdio_card_t *card, sdio_func_num_t func, const uint32_t *tupleList, uint32_t tupleNum)
 read SDIO card CIS for each function More...
 
status_t SDIO_WaitCardDetectStatus (SDMMCHOST_TYPE *hostBase, const sdmmchost_detect_card_t *cd, bool waitCardStatus)
 sdio wait card detect function. More...
 
bool SDIO_IsCardPresent (sdio_card_t *card)
 sdio card present check function. More...
 

IO operations

status_t SDIO_IO_Write_Direct (sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *data, bool raw)
 IO direct write transfer function. More...
 
status_t SDIO_IO_Read_Direct (sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *data)
 IO direct read transfer function. More...
 
status_t SDIO_IO_RW_Direct (sdio_card_t *card, sdio_io_direction_t direction, sdio_func_num_t func, uint32_t regAddr, uint8_t dataIn, uint8_t *dataOut)
 IO direct read/write transfer function. More...
 
status_t SDIO_IO_Write_Extended (sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *buffer, uint32_t count, uint32_t flags)
 IO extended write transfer function. More...
 
status_t SDIO_IO_Read_Extended (sdio_card_t *card, sdio_func_num_t func, uint32_t regAddr, uint8_t *buffer, uint32_t count, uint32_t flags)
 IO extended read transfer function. More...
 
status_t SDIO_EnableIOInterrupt (sdio_card_t *card, sdio_func_num_t func, bool enable)
 enable IO interrupt More...
 
status_t SDIO_EnableIO (sdio_card_t *card, sdio_func_num_t func, bool enable)
 enable IO and wait IO ready More...
 
status_t SDIO_SelectIO (sdio_card_t *card, sdio_func_num_t func)
 select IO More...
 
status_t SDIO_AbortIO (sdio_card_t *card, sdio_func_num_t func)
 Abort IO transfer. More...
 
status_t SDIO_SetDriverStrength (sdio_card_t *card, sd_driver_strength_t driverStrength)
 Set driver strength. More...
 
status_t SDIO_EnableAsyncInterrupt (sdio_card_t *card, bool enable)
 Enable/Disable Async interrupt. More...
 
status_t SDIO_GetPendingInterrupt (sdio_card_t *card, uint8_t *pendingInt)
 Get pending interrupt. More...
 
status_t SDIO_IO_Transfer (sdio_card_t *card, sdio_command_t cmd, uint32_t argument, uint32_t blockSize, uint8_t *txData, uint8_t *rxData, uint16_t dataSize, uint32_t *response)
 sdio card io transfer function. More...
 
void SDIO_SetIOIRQHandler (sdio_card_t *card, sdio_func_num_t func, sdio_io_irq_handler_t handler)
 sdio set io IRQ handler. More...
 

Data Structure Documentation

struct _sdio_card

sdio card descriptor

Define the card structure including the necessary fields to identify and describe the card.

Data Fields

SDMMCHOST_CONFIG host
 Host information.
 
sdiocard_usr_param_t usrParam
 user parameter
 
bool noInternalAlign
 use this flag to disable sdmmc align. More...
 
bool isHostReady
 use this flag to indicate if need host re-init or not
 
bool memPresentFlag
 indicate if memory present
 
uint32_t busClock_Hz
 SD bus clock frequency united in Hz.
 
uint32_t relativeAddress
 Relative address of the card.
 
uint8_t sdVersion
 SD version.
 
sd_timing_mode_t currentTiming
 current timing mode
 
sd_driver_strength_t driverStrength
 driver strength
 
sd_max_current_t maxCurrent
 card current limit
 
sdmmc_operation_voltage_t operationVoltage
 card operation voltage
 
uint8_t sdioVersion
 SDIO version.
 
uint8_t cccrVersioin
 CCCR version.
 
uint8_t ioTotalNumber
 total number of IO function
 
uint32_t cccrflags
 Flags in _sd_card_flag.
 
uint32_t io0blockSize
 record the io0 block size
 
uint32_t ocr
 Raw OCR content, only 24bit avalible for SDIO card.
 
uint32_t commonCISPointer
 point to common CIS
 
sdio_common_cis_t commonCIS
 CIS table.
 
sdio_fbr_t ioFBR [FSL_SDIO_MAX_IO_NUMS]
 FBR table.
 
sdio_func_cis_t funcCIS [FSL_SDIO_MAX_IO_NUMS]
 function CIS table
 
sdio_io_irq_handler_t ioIRQHandler [FSL_SDIO_MAX_IO_NUMS]
 io IRQ handler
 
uint8_t ioIntIndex
 used to record current enabled io interrupt index
 
uint8_t ioIntNums
 used to record total enabled io interrupt numbers
 

Macro Definition Documentation

#define FSL_SDIO_DRIVER_VERSION   (MAKE_VERSION(2U, 2U, 13U)) /*2.2.13*/

Enumeration Type Documentation

Enumerator
kSDIO_IORead 

io read

kSDIO_IOWrite 

io write

Function Documentation

status_t SDIO_Init ( sdio_card_t *  card)
Parameters
cardCard descriptor.
Return values
kStatus_SDMMC_GoIdleFailed
kStatus_SDMMC_HandShakeOperationConditionFailed
kStatus_SDMMC_SDIO_InvalidCard
kStatus_SDMMC_SDIO_InvalidVoltage
kStatus_SDMMC_SendRelativeAddressFailed
kStatus_SDMMC_SelectCardFailed
kStatus_SDMMC_SDIO_SwitchHighSpeedFail
kStatus_SDMMC_SDIO_ReadCISFail
kStatus_SDMMC_TransferFailed
kStatus_Success
void SDIO_Deinit ( sdio_card_t *  card)
Parameters
cardCard descriptor.
status_t SDIO_CardInit ( sdio_card_t *  card)

This function initializes the card only, make sure the host is ready when call this function, otherwise it will return kStatus_SDMMC_HostNotReady.

Parameters
cardCard descriptor.
Return values
kStatus_SDMMC_HostNotReadyhost is not ready.
kStatus_SDMMC_GoIdleFailedGo idle failed.
kStatus_SDMMC_NotSupportYetCard not support.
kStatus_SDMMC_SendOperationConditionFailedSend operation condition failed.
kStatus_SDMMC_AllSendCidFailedSend CID failed.
kStatus_SDMMC_SendRelativeAddressFailedSend relative address failed.
kStatus_SDMMC_SendCsdFailedSend CSD failed.
kStatus_SDMMC_SelectCardFailedSend SELECT_CARD command failed.
kStatus_SDMMC_SendScrFailedSend SCR failed.
kStatus_SDMMC_SetBusWidthFailedSet bus width failed.
kStatus_SDMMC_SwitchHighSpeedFailedSwitch high speed failed.
kStatus_SDMMC_SetCardBlockSizeFailedSet card block size failed.
kStatus_SuccessOperate successfully.
void SDIO_CardDeinit ( sdio_card_t *  card)

This function deinitializes the specific card.

Parameters
cardCard descriptor.
status_t SDIO_HostInit ( sdio_card_t *  card)

This function deinitializes the specific host.

Parameters
cardCard descriptor.
void SDIO_HostDeinit ( sdio_card_t *  card)

This function deinitializes the host.

Parameters
cardCard descriptor.
void SDIO_HostReset ( SDMMCHOST_CONFIG *  host)

This function reset the specific host.

Parameters
hosthost descriptor.
void SDIO_PowerOnCard ( SDMMCHOST_TYPE *  base,
const sdmmchost_pwr_card_t pwr 
)

The power on operation depend on host or the user define power on function.

Parameters
basehost base address.
pwruser define power control configuration
void SDIO_PowerOffCard ( SDMMCHOST_TYPE *  base,
const sdmmchost_pwr_card_t pwr 
)

The power off operation depend on host or the user define power on function.

Parameters
basehost base address.
pwruser define power control configuration
status_t SDIO_CardInActive ( sdio_card_t *  card)
Parameters
cardCard descriptor.
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_GetCardCapability ( sdio_card_t *  card,
sdio_func_num_t  func 
)
Parameters
cardCard descriptor.
functionIO number
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_SetBlockSize ( sdio_card_t *  card,
sdio_func_num_t  func,
uint32_t  blockSize 
)
Parameters
cardCard descriptor.
functionio number
blocksize
Return values
kStatus_SDMMC_SetCardBlockSizeFailed
kStatus_SDMMC_SDIO_InvalidArgument
kStatus_Success
status_t SDIO_CardReset ( sdio_card_t *  card)
Parameters
cardCard descriptor.
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_SetDataBusWidth ( sdio_card_t *  card,
sdio_bus_width_t  busWidth 
)
Parameters
cardCard descriptor.
databus width
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_SwitchToHighSpeed ( sdio_card_t *  card)
Parameters
cardCard descriptor.
Return values
kStatus_SDMMC_TransferFailed
kStatus_SDMMC_SDIO_SwitchHighSpeedFail
kStatus_Success
status_t SDIO_ReadCIS ( sdio_card_t *  card,
sdio_func_num_t  func,
const uint32_t *  tupleList,
uint32_t  tupleNum 
)
Parameters
cardCard descriptor.
functionio number
tuplecode list
tuplecode number
Return values
kStatus_SDMMC_SDIO_ReadCISFail
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_WaitCardDetectStatus ( SDMMCHOST_TYPE *  hostBase,
const sdmmchost_detect_card_t cd,
bool  waitCardStatus 
)

Detect card through GPIO, CD, DATA3.

Parameters
cardcard descriptor.
carddetect configuration
waitCardStatuswait card detect status
bool SDIO_IsCardPresent ( sdio_card_t *  card)
Parameters
cardcard descriptor.
status_t SDIO_IO_Write_Direct ( sdio_card_t *  card,
sdio_func_num_t  func,
uint32_t  regAddr,
uint8_t *  data,
bool  raw 
)
Parameters
cardCard descriptor.
functionIO numner
registeraddress
thedata pinter to write
rawflag, indicate read after write or write only
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_IO_Read_Direct ( sdio_card_t *  card,
sdio_func_num_t  func,
uint32_t  regAddr,
uint8_t *  data 
)
Parameters
cardCard descriptor.
functionIO number
registeraddress
datapointer to read
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_IO_RW_Direct ( sdio_card_t *  card,
sdio_io_direction_t  direction,
sdio_func_num_t  func,
uint32_t  regAddr,
uint8_t  dataIn,
uint8_t *  dataOut 
)
Parameters
cardCard descriptor.
directionio access direction, please reference sdio_io_direction_t.
functionIO number
registeraddress
dataIndata to write
dataOutdata pointer for readback data, support both for read and write, when application want readback the data after write command, dataOut should not be NULL.
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_IO_Write_Extended ( sdio_card_t *  card,
sdio_func_num_t  func,
uint32_t  regAddr,
uint8_t *  buffer,
uint32_t  count,
uint32_t  flags 
)
Parameters
cardCard descriptor.
functionIO number
registeraddress
databuffer to write
datacount
writeflags
Return values
kStatus_SDMMC_TransferFailed
kStatus_SDMMC_SDIO_InvalidArgument
kStatus_Success
status_t SDIO_IO_Read_Extended ( sdio_card_t *  card,
sdio_func_num_t  func,
uint32_t  regAddr,
uint8_t *  buffer,
uint32_t  count,
uint32_t  flags 
)
Parameters
cardCard descriptor.
functionIO number
registeraddress
databuffer to read
datacount
writeflags
Return values
kStatus_SDMMC_TransferFailed
kStatus_SDMMC_SDIO_InvalidArgument
kStatus_Success
status_t SDIO_EnableIOInterrupt ( sdio_card_t *  card,
sdio_func_num_t  func,
bool  enable 
)
Parameters
cardCard descriptor.
functionIO number
enable/disableflag
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_EnableIO ( sdio_card_t *  card,
sdio_func_num_t  func,
bool  enable 
)
Parameters
cardCard descriptor.
functionIO number
enable/disableflag
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_SelectIO ( sdio_card_t *  card,
sdio_func_num_t  func 
)
Parameters
cardCard descriptor.
functionIO number
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_AbortIO ( sdio_card_t *  card,
sdio_func_num_t  func 
)
Parameters
cardCard descriptor.
functionIO number
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_SetDriverStrength ( sdio_card_t *  card,
sd_driver_strength_t  driverStrength 
)
Parameters
cardCard descriptor.
driverStrengthtarget driver strength.
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_EnableAsyncInterrupt ( sdio_card_t *  card,
bool  enable 
)
Parameters
cardCard descriptor.
funcfunction io number.
enabletrue is enable, false is disable.
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_GetPendingInterrupt ( sdio_card_t *  card,
uint8_t *  pendingInt 
)
Parameters
cardCard descriptor.
pendingIntpointer store pending interrupt
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
status_t SDIO_IO_Transfer ( sdio_card_t *  card,
sdio_command_t  cmd,
uint32_t  argument,
uint32_t  blockSize,
uint8_t *  txData,
uint8_t *  rxData,
uint16_t  dataSize,
uint32_t *  response 
)

This function can be used for trnansfer direct/extend command. Please pay attention to the non-align data buffer address transfer, if data buffer address can not meet host controller internal DMA requirement, sdio driver will try to use internal align buffer if data size is not bigger than internal buffer size, Align address transfer always can get a better performance, so if application want sdio driver make sure buffer address align, please redefine the SDMMC_GLOBAL_BUFFER_SIZE macro to a value which is big enough for your application.

Parameters
cardcard descriptor.
cmdcommand to transfer
argumentargument to transfer
blockSizeused for block mode.
txDatatx buffer pointer or NULL
rxDatarx buffer pointer or NULL
dataSizetransfer data size
responsereponse pointer, if application want read response back, please set it to a NON-NULL pointer.
void SDIO_SetIOIRQHandler ( sdio_card_t *  card,
sdio_func_num_t  func,
sdio_io_irq_handler_t  handler 
)
Parameters
cardcard descriptor.
funcfunction io number.
handler,ioIRQ handler.

Variable Documentation

bool sdio_card_t::noInternalAlign

If disable, sdmmc will not make sure the data buffer address is word align, otherwise all the transfer are align to low level driver