MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The MCUXpresso SDK provides a driver to access the Secure Digital Card and Embedded MultiMedia Card based on the SDHC driver.
This function group implements the SD card functional API.
This function group implements the MMC card functional API.
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 | |
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... | |
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. | |
#define FSL_SDMMC_DRIVER_VERSION (MAKE_VERSION(2U, 1U, 2U)) /*2.1.2*/ |
enum _sdmmc_status |
enum _sd_card_flag |
enum _mmc_card_flag |
enum _host_endian_mode |
status_t SD_Init | ( | sd_card_t * | card | ) |
This function initializes the card on a specific host controller.
card | Card descriptor. |
kStatus_SDMMC_GoIdleFailed | Go idle failed. |
kStatus_SDMMC_NotSupportYet | Card not support. |
kStatus_SDMMC_SendOperationConditionFailed | Send operation condition failed. |
kStatus_SDMMC_AllSendCidFailed | Send CID failed. |
kStatus_SDMMC_SendRelativeAddressFailed | Send relative address failed. |
kStatus_SDMMC_SendCsdFailed | Send CSD failed. |
kStatus_SDMMC_SelectCardFailed | Send SELECT_CARD command failed. |
kStatus_SDMMC_SendScrFailed | Send SCR failed. |
kStatus_SDMMC_SetBusWidthFailed | Set bus width failed. |
kStatus_SDMMC_SwitchHighSpeedFailed | Switch high speed failed. |
kStatus_SDMMC_SetCardBlockSizeFailed | Set card block size failed. |
kStatus_Success | Operate successfully. |
void SD_Deinit | ( | sd_card_t * | card | ) |
This function deinitializes the specific card.
card | Card descriptor. |
bool SD_CheckReadOnly | ( | sd_card_t * | card | ) |
This function checks if the card is write-protected via the CSD register.
card | The specific card. |
true | Card is read only. |
false | Card 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.
card | Card descriptor. |
buffer | The buffer to save the data read from card. |
startBlock | The start block index. |
blockCount | The number of blocks to read. |
kStatus_InvalidArgument | Invalid argument. |
kStatus_SDMMC_CardNotSupport | Card not support. |
kStatus_SDMMC_NotSupportYet | Not support now. |
kStatus_SDMMC_WaitWriteCompleteFailed | Send status failed. |
kStatus_SDMMC_TransferFailed | Transfer failed. |
kStatus_SDMMC_StopTransmissionFailed | Stop transmission failed. |
kStatus_Success | Operate 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.
card | Card descriptor. |
buffer | The buffer holding the data to be written to the card. |
startBlock | The start block index. |
blockCount | The number of blocks to write. |
kStatus_InvalidArgument | Invalid argument. |
kStatus_SDMMC_NotSupportYet | Not support now. |
kStatus_SDMMC_CardNotSupport | Card not support. |
kStatus_SDMMC_WaitWriteCompleteFailed | Send status failed. |
kStatus_SDMMC_TransferFailed | Transfer failed. |
kStatus_SDMMC_StopTransmissionFailed | Stop transmission failed. |
kStatus_Success | Operate 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.
card | Card descriptor. |
startBlock | The start block index. |
blockCount | The number of blocks to erase. |
kStatus_InvalidArgument | Invalid argument. |
kStatus_SDMMC_WaitWriteCompleteFailed | Send status failed. |
kStatus_SDMMC_TransferFailed | Transfer failed. |
kStatus_SDMMC_WaitWriteCompleteFailed | Send status failed. |
kStatus_Success | Operate successfully. |
status_t MMC_Init | ( | mmc_card_t * | card | ) |
card | Card descriptor. |
kStatus_SDMMC_GoIdleFailed | Go idle failed. |
kStatus_SDMMC_SendOperationConditionFailed | Send operation condition failed. |
kStatus_SDMMC_AllSendCidFailed | Send CID failed. |
kStatus_SDMMC_SetRelativeAddressFailed | Set relative address failed. |
kStatus_SDMMC_SendCsdFailed | Send CSD failed. |
kStatus_SDMMC_CardNotSupport | Card not support. |
kStatus_SDMMC_SelectCardFailed | Send SELECT_CARD command failed. |
kStatus_SDMMC_SendExtendedCsdFailed | Send EXT_CSD failed. |
kStatus_SDMMC_SetBusWidthFailed | Set bus width failed. |
kStatus_SDMMC_SwitchHighSpeedFailed | Switch high speed failed. |
kStatus_SDMMC_SetCardBlockSizeFailed | Set card block size failed. |
kStatus_Success | Operate successfully. |
void MMC_Deinit | ( | mmc_card_t * | card | ) |
card | Card descriptor. |
bool MMC_CheckReadOnly | ( | mmc_card_t * | card | ) |
card | Card descriptor. |
true | Card is read only. |
false | Card isn't read only. |
status_t MMC_ReadBlocks | ( | mmc_card_t * | card, |
uint8_t * | buffer, | ||
uint32_t | startBlock, | ||
uint32_t | blockCount | ||
) |
card | Card descriptor. |
buffer | The buffer to save data. |
startBlock | The start block index. |
blockCount | The number of blocks to read. |
kStatus_InvalidArgument | Invalid argument. |
kStatus_SDMMC_CardNotSupport | Card not support. |
kStatus_SDMMC_SetBlockCountFailed | Set block count failed. |
kStatus_SDMMC_TransferFailed | Transfer failed. |
kStatus_SDMMC_StopTransmissionFailed | Stop transmission failed. |
kStatus_Success | Operate successfully. |
status_t MMC_WriteBlocks | ( | mmc_card_t * | card, |
const uint8_t * | buffer, | ||
uint32_t | startBlock, | ||
uint32_t | blockCount | ||
) |
card | Card descriptor. |
buffer | The buffer to save data blocks. |
startBlock | Start block number to write. |
blockCount | Block count. |
kStatus_InvalidArgument | Invalid argument. |
kStatus_SDMMC_NotSupportYet | Not support now. |
kStatus_SDMMC_SetBlockCountFailed | Set block count failed. |
kStatus_SDMMC_WaitWriteCompleteFailed | Send status failed. |
kStatus_SDMMC_TransferFailed | Transfer failed. |
kStatus_SDMMC_StopTransmissionFailed | Stop transmission failed. |
kStatus_Success | Operate 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].
card | Card descriptor. |
startGroup | Start group number. |
endGroup | End group number. |
kStatus_InvalidArgument | Invalid argument. |
kStatus_SDMMC_WaitWriteCompleteFailed | Send status failed. |
kStatus_SDMMC_TransferFailed | Transfer failed. |
kStatus_Success | Operate successfully. |
status_t MMC_SelectPartition | ( | mmc_card_t * | card, |
mmc_access_partition_t | partitionNumber | ||
) |
card | Card descriptor. |
partitionNumber | The partition number. |
kStatus_SDMMC_ConfigureExtendedCsdFailed | Configure EXT_CSD failed. |
kStatus_Success | Operate successfully. |
status_t MMC_SetBootConfig | ( | mmc_card_t * | card, |
const mmc_boot_config_t * | config | ||
) |
card | Card descriptor. |
config | Boot configuration structure. |
kStatus_SDMMC_NotSupportYet | Not support now. |
kStatus_SDMMC_ConfigureExtendedCsdFailed | Configure EXT_CSD failed. |
kStatus_SDMMC_ConfigureBootFailed | Configure boot failed. |
kStatus_Success | Operate successfully. |
status_t SDIO_CardInActive | ( | sdio_card_t * | card | ) |
card | Card descriptor. |
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 | ||
) |
card | Card descriptor. |
function | IO numner |
register | address |
the | data pinter to write |
raw | flag, indicate read after write or write only |
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 | ||
) |
card | Card descriptor. |
function | IO number |
register | address |
data | pointer to read |
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 | ||
) |
card | Card descriptor. |
function | IO number |
register | address |
data | buffer to write |
data | count |
write | flags |
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 | ||
) |
card | Card descriptor. |
function | IO number |
register | address |
data | buffer to read |
data | count |
write | flags |
kStatus_SDMMC_TransferFailed | |
kStatus_SDMMC_SDIO_InvalidArgument | |
kStatus_Success |
status_t SDIO_GetCardCapability | ( | sdio_card_t * | card, |
sdio_func_num_t | func | ||
) |
card | Card descriptor. |
function | IO number |
kStatus_SDMMC_TransferFailed | |
kStatus_Success |
status_t SDIO_SetBlockSize | ( | sdio_card_t * | card, |
sdio_func_num_t | func, | ||
uint32_t | blockSize | ||
) |
card | Card descriptor. |
function | io number |
block | size |
kStatus_SDMMC_SetCardBlockSizeFailed | |
kStatus_SDMMC_SDIO_InvalidArgument | |
kStatus_Success |
status_t SDIO_CardReset | ( | sdio_card_t * | card | ) |
card | Card descriptor. |
kStatus_SDMMC_TransferFailed | |
kStatus_Success |
status_t SDIO_SetDataBusWidth | ( | sdio_card_t * | card, |
sdio_bus_width_t | busWidth | ||
) |
card | Card descriptor. |
data | bus width |
kStatus_SDMMC_TransferFailed | |
kStatus_Success |
status_t SDIO_SwitchToHighSpeed | ( | sdio_card_t * | card | ) |
card | Card descriptor. |
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 | ||
) |
card | Card descriptor. |
function | io number |
tuple | code list |
tuple | code number |
kStatus_SDMMC_SDIO_ReadCISFail | |
kStatus_SDMMC_TransferFailed | |
kStatus_Success |
status_t SDIO_Init | ( | sdio_card_t * | card | ) |
card | Card descriptor. |
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 | ||
) |
card | Card descriptor. |
function | IO number |
enable/disable | flag |
kStatus_SDMMC_TransferFailed | |
kStatus_Success |
status_t SDIO_EnableIO | ( | sdio_card_t * | card, |
sdio_func_num_t | func, | ||
bool | enable | ||
) |
card | Card descriptor. |
function | IO number |
enable/disable | flag |
kStatus_SDMMC_TransferFailed | |
kStatus_Success |
status_t SDIO_SelectIO | ( | sdio_card_t * | card, |
sdio_func_num_t | func | ||
) |
card | Card descriptor. |
function | IO number |
kStatus_SDMMC_TransferFailed | |
kStatus_Success |
status_t SDIO_AbortIO | ( | sdio_card_t * | card, |
sdio_func_num_t | func | ||
) |
card | Card descriptor. |
function | IO number |
kStatus_SDMMC_TransferFailed | |
kStatus_Success |
void SDIO_DeInit | ( | sdio_card_t * | card | ) |
card | Card descriptor. |
|
inlinestatic |
void | parameter ,used to avoid build warning |
kStatus_Fail,host | do not suppport |
status_t CardInsertDetect | ( | HOST_TYPE * | hostBase | ) |
hostBase | the pointer to host base address |
kStatus_Success | detect card insert |
kStatus_Fail | card insert event fail |
status_t HOST_Init | ( | void * | host | ) |
host | the pointer to host structure in card structure. |
kStatus_Success | host init success |
kStatus_Fail | event fail |
void HOST_Deinit | ( | void * | host | ) |
host | the pointer to host structure in card structure. |