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 :

Library Routines

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
  • mask: corresponding interrupt. Valid values :
    Value Description
    _SDHC_IRQ_CC Command Complete Interrupt.
    _SDHC_IRQ_TC Transfer Complete Interrupt.
    _SDHC_IRQ_BGE Block Gap Event Interrupt.
    _SDHC_IRQ_DINT DMA Interrupt.
    _SDHC_IRQ_BWR Buffer Write Ready Interrupt.
    _SDHC_IRQ_BRR Buffer Read Ready Interrupt.
    _SDHC_IRQ_CINS Card Insertion Interrupt.
    _SDHC_IRQ_CRM Card Removal Interrupt.
    _SDHC_IRQ_CINT Card Interrupt Enable.
    _SDHC_IRQ_CTOE Command Timeout Error Interrupt.
    _SDHC_IRQ_CCE Command CRC Error Interrupt Enable.
    _SDHC_IRQ_CEBE Command End Bit Error Interrupt.
    _SDHC_IRQ_CIE Command Index Error Interrupt.
    _SDHC_IRQ_DTOE Data Timeout Error Interrupt.
    _SDHC_IRQ_DCE Data CRC Error Interrupt.
    _SDHC_IRQ_DEBE Data End Bit Error Interrupt.
    _SDHC_IRQ_AC12E Auto CMD12 Error Interrupt.
    _SDHC_IRQ_DMAE DMA Error Interrupt.
  • newState: interrupt status. Valid values :
    Value Description
    _SDHC_DISABLE Interrupt disabled.
    _SDHC_ENABLE Interrupt enabled.
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
  • mask: corresponding interrupt. Valid values :
    Value Description
    _SDHC_IRQ_CC Command Complete Interrupt.
    _SDHC_IRQ_TC Transfer Complete Interrupt.
    _SDHC_IRQ_BGE Block Gap Event Interrupt.
    _SDHC_IRQ_DINT DMA Interrupt.
    _SDHC_IRQ_BWR Buffer Write Ready Interrupt.
    _SDHC_IRQ_BRR Buffer Read Ready Interrupt.
    _SDHC_IRQ_CINS Card Insertion Interrupt.
    _SDHC_IRQ_CRM Card Removal Interrupt.
    _SDHC_IRQ_CINT Card Interrupt Enable.
    _SDHC_IRQ_CTOE Command Timeout Error Interrupt.
    _SDHC_IRQ_CCE Command CRC Error Interrupt Enable.
    _SDHC_IRQ_CEBE Command End Bit Error Interrupt.
    _SDHC_IRQ_CIE Command Index Error Interrupt.
    _SDHC_IRQ_DTOE Data Timeout Error Interrupt.
    _SDHC_IRQ_DCE Data CRC Error Interrupt.
    _SDHC_IRQ_DEBE Data End Bit Error Interrupt.
    _SDHC_IRQ_AC12E Auto CMD12 Error Interrupt.
    _SDHC_IRQ_DMAE DMA Error Interrupt.
  • newState: interrupt status. Valid values :
    Value Description
    _SDHC_DISABLE Interrupt set.
    _SDHC_ENABLE Interrupt reset.
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
  • mask: interrupt to be checked. Valid values :
    Value Description
    _SDHC_IRQ_CC Command Complete Interrupt.
    _SDHC_IRQ_TC Transfer Complete Interrupt.
    _SDHC_IRQ_BGE Block Gap Event Interrupt.
    _SDHC_IRQ_DINT DMA Interrupt.
    _SDHC_IRQ_BWR Buffer Write Ready Interrupt.
    _SDHC_IRQ_BRR Buffer Read Ready Interrupt.
    _SDHC_IRQ_CINS Card Insertion Interrupt.
    _SDHC_IRQ_CRM Card Removal Interrupt.
    _SDHC_IRQ_CINT Card Interrupt Enable.
    _SDHC_IRQ_CTOE Command Timeout Error Interrupt.
    _SDHC_IRQ_CCE Command CRC Error Interrupt Enable.
    _SDHC_IRQ_CEBE Command End Bit Error Interrupt.
    _SDHC_IRQ_CIE Command Index Error Interrupt.
    _SDHC_IRQ_DTOE Data Timeout Error Interrupt.
    _SDHC_IRQ_DCE Data CRC Error Interrupt.
    _SDHC_IRQ_DEBE Data End Bit Error Interrupt.
    _SDHC_IRQ_AC12E Auto CMD12 Error Interrupt.
    _SDHC_IRQ_DMAE DMA Error Interrupt.
Returns
  • _SDHC_SET: interrupt mask is set,
  • _SDHC_RESET: interrupt mask is not set.
Requires

Nothing.

Notes

None.

SDHC_ClearFlag

Prototype

void SDHC_ClearFlag(unsigned long mask);

Description

This function clears Interrrupt Status Register.

Parameters
  • mask: corresponding bits interrupt mask. Valid values :
    Value Description
    _SDHC_IRQ_CC Command Complete Interrupt.
    _SDHC_IRQ_TC Transfer Complete Interrupt.
    _SDHC_IRQ_BGE Block Gap Event Interrupt.
    _SDHC_IRQ_DINT DMA Interrupt.
    _SDHC_IRQ_BWR Buffer Write Ready Interrupt.
    _SDHC_IRQ_BRR Buffer Read Ready Interrupt.
    _SDHC_IRQ_CINS Card Insertion Interrupt.
    _SDHC_IRQ_CRM Card Removal Interrupt.
    _SDHC_IRQ_CINT Card Interrupt Enable.
    _SDHC_IRQ_CTOE Command Timeout Error Interrupt.
    _SDHC_IRQ_CCE Command CRC Error Interrupt Enable.
    _SDHC_IRQ_CEBE Command End Bit Error Interrupt.
    _SDHC_IRQ_CIE Command Index Error Interrupt.
    _SDHC_IRQ_DTOE Data Timeout Error Interrupt.
    _SDHC_IRQ_DCE Data CRC Error Interrupt.
    _SDHC_IRQ_DEBE Data End Bit Error Interrupt.
    _SDHC_IRQ_AC12E Auto CMD12 Error Interrupt.
    _SDHC_IRQ_DMAE DMA Error Interrupt.
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
  • mask: corresponding interrupt mask. Valid values :
    Value Description
    _SDHC_IRQ_CC Command Complete Interrupt.
    _SDHC_IRQ_TC Transfer Complete Interrupt.
    _SDHC_IRQ_BGE Block Gap Event Interrupt.
    _SDHC_IRQ_DINT DMA Interrupt.
    _SDHC_IRQ_BWR Buffer Write Ready Interrupt.
    _SDHC_IRQ_BRR Buffer Read Ready Interrupt.
    _SDHC_IRQ_CINS Card Insertion Interrupt.
    _SDHC_IRQ_CRM Card Removal Interrupt.
    _SDHC_IRQ_CINT Card Interrupt Enable.
    _SDHC_IRQ_CTOE Command Timeout Error Interrupt.
    _SDHC_IRQ_CCE Command CRC Error Interrupt Enable.
    _SDHC_IRQ_CEBE Command End Bit Error Interrupt.
    _SDHC_IRQ_CIE Command Index Error Interrupt.
    _SDHC_IRQ_DTOE Data Timeout Error Interrupt.
    _SDHC_IRQ_DCE Data CRC Error Interrupt.
    _SDHC_IRQ_DEBE Data End Bit Error Interrupt.
    _SDHC_IRQ_AC12E Auto CMD12 Error Interrupt.
    _SDHC_IRQ_DMAE DMA Error Interrupt.
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
  • type: type of the software reset. Valid values :
    Value Description
    _SDHC_SYSCTL_RSTA_MASK Software Reset For ALL.
    _SDHC_SYSCTL_RSTC_MASK Software Reset For CMD Line.
    _SDHC_SYSCTL_RSTD_MASK Software Reset For DAT Line.
  • timeout: timeout (in instruction cycles).
Returns

IRQSTAT value.

Requires

Nothing.

Notes

None.

SDHC_StructInit

Prototype

void SDHC_StructInit(SDHC_InitTypeDef *initConf);

Description

This function fills each SDHC_InitTypeDef member with its default value.

Parameters
  • initConf: pointer to the SDHC_InitTypeDef structure consisted of the following members :
    typedef struct {
        SDHC_clk_param clk;
        SDHC_mmcboot_param bootParams;          // Configture read MMC card boot data feature
        SDHC_proctl_param  proctlParams;        // Configture Protocol Control register
        SDHC_watermark_param wmlParams;         // Configture Watermark Level register 
        unsigned long enVENDORflags;            // Enable or disable corresponding feature 
    } SDHC_InitTypeDef;
    
    // SDHC_clk_param definition :
    typedef struct {
      unsigned char enable;                     // Enable or disable clock
      unsigned long destClk;                    // Desired clock speed
    } SDHC_clk_param;
    
    // SDHC_mmcboot_param definition :
    typedef struct {
      unsigned long ackTimeout;                 // Sets the timeout value for the boot ACK. ackTimeout has value 0x0 - 0xE
      unsigned long mode;                       // Configures the boot mode
      unsigned long blockCount;                 // Configures the the block count for the boot. BLOCKcOUNT HAS VALUE 0x0 .. 0xFFFF
      unsigned long enMMCBOOTflags;             // Enable or disable corresponding feature
    } SDHC_mmcboot_param;
    
    // SDHC_proctl_param definition :
    typedef struct {
        unsigned long ledState;                 // Sets the LED state
        unsigned long endianMode;               // Configures the endian mode
        unsigned long dmaMode;                  // Sets the DMA mode
        unsigned long enPROCTLflags;            // Enable or disable corresponding feature
    } SDHC_proctl_param;    
    
    // SDHC_watermark_param definition :
    typedef struct {
        unsigned long writeWatermarkLevel;      // Sets the watermark for writing
        unsigned long readWatermarkLevel;       // Sets the watermark for reading
    } SDHC_watermark_param;
    
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
  • initConf: pointer to SDHC_clk_param struct that contains the configuration information for the clock :
    typedef struct {
      unsigned char enable;                     // Enable or disable clock.
      unsigned long destClk;                    // Desired clock speed.
    } SDHC_clk_param;
    
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
  • powerState: power state. Valid values :
    Value Description
    _SDHC_PowerState_OFF Power state off.
    _SDHC_PowerState_ON Power state on.
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
  • _SDHC_SET: power state is ON,
  • _SDHC_RESET: power state is OFF.
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
  • clk: SDHC clock source. Valid values :
    Value Description
    _SDHC_CLK_SYSTEM System clock.
    _SDHC_CLK_MCGFLL Multipurpose clock generator with PLL.
    _SDHC_CLK_IRC48M Internal 48 MHz oscillator.
    _SDHC_CLK_OSCERCLK External reference clock.
    _SDHC_CLKIN SDHC clock input.
Returns
  • _SDHC_SET: clock is selected,
  • _SDHC_RESET: clock is not selected.
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 initConfig structure.

Parameters
  • initConfig: pointer to SDHC_proctl_param structure that contains the configuration information for the Protocol Control Register :
    typedef struct {
        unsigned long ledState;                 // Sets the LED state.
        unsigned long endianMode;               // Configures the endian mode.
        unsigned long dmaMode;                  // Sets the DMA mode.
        unsigned long enPROCTLflags;            // Enable or disable corresponding feature.
    } SDHC_proctl_param;
    
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 initConfig.

Parameters
  • initConfig: pointer to SDHC_watermark_param structure that contains the configuration information for the Watermark Level Register :
    typedef struct {
        unsigned long writeWatermarkLevel;      // Sets the watermark for writing.
        unsigned long readWatermarkLevel;       // Sets the watermark for reading.
    } SDHC_watermark_param;
    
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 initConfig.

Parameters
  • initConfig: pointer to SDHC_InitTypeDef structure that contains the configuration information for the Vendor Specific Register :
    typedef struct {
        SDHC_clk_param clk;
        SDHC_mmcboot_param bootParams;          // Configture read MMC card boot data feature
        SDHC_proctl_param  proctlParams;        // Configture Protocol Control register
        SDHC_watermark_param wmlParams;         // Configture Watermark Level register 
        unsigned long enVENDORflags;            // Enable or disable corresponding feature 
    } SDHC_InitTypeDef;
    
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 initBootConfig.

Parameters
  • initBootConfig: pointer to SDHC_mmcboot_param structure that contains the configuration information for the MMC Boot Register :
    typedef struct {
      unsigned long ackTimeout;                 // Sets the timeout value for the boot ACK. ackTimeout has value 0x0 - 0xE
      unsigned long mode;                       // Configures the boot mode
      unsigned long blockCount;                 // Configures the the block count for the boot. BLOCKcOUNT HAS VALUE 0x0 .. 0xFFFF
      unsigned long enMMCBOOTflags;             // Enable or disable corresponding feature
    } SDHC_mmcboot_param;
    
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 SDHC_InitTypeDef.

Parameters
  • initConfig: pointer to SDHC_InitTypeDef structure that which will be initialized :
    typedef struct {
        SDHC_clk_param clk;
        SDHC_mmcboot_param bootParams;          // Configture read MMC card boot data feature
        SDHC_proctl_param  proctlParams;        // Configture Protocol Control register
        SDHC_watermark_param wmlParams;         // Configture Watermark Level register 
        unsigned long enVENDORflags;            // Enable or disable corresponding feature 
    } SDHC_InitTypeDef;
    
    // SDHC_clk_param definition :
    typedef struct {
      unsigned char enable;                     // Enable or disable clock
      unsigned long destClk;                    // Desired clock speed
    } SDHC_clk_param;
    
    // SDHC_mmcboot_param definition :
    typedef struct {
      unsigned long ackTimeout;                 // Sets the timeout value for the boot ACK. ackTimeout has value 0x0 - 0xE
      unsigned long mode;                       // Configures the boot mode
      unsigned long blockCount;                 // Configures the the block count for the boot. BLOCKcOUNT HAS VALUE 0x0 .. 0xFFFF
      unsigned long enMMCBOOTflags;             // Enable or disable corresponding feature
    } SDHC_mmcboot_param;
    
    // SDHC_proctl_param definition :
    typedef struct {
        unsigned long ledState;                 // Sets the LED state
        unsigned long endianMode;               // Configures the endian mode
        unsigned long dmaMode;                  // Sets the DMA mode
        unsigned long enPROCTLflags;            // Enable or disable corresponding feature
    } SDHC_proctl_param;    
    
    // SDHC_watermark_param definition :
    typedef struct {
        unsigned long writeWatermarkLevel;      // Sets the watermark for writing
        unsigned long readWatermarkLevel;       // Sets the watermark for reading
    } SDHC_watermark_param;
    
  • module: appropriate module pinout. Use Code Assistant to list available module pinouts by typing _GPIO_Module_SDHC and pressing Ctrl + Space.
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
  • timeout: time to wait for initialization.
Returns
  • 0: success,
  • timeout: error.
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
  • basicInfo: pointer to SDHC_basic_info structure that contains the capability information of the SDHC card :
    typedef struct {
        unsigned char specVer;        // Save the specification version
        unsigned char vendorVer;      // Save the verdor version
        unsigned long maxBlkLen;      // Save the max block length
        unsigned long capability;     // The capability flags 
    } SDHC_basic_info;
    
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 dataStruct.

Parameters
  • basicInfo: pointer to SDHC_dataStruct structure that contains the capability information of the SDHC card :
    typedef struct {  
      unsigned long dataTimeout;       // data timeout,     value 0x0..0xE
      unsigned long dataBlkSize;       // data Block size,  value 0x0..0x1FFF
      unsigned long dataBlkCount;      // data Block count, value 0x0..0xFFFF
    } SDHC_dataStruct;
    
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 cmdReq and sends the command.

Parameters
  • cmdReq: pointer to SDHC_cmdReq structure that contains the configuration information for the SDHC command :
    typedef struct {
        unsigned long argument;          // Cmd argument
        unsigned long cmdIndex;          // Cmd index
        unsigned long cmdType;           // Cmd type
        unsigned long response;          // Cmd response
        unsigned long flags;             // Cmd Flags
    } SDHC_cmdReq;
    
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
  • mask: corresponding bits in Present State Register will be read by mask parameter. Valid values :
    Value Description
    _SDHC_PRSSTAT_CIHB Command Inhibit (CMD) bit mask.
    _SDHC_PRSSTAT_CDIHB Command Inhibit (DAT) bit mask.
    _SDHC_PRSSTAT_DLA Data Line Active bit mask.
    _SDHC_PRSSTAT_SDSTB SD Clock Stable bit mask.
    _SDHC_PRSSTAT_IPGOFF Bus Clock bit mask.
    _SDHC_PRSSTAT_HCKOFF System Clock bit mask.
    _SDHC_PRSSTAT_PEROFF SDHC clock bit mask.
    _SDHC_PRSSTAT_SDOFF SD Clock Gated Off Internally bit mask.
    _SDHC_PRSSTAT_WTA Write Transfer Active bit mask.
    _SDHC_PRSSTAT_RTA Read Transfer Active bit mask.
    _SDHC_PRSSTAT_BWEN Buffer Write Enable bit mask.
    _SDHC_PRSSTAT_BREN Buffer Read Enable bit mask.
    _SDHC_PRSSTAT_CINS Card Inserted bit mask.
    _SDHC_PRSSTAT_CLSL CMD Line Signal Level bit mask.
    _SDHC_PRSSTAT_DLSL0 DAT0 Line Signal Level bit mask.
    _SDHC_PRSSTAT_DLSL1 DAT1 Line Signal Level bit mask.
    _SDHC_PRSSTAT_DLSL2 DAT2 Line Signal Level bit mask.
    _SDHC_PRSSTAT_DLSL3 DAT3 Line Signal Level bit mask.
    _SDHC_PRSSTAT_DLSL4 DAT4 Line Signal Level bit mask.
    _SDHC_PRSSTAT_DLSL5 DAT5 Line Signal Level bit mask.
    _SDHC_PRSSTAT_DLSL6 DAT6 Line Signal Level bit mask.
    _SDHC_PRSSTAT_DLSL7 DAT7 Line Signal Level bit mask.
Returns
  • _SDHC_SET: corresponding mask is set,
  • _SDHC_RESET: corresponding mask is not set.
Requires

Nothing.

Notes

None.

SDHC_DataStructInit

Prototype

void SDHC_DataStructInit(SDHC_dataStruct *dataStruct);

Description

This function fills each SDHC_dataStruct member with its default value.

Parameters
  • dataStruct: pointer to SDHC_dataStruct structure :
    typedef struct {  
      unsigned long dataTimeout;       // data timeout,     value 0x0..0xE
      unsigned long dataBlkSize;       // data Block size,  value 0x0..0x1FFF
      unsigned long dataBlkCount;      // data Block count, value 0x0..0xFFFF
    } SDHC_dataStruct;
    
Returns

Nothing.

Requires

Nothing.

Notes

None.

SDHC_CmdStructInit

Prototype

void SDHC_CmdStructInit(SDHC_cmdReq *cmdReq);

Description

This function fills each SDHC_cmdReq member with its default value.

Parameters
  • cmdReq: pointer to SDHC_cmdReq structure :
    typedef struct {
        unsigned long argument;          // Cmd argument
        unsigned long cmdIndex;          // Cmd index
        unsigned long cmdType;           // Cmd type
        unsigned long response;          // Cmd response
        unsigned long flags;             // Cmd Flags
    } SDHC_cmdReq;
    
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
  • index: index of Command Response Register :
    Value Description
    SDHC_RESP0 Command Response Register 0.
    SDHC_RESP1 Command Response Register 1.
    SDHC_RESP2 Command Response Register 2.
    SDHC_RESP3 Command Response Register 3.
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
  • dat: data to be written.
Returns

Nothing.

Requires

Nothing.

Notes

None.

SDHC_SetDataTransferWidth

Prototype

void SDHC_SetDataTransferWidth(unsigned long dtw);

Description

This function sets data transfer width.

Parameters
  • dtw: data to be sent. Valid values :
    Value Description
    _SDHC_PROCTL_1BIT 1-bit data transfer width.
    _SDHC_PROCTL_4BIT 4-bit data transfer width.
    _SDHC_PROCTL_BIT 8-bit data transfer width.
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
  • errType: error type. Valid values :
    Value Description
    _SDHC_ERR_AC12ERR Auto CMD12 Error Status Register.
    _SDHC_ERR_ADMAES ADMA Error Status register.
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
  • address: address for ADMA transfer.
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
  • newState: enables or disables read wait control. Valid values :
    Value Description
    _SDHC_ENABLE Enable read wait control.
    _SDHC_DISABLE Disable read wait control.
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
  • newState: enables or disables SABGREQ. Valid values :
    Value Description
    _SDHC_ENABLE Enable SABGREQ.
    _SDHC_DISABLE Disable SABGREQ.
Returns

Nothing.

Requires

Nothing.

Notes

None.

SDHC_SetDMAS

Prototype

void SDHC_SetDMAS(unsigned long newState);

Description

This function selects DMA.

Parameters
  • newState: selects DMA. Valid values :
    Value Description
    _SDHC_PROCTL_DmaSimple Simple DMA.
    _SDHC_PROCTL_DmaAdma1 ADMA1.
    _SDHC_PROCTL_DmaAdma2 ADMA2.
Returns

Nothing.

Requires

Nothing.

Notes

None.

Copyright (c) 2002-2019 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code