MCUXpresso SDK API Reference Manual  Rev 2.15.000
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
USDHC HOST adapter Driver

Overview

The USDHC host adapter driver provide adapter for blocking/non_blocking mode.

Cache maintain capability

To maintain data integrity during DMA operations on the platform that has cache, host driver provide a cache maintain functionality by set: host.enableCacheControl = kSDMMCHOST_CacheControlRWBuffer This is used for only when the low level driver cache maintain functionality is disabled. It is suggest that the address of buffer used for read/write is align with cache line size.

Cache line alignment maintain capability

when application submit a transfer request that the data buffer address is not align with cache line size, the potential data loss may happen during driver maintain the data cache, to aovid such issue happens, sdmmc usdhc host driver provides support on convert the unalign data transfer into align data transfer, if application would like to use the feature, please enable this functionality by define below macro firstly, #define SDMMCHOST_ENABLE_CACHE_LINE_ALIGN_TRANSFER 1 And then call SDMMCHOST_InstallCacheAlignBuffer to install a cache line size align buffer, please note the installed buffer size must not small than 2 * cache line size. Please note that this functionality is support by the non blocking adapter only.

Data Structures

struct  _sdmmchost_
 sdmmc host handler More...
 

Macros

#define FSL_SDMMC_HOST_ADAPTER_VERSION   (MAKE_VERSION(2U, 6U, 3U)) /*2.6.3*/
 Middleware adapter version. More...
 
#define SDMMCHOST_SUPPORT_HIGH_SPEED   (1U)
 sdmmc host misc capability
 
#define SDMMCHOST_SUPPORT_DDR50   (SDMMCHOST_SUPPORT_DDR_MODE)
 sdmmc host sdcard DDR50 mode capability
 
#define SDMMCHOST_SUPPORT_SDR104   (1U)
 sdmmc host sdcard SDR50 mode capability
 
#define SDMMCHOST_SUPPORT_SDR50   (1U)
 sdmmc host sdcard SDR104/mmccard HS200 mode capability
 
#define SDMMCHOST_SUPPORT_HS400   (0U)
 sdmmc host mmccard HS400 mode capability
 
#define SDMMCHOST_INSTANCE_SUPPORT_8_BIT_WIDTH(host)   FSL_FEATURE_USDHC_INSTANCE_SUPPORT_8_BIT_WIDTHn(host->hostController.base)
 sdmmc host instance capability
 
#define SDMMCHOST_DATA3_DETECT_CARD_DELAY   (10U)
 sdmmchost delay for DAT3 detect card
 
#define SDMMCHOST_DMA_DESCRIPTOR_BUFFER_ALIGN_SIZE   (4U)
 SDMMC host dma descriptor buffer address align size.
 
#define SDMMCHOST_STANDARD_TUNING_START   (10U)
 tuning configuration More...
 
#define SDMMCHOST_TUINIG_STEP   (2U)
 standard tuning stBep
 

Typedefs

typedef usdhc_transfer_t sdmmchost_transfer_t
 sdmmc host transfer function
 
typedef struct _sdmmchost_ sdmmchost_t
 sdmmc host handler
 

Enumerations

enum  {
  kSDMMCHOST_SupportHighSpeed = 1U << 0U,
  kSDMMCHOST_SupportSuspendResume = 1U << 1U,
  kSDMMCHOST_SupportVoltage3v3 = 1U << 2U,
  kSDMMCHOST_SupportVoltage3v0 = 1U << 3U,
  kSDMMCHOST_SupportVoltage1v8 = 1U << 4U,
  kSDMMCHOST_SupportVoltage1v2 = 1U << 5U,
  kSDMMCHOST_Support4BitDataWidth = 1U << 6U,
  kSDMMCHOST_Support8BitDataWidth = 1U << 7U,
  kSDMMCHOST_SupportDDRMode = 1U << 8U,
  kSDMMCHOST_SupportDetectCardByData3 = 1U << 9U,
  kSDMMCHOST_SupportDetectCardByCD = 1U << 10U,
  kSDMMCHOST_SupportAutoCmd12 = 1U << 11U,
  kSDMMCHOST_SupportSDR104 = 1U << 12U,
  kSDMMCHOST_SupportSDR50 = 1U << 13U,
  kSDMMCHOST_SupportHS200 = 1U << 14U,
  kSDMMCHOST_SupportHS400 = 1U << 15U
}
 sdmmc host capability More...
 
enum  {
  kSDMMCHOST_EndianModeBig = 0U,
  kSDMMCHOST_EndianModeHalfWordBig = 1U,
  kSDMMCHOST_EndianModeLittle = 2U
}
 host Endian mode corresponding to driver define More...
 
enum  {
  kSDMMCHOST_StandardTuning = 0U,
  kSDMMCHOST_ManualTuning = 1U
}
 sdmmc host tuning type More...
 
enum  {
  kSDMMCHOST_NoCacheControl = 0U,
  kSDMMCHOST_CacheControlRWBuffer = 1U
}
 sdmmc host maintain cache flag More...
 

USDHC host controller function

void SDMMCHOST_SetCardBusWidth (sdmmchost_t *host, uint32_t dataBusWidth)
 set data bus width. More...
 
static void SDMMCHOST_SendCardActive (sdmmchost_t *host)
 Send initilization active 80 clocks to card. More...
 
static uint32_t SDMMCHOST_SetCardClock (sdmmchost_t *host, uint32_t targetClock)
 Set card bus clock. More...
 
static bool SDMMCHOST_IsCardBusy (sdmmchost_t *host)
 check card status by DATA0. More...
 
static uint32_t SDMMCHOST_GetSignalLineStatus (sdmmchost_t *host, uint32_t signalLine)
 Get signal line status. More...
 
static void SDMMCHOST_EnableCardInt (sdmmchost_t *host, bool enable)
 enable card interrupt. More...
 
static void SDMMCHOST_EnableDDRMode (sdmmchost_t *host, bool enable, uint32_t nibblePos)
 enable DDR mode. More...
 
static void SDMMCHOST_EnableHS400Mode (sdmmchost_t *host, bool enable)
 enable HS400 mode. More...
 
static void SDMMCHOST_EnableStrobeDll (sdmmchost_t *host, bool enable)
 enable STROBE DLL. More...
 
status_t SDMMCHOST_StartBoot (sdmmchost_t *host, sdmmchost_boot_config_t *hostConfig, sdmmchost_cmd_t *cmd, uint8_t *buffer)
 start read boot data. More...
 
status_t SDMMCHOST_ReadBootData (sdmmchost_t *host, sdmmchost_boot_config_t *hostConfig, uint8_t *buffer)
 read boot data. More...
 
static void SDMMCHOST_EnableBoot (sdmmchost_t *host, bool enable)
 enable boot mode. More...
 
status_t SDMMCHOST_CardIntInit (sdmmchost_t *host, void *sdioInt)
 card interrupt function. More...
 
static void SDMMCHOST_ForceClockOn (sdmmchost_t *host, bool enable)
 force card clock on. More...
 
void SDMMCHOST_SwitchToVoltage (sdmmchost_t *host, uint32_t voltage)
 switch to voltage. More...
 
status_t SDMMCHOST_CardDetectInit (sdmmchost_t *host, void *cd)
 card detect init function. More...
 
status_t SDMMCHOST_PollingCardDetectStatus (sdmmchost_t *host, uint32_t waitCardStatus, uint32_t timeout)
 Detect card insert, only need for SD cases. More...
 
uint32_t SDMMCHOST_CardDetectStatus (sdmmchost_t *host)
 card detect status. More...
 
status_t SDMMCHOST_Init (sdmmchost_t *host)
 Init host controller. More...
 
void SDMMCHOST_Deinit (sdmmchost_t *host)
 Deinit host controller. More...
 
void SDMMCHOST_SetCardPower (sdmmchost_t *host, bool enable)
 host power off card function. More...
 
status_t SDMMCHOST_TransferFunction (sdmmchost_t *host, sdmmchost_transfer_t *content)
 host transfer function. More...
 
status_t SDMMCHOST_ExecuteTuning (sdmmchost_t *host, uint32_t tuningCmd, uint32_t *revBuf, uint32_t blockSize)
 sdmmc host excute tuning. More...
 
void SDMMCHOST_Reset (sdmmchost_t *host)
 host reset function. More...
 
void SDMMCHOST_ConvertDataToLittleEndian (sdmmchost_t *host, uint32_t *data, uint32_t wordSize, uint32_t format)
 sdmmc host convert data sequence to little endian sequence More...
 

Data Structure Documentation

struct _sdmmchost_

Data Fields

usdhc_host_t hostController
 host configuration
 
void * dmaDesBuffer
 DMA descriptor buffer address.
 
uint32_t dmaDesBufferWordsNum
 DMA descriptor buffer size in byte.
 
usdhc_handle_t handle
 host controller handler
 
uint32_t capability
 host controller capability
 
uint32_t maxBlockCount
 host controller maximum block count
 
uint32_t maxBlockSize
 host controller maximum block size
 
uint8_t tuningType
 host tuning type
 
sdmmc_osa_event_t hostEvent
 host event handler
 
void * cd
 card detect
 
void * cardInt
 call back function for card interrupt
 
sdmmc_osa_mutex_t lock
 host access lock
 

Macro Definition Documentation

#define FSL_SDMMC_HOST_ADAPTER_VERSION   (MAKE_VERSION(2U, 6U, 3U)) /*2.6.3*/
#define SDMMCHOST_STANDARD_TUNING_START   (10U)

standard tuning start point

Enumeration Type Documentation

anonymous enum
Enumerator
kSDMMCHOST_SupportHighSpeed 

high speed capability

kSDMMCHOST_SupportSuspendResume 

suspend resume capability

kSDMMCHOST_SupportVoltage3v3 

3V3 capability

kSDMMCHOST_SupportVoltage3v0 

3V0 capability

kSDMMCHOST_SupportVoltage1v8 

1V8 capability

kSDMMCHOST_SupportVoltage1v2 

1V2 capability

kSDMMCHOST_Support4BitDataWidth 

4 bit data width capability

kSDMMCHOST_Support8BitDataWidth 

8 bit data width capability

kSDMMCHOST_SupportDDRMode 

DDR mode capability.

kSDMMCHOST_SupportDetectCardByData3 

data3 detect card capability

kSDMMCHOST_SupportDetectCardByCD 

CD detect card capability.

kSDMMCHOST_SupportAutoCmd12 

auto command 12 capability

kSDMMCHOST_SupportSDR104 

SDR104 capability.

kSDMMCHOST_SupportSDR50 

SDR50 capability.

kSDMMCHOST_SupportHS200 

HS200 capability.

kSDMMCHOST_SupportHS400 

HS400 capability.

anonymous enum

Enumerator
kSDMMCHOST_EndianModeBig 

Big endian mode.

kSDMMCHOST_EndianModeHalfWordBig 

Half word big endian mode.

kSDMMCHOST_EndianModeLittle 

Little endian mode.

anonymous enum

Enumerator
kSDMMCHOST_StandardTuning 

standard tuning type

kSDMMCHOST_ManualTuning 

manual tuning type

anonymous enum

Enumerator
kSDMMCHOST_NoCacheControl 

sdmmc host cache control disabled

kSDMMCHOST_CacheControlRWBuffer 

sdmmc host cache control read/write buffer

Function Documentation

void SDMMCHOST_SetCardBusWidth ( sdmmchost_t host,
uint32_t  dataBusWidth 
)
Parameters
hosthost handler
dataBusWidthdata bus width
static void SDMMCHOST_SendCardActive ( sdmmchost_t host)
inlinestatic
Parameters
hosthost handler
static uint32_t SDMMCHOST_SetCardClock ( sdmmchost_t host,
uint32_t  targetClock 
)
inlinestatic
Parameters
hosthost handler
targetClocktarget clock frequency
Return values
actualclock frequency can be reach.
static bool SDMMCHOST_IsCardBusy ( sdmmchost_t host)
inlinestatic
Parameters
hosthost handler
Return values
trueis busy, false is idle.
static uint32_t SDMMCHOST_GetSignalLineStatus ( sdmmchost_t host,
uint32_t  signalLine 
)
inlinestatic
Parameters
hosthost handler
signalLinesignal line type, reference _sdmmc_signal_line
static void SDMMCHOST_EnableCardInt ( sdmmchost_t host,
bool  enable 
)
inlinestatic
Parameters
hosthost handler
enabletrue is enable, false is disable.
static void SDMMCHOST_EnableDDRMode ( sdmmchost_t host,
bool  enable,
uint32_t  nibblePos 
)
inlinestatic
Parameters
hosthost handler
enabletrue is enable, false is disable.
nibblePosnibble position indictation. 0- the sequence is 'odd high nibble -> even high nibble -> odd low nibble -> even low nibble'; 1- the sequence is 'odd high nibble -> odd low nibble -> even high nibble -> even low nibble'.
static void SDMMCHOST_EnableHS400Mode ( sdmmchost_t host,
bool  enable 
)
inlinestatic
Parameters
hosthost handler
enabletrue is enable, false is disable.
static void SDMMCHOST_EnableStrobeDll ( sdmmchost_t host,
bool  enable 
)
inlinestatic
Parameters
hosthost handler
enabletrue is enable, false is disable.
status_t SDMMCHOST_StartBoot ( sdmmchost_t host,
sdmmchost_boot_config_t hostConfig,
sdmmchost_cmd_t cmd,
uint8_t *  buffer 
)
Parameters
hosthost handler
hostConfigboot configuration
cmdboot command
bufferbuffer address
status_t SDMMCHOST_ReadBootData ( sdmmchost_t host,
sdmmchost_boot_config_t hostConfig,
uint8_t *  buffer 
)
Parameters
hosthost handler
hostConfigboot configuration
bufferbuffer address
static void SDMMCHOST_EnableBoot ( sdmmchost_t host,
bool  enable 
)
inlinestatic
Parameters
hosthost handler
enabletrue is enable, false is disable
status_t SDMMCHOST_CardIntInit ( sdmmchost_t host,
void *  sdioInt 
)
Parameters
hosthost handler
sdioIntcard interrupt configuration
static void SDMMCHOST_ForceClockOn ( sdmmchost_t host,
bool  enable 
)
inlinestatic
Parameters
hosthost handler
enabletrue is enable, false is disable.
void SDMMCHOST_SwitchToVoltage ( sdmmchost_t host,
uint32_t  voltage 
)
Parameters
hosthost handler
voltageswitch to voltage level.
status_t SDMMCHOST_CardDetectInit ( sdmmchost_t host,
void *  cd 
)
Parameters
hosthost handler
cdcard detect configuration
status_t SDMMCHOST_PollingCardDetectStatus ( sdmmchost_t host,
uint32_t  waitCardStatus,
uint32_t  timeout 
)
Parameters
hosthost handler
waitCardStatusstatus which user want to wait
timeoutwait time out.
Return values
kStatus_Successdetect card insert
kStatus_Failcard insert event fail
uint32_t SDMMCHOST_CardDetectStatus ( sdmmchost_t host)
Parameters
hosthost handler
Return values
kSD_Inserted,kSD_Removed
status_t SDMMCHOST_Init ( sdmmchost_t host)

Thread safe function, please note that the function will create the mutex lock dynamically by default, so to avoid the mutex create redundantly, application must follow bellow sequence for card re-initialization

*
Parameters
hosthost handler
Return values
kStatus_Successhost init success
kStatus_Failevent fail
void SDMMCHOST_Deinit ( sdmmchost_t host)

Please note it is a thread safe function.

Parameters
hosthost handler
void SDMMCHOST_SetCardPower ( sdmmchost_t host,
bool  enable 
)
Parameters
hosthost handler
enabletrue is power on, false is power down.
status_t SDMMCHOST_TransferFunction ( sdmmchost_t host,
sdmmchost_transfer_t content 
)

Please note it is a thread safe function.

Note
the host transfer function support below functionality,
  1. Non-cache line size alignment check on the data buffer, it is means that no matter the data buffer used for data transfer is align with cache line size or not, sdmmc host driver will use the address directly.
  2. Cache line size alignment check on the data buffer, sdmmc host driver will check the data buffer address, if the buffer is not align with cache line size, sdmmc host driver will convert it to cache line size align buffer, the functionality is enabled by #define SDMMCHOST_ENABLE_CACHE_LINE_ALIGN_TRANSFER 1 #define FSL_USDHC_ENABLE_SCATTER_GATHER_TRANSFER 1U If application would like to enable the cache line size align functionality, please make sure the SDMMCHOST_InstallCacheAlignBuffer is called before submit data transfer request and make sure the installing buffer size is not smaller than 2 * cache line size.
Parameters
hosthost handler
contenttransfer content.
status_t SDMMCHOST_ExecuteTuning ( sdmmchost_t host,
uint32_t  tuningCmd,
uint32_t *  revBuf,
uint32_t  blockSize 
)
Parameters
hosthost handler
tuningCmdtuning command.
revBufreceive buffer pointer
blockSizetuning data block size.
void SDMMCHOST_Reset ( sdmmchost_t host)
Parameters
hosthost handler
void SDMMCHOST_ConvertDataToLittleEndian ( sdmmchost_t host,
uint32_t *  data,
uint32_t  wordSize,
uint32_t  format 
)
Parameters
hosthost handler.
datadata buffer address.
wordSizedata buffer size in word.
formatdata packet format.