MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Secure Digital Card/Embedded MultiMedia Card (CARD)

Overview

The MCUXpresso SDK provides a driver to access the Secure Digital Card and Embedded MultiMedia Card based on the SDHC driver.

Function groups

This function group implements the SD card functional API.

This function group implements the MMC card functional API.

Typical use case

/* Initialize SDHC. */
sdhcConfig->cardDetectDat3 = false;
sdhcConfig->endianMode = kSDHC_EndianModeLittle;
sdhcConfig->dmaMode = kSDHC_DmaModeAdma2;
sdhcConfig->readWatermarkLevel = 0x80U;
sdhcConfig->writeWatermarkLevel = 0x80U;
SDHC_Init(BOARD_SDHC_BASEADDR, sdhcConfig);
/* Save host information. */
card->host.base = BOARD_SDHC_BASEADDR;
card->host.sourceClock_Hz = CLOCK_GetFreq(BOARD_SDHC_CLKSRC);
card->host.transfer = SDHC_TransferFunction;
/* Init card. */
if (SD_Init(card))
{
PRINTF("\r\nSD card init failed.\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);
/* Initialize SDHC. */
sdhcConfig->cardDetectDat3 = false;
sdhcConfig->endianMode = kSDHC_EndianModeLittle;
sdhcConfig->dmaMode = kSDHC_DmaModeAdma2;
sdhcConfig->readWatermarkLevel = 0x80U;
sdhcConfig->writeWatermarkLevel = 0x80U;
SDHC_Init(BOARD_SDHC_BASEADDR, sdhcConfig);
/* Save host information. */
card->host.base = BOARD_SDHC_BASEADDR;
card->host.sourceClock_Hz = CLOCK_GetFreq(BOARD_SDHC_CLKSRC);
card->host.transfer = SDHC_TransferFunction;
/* Init card. */
if (MMC_Init(card))
{
PRINTF("\n MMC card init failed \n");
}
while (true)
{
if (kStatus_Success != MMC_WriteBlocks(card, g_dataWrite, DATA_BLOCK_START, DATA_BLOCK_COUNT))
{
PRINTF("Write multiple data blocks failed.\r\n");
}
if (kStatus_Success != MMC_ReadBlocks(card, g_dataRead, DATA_BLOCK_START, DATA_BLOCK_COUNT))
{
PRINTF("Read multiple data blocks failed.\r\n");
}
}
MMC_Deinit(card);

Data Structures

struct  sd_card_t
 SD card state. More...
 
struct  sdio_card_t
 SDIO card state. More...
 
struct  mmc_card_t
 SD card state. More...
 
struct  mmc_boot_config_t
 MMC card boot configuration definition. More...
 

Macros

#define FSL_SDMMC_DRIVER_VERSION   (MAKE_VERSION(2U, 1U, 2U)) /*2.1.2*/
 Driver version. More...
 
#define FSL_SDMMC_DEFAULT_BLOCK_SIZE   (512U)
 Default block size.
 
#define HOST_NOT_SUPPORT   0U
 use this define to indicate the host not support feature
 
#define HOST_SUPPORT   1U
 use this define to indicate the host support feature
 

Enumerations

enum  _sdmmc_status {
  kStatus_SDMMC_NotSupportYet = MAKE_STATUS(kStatusGroup_SDMMC, 0U),
  kStatus_SDMMC_TransferFailed = MAKE_STATUS(kStatusGroup_SDMMC, 1U),
  kStatus_SDMMC_SetCardBlockSizeFailed = MAKE_STATUS(kStatusGroup_SDMMC, 2U),
  kStatus_SDMMC_HostNotSupport = MAKE_STATUS(kStatusGroup_SDMMC, 3U),
  kStatus_SDMMC_CardNotSupport = MAKE_STATUS(kStatusGroup_SDMMC, 4U),
  kStatus_SDMMC_AllSendCidFailed = MAKE_STATUS(kStatusGroup_SDMMC, 5U),
  kStatus_SDMMC_SendRelativeAddressFailed = MAKE_STATUS(kStatusGroup_SDMMC, 6U),
  kStatus_SDMMC_SendCsdFailed = MAKE_STATUS(kStatusGroup_SDMMC, 7U),
  kStatus_SDMMC_SelectCardFailed = MAKE_STATUS(kStatusGroup_SDMMC, 8U),
  kStatus_SDMMC_SendScrFailed = MAKE_STATUS(kStatusGroup_SDMMC, 9U),
  kStatus_SDMMC_SetDataBusWidthFailed = MAKE_STATUS(kStatusGroup_SDMMC, 10U),
  kStatus_SDMMC_GoIdleFailed = MAKE_STATUS(kStatusGroup_SDMMC, 11U),
  kStatus_SDMMC_HandShakeOperationConditionFailed,
  kStatus_SDMMC_SendApplicationCommandFailed,
  kStatus_SDMMC_SwitchFailed = MAKE_STATUS(kStatusGroup_SDMMC, 14U),
  kStatus_SDMMC_StopTransmissionFailed = MAKE_STATUS(kStatusGroup_SDMMC, 15U),
  kStatus_SDMMC_WaitWriteCompleteFailed = MAKE_STATUS(kStatusGroup_SDMMC, 16U),
  kStatus_SDMMC_SetBlockCountFailed = MAKE_STATUS(kStatusGroup_SDMMC, 17U),
  kStatus_SDMMC_SetRelativeAddressFailed = MAKE_STATUS(kStatusGroup_SDMMC, 18U),
  kStatus_SDMMC_SwitchBusTimingFailed = MAKE_STATUS(kStatusGroup_SDMMC, 19U),
  kStatus_SDMMC_SendExtendedCsdFailed = MAKE_STATUS(kStatusGroup_SDMMC, 20U),
  kStatus_SDMMC_ConfigureBootFailed = MAKE_STATUS(kStatusGroup_SDMMC, 21U),
  kStatus_SDMMC_ConfigureExtendedCsdFailed = MAKE_STATUS(kStatusGroup_SDMMC, 22U),
  kStatus_SDMMC_EnableHighCapacityEraseFailed,
  kStatus_SDMMC_SendTestPatternFailed = MAKE_STATUS(kStatusGroup_SDMMC, 24U),
  kStatus_SDMMC_ReceiveTestPatternFailed = MAKE_STATUS(kStatusGroup_SDMMC, 25U),
  kStatus_SDMMC_SDIO_ResponseError = MAKE_STATUS(kStatusGroup_SDMMC, 26U),
  kStatus_SDMMC_SDIO_InvalidArgument,
  kStatus_SDMMC_SDIO_SendOperationConditionFail,
  kStatus_SDMMC_InvalidVoltage = MAKE_STATUS(kStatusGroup_SDMMC, 29U),
  kStatus_SDMMC_SDIO_SwitchHighSpeedFail = MAKE_STATUS(kStatusGroup_SDMMC, 30U),
  kStatus_SDMMC_SDIO_ReadCISFail = MAKE_STATUS(kStatusGroup_SDMMC, 31U),
  kStatus_SDMMC_SDIO_InvalidCard = MAKE_STATUS(kStatusGroup_SDMMC, 32U),
  kStatus_SDMMC_TuningFail = MAKE_STATUS(kStatusGroup_SDMMC, 33U),
  kStatus_SDMMC_SwitchVoltageFail = MAKE_STATUS(kStatusGroup_SDMMC, 34U),
  kStatus_SDMMC_ReTuningRequest = MAKE_STATUS(kStatusGroup_SDMMC, 35U),
  kStatus_SDMMC_SetDriverStrengthFail = MAKE_STATUS(kStatusGroup_SDMMC, 36U),
  kStatus_SDMMC_SetPowerClassFail = MAKE_STATUS(kStatusGroup_SDMMC, 37U)
}
 SD/MMC card API's running status. More...
 
enum  _sd_card_flag {
  kSD_SupportHighCapacityFlag = (1U << 1U),
  kSD_Support4BitWidthFlag = (1U << 2U),
  kSD_SupportSdhcFlag = (1U << 3U),
  kSD_SupportSdxcFlag = (1U << 4U),
  kSD_SupportVoltage180v = (1U << 5U),
  kSD_SupportSetBlockCountCmd = (1U << 6U),
  kSD_SupportSpeedClassControlCmd = (1U << 7U)
}
 SD card flags. More...
 
enum  _mmc_card_flag {
  kMMC_SupportHighSpeed26MHZFlag = (1U << 0U),
  kMMC_SupportHighSpeed52MHZFlag = (1U << 1U),
  kMMC_SupportHighSpeedDDR52MHZ180V300VFlag = (1 << 2U),
  kMMC_SupportHighSpeedDDR52MHZ120VFlag = (1 << 3U),
  kMMC_SupportHS200200MHZ180VFlag = (1 << 4U),
  kMMC_SupportHS200200MHZ120VFlag = (1 << 5U),
  kMMC_SupportHS400DDR200MHZ180VFlag = (1 << 6U),
  kMMC_SupportHS400DDR200MHZ120VFlag = (1 << 7U),
  kMMC_SupportHighCapacityFlag = (1U << 8U),
  kMMC_SupportAlternateBootFlag = (1U << 9U),
  kMMC_SupportDDRBootFlag = (1U << 10U),
  kMMC_SupportHighSpeedBootFlag = (1U << 11U),
  kMMC_DataBusWidth4BitFlag = (1U << 12U),
  kMMC_DataBusWidth8BitFlag = (1U << 13U),
  kMMC_DataBusWidth1BitFlag = (1U << 14U)
}
 MMC card flags. More...
 
enum  card_operation_voltage_t {
  kCARD_OperationVoltageNone = 0U,
  kCARD_OperationVoltage330V = 1U,
  kCARD_OperationVoltage300V = 2U,
  kCARD_OperationVoltage180V = 3U
}
 card operation voltage More...
 
enum  _host_endian_mode {
  kHOST_EndianModeBig = 0U,
  kHOST_EndianModeHalfWordBig = 1U,
  kHOST_EndianModeLittle = 2U
}
 host Endian mode corresponding to driver define More...
 

SDCARD Function

status_t SD_Init (sd_card_t *card)
 Initializes the card on a specific host controller. More...
 
void SD_Deinit (sd_card_t *card)
 Deinitializes the card. More...
 
bool SD_CheckReadOnly (sd_card_t *card)
 Checks whether the card is write-protected. More...
 
status_t SD_ReadBlocks (sd_card_t *card, uint8_t *buffer, uint32_t startBlock, uint32_t blockCount)
 Reads blocks from the specific card. More...
 
status_t SD_WriteBlocks (sd_card_t *card, const uint8_t *buffer, uint32_t startBlock, uint32_t blockCount)
 Writes blocks of data to the specific card. More...
 
status_t SD_EraseBlocks (sd_card_t *card, uint32_t startBlock, uint32_t blockCount)
 Erases blocks of the specific card. More...
 

MMCCARD Function

status_t MMC_Init (mmc_card_t *card)
 Initializes the MMC card. More...
 
void MMC_Deinit (mmc_card_t *card)
 Deinitializes the card. More...
 
bool MMC_CheckReadOnly (mmc_card_t *card)
 Checks if the card is read-only. More...
 
status_t MMC_ReadBlocks (mmc_card_t *card, uint8_t *buffer, uint32_t startBlock, uint32_t blockCount)
 Reads data blocks from the card. More...
 
status_t MMC_WriteBlocks (mmc_card_t *card, const uint8_t *buffer, uint32_t startBlock, uint32_t blockCount)
 Writes data blocks to the card. More...
 
status_t MMC_EraseGroups (mmc_card_t *card, uint32_t startGroup, uint32_t endGroup)
 Erases groups of the card. More...
 
status_t MMC_SelectPartition (mmc_card_t *card, mmc_access_partition_t partitionNumber)
 Selects the partition to access. More...
 
status_t MMC_SetBootConfig (mmc_card_t *card, const mmc_boot_config_t *config)
 Configures the boot activity of the card. More...
 
status_t SDIO_CardInActive (sdio_card_t *card)
 set SDIO card to inactive state More...
 
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_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_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_Init (sdio_card_t *card)
 SDIO card init 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...
 
void SDIO_DeInit (sdio_card_t *card)
 SDIO card deinit. More...
 

adaptor function

static status_t HOST_NotSupport (void *parameter)
 host not support function, this function is used for host not support feature More...
 
status_t CardInsertDetect (HOST_TYPE *hostBase)
 Detect card insert, only need for SD cases. More...
 
status_t HOST_Init (void *host)
 Init host controller. More...
 
void HOST_Deinit (void *host)
 Deinit host controller. More...
 

Data Structure Documentation

struct sd_card_t

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

Data Fields

HOST_CONFIG host
 Host information.
 
bool isHostReady
 use this flag to indicate if need host re-init or not
 
uint32_t busClock_Hz
 SD bus clock frequency united in Hz.
 
uint32_t relativeAddress
 Relative address of the card.
 
uint32_t version
 Card version.
 
uint32_t flags
 Flags in _sd_card_flag.
 
uint32_t rawCid [4U]
 Raw CID content.
 
uint32_t rawCsd [4U]
 Raw CSD content.
 
uint32_t rawScr [2U]
 Raw CSD content.
 
uint32_t ocr
 Raw OCR content.
 
sd_cid_t cid
 CID.
 
sd_csd_t csd
 CSD.
 
sd_scr_t scr
 SCR.
 
uint32_t blockCount
 Card total block number.
 
uint32_t blockSize
 Card block size.
 
sd_timing_mode_t currentTiming
 current timing mode
 
sd_driver_strength_t driverStrength
 driver strength
 
sd_max_current_t maxCurrent
 card current limit
 
card_operation_voltage_t operationVoltage
 card operation voltage
 
struct sdio_card_t

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

Data Fields

HOST_CONFIG host
 Host information.
 
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.
 
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_fbr_t ioFBR [7U]
 FBR table.
 
sdio_common_cis_t commonCIS
 CIS table.
 
sdio_func_cis_t funcCIS [7U]
 function CIS table
 
struct mmc_card_t

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

Data Fields

HOST_CONFIG host
 Host information.
 
bool isHostReady
 use this flag to indicate if need host re-init or not
 
uint32_t busClock_Hz
 MMC bus clock united in Hz.
 
uint32_t relativeAddress
 Relative address of the card.
 
bool enablePreDefinedBlockCount
 Enable PRE-DEFINED block count when read/write.
 
uint32_t flags
 Capability flag in _mmc_card_flag.
 
uint32_t rawCid [4U]
 Raw CID content.
 
uint32_t rawCsd [4U]
 Raw CSD content.
 
uint32_t rawExtendedCsd [MMC_EXTENDED_CSD_BYTES/4U]
 Raw MMC Extended CSD content.
 
uint32_t ocr
 Raw OCR content.
 
mmc_cid_t cid
 CID.
 
mmc_csd_t csd
 CSD.
 
mmc_extended_csd_t extendedCsd
 Extended CSD.
 
uint32_t blockSize
 Card block size.
 
uint32_t userPartitionBlocks
 Card total block number in user partition.
 
uint32_t bootPartitionBlocks
 Boot partition size united as block size.
 
uint32_t eraseGroupBlocks
 Erase group size united as block size.
 
mmc_access_partition_t currentPartition
 Current access partition.
 
mmc_voltage_window_t hostVoltageWindow
 Host voltage window.
 
mmc_high_speed_timing_t currentTiming
 indicate the current host timing mode
 
struct mmc_boot_config_t

Data Fields

bool enableBootAck
 Enable boot ACK.
 
mmc_boot_partition_enable_t bootPartition
 Boot partition.
 
bool retainBootBusWidth
 If retain boot bus width.
 
mmc_data_bus_width_t bootDataBusWidth
 Boot data bus width.
 

Macro Definition Documentation

#define FSL_SDMMC_DRIVER_VERSION   (MAKE_VERSION(2U, 1U, 2U)) /*2.1.2*/

Enumeration Type Documentation

Enumerator
kStatus_SDMMC_NotSupportYet 

Haven't supported.

kStatus_SDMMC_TransferFailed 

Send command failed.

kStatus_SDMMC_SetCardBlockSizeFailed 

Set block size failed.

kStatus_SDMMC_HostNotSupport 

Host doesn't support.

kStatus_SDMMC_CardNotSupport 

Card doesn't support.

kStatus_SDMMC_AllSendCidFailed 

Send CID failed.

kStatus_SDMMC_SendRelativeAddressFailed 

Send relative address failed.

kStatus_SDMMC_SendCsdFailed 

Send CSD failed.

kStatus_SDMMC_SelectCardFailed 

Select card failed.

kStatus_SDMMC_SendScrFailed 

Send SCR failed.

kStatus_SDMMC_SetDataBusWidthFailed 

Set bus width failed.

kStatus_SDMMC_GoIdleFailed 

Go idle failed.

kStatus_SDMMC_HandShakeOperationConditionFailed 

Send Operation Condition failed.

kStatus_SDMMC_SendApplicationCommandFailed 

Send application command failed.

kStatus_SDMMC_SwitchFailed 

Switch command failed.

kStatus_SDMMC_StopTransmissionFailed 

Stop transmission failed.

kStatus_SDMMC_WaitWriteCompleteFailed 

Wait write complete failed.

kStatus_SDMMC_SetBlockCountFailed 

Set block count failed.

kStatus_SDMMC_SetRelativeAddressFailed 

Set relative address failed.

kStatus_SDMMC_SwitchBusTimingFailed 

Switch high speed failed.

kStatus_SDMMC_SendExtendedCsdFailed 

Send EXT_CSD failed.

kStatus_SDMMC_ConfigureBootFailed 

Configure boot failed.

kStatus_SDMMC_ConfigureExtendedCsdFailed 

Configure EXT_CSD failed.

kStatus_SDMMC_EnableHighCapacityEraseFailed 

Enable high capacity erase failed.

kStatus_SDMMC_SendTestPatternFailed 

Send test pattern failed.

kStatus_SDMMC_ReceiveTestPatternFailed 

Receive test pattern failed.

kStatus_SDMMC_SDIO_ResponseError 

sdio response error

kStatus_SDMMC_SDIO_InvalidArgument 

sdio invalid argument response error

kStatus_SDMMC_SDIO_SendOperationConditionFail 

sdio send operation condition fail

kStatus_SDMMC_InvalidVoltage 

invaild voltage

kStatus_SDMMC_SDIO_SwitchHighSpeedFail 

switch to high speed fail

kStatus_SDMMC_SDIO_ReadCISFail 

read CIS fail

kStatus_SDMMC_SDIO_InvalidCard 

invaild SDIO card

kStatus_SDMMC_TuningFail 

tuning fail

kStatus_SDMMC_SwitchVoltageFail 

switch voltage fail

kStatus_SDMMC_ReTuningRequest 

retuning request

kStatus_SDMMC_SetDriverStrengthFail 

set driver strength fail

kStatus_SDMMC_SetPowerClassFail 

set power class fail

Enumerator
kSD_SupportHighCapacityFlag 

Support high capacity.

kSD_Support4BitWidthFlag 

Support 4-bit data width.

kSD_SupportSdhcFlag 

Card is SDHC.

kSD_SupportSdxcFlag 

Card is SDXC.

kSD_SupportVoltage180v 

card support 1.8v voltage

kSD_SupportSetBlockCountCmd 

card support cmd23 flag

kSD_SupportSpeedClassControlCmd 

card support speed class control flag

Enumerator
kMMC_SupportHighSpeed26MHZFlag 

Support high speed 26MHZ.

kMMC_SupportHighSpeed52MHZFlag 

Support high speed 52MHZ.

kMMC_SupportHighSpeedDDR52MHZ180V300VFlag 

ddr 52MHZ 1.8V or 3.0V

kMMC_SupportHighSpeedDDR52MHZ120VFlag 

DDR 52MHZ 1.2V.

kMMC_SupportHS200200MHZ180VFlag 

HS200 ,200MHZ,1.8V.

kMMC_SupportHS200200MHZ120VFlag 

HS200, 200MHZ, 1.2V.

kMMC_SupportHS400DDR200MHZ180VFlag 

HS400, DDR, 200MHZ,1.8V.

kMMC_SupportHS400DDR200MHZ120VFlag 

HS400, DDR, 200MHZ,1.2V.

kMMC_SupportHighCapacityFlag 

Support high capacity.

kMMC_SupportAlternateBootFlag 

Support alternate boot.

kMMC_SupportDDRBootFlag 

support DDR boot flag

kMMC_SupportHighSpeedBootFlag 

support high speed boot flag

kMMC_DataBusWidth4BitFlag 

current data bus is 4 bit mode

kMMC_DataBusWidth8BitFlag 

current data bus is 8 bit mode

kMMC_DataBusWidth1BitFlag 

current data bus is 1 bit mode

Enumerator
kCARD_OperationVoltageNone 

indicate current voltage setting is not setting bu suser

kCARD_OperationVoltage330V 

card operation voltage around 3.3v

kCARD_OperationVoltage300V 

card operation voltage around 3.0v

kCARD_OperationVoltage180V 

card operation voltage around 31.8v

Enumerator
kHOST_EndianModeBig 

Big endian mode.

kHOST_EndianModeHalfWordBig 

Half word big endian mode.

kHOST_EndianModeLittle 

Little endian mode.

Function Documentation

status_t SD_Init ( sd_card_t card)

This function initializes the card on a specific host controller.

Parameters
cardCard descriptor.
Return values
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 SD_Deinit ( sd_card_t card)

This function deinitializes the specific card.

Parameters
cardCard descriptor.
bool SD_CheckReadOnly ( sd_card_t card)

This function checks if the card is write-protected via the CSD register.

Parameters
cardThe specific card.
Return values
trueCard is read only.
falseCard isn't read only.
status_t SD_ReadBlocks ( sd_card_t card,
uint8_t *  buffer,
uint32_t  startBlock,
uint32_t  blockCount 
)

This function reads blocks from the specific card with default block size defined by the SDHC_CARD_DEFAULT_BLOCK_SIZE.

Parameters
cardCard descriptor.
bufferThe buffer to save the data read from card.
startBlockThe start block index.
blockCountThe number of blocks to read.
Return values
kStatus_InvalidArgumentInvalid argument.
kStatus_SDMMC_CardNotSupportCard not support.
kStatus_SDMMC_NotSupportYetNot support now.
kStatus_SDMMC_WaitWriteCompleteFailedSend status failed.
kStatus_SDMMC_TransferFailedTransfer failed.
kStatus_SDMMC_StopTransmissionFailedStop transmission failed.
kStatus_SuccessOperate successfully.
status_t SD_WriteBlocks ( sd_card_t card,
const uint8_t *  buffer,
uint32_t  startBlock,
uint32_t  blockCount 
)

This function writes blocks to the specific card with default block size 512 bytes.

Parameters
cardCard descriptor.
bufferThe buffer holding the data to be written to the card.
startBlockThe start block index.
blockCountThe number of blocks to write.
Return values
kStatus_InvalidArgumentInvalid argument.
kStatus_SDMMC_NotSupportYetNot support now.
kStatus_SDMMC_CardNotSupportCard not support.
kStatus_SDMMC_WaitWriteCompleteFailedSend status failed.
kStatus_SDMMC_TransferFailedTransfer failed.
kStatus_SDMMC_StopTransmissionFailedStop transmission failed.
kStatus_SuccessOperate successfully.
status_t SD_EraseBlocks ( sd_card_t card,
uint32_t  startBlock,
uint32_t  blockCount 
)

This function erases blocks of the specific card with default block size 512 bytes.

Parameters
cardCard descriptor.
startBlockThe start block index.
blockCountThe number of blocks to erase.
Return values
kStatus_InvalidArgumentInvalid argument.
kStatus_SDMMC_WaitWriteCompleteFailedSend status failed.
kStatus_SDMMC_TransferFailedTransfer failed.
kStatus_SDMMC_WaitWriteCompleteFailedSend status failed.
kStatus_SuccessOperate successfully.
status_t MMC_Init ( mmc_card_t card)
Parameters
cardCard descriptor.
Return values
kStatus_SDMMC_GoIdleFailedGo idle failed.
kStatus_SDMMC_SendOperationConditionFailedSend operation condition failed.
kStatus_SDMMC_AllSendCidFailedSend CID failed.
kStatus_SDMMC_SetRelativeAddressFailedSet relative address failed.
kStatus_SDMMC_SendCsdFailedSend CSD failed.
kStatus_SDMMC_CardNotSupportCard not support.
kStatus_SDMMC_SelectCardFailedSend SELECT_CARD command failed.
kStatus_SDMMC_SendExtendedCsdFailedSend EXT_CSD failed.
kStatus_SDMMC_SetBusWidthFailedSet bus width failed.
kStatus_SDMMC_SwitchHighSpeedFailedSwitch high speed failed.
kStatus_SDMMC_SetCardBlockSizeFailedSet card block size failed.
kStatus_SuccessOperate successfully.
void MMC_Deinit ( mmc_card_t card)
Parameters
cardCard descriptor.
bool MMC_CheckReadOnly ( mmc_card_t card)
Parameters
cardCard descriptor.
Return values
trueCard is read only.
falseCard isn't read only.
status_t MMC_ReadBlocks ( mmc_card_t card,
uint8_t *  buffer,
uint32_t  startBlock,
uint32_t  blockCount 
)
Parameters
cardCard descriptor.
bufferThe buffer to save data.
startBlockThe start block index.
blockCountThe number of blocks to read.
Return values
kStatus_InvalidArgumentInvalid argument.
kStatus_SDMMC_CardNotSupportCard not support.
kStatus_SDMMC_SetBlockCountFailedSet block count failed.
kStatus_SDMMC_TransferFailedTransfer failed.
kStatus_SDMMC_StopTransmissionFailedStop transmission failed.
kStatus_SuccessOperate successfully.
status_t MMC_WriteBlocks ( mmc_card_t card,
const uint8_t *  buffer,
uint32_t  startBlock,
uint32_t  blockCount 
)
Parameters
cardCard descriptor.
bufferThe buffer to save data blocks.
startBlockStart block number to write.
blockCountBlock count.
Return values
kStatus_InvalidArgumentInvalid argument.
kStatus_SDMMC_NotSupportYetNot support now.
kStatus_SDMMC_SetBlockCountFailedSet block count failed.
kStatus_SDMMC_WaitWriteCompleteFailedSend status failed.
kStatus_SDMMC_TransferFailedTransfer failed.
kStatus_SDMMC_StopTransmissionFailedStop transmission failed.
kStatus_SuccessOperate successfully.
status_t MMC_EraseGroups ( mmc_card_t card,
uint32_t  startGroup,
uint32_t  endGroup 
)

Erase group is the smallest erase unit in MMC card. The erase range is [startGroup, endGroup].

Parameters
cardCard descriptor.
startGroupStart group number.
endGroupEnd group number.
Return values
kStatus_InvalidArgumentInvalid argument.
kStatus_SDMMC_WaitWriteCompleteFailedSend status failed.
kStatus_SDMMC_TransferFailedTransfer failed.
kStatus_SuccessOperate successfully.
status_t MMC_SelectPartition ( mmc_card_t card,
mmc_access_partition_t  partitionNumber 
)
Parameters
cardCard descriptor.
partitionNumberThe partition number.
Return values
kStatus_SDMMC_ConfigureExtendedCsdFailedConfigure EXT_CSD failed.
kStatus_SuccessOperate successfully.
status_t MMC_SetBootConfig ( mmc_card_t card,
const mmc_boot_config_t config 
)
Parameters
cardCard descriptor.
configBoot configuration structure.
Return values
kStatus_SDMMC_NotSupportYetNot support now.
kStatus_SDMMC_ConfigureExtendedCsdFailedConfigure EXT_CSD failed.
kStatus_SDMMC_ConfigureBootFailedConfigure boot failed.
kStatus_SuccessOperate successfully.
status_t SDIO_CardInActive ( sdio_card_t card)
Parameters
cardCard descriptor.
Return values
kStatus_SDMMC_TransferFailed
kStatus_Success
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_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_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_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
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
void SDIO_DeInit ( sdio_card_t card)
Parameters
cardCard descriptor.
static status_t HOST_NotSupport ( void *  parameter)
inlinestatic
Parameters
voidparameter ,used to avoid build warning
Return values
kStatus_Fail,hostdo not suppport
status_t CardInsertDetect ( HOST_TYPE *  hostBase)
Parameters
hostBasethe pointer to host base address
Return values
kStatus_Successdetect card insert
kStatus_Failcard insert event fail
status_t HOST_Init ( void *  host)
Parameters
hostthe pointer to host structure in card structure.
Return values
kStatus_Successhost init success
kStatus_Failevent fail
void HOST_Deinit ( void *  host)
Parameters
hostthe pointer to host structure in card structure.