SDHC Library
The SDHC provides an interface between the APB2 peripheral bus and MultiMediaCards (MMCs), SD memory cards, SDIO cards and CE-ATA devices. It is available only for the Cortex M4 devices.
The MultiMediaCard/SD bus connects cards to the controller.
The SDHC features include the following :
- Conforms to the SD Host Controller Standard Specification version 2.0 including test event register support
- Compatible with the MMC System Specification version 4.2/4.3
- Compatible with the SD Memory Card Specification version 2.0 and supports the high capacity SD memory card
- Compatible with the SDIO Card Specification version 2.0
- Compatible with the CE-ATA Card Specification version 1.0
- Designed to work with CE-ATA, SD memory, miniSD memory, SDIO, miniSDIO,
- Card bus clock frequency up to 52 MHz
- Supports 1-bit/4-bit SD and SDIO modes, 1-bit/4-bit / 8-bit MMC modes, 1-bit/4-bit/8-bit CE-ATA devices
- Up to 200 Mbps of data transfer for SD/SDIO cards using 4 parallel data lines
- Up to 416 Mbps of data transfer for MMC cards using 8 parallel data lines in Single Data Rate (SDR) mode
Library Routines
- SDHC_IRQStatenConfig
- SDHC_IRQSignalConfig
- SDHC_GetStatus
- SDHC_ClearFlag
- SDHC_SetForceEventFlags
- SDHC_GetIRQSTAT
- SDHC_Reset
- SDHC_StructInit
- SDHC_ClockCmd
- SDHC_SetPowerState
- SDHC_GetPowerState
- SDHC_Set_PROCTL
- SDHC_Set_WML
- SDHC_Set_VENDOR
- SDHC_Set_MMCBOOT
- SDHC_Init
- SDHC_InitCard
- SDHC_GetBasicInfo
- SDHC_DataConfig
- SDHC_SendCommand
- SDHC_GetCurState
- SDHC_DataStructInit
- SDHC_CmdStructInit
- SDHC_GetResponse
- SDHC_GetBlockCounter
- SDHC_GetDataCounter
- SDHC_ReadData
- SDHC_WriteData
- SDHC_SetDataTransferWidth
- SDHC_SetContinueRequest
- SDHC_GetErrStatus
- SDHC_SetAdmaAddress
- SDHC_SetReadWait
- SDHC_ContinueRequest
- SDHC_SetSABGREQ
- SDHC_SetDMAS
SDHC_IRQStatenConfig
Prototype |
void SDHC_IRQStatenConfig(unsigned long mask, unsigned char newState); |
||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
This function enables the corresponding interrupt status to be set/reset. |
||||||||||||||||||||||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||||||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||
Notes |
None. |
SDHC_IRQSignalConfig
Prototype |
void SDHC_IRQSignalConfig(unsigned long mask, unsigned char newState); |
||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
This function generates an interrupt when the corresponding interrupt bit is set. |
||||||||||||||||||||||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||||||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||
Notes |
None. |
SDHC_GetStatus
Prototype |
char SDHC_GetStatus(unsigned long mask); |
||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
This function checks whether the specified interrupt mask is set or not. |
||||||||||||||||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||||||||||||||||
Returns |
|
||||||||||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||||||||||
Notes |
None. |
SDHC_ClearFlag
Prototype |
void SDHC_ClearFlag(unsigned long mask); |
||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
This function clears Interrrupt Status Register. |
||||||||||||||||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||||||||||
Notes |
None. |
SDHC_SetForceEventFlags
Prototype |
void SDHC_SetForceEventFlags(unsigned long mask); |
||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
This function forces interrupt, sets the corresponding bit of Interrupt Status register. |
||||||||||||||||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||||||||||||||||
Returns |
Nothing. |
||||||||||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||||||||||
Notes |
None. |
SDHC_GetIRQSTAT
Prototype |
unsigned long SDHC_GetIRQSTAT(); |
---|---|
Description |
This function gets IRQSTAT value. |
Parameters |
None. |
Returns |
IRQSTAT value. |
Requires |
Nothing. |
Notes |
None. |
SDHC_Reset
Prototype |
unsigned long SDHC_Reset(unsigned long type, unsigned long timeout); |
||||||||
---|---|---|---|---|---|---|---|---|---|
Description |
This function performs software reset. |
||||||||
Parameters |
|
||||||||
Returns |
IRQSTAT value. |
||||||||
Requires |
Nothing. |
||||||||
Notes |
None. |
SDHC_StructInit
Prototype |
void SDHC_StructInit(SDHC_InitTypeDef *initConf); |
---|---|
Description |
This function fills each |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_ClockCmd
Prototype |
void SDHC_ClockCmd(const SDHC_clk_param *initClkConfig); |
---|---|
Description |
This function set prescaler and divider and enables or disables the SDHC Clock. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_SetPowerState
Prototype |
void SDHC_SetPowerState(char powerState); |
||||||
---|---|---|---|---|---|---|---|
Description |
This function sets the power status of the controller. |
||||||
Parameters |
|
||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDHC_GetPowerState
Prototype |
unsigned char SDHC_GetPowerState(); |
---|---|
Description |
This function gets the power status of the controller. |
Parameters |
None. |
Returns |
|
Requires |
Nothing. |
Notes |
None. |
SDHC_SelectClk
Prototype |
unsigned char SDHC_SelectClk(unsigned long clk); |
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
This function selects the clock source for the SDHC clock. |
||||||||||||
Parameters |
|
||||||||||||
Returns |
|
||||||||||||
Requires |
Nothing. |
||||||||||||
Notes |
None. |
SDHC_Set_PROCTL
Prototype |
void SDHC_Set_PROCTL(const SDHC_proctl_param *initConfig); |
---|---|
Description |
This function sets Protocol Control Register according to the specified parameters in the |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_Set_WML
Prototype |
void SDHC_Set_WML(const SDHC_watermark_param *initConfig); |
---|---|
Description |
This function sets Watermark Level Register according to the specified parameters in the |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_Set_VENDOR
Prototype |
void SDHC_Set_VENDOR(const SDHC_InitTypeDef *initConfig); |
---|---|
Description |
This function sets Vendor Specific Register according to the specified parameters in the |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_Set_MMCBOOT
Prototype |
void SDHC_Set_MMCBOOT(const SDHC_mmcboot_param *initBootConfig); |
---|---|
Description |
This function sets MMC Boot Register according to the specified parameters in the |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_Init
Prototype |
void SDHC_Init(SDHC_InitTypeDef initConfig, const Module_Struct *module); |
---|---|
Description |
This function Initializes the SDHC peripheral according to the specified parameters in the |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_InitCard
Prototype |
unsigned long SDHC_InitCard(unsigned long timeout); |
---|---|
Description |
This function initializes the SDHC card by sending 80 SD-clocks to the card. |
Parameters |
|
Returns |
|
Requires |
Nothing. |
Notes |
None. |
SDHC_GetBasicInfo
Prototype |
void SDHC_GetBasicInfo(SDHC_basic_info *basicInfo); |
---|---|
Description |
This function gets the capability information of the SDHC card. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_DataConfig
Prototype |
void SDHC_DataConfig(SDHC_dataStruct *dataStruct); |
---|---|
Description |
This function initializes the SDHC data path according to the specified parameters in the |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_SendCommand
Prototype |
void SDHC_SendCommand(SDHC_cmdReq *cmdReq); |
---|---|
Description |
This function initializes the SDHC command according to the specified parameters in the |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_GetCurState
Prototype |
unsigned char SDHC_GetCurState(unsigned long mask); |
||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Description |
This function gets current state of Present State Register for corresponding mask. |
||||||||||||||||||||||||||||||||||||||||||||||
Parameters |
|
||||||||||||||||||||||||||||||||||||||||||||||
Returns |
|
||||||||||||||||||||||||||||||||||||||||||||||
Requires |
Nothing. |
||||||||||||||||||||||||||||||||||||||||||||||
Notes |
None. |
SDHC_DataStructInit
Prototype |
void SDHC_DataStructInit(SDHC_dataStruct *dataStruct); |
---|---|
Description |
This function fills each |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_CmdStructInit
Prototype |
void SDHC_CmdStructInit(SDHC_cmdReq *cmdReq); |
---|---|
Description |
This function fills each |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_GetResponse
Prototype |
unsigned long SDHC_GetResponse(unsigned char *index); |
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Description |
This function returns value of chosed Command Response Register. |
||||||||||
Parameters |
|
||||||||||
Returns |
The corresponding register value. |
||||||||||
Requires |
Nothing. |
||||||||||
Notes |
None. |
SDHC_GetBlockCounter
Prototype |
unsigned long SDHC_GetBlockCounter(); |
---|---|
Description |
This function gets block count number for current transfer. |
Parameters |
None. |
Returns |
Block count number. |
Requires |
Nothing. |
Notes |
None. |
SDHC_GetDataCounter
Prototype |
unsigned long SDHC_GetDataCounter(); |
---|---|
Description |
This function gets data count number for current transfer. |
Parameters |
None. |
Returns |
Data count number. |
Requires |
Nothing. |
Notes |
None. |
SDHC_ReadData
Prototype |
unsigned long SDHC_ReadData(); |
---|---|
Description |
This function retrieves the data from the data port. |
Parameters |
None. |
Returns |
Read data. |
Requires |
Nothing. |
Notes |
None. |
SDHC_WriteData
Prototype |
void SDHC_WriteData(unsigned long dat); |
---|---|
Description |
This function fills the the data port. |
Parameters |
|
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_SetDataTransferWidth
Prototype |
void SDHC_SetDataTransferWidth(unsigned long dtw); |
||||||||
---|---|---|---|---|---|---|---|---|---|
Description |
This function sets data transfer width. |
||||||||
Parameters |
|
||||||||
Returns |
Nothing. |
||||||||
Requires |
Nothing. |
||||||||
Notes |
None. |
SDHC_SetContinueRequest
Prototype |
void SDHC_SetContinueRequest(); |
---|---|
Description |
This function sets continue request. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_GetErrStatus
Prototype |
unsigned long SDHC_GetErrStatus(unsigned char errType); |
||||||
---|---|---|---|---|---|---|---|
Description |
This function gets the SDHC error status. |
||||||
Parameters |
|
||||||
Returns |
Error register value. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDHC_SetAdmaAddress
Prototype |
void SDHC_SetAdmaAddress(unsigned long address); |
---|---|
Description |
This function sets the ADMA address. |
Parameters |
|
Returns |
Error register value. |
Requires |
Nothing. |
Notes |
None. |
SDHC_SetReadWait
Prototype |
void SDHC_SetReadWait(unsigned char newState); |
||||||
---|---|---|---|---|---|---|---|
Description |
This function enables or disables read wait control. |
||||||
Parameters |
|
||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDHC_ContinueRequest
Prototype |
void SDHC_ContinueRequest(); |
---|---|
Description |
This function continues request. |
Parameters |
None. |
Returns |
Nothing. |
Requires |
Nothing. |
Notes |
None. |
SDHC_SetSABGREQ
Prototype |
void SDHC_SetSABGREQ(unsigned char newState); |
||||||
---|---|---|---|---|---|---|---|
Description |
This function stops executing a transaction at the next block gap request. |
||||||
Parameters |
|
||||||
Returns |
Nothing. |
||||||
Requires |
Nothing. |
||||||
Notes |
None. |
SDHC_SetDMAS
Prototype |
void SDHC_SetDMAS(unsigned long newState); |
||||||||
---|---|---|---|---|---|---|---|---|---|
Description |
This function selects DMA. |
||||||||
Parameters |
|
||||||||
Returns |
Nothing. |
||||||||
Requires |
Nothing. |
||||||||
Notes |
None. |
What do you think about this topic ? Send us feedback!