All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
SDHC: Secured Digital Host Controller Driver

## Overview

The KSDK provides a peripheral driver for the Secured Digital Host Controller (SDHC) module of Kinetis devices.

# Typical use case

## SDHC Operation

/* Initializes the SDHC. */
sdhcConfig->cardDetectDat3 = false;
sdhcConfig->endianMode = kSDHC_EndianModeLittle;
sdhcConfig->dmaMode = kSDHC_DmaModeAdma2;
sdhcConfig->readWatermarkLevel = 0x80U;
sdhcConfig->writeWatermarkLevel = 0x80U;
SDHC_Init(BOARD_SDHC_BASEADDR, sdhcConfig);
/* Fills state in the card driver. */
card->sdhcBase = BOARD_SDHC_BASEADDR;
card->sdhcSourceClock = CLOCK_GetFreq(BOARD_SDHC_CLKSRC);
card->sdhcTransfer = sdhc_transfer_function;
/* Initializes the card. */
if (SD_Init(card))
{
PRINTF("\r\nSD card init failed.\r\n");
}
PRINTF("\r\nRead/Write/Erase the card continuously until it encounters error......\r\n");
while (true)
{
if (kStatus_Success != SD_WriteBlocks(card, g_dataWrite, DATA_BLOCK_START, DATA_BLOCK_COUNT))
{
PRINTF("Write multiple data blocks failed.\r\n");
}
if (kStatus_Success != SD_ReadBlocks(card, g_dataRead, DATA_BLOCK_START, DATA_BLOCK_COUNT))
{
PRINTF("Read multiple data blocks failed.\r\n");
}
if (kStatus_Success != SD_EraseBlocks(card, DATA_BLOCK_START, DATA_BLOCK_COUNT))
{
PRINTF("Erase multiple data blocks failed.\r\n");
}
}
SD_Deinit(card);

## Data Structures

struct | sdhc_adma2_descriptor_t
| Defines the ADMA2 descriptor structure. More...
struct | sdhc_capability_t
| SDHC capability information. More...
struct | sdhc_transfer_config_t
| Card transfer configuration. More...
struct | sdhc_boot_config_t
| Data structure to configure the MMC boot feature. More...
struct | sdhc_config_t
| Data structure to initialize the SDHC. More...
struct | sdhc_data_t
| Card data descriptor. More...
struct | sdhc_command_t
| Card command descriptor. More...
struct | sdhc_transfer_t
| Transfer state. More...
struct | sdhc_transfer_callback_t
| SDHC callback functions. More...
struct | sdhc_handle_t
| SDHC handle. More...
struct | sdhc_host_t
| SDHC host descriptor. More...

## Macros

#define | SDHC_MAX_BLOCK_COUNT (SDHC_BLKATTR_BLKCNT_MASK >> SDHC_BLKATTR_BLKCNT_SHIFT)
| Maximum block count can be set one time.
#define | SDHC_ADMA1_ADDRESS_ALIGN (4096U)
| The alignment size for ADDRESS filed in ADMA1's descriptor.
#define | SDHC_ADMA1_LENGTH_ALIGN (4096U)
| The alignment size for LENGTH field in ADMA1's descriptor.
#define | SDHC_ADMA2_ADDRESS_ALIGN (4U)
| The alignment size for ADDRESS field in ADMA2's descriptor.
#define | SDHC_ADMA2_LENGTH_ALIGN (4U)
| The alignment size for LENGTH filed in ADMA2's descriptor.
#define | SDHC_ADMA1_DESCRIPTOR_ADDRESS_SHIFT (12U)
| The bit shift for ADDRESS filed in ADMA1's descriptor.
#define | SDHC_ADMA1_DESCRIPTOR_ADDRESS_MASK (0xFFFFFU)
| The bit mask for ADDRESS field in ADMA1's descriptor.
#define | SDHC_ADMA1_DESCRIPTOR_LENGTH_SHIFT (12U)
| The bit shift for LENGTH filed in ADMA1's descriptor.
#define | SDHC_ADMA1_DESCRIPTOR_LENGTH_MASK (0xFFFFU)
| The mask for LENGTH field in ADMA1's descriptor.
#define | SDHC_ADMA1_DESCRIPTOR_MAX_LENGTH_PER_ENTRY (SDHC_ADMA1_DESCRIPTOR_LENGTH_MASK + 1U)
| The maximum value of LENGTH filed in ADMA1's descriptor.
#define | SDHC_ADMA2_DESCRIPTOR_LENGTH_SHIFT (16U)
| The bit shift for LENGTH field in ADMA2's descriptor.
#define | SDHC_ADMA2_DESCRIPTOR_LENGTH_MASK (0xFFFFU)
| The bit mask for LENGTH field in ADMA2's descriptor.
#define | SDHC_ADMA2_DESCRIPTOR_MAX_LENGTH_PER_ENTRY (SDHC_ADMA2_DESCRIPTOR_LENGTH_MASK)
| The maximum value of LENGTH field in ADMA2's descriptor.

## Typedefs

typedef uint32_t | sdhc_adma1_descriptor_t
| Defines the adma1 descriptor structure. More...
typedef status_t(* | sdhc_transfer_function_t )(SDHC_Type *base, sdhc_transfer_t *content)
| SDHC transfer function. More...

## Enumerations

enum | _sdhc_status { kStatus_SDHC_BusyTransferring = MAKE_STATUS(kStatusGroup_SDHC, 0U), kStatus_SDHC_PrepareAdmaDescriptorFailed = MAKE_STATUS(kStatusGroup_SDHC, 1U), kStatus_SDHC_SendCommandFailed = MAKE_STATUS(kStatusGroup_SDHC, 2U), kStatus_SDHC_TransferDataFailed = MAKE_STATUS(kStatusGroup_SDHC, 3U) }
| SDHC status. More...

enum

_sdhc_capability_flag {
kSDHC_SupportAdmaFlag = SDHC_HTCAPBLT_ADMAS_MASK,
kSDHC_SupportHighSpeedFlag = SDHC_HTCAPBLT_HSS_MASK,
kSDHC_SupportDmaFlag = SDHC_HTCAPBLT_DMAS_MASK,
kSDHC_SupportSuspendResumeFlag = SDHC_HTCAPBLT_SRS_MASK,
kSDHC_SupportV330Flag = SDHC_HTCAPBLT_VS33_MASK,
kSDHC_Support4BitFlag = (SDHC_HTCAPBLT_MBL_SHIFT << 0U),
kSDHC_Support8BitFlag = (SDHC_HTCAPBLT_MBL_SHIFT << 1U)
}

| Host controller capabilities flag mask. More...
enum | _sdhc_wakeup_event { kSDHC_WakeupEventOnCardInt = SDHC_PROCTL_WECINT_MASK, kSDHC_WakeupEventOnCardInsert = SDHC_PROCTL_WECINS_MASK, kSDHC_WakeupEventOnCardRemove = SDHC_PROCTL_WECRM_MASK, kSDHC_WakeupEventsAll }
| Wakeup event mask. More...
enum | _sdhc_reset { kSDHC_ResetAll = SDHC_SYSCTL_RSTA_MASK, kSDHC_ResetCommand = SDHC_SYSCTL_RSTC_MASK, kSDHC_ResetData = SDHC_SYSCTL_RSTD_MASK, kSDHC_ResetsAll = (kSDHC_ResetAll | kSDHC_ResetCommand | kSDHC_ResetData) }
| Reset type mask. More...

enum

_sdhc_transfer_flag {
kSDHC_EnableDmaFlag = SDHC_XFERTYP_DMAEN_MASK,
kSDHC_CommandTypeSuspendFlag = (SDHC_XFERTYP_CMDTYP(1U)),
kSDHC_CommandTypeResumeFlag = (SDHC_XFERTYP_CMDTYP(2U)),
kSDHC_CommandTypeAbortFlag = (SDHC_XFERTYP_CMDTYP(3U)),
kSDHC_EnableBlockCountFlag = SDHC_XFERTYP_BCEN_MASK,
kSDHC_EnableAutoCommand12Flag = SDHC_XFERTYP_AC12EN_MASK,
kSDHC_DataReadFlag = SDHC_XFERTYP_DTDSEL_MASK,
kSDHC_MultipleBlockFlag = SDHC_XFERTYP_MSBSEL_MASK,
kSDHC_ResponseLength136Flag = SDHC_XFERTYP_RSPTYP(1U),
kSDHC_ResponseLength48Flag = SDHC_XFERTYP_RSPTYP(2U),
kSDHC_ResponseLength48BusyFlag = SDHC_XFERTYP_RSPTYP(3U),
kSDHC_EnableCrcCheckFlag = SDHC_XFERTYP_CCCEN_MASK,
kSDHC_EnableIndexCheckFlag = SDHC_XFERTYP_CICEN_MASK,
kSDHC_DataPresentFlag = SDHC_XFERTYP_DPSEL_MASK
}

| Transfer flag mask. More...

enum

_sdhc_present_status_flag {
kSDHC_CommandInhibitFlag = SDHC_PRSSTAT_CIHB_MASK,
kSDHC_DataInhibitFlag = SDHC_PRSSTAT_CDIHB_MASK,
kSDHC_DataLineActiveFlag = SDHC_PRSSTAT_DLA_MASK,
kSDHC_SdClockStableFlag = SDHC_PRSSTAT_SDSTB_MASK,
kSDHC_WriteTransferActiveFlag = SDHC_PRSSTAT_WTA_MASK,
kSDHC_ReadTransferActiveFlag = SDHC_PRSSTAT_RTA_MASK,
kSDHC_BufferWriteEnableFlag = SDHC_PRSSTAT_BWEN_MASK,
kSDHC_BufferReadEnableFlag = SDHC_PRSSTAT_BREN_MASK,
kSDHC_CardInsertedFlag = SDHC_PRSSTAT_CINS_MASK,
kSDHC_CommandLineLevelFlag = SDHC_PRSSTAT_CLSL_MASK,
kSDHC_Data0LineLevelFlag = (1U << 24U),
kSDHC_Data1LineLevelFlag = (1U << 25U),
kSDHC_Data2LineLevelFlag = (1U << 26U),
kSDHC_Data3LineLevelFlag = (1U << 27U),
kSDHC_Data4LineLevelFlag = (1U << 28U),
kSDHC_Data5LineLevelFlag = (1U << 29U),
kSDHC_Data6LineLevelFlag = (1U << 30U),
kSDHC_Data7LineLevelFlag = (1U << 31U)
}

| Present status flag mask. More...

enum

_sdhc_interrupt_status_flag {
kSDHC_CommandCompleteFlag = SDHC_IRQSTAT_CC_MASK,
kSDHC_DataCompleteFlag = SDHC_IRQSTAT_TC_MASK,
kSDHC_BlockGapEventFlag = SDHC_IRQSTAT_BGE_MASK,
kSDHC_DmaCompleteFlag = SDHC_IRQSTAT_DINT_MASK,
kSDHC_BufferWriteReadyFlag = SDHC_IRQSTAT_BWR_MASK,
kSDHC_BufferReadReadyFlag = SDHC_IRQSTAT_BRR_MASK,
kSDHC_CardInsertionFlag = SDHC_IRQSTAT_CINS_MASK,
kSDHC_CardRemovalFlag = SDHC_IRQSTAT_CRM_MASK,
kSDHC_CardInterruptFlag = SDHC_IRQSTAT_CINT_MASK,
kSDHC_CommandTimeoutFlag = SDHC_IRQSTAT_CTOE_MASK,
kSDHC_CommandCrcErrorFlag = SDHC_IRQSTAT_CCE_MASK,
kSDHC_CommandEndBitErrorFlag = SDHC_IRQSTAT_CEBE_MASK,
kSDHC_CommandIndexErrorFlag = SDHC_IRQSTAT_CIE_MASK,
kSDHC_DataTimeoutFlag = SDHC_IRQSTAT_DTOE_MASK,
kSDHC_DataCrcErrorFlag = SDHC_IRQSTAT_DCE_MASK,
kSDHC_DataEndBitErrorFlag = SDHC_IRQSTAT_DEBE_MASK,
kSDHC_AutoCommand12ErrorFlag = SDHC_IRQSTAT_AC12E_MASK,
kSDHC_DmaErrorFlag = SDHC_IRQSTAT_DMAE_MASK,
kSDHC_CommandErrorFlag,
kSDHC_DataErrorFlag,
kSDHC_ErrorFlag = (kSDHC_CommandErrorFlag | kSDHC_DataErrorFlag | kSDHC_DmaErrorFlag),
kSDHC_DataFlag,
kSDHC_CommandFlag = (kSDHC_CommandErrorFlag | kSDHC_CommandCompleteFlag),
kSDHC_CardDetectFlag = (kSDHC_CardInsertionFlag | kSDHC_CardRemovalFlag),
kSDHC_AllInterruptFlags
}

| Interrupt status flag mask. More...

enum

_sdhc_auto_command12_error_status_flag {
kSDHC_AutoCommand12NotExecutedFlag = SDHC_AC12ERR_AC12NE_MASK,
kSDHC_AutoCommand12TimeoutFlag = SDHC_AC12ERR_AC12TOE_MASK,
kSDHC_AutoCommand12EndBitErrorFlag = SDHC_AC12ERR_AC12EBE_MASK,
kSDHC_AutoCommand12CrcErrorFlag = SDHC_AC12ERR_AC12CE_MASK,
kSDHC_AutoCommand12IndexErrorFlag = SDHC_AC12ERR_AC12IE_MASK,
kSDHC_AutoCommand12NotIssuedFlag = SDHC_AC12ERR_CNIBAC12E_MASK
}

| Auto CMD12 error status flag mask. More...
enum | _sdhc_adma_error_status_flag { kSDHC_AdmaLenghMismatchFlag = SDHC_ADMAES_ADMALME_MASK, kSDHC_AdmaDescriptorErrorFlag = SDHC_ADMAES_ADMADCE_MASK }
| ADMA error status flag mask. More...
enum | sdhc_adma_error_state_t { kSDHC_AdmaErrorStateStopDma = 0x00U, kSDHC_AdmaErrorStateFetchDescriptor = 0x01U, kSDHC_AdmaErrorStateChangeAddress = 0x02U, kSDHC_AdmaErrorStateTransferData = 0x03U }
| ADMA error state. More...

enum

_sdhc_force_event {
kSDHC_ForceEventAutoCommand12NotExecuted = SDHC_FEVT_AC12NE_MASK,
kSDHC_ForceEventAutoCommand12Timeout = SDHC_FEVT_AC12TOE_MASK,
kSDHC_ForceEventAutoCommand12CrcError = SDHC_FEVT_AC12CE_MASK,
kSDHC_ForceEventEndBitError = SDHC_FEVT_AC12EBE_MASK,
kSDHC_ForceEventAutoCommand12IndexError = SDHC_FEVT_AC12IE_MASK,
kSDHC_ForceEventAutoCommand12NotIssued = SDHC_FEVT_CNIBAC12E_MASK,
kSDHC_ForceEventCommandTimeout = SDHC_FEVT_CTOE_MASK,
kSDHC_ForceEventCommandCrcError = SDHC_FEVT_CCE_MASK,
kSDHC_ForceEventCommandEndBitError = SDHC_FEVT_CEBE_MASK,
kSDHC_ForceEventCommandIndexError = SDHC_FEVT_CIE_MASK,
kSDHC_ForceEventDataTimeout = SDHC_FEVT_DTOE_MASK,
kSDHC_ForceEventDataCrcError = SDHC_FEVT_DCE_MASK,
kSDHC_ForceEventDataEndBitError = SDHC_FEVT_DEBE_MASK,
kSDHC_ForceEventAutoCommand12Error = SDHC_FEVT_AC12E_MASK,
kSDHC_ForceEventCardInt = SDHC_FEVT_CINT_MASK,
kSDHC_ForceEventDmaError = SDHC_FEVT_DMAE_MASK,
kSDHC_ForceEventsAll
}

| Force event mask. More...
enum | sdhc_data_bus_width_t { kSDHC_DataBusWidth1Bit = 0U, kSDHC_DataBusWidth4Bit = 1U, kSDHC_DataBusWidth8Bit = 2U }
| Data transfer width. More...
enum | sdhc_endian_mode_t { kSDHC_EndianModeBig = 0U, kSDHC_EndianModeHalfWordBig = 1U, kSDHC_EndianModeLittle = 2U }
| Endian mode. More...
enum | sdhc_dma_mode_t { kSDHC_DmaModeNo = 0U, kSDHC_DmaModeAdma1 = 1U, kSDHC_DmaModeAdma2 = 2U }
| DMA mode. More...
enum | _sdhc_sdio_control_flag { kSDHC_StopAtBlockGapFlag = 0x01, kSDHC_ReadWaitControlFlag = 0x02, kSDHC_InterruptAtBlockGapFlag = 0x04, kSDHC_ExactBlockNumberReadFlag = 0x08 }
| SDIO control flag mask. More...
enum | sdhc_boot_mode_t { kSDHC_BootModeNormal = 0U, kSDHC_BootModeAlternative = 1U }
| MMC card boot mode. More...
enum | sdhc_command_type_t { kSDHC_CommandTypeNormal = 0U, kSDHC_CommandTypeSuspend = 1U, kSDHC_CommandTypeResume = 2U, kSDHC_CommandTypeAbort = 3U }
| The command type. More...
enum | sdhc_response_type_t { kSDHC_ResponseTypeNone = 0U, kSDHC_ResponseTypeR1 = 1U, kSDHC_ResponseTypeR1b = 2U, kSDHC_ResponseTypeR2 = 3U, kSDHC_ResponseTypeR3 = 4U, kSDHC_ResponseTypeR4 = 5U, kSDHC_ResponseTypeR5 = 6U, kSDHC_ResponseTypeR5b = 7U, kSDHC_ResponseTypeR6 = 8U, kSDHC_ResponseTypeR7 = 9U }
| The command response type. More...

enum

_sdhc_adma1_descriptor_flag {
kSDHC_Adma1DescriptorValidFlag = (1U << 0U),
kSDHC_Adma1DescriptorEndFlag = (1U << 1U),
kSDHC_Adma1DescriptorInterrupFlag = (1U << 2U),
kSDHC_Adma1DescriptorActivity1Flag = (1U << 4U),
kSDHC_Adma1DescriptorActivity2Flag = (1U << 5U),
kSDHC_Adma1DescriptorTypeNop = (kSDHC_Adma1DescriptorValidFlag),
kSDHC_Adma1DescriptorTypeTransfer,
kSDHC_Adma1DescriptorTypeLink,
kSDHC_Adma1DescriptorTypeSetLength
}

| The mask for the control/status field in ADMA1 descriptor. More...

enum

_sdhc_adma2_descriptor_flag {
kSDHC_Adma2DescriptorValidFlag = (1U << 0U),
kSDHC_Adma2DescriptorEndFlag = (1U << 1U),
kSDHC_Adma2DescriptorInterruptFlag = (1U << 2U),
kSDHC_Adma2DescriptorActivity1Flag = (1U << 4U),
kSDHC_Adma2DescriptorActivity2Flag = (1U << 5U),
kSDHC_Adma2DescriptorTypeNop = (kSDHC_Adma2DescriptorValidFlag),
kSDHC_Adma2DescriptorTypeReserved,
kSDHC_Adma2DescriptorTypeTransfer,
kSDHC_Adma2DescriptorTypeLink
}

| ADMA1 descriptor control and status mask. More...

## Driver version

#define | FSL_SDHC_DRIVER_VERSION (MAKE_VERSION(2U, 1U, 1U))
| Driver version 2.1.1. More...

## Initialization and deinitialization

void | SDHC_Init (SDHC_Type *base, const sdhc_config_t *config)
| SDHC module initialization function. More...
void | SDHC_Deinit (SDHC_Type *base)
| Deinitializes the SDHC. More...
bool | SDHC_Reset (SDHC_Type *base, uint32_t mask, uint32_t timeout)
| Resets the SDHC. More...

## DMA Control

status_t | SDHC_SetAdmaTableConfig (SDHC_Type *base, sdhc_dma_mode_t dmaMode, uint32_t *table, uint32_t tableWords, const uint32_t *data, uint32_t dataBytes)
| Sets the ADMA descriptor table configuration. More...

## Interrupts

static void | SDHC_EnableInterruptStatus (SDHC_Type *base, uint32_t mask)
| Enables the interrupt status. More...
static void | SDHC_DisableInterruptStatus (SDHC_Type *base, uint32_t mask)
| Disables the interrupt status. More...
static void | SDHC_EnableInterruptSignal (SDHC_Type *base, uint32_t mask)
| Enables interrupts signal corresponding to the interrupt status flag. More...
static void | SDHC_DisableInterruptSignal (SDHC_Type *base, uint32_t mask)
| Disables interrupts signal corresponding to the interrupt status flag. More...

## Status

static uint32_t | SDHC_GetInterruptStatusFlags (SDHC_Type *base)
| Gets the current interrupt status. More...
static void | SDHC_ClearInterruptStatusFlags (SDHC_Type *base, uint32_t mask)
| Clears a specified interrupt status. More...
static uint32_t | SDHC_GetAutoCommand12ErrorStatusFlags (SDHC_Type *base)
| Gets the status of auto command 12 error. More...
static uint32_t | SDHC_GetAdmaErrorStatusFlags (SDHC_Type *base)
| Gets the status of the ADMA error. More...
static uint32_t | SDHC_GetPresentStatusFlags (SDHC_Type *base)
| Gets a present status. More...

## Bus Operations

void | SDHC_GetCapability (SDHC_Type *base, sdhc_capability_t *capability)
| Gets the capability information. More...
static void | SDHC_EnableSdClock (SDHC_Type *base, bool enable)
| Enables or disables the SD bus clock. More...
uint32_t | SDHC_SetSdClock (SDHC_Type *base, uint32_t srcClock_Hz, uint32_t busClock_Hz)
| Sets the SD bus clock frequency. More...
bool | SDHC_SetCardActive (SDHC_Type *base, uint32_t timeout)
| Sends 80 clocks to the card to set it to be active state. More...
static void | SDHC_SetDataBusWidth (SDHC_Type *base, sdhc_data_bus_width_t width)
| Sets the data transfer width. More...
void | SDHC_SetTransferConfig (SDHC_Type *base, const sdhc_transfer_config_t *config)
| Sets the card transfer-related configuration. More...
static uint32_t | SDHC_GetCommandResponse (SDHC_Type *base, uint32_t index)
| Gets the command response. More...
static void | SDHC_WriteData (SDHC_Type *base, uint32_t data)
| Fills the the data port. More...
static uint32_t | SDHC_ReadData (SDHC_Type *base)
| Retrieves the data from the data port. More...
static void | SDHC_EnableWakeupEvent (SDHC_Type *base, uint32_t mask, bool enable)
| Enables or disables a wakeup event in low-power mode. More...
static void | SDHC_EnableCardDetectTest (SDHC_Type *base, bool enable)
| Enables or disables the card detection level for test. More...
static void | SDHC_SetCardDetectTestLevel (SDHC_Type *base, bool high)
| Sets the card detection test level. More...
void | SDHC_EnableSdioControl (SDHC_Type *base, uint32_t mask, bool enable)
| Enables or disables the SDIO card control. More...
static void | SDHC_SetContinueRequest (SDHC_Type *base)
| Restarts a transaction which has stopped at the block gap for SDIO card. More...
void | SDHC_SetMmcBootConfig (SDHC_Type *base, const sdhc_boot_config_t *config)
| Configures the MMC boot feature. More...
static void | SDHC_SetForceEvent (SDHC_Type *base, uint32_t mask)
| Forces to generate events according to the given mask. More...

## Transactional

status_t | SDHC_TransferBlocking (SDHC_Type *base, uint32_t *admaTable, uint32_t admaTableWords, sdhc_transfer_t *transfer)
| Transfers the command/data using blocking way. More...
void | SDHC_TransferCreateHandle (SDHC_Type *base, sdhc_handle_t *handle, const sdhc_transfer_callback_t *callback, void *userData)
| Creates the SDHC handle. More...
status_t | SDHC_TransferNonBlocking (SDHC_Type *base, sdhc_handle_t *handle, uint32_t *admaTable, uint32_t admaTableWords, sdhc_transfer_t *transfer)
| Transfers the command/data using interrupt and asynchronous way. More...
void | SDHC_TransferHandleIRQ (SDHC_Type *base, sdhc_handle_t *handle)
| IRQ handler for SDHC. More...

## Data Structure Documentation

struct sdhc_adma2_descriptor_t

### Data Fields

uint32_t | attribute
| The control and status field.
const uint32_t * | address
| The address field.

struct sdhc_capability_t

Defines a structure to save the capability information of SDHC.

### Data Fields

uint32_t | specVersion
| Specification version.
uint32_t | vendorVersion
| Vendor version.
uint32_t | maxBlockLength
| Maximum block length united as byte.
uint32_t | maxBlockCount
| Maximum block count can be set one time.
uint32_t | flags
| Capability flags to indicate the support information(_sdhc_capability_flag)

struct sdhc_transfer_config_t

Define structure to configure the transfer-related command index/argument/flags and data block size/data block numbers. This structure needs to be filled each time a command is sent to the card.

### Data Fields

size_t | dataBlockSize
| Data block size.
uint32_t | dataBlockCount
| Data block count.
uint32_t | commandArgument
| Command argument.
uint32_t | commandIndex
| Command index.
uint32_t | flags
| Transfer flags(_sdhc_transfer_flag)

struct sdhc_boot_config_t

### Data Fields

uint32_t | ackTimeoutCount
| Timeout value for the boot ACK.
sdhc_boot_mode_t | bootMode
| Boot mode selection. More...
uint32_t | blockCount
| Stop at block gap value of automatic mode.
bool | enableBootAck
| Enable or disable boot ACK.
bool | enableBoot
| Enable or disable fast boot.
bool | enableAutoStopAtBlockGap
| Enable or disable auto stop at block gap function in boot period.

#### Field Documentation

sdhc_boot_mode_t sdhc_boot_config_t::bootMode

struct sdhc_config_t

### Data Fields

bool | cardDetectDat3
| Enable DAT3 as card detection pin.
sdhc_endian_mode_t | endianMode
| Endian mode.
sdhc_dma_mode_t | dmaMode
| DMA mode.
uint32_t | readWatermarkLevel
| Watermark level for DMA read operation.
uint32_t | writeWatermarkLevel
| Watermark level for DMA write operation.

struct sdhc_data_t

Defines a structure to contain data-related attribute. 'enableIgnoreError' is used for the case that upper card driver want to ignore the error event to read/write all the data not to stop read/write immediately when error event happen for example bus testing procedure for MMC card.

### Data Fields

bool | enableAutoCommand12
| Enable auto CMD12.
bool | enableIgnoreError
| Enable to ignore error event to read/write all the data.
size_t | blockSize
| Block size.
uint32_t | blockCount
| Block count.
uint32_t * | rxData
| Buffer to save data read.
const uint32_t * | txData
| Data buffer to write.

struct sdhc_command_t

Define card command-related attribute.

### Data Fields

uint32_t | index
| Command index.
uint32_t | argument
| Command argument.
sdhc_command_type_t | type
| Command type.
sdhc_response_type_t | responseType
| Command response type.
uint32_t | response [4U]
| Response for this command.

struct sdhc_transfer_t

### Data Fields

sdhc_data_t * | data
| Data to transfer.
sdhc_command_t * | command
| Command to send.

struct sdhc_transfer_callback_t

### Data Fields

void(* | CardInserted )(void)
| Card inserted occurs when DAT3/CD pin is for card detect.
void(* | CardRemoved )(void)
| Card removed occurs.
void(* | SdioInterrupt )(void)
| SDIO card interrupt occurs.
void(* | SdioBlockGap )(void)
| SDIO card stopped at block gap occurs.
void(* | TransferComplete )(SDHC_Type *base, sdhc_handle_t *handle, status_t status, void *userData)
| Transfer complete callback.

struct _sdhc_handle

SDHC handle typedef.

Defines the structure to save the SDHC state information and callback function. The detail interrupt status when send command or transfer data can be obtained from interruptFlags field by using mask defined in sdhc_interrupt_flag_t;

Note
  All the fields except interruptFlags and transferredWords must be allocated by the user.

### Data Fields

sdhc_data_t *volatile | data
| Data to transfer.
sdhc_command_t *volatile | command
| Command to send.
volatile uint32_t | interruptFlags
| Interrupt flags of last transaction.
volatile uint32_t | transferredWords
| Words transferred by DATAPORT way.
sdhc_transfer_callback_t | callback
| Callback function.
void * | userData
| Parameter for transfer complete callback.

struct sdhc_host_t

### Data Fields

SDHC_Type * | base
| SDHC peripheral base address.
uint32_t | sourceClock_Hz
| SDHC source clock frequency united in Hz.
sdhc_config_t | config
| SDHC configuration.
sdhc_capability_t | capability
| SDHC capability information.
sdhc_transfer_function_t | transfer
| SDHC transfer function.

## Macro Definition Documentation

#define FSL_SDHC_DRIVER_VERSION (MAKE_VERSION(2U, 1U, 1U))

## Typedef Documentation

typedef uint32_t sdhc_adma1_descriptor_t

typedef status_t(* sdhc_transfer_function_t)(SDHC_Type *base, sdhc_transfer_t *content)

## Enumeration Type Documentation

enum _sdhc_status

Enumerator
kStatus_SDHC_BusyTransferring | Transfer is on-going.
kStatus_SDHC_PrepareAdmaDescriptorFailed | Set DMA descriptor failed.
kStatus_SDHC_SendCommandFailed | Send command failed.
kStatus_SDHC_TransferDataFailed | Transfer data failed.

enum _sdhc_capability_flag

Enumerator
kSDHC_SupportAdmaFlag | Support ADMA.
kSDHC_SupportHighSpeedFlag | Support high-speed.
kSDHC_SupportDmaFlag | Support DMA.
kSDHC_SupportSuspendResumeFlag | Support suspend/resume.
kSDHC_SupportV330Flag | Support voltage 3.3V.
kSDHC_Support4BitFlag | Support 4 bit mode.
kSDHC_Support8BitFlag | Support 8 bit mode.

enum _sdhc_wakeup_event

Enumerator
kSDHC_WakeupEventOnCardInt | Wakeup on card interrupt.
kSDHC_WakeupEventOnCardInsert | Wakeup on card insertion.
kSDHC_WakeupEventOnCardRemove | Wakeup on card removal.
kSDHC_WakeupEventsAll | All wakeup events.

enum _sdhc_reset

Enumerator
kSDHC_ResetAll | Reset all except card detection.
kSDHC_ResetCommand | Reset command line.
kSDHC_ResetData | Reset data line.
kSDHC_ResetsAll | All reset types.

enum _sdhc_transfer_flag

Enumerator
kSDHC_EnableDmaFlag | Enable DMA.
kSDHC_CommandTypeSuspendFlag | Suspend command.
kSDHC_CommandTypeResumeFlag | Resume command.
kSDHC_CommandTypeAbortFlag | Abort command.
kSDHC_EnableBlockCountFlag | Enable block count.
kSDHC_EnableAutoCommand12Flag | Enable auto CMD12.
kSDHC_DataReadFlag | Enable data read.
kSDHC_MultipleBlockFlag | Multiple block data read/write.
kSDHC_ResponseLength136Flag | 136 bit response length
kSDHC_ResponseLength48Flag | 48 bit response length
kSDHC_ResponseLength48BusyFlag | 48 bit response length with busy status
kSDHC_EnableCrcCheckFlag | Enable CRC check.
kSDHC_EnableIndexCheckFlag | Enable index check.
kSDHC_DataPresentFlag | Data present flag.

enum _sdhc_present_status_flag

Enumerator
kSDHC_CommandInhibitFlag | Command inhibit.
kSDHC_DataInhibitFlag | Data inhibit.
kSDHC_DataLineActiveFlag | Data line active.
kSDHC_SdClockStableFlag | SD bus clock stable.
kSDHC_WriteTransferActiveFlag | Write transfer active.
kSDHC_ReadTransferActiveFlag | Read transfer active.
kSDHC_BufferWriteEnableFlag | Buffer write enable.
kSDHC_BufferReadEnableFlag | Buffer read enable.
kSDHC_CardInsertedFlag | Card inserted.
kSDHC_CommandLineLevelFlag | Command line signal level.
kSDHC_Data0LineLevelFlag | Data0 line signal level.
kSDHC_Data1LineLevelFlag | Data1 line signal level.
kSDHC_Data2LineLevelFlag | Data2 line signal level.
kSDHC_Data3LineLevelFlag | Data3 line signal level.
kSDHC_Data4LineLevelFlag | Data4 line signal level.
kSDHC_Data5LineLevelFlag | Data5 line signal level.
kSDHC_Data6LineLevelFlag | Data6 line signal level.
kSDHC_Data7LineLevelFlag | Data7 line signal level.

enum _sdhc_interrupt_status_flag

Enumerator
kSDHC_CommandCompleteFlag | Command complete.
kSDHC_DataCompleteFlag | Data complete.
kSDHC_BlockGapEventFlag | Block gap event.
kSDHC_DmaCompleteFlag | DMA interrupt.
kSDHC_BufferWriteReadyFlag | Buffer write ready.
kSDHC_BufferReadReadyFlag | Buffer read ready.
kSDHC_CardInsertionFlag | Card inserted.
kSDHC_CardRemovalFlag | Card removed.
kSDHC_CardInterruptFlag | Card interrupt.
kSDHC_CommandTimeoutFlag | Command timeout error.
kSDHC_CommandCrcErrorFlag | Command CRC error.
kSDHC_CommandEndBitErrorFlag | Command end bit error.
kSDHC_CommandIndexErrorFlag | Command index error.
kSDHC_DataTimeoutFlag | Data timeout error.
kSDHC_DataCrcErrorFlag | Data CRC error.
kSDHC_DataEndBitErrorFlag | Data end bit error.
kSDHC_AutoCommand12ErrorFlag | Auto CMD12 error.
kSDHC_DmaErrorFlag | DMA error.
kSDHC_CommandErrorFlag | Command error.
kSDHC_DataErrorFlag | Data error.
kSDHC_ErrorFlag | All error.
kSDHC_DataFlag | Data interrupts.
kSDHC_CommandFlag | Command interrupts.
kSDHC_CardDetectFlag | Card detection interrupts.
kSDHC_AllInterruptFlags | All flags mask.

enum _sdhc_auto_command12_error_status_flag

Enumerator
kSDHC_AutoCommand12NotExecutedFlag | Not executed error.
kSDHC_AutoCommand12TimeoutFlag | Timeout error.
kSDHC_AutoCommand12EndBitErrorFlag | End bit error.
kSDHC_AutoCommand12CrcErrorFlag | CRC error.
kSDHC_AutoCommand12IndexErrorFlag | Index error.
kSDHC_AutoCommand12NotIssuedFlag | Not issued error.

enum _sdhc_adma_error_status_flag

Enumerator
kSDHC_AdmaLenghMismatchFlag | Length mismatch error.
kSDHC_AdmaDescriptorErrorFlag | Descriptor error.

enum sdhc_adma_error_state_t

This state is the detail state when ADMA error has occurred.

Enumerator
kSDHC_AdmaErrorStateStopDma | Stop DMA.
kSDHC_AdmaErrorStateFetchDescriptor | Fetch descriptor.
kSDHC_AdmaErrorStateChangeAddress | Change address.
kSDHC_AdmaErrorStateTransferData | Transfer data.

enum _sdhc_force_event

Enumerator
kSDHC_ForceEventAutoCommand12NotExecuted | Auto CMD12 not executed error.
kSDHC_ForceEventAutoCommand12Timeout | Auto CMD12 timeout error.
kSDHC_ForceEventAutoCommand12CrcError | Auto CMD12 CRC error.
kSDHC_ForceEventEndBitError | Auto CMD12 end bit error.
kSDHC_ForceEventAutoCommand12IndexError | Auto CMD12 index error.
kSDHC_ForceEventAutoCommand12NotIssued | Auto CMD12 not issued error.
kSDHC_ForceEventCommandTimeout | Command timeout error.
kSDHC_ForceEventCommandCrcError | Command CRC error.
kSDHC_ForceEventCommandEndBitError | Command end bit error.
kSDHC_ForceEventCommandIndexError | Command index error.
kSDHC_ForceEventDataTimeout | Data timeout error.
kSDHC_ForceEventDataCrcError | Data CRC error.
kSDHC_ForceEventDataEndBitError | Data end bit error.
kSDHC_ForceEventAutoCommand12Error | Auto CMD12 error.
kSDHC_ForceEventCardInt | Card interrupt.
kSDHC_ForceEventDmaError | Dma error.
kSDHC_ForceEventsAll | All force event flags mask.

enum sdhc_data_bus_width_t

Enumerator
kSDHC_DataBusWidth1Bit | 1-bit mode
kSDHC_DataBusWidth4Bit | 4-bit mode
kSDHC_DataBusWidth8Bit | 8-bit mode

enum sdhc_endian_mode_t

Enumerator
kSDHC_EndianModeBig | Big endian mode.
kSDHC_EndianModeHalfWordBig | Half word big endian mode.
kSDHC_EndianModeLittle | Little endian mode.

enum sdhc_dma_mode_t

Enumerator
kSDHC_DmaModeNo | No DMA.
kSDHC_DmaModeAdma1 | ADMA1 is selected.
kSDHC_DmaModeAdma2 | ADMA2 is selected.

enum _sdhc_sdio_control_flag

Enumerator
kSDHC_StopAtBlockGapFlag | Stop at block gap.
kSDHC_ReadWaitControlFlag | Read wait control.
kSDHC_InterruptAtBlockGapFlag | Interrupt at block gap.
kSDHC_ExactBlockNumberReadFlag | Exact block number read.

enum sdhc_boot_mode_t

Enumerator
kSDHC_BootModeNormal | Normal boot.
kSDHC_BootModeAlternative | Alternative boot.

enum sdhc_command_type_t

Enumerator
kSDHC_CommandTypeNormal | Normal command.
kSDHC_CommandTypeSuspend | Suspend command.
kSDHC_CommandTypeResume | Resume command.
kSDHC_CommandTypeAbort | Abort command.

enum sdhc_response_type_t

Define the command response type from card to host controller.

Enumerator
kSDHC_ResponseTypeNone | Response type: none.
kSDHC_ResponseTypeR1 | Response type: R1.
kSDHC_ResponseTypeR1b | Response type: R1b.
kSDHC_ResponseTypeR2 | Response type: R2.
kSDHC_ResponseTypeR3 | Response type: R3.
kSDHC_ResponseTypeR4 | Response type: R4.
kSDHC_ResponseTypeR5 | Response type: R5.
kSDHC_ResponseTypeR5b | Response type: R5b.
kSDHC_ResponseTypeR6 | Response type: R6.
kSDHC_ResponseTypeR7 | Response type: R7.

enum _sdhc_adma1_descriptor_flag

Enumerator
kSDHC_Adma1DescriptorValidFlag | Valid flag.
kSDHC_Adma1DescriptorEndFlag | End flag.
kSDHC_Adma1DescriptorInterrupFlag | Interrupt flag.
kSDHC_Adma1DescriptorActivity1Flag | Activity 1 flag.
kSDHC_Adma1DescriptorActivity2Flag | Activity 2 flag.
kSDHC_Adma1DescriptorTypeNop | No operation.
kSDHC_Adma1DescriptorTypeTransfer | Transfer data.
kSDHC_Adma1DescriptorTypeLink | Link descriptor.
kSDHC_Adma1DescriptorTypeSetLength | Set data length.

enum _sdhc_adma2_descriptor_flag

Enumerator
kSDHC_Adma2DescriptorValidFlag | Valid flag.
kSDHC_Adma2DescriptorEndFlag | End flag.
kSDHC_Adma2DescriptorInterruptFlag | Interrupt flag.
kSDHC_Adma2DescriptorActivity1Flag | Activity 1 mask.
kSDHC_Adma2DescriptorActivity2Flag | Activity 2 mask.
kSDHC_Adma2DescriptorTypeNop | No operation.
kSDHC_Adma2DescriptorTypeReserved | Reserved.
kSDHC_Adma2DescriptorTypeTransfer | Transfer type.
kSDHC_Adma2DescriptorTypeLink | Link type.

## Function Documentation

void SDHC_Init | ( | SDHC_Type * | base,
|  | const sdhc_config_t * | config
| ) |  |

Configures the SDHC according to the user configuration.

Example:

sdhc_config_t config;
config.enableDat3AsCDPin = false;
config.endianMode = kSDHC_EndianModeLittle;
config.dmaMode = kSDHC_DmaModeAdma2;
config.readWatermarkLevel = 512U;
config.writeWatermarkLevel = 512U;
SDHC_Init(SDHC, &config);

Parameters

  base | SDHC peripheral base address.
  config | SDHC configuration information.

Return values

  kStatus_Success | Operate successfully.

void SDHC_Deinit | ( | SDHC_Type * | base | ) |

Parameters

  base | SDHC peripheral base address.

bool SDHC_Reset | ( | SDHC_Type * | base,
|  | uint32_t | mask,
|  | uint32_t | timeout
| ) |  |

Parameters

  base | SDHC peripheral base address.
  mask | The reset type mask(_sdhc_reset).
  timeout | Timeout for reset.

Return values

  true | Reset successfully.
  false | Reset failed.

status_t SDHC_SetAdmaTableConfig | ( | SDHC_Type * | base,
|  | sdhc_dma_mode_t | dmaMode,
|  | uint32_t * | table,
|  | uint32_t | tableWords,
|  | const uint32_t * | data,
|  | uint32_t | dataBytes
| ) |  |

Parameters

  base | SDHC peripheral base address.
  dmaMode | DMA mode.
  table | ADMA table address.
  tableWords | ADMA table buffer length united as Words.
  data | Data buffer address.
  dataBytes | Data length united as bytes.

Return values

  kStatus_OutOfRange | ADMA descriptor table length isn't enough to describe data.
  kStatus_Success | Operate successfully.

static void SDHC_EnableInterruptStatus | ( | SDHC_Type * | base,
|  | uint32_t | mask
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  mask | Interrupt status flags mask(_sdhc_interrupt_status_flag).

static void SDHC_DisableInterruptStatus | ( | SDHC_Type * | base,
|  | uint32_t | mask
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  mask | The interrupt status flags mask(_sdhc_interrupt_status_flag).

static void SDHC_EnableInterruptSignal | ( | SDHC_Type * | base,
|  | uint32_t | mask
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  mask | The interrupt status flags mask(_sdhc_interrupt_status_flag).

static void SDHC_DisableInterruptSignal | ( | SDHC_Type * | base,
|  | uint32_t | mask
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  mask | The interrupt status flags mask(_sdhc_interrupt_status_flag).

static uint32_t SDHC_GetInterruptStatusFlags | ( | SDHC_Type * | base | ) |

inlinestatic

Parameters

  base | SDHC peripheral base address.

Returns
  Current interrupt status flags mask(_sdhc_interrupt_status_flag).

static void SDHC_ClearInterruptStatusFlags | ( | SDHC_Type * | base,
|  | uint32_t | mask
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  mask | The interrupt status flags mask(_sdhc_interrupt_status_flag).

static uint32_t SDHC_GetAutoCommand12ErrorStatusFlags | ( | SDHC_Type * | base | ) |

inlinestatic

Parameters

  base | SDHC peripheral base address.

Returns
  Auto command 12 error status flags mask(_sdhc_auto_command12_error_status_flag).

static uint32_t SDHC_GetAdmaErrorStatusFlags | ( | SDHC_Type * | base | ) |

inlinestatic

Parameters

  base | SDHC peripheral base address.

Returns
  ADMA error status flags mask(_sdhc_adma_error_status_flag).

static uint32_t SDHC_GetPresentStatusFlags | ( | SDHC_Type * | base | ) |

inlinestatic

This function gets the present SDHC's status except for interrupt status and error status.

Parameters

  base | SDHC peripheral base address.

Returns
  Present SDHC's status flags mask(_sdhc_present_status_flag).

void SDHC_GetCapability | ( | SDHC_Type * | base,
|  | sdhc_capability_t * | capability
| ) |  |

Parameters

  base | SDHC peripheral base address.
  capability | Structure to save capability information.

static void SDHC_EnableSdClock | ( | SDHC_Type * | base,
|  | bool | enable
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  enable | True to enable, false to disable.

uint32_t SDHC_SetSdClock | ( | SDHC_Type * | base,
|  | uint32_t | srcClock_Hz,
|  | uint32_t | busClock_Hz
| ) |  |

Parameters

  base | SDHC peripheral base address.
  srcClock_Hz | SDHC source clock frequency united in Hz.
  busClock_Hz | SD bus clock frequency united in Hz.

Returns
  The nearest frequency of busClock_Hz configured to SD bus.

bool SDHC_SetCardActive | ( | SDHC_Type * | base,
|  | uint32_t | timeout
| ) |  |

This function must be called after each time the card is inserted to make card can receive command correctly.

Parameters

  base | SDHC peripheral base address.
  timeout | Timeout to initialize card.

Return values

  true | Set card active successfully.
  false | Set card active failed.

static void SDHC_SetDataBusWidth | ( | SDHC_Type * | base,
|  | sdhc_data_bus_width_t | width
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  width | Data transfer width.

void SDHC_SetTransferConfig | ( | SDHC_Type * | base,
|  | const sdhc_transfer_config_t * | config
| ) |  |

This function fills card transfer-related command argument/transfer flag/data size. Command and data are sent by SDHC after calling this function.

Example:

sdhc_transfer_config_t transferConfig;
transferConfig.dataBlockSize = 512U;
transferConfig.dataBlockCount = 2U;
transferConfig.commandArgument = 0x01AAU;
transferConfig.commandIndex = 8U;
transferConfig.flags |= (kSDHC_EnableDmaFlag | kSDHC_EnableAutoCommand12Flag | kSDHC_MultipleBlockFlag);
SDHC_SetTransferConfig(SDHC, &transferConfig);

Parameters

  base | SDHC peripheral base address.
  config | Command configuration structure.

static uint32_t SDHC_GetCommandResponse | ( | SDHC_Type * | base,
|  | uint32_t | index
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  index | The index of response register, range from 0 to 3.

Returns
  Response register transfer.

static void SDHC_WriteData | ( | SDHC_Type * | base,
|  | uint32_t | data
| ) |  |

inlinestatic

This function is mainly used to implement the data transfer by Data Port instead of DMA.

Parameters

  base | SDHC peripheral base address.
  data | The data about to be sent.

static uint32_t SDHC_ReadData | ( | SDHC_Type * | base | ) |

inlinestatic

This function is mainly used to implement the data transfer by Data Port instead of DMA.

Parameters

  base | SDHC peripheral base address.

Returns
  The data has been read.

static void SDHC_EnableWakeupEvent | ( | SDHC_Type * | base,
|  | uint32_t | mask,
|  | bool | enable
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  mask | Wakeup events mask(_sdhc_wakeup_event).
  enable | True to enable, false to disable.

static void SDHC_EnableCardDetectTest | ( | SDHC_Type * | base,
|  | bool | enable
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  enable | True to enable, false to disable.

static void SDHC_SetCardDetectTestLevel | ( | SDHC_Type * | base,
|  | bool | high
| ) |  |

inlinestatic

This function set the card detection test level to indicate whether the card is inserted into SDHC when DAT[3]/ CD pin is selected as card detection pin. This function can also assert the pin logic when DAT[3]/CD pin is select as the card detection pin.

Parameters

  base | SDHC peripheral base address.
  high | True to set the card detect level to high.

void SDHC_EnableSdioControl | ( | SDHC_Type * | base,
|  | uint32_t | mask,
|  | bool | enable
| ) |  |

Parameters

  base | SDHC peripheral base address.
  mask | SDIO card control flags mask(_sdhc_sdio_control_flag).
  enable | True to enable, false to disable.

static void SDHC_SetContinueRequest | ( | SDHC_Type * | base | ) |

inlinestatic

Parameters

  base | SDHC peripheral base address.

void SDHC_SetMmcBootConfig | ( | SDHC_Type * | base,
|  | const sdhc_boot_config_t * | config
| ) |  |

Example:

sdhc_boot_config_t bootConfig;
bootConfig.ackTimeoutCount = 4;
bootConfig.bootMode = kSDHC_BootModeNormal;
bootConfig.blockCount = 5;
bootConfig.enableBootAck = true;
bootConfig.enableBoot = true;
enableBoot.enableAutoStopAtBlockGap = true;
SDHC_SetMmcBootConfig(SDHC, &bootConfig);

Parameters

  base | SDHC peripheral base address.
  config | The MMC boot configuration information.

static void SDHC_SetForceEvent | ( | SDHC_Type * | base,
|  | uint32_t | mask
| ) |  |

inlinestatic

Parameters

  base | SDHC peripheral base address.
  mask | The force events mask(_sdhc_force_event).

status_t SDHC_TransferBlocking | ( | SDHC_Type * | base,
|  | uint32_t * | admaTable,
|  | uint32_t | admaTableWords,
|  | sdhc_transfer_t * | transfer
| ) |  |

This function waits until the command response/data is got or SDHC encounters error by polling the status flag. Application must not call this API in multiple threads at the same time because of that this API doesn't support re-entry mechanism.

Note
  There is no need to call the API 'SDHC_TransferCreateHandle' when calling this API.

Parameters

  base | SDHC peripheral base address.
  admaTable | ADMA table address, can't be null if transfer way is ADMA1/ADMA2.
  admaTableWords | ADMA table length united as words, can't be 0 if transfer way is ADMA1/ADMA2.
  transfer | Transfer content.

Return values

  kStatus_InvalidArgument | Argument is invalid.
  kStatus_SDHC_PrepareAdmaDescriptorFailed | Prepare ADMA descriptor failed.
  kStatus_SDHC_SendCommandFailed | Send command failed.
  kStatus_SDHC_TransferDataFailed | Transfer data failed.
  kStatus_Success | Operate successfully.

void SDHC_TransferCreateHandle | ( | SDHC_Type * | base,
|  | sdhc_handle_t * | handle,
|  | const sdhc_transfer_callback_t * | callback,
|  | void * | userData
| ) |  |

Parameters

  base | SDHC peripheral base address.
  handle | SDHC handle pointer.
  callback | Structure pointer to contain all callback functions.
  userData | Callback function parameter.

status_t SDHC_TransferNonBlocking | ( | SDHC_Type * | base,
|  | sdhc_handle_t * | handle,
|  | uint32_t * | admaTable,
|  | uint32_t | admaTableWords,
|  | sdhc_transfer_t * | transfer
| ) |  |

This function send command and data and return immediately. It doesn't wait the transfer complete or encounter error. Application must not call this API in multiple threads at the same time because of that this API doesn't support re-entry mechanism.

Note
  Must call the API 'SDHC_TransferCreateHandle' when calling this API.

Parameters

  base | SDHC peripheral base address.
  handle | SDHC handle.
  admaTable | ADMA table address, can't be null if transfer way is ADMA1/ADMA2.
  admaTableWords | ADMA table length united as words, can't be 0 if transfer way is ADMA1/ADMA2.
  transfer | Transfer content.

Return values

  kStatus_InvalidArgument | Argument is invalid.
  kStatus_SDHC_BusyTransferring | Busy transferring.
  kStatus_SDHC_PrepareAdmaDescriptorFailed | Prepare ADMA descriptor failed.
  kStatus_Success | Operate successfully.

void SDHC_TransferHandleIRQ | ( | SDHC_Type * | base,
|  | sdhc_handle_t * | handle
| ) |  |

This function deals with IRQs on the given host controller.

Parameters

  base | SDHC peripheral base address.
  handle | SDHC handle.