XMC Peripheral Library for XMC4000 Family: SDMMC

XMC Peripheral Library for XMC4000 Family

XMC Peripheral Library for XMC4000 Family  2.1.16

Data Structures

union  XMC_SDMMC_COMMAND_t
 
struct  XMC_SDMMC_CONFIG_t
 
union  XMC_SDMMC_PRESENT_STATE_t
 
struct  XMC_SDMMC_RESPONSE_t
 
struct  XMC_SDMMC_t
 
struct  XMC_SDMMC_TRANSFER_MODE_t
 

Macros

#define XMC_SDMMC   ((XMC_SDMMC_t *)SDMMC_BASE)
 

Enumerations

Functions

void XMC_SDMMC_BusPowerOff (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_BusPowerOn (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_ClearEvent (XMC_SDMMC_t *const sdmmc, uint32_t event)
 
void XMC_SDMMC_Disable (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_DisableDelayCmdDatLines (void)
 
void XMC_SDMMC_DisableEvent (XMC_SDMMC_t *const sdmmc, uint32_t event)
 
void XMC_SDMMC_DisableEventStatus (XMC_SDMMC_t *const sdmmc, uint32_t event)
 
void XMC_SDMMC_DisableHighSpeed (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_DisableInterruptAtBlockGap (XMC_SDMMC_t *const sdmmc, const XMC_SDMMC_CONFIG_t *config)
 
void XMC_SDMMC_DisableWakeupEvent (XMC_SDMMC_t *const sdmmc, uint32_t event)
 
void XMC_SDMMC_Enable (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_EnableDelayCmdDatLines (void)
 
void XMC_SDMMC_EnableEvent (XMC_SDMMC_t *const sdmmc, uint32_t event)
 
void XMC_SDMMC_EnableEventStatus (XMC_SDMMC_t *const sdmmc, uint32_t event)
 
void XMC_SDMMC_EnableHighSpeed (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_EnableInterruptAtBlockGap (XMC_SDMMC_t *const sdmmc, const XMC_SDMMC_CONFIG_t *config)
 
void XMC_SDMMC_EnableWakeupEvent (XMC_SDMMC_t *const sdmmc, uint32_t event)
 
bool XMC_SDMMC_GetACMDErrStatus (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_ACMD_ERR_t error)
 
uint32_t XMC_SDMMC_GetAutoCommandResponse (const XMC_SDMMC_t *const sdmmc)
 
bool XMC_SDMMC_GetClockStability (XMC_SDMMC_t *const sdmmc)
 
uint32_t XMC_SDMMC_GetCommandResponse (XMC_SDMMC_t *const sdmmc)
 
bool XMC_SDMMC_GetContinueRequest (XMC_SDMMC_t *const sdmmc)
 
bool XMC_SDMMC_GetEvent (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_EVENT_t event)
 
bool XMC_SDMMC_GetPowerStatus (XMC_SDMMC_t *const sdmmc)
 
XMC_SDMMC_PRESENT_STATE_t XMC_SDMMC_GetPresentState (const XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_GetR2Response (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_RESPONSE_t *const response)
 
uint32_t XMC_SDMMC_GetSWResetStatus (XMC_SDMMC_t *const sdmmc)
 
uint32_t XMC_SDMMC_GetTransferBlocksNum (XMC_SDMMC_t *const sdmmc)
 
XMC_SDMMC_STATUS_t XMC_SDMMC_Init (XMC_SDMMC_t *const sdmmc, const XMC_SDMMC_CONFIG_t *config)
 
bool XMC_SDMMC_IsAllDataLinesHigh (XMC_SDMMC_t *const sdmmc)
 
bool XMC_SDMMC_IsAnyErrorEvent (XMC_SDMMC_t *const sdmmc)
 
bool XMC_SDMMC_IsCommandLineBusy (XMC_SDMMC_t *const sdmmc)
 
bool XMC_SDMMC_IsDataLineBusy (XMC_SDMMC_t *const sdmmc)
 
uint32_t XMC_SDMMC_ReadFIFO (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_SDClockDisable (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_SDClockEnable (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_SDClockFreqSelect (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_SDCLK_FREQ_SEL_t clk)
 
XMC_SDMMC_STATUS_t XMC_SDMMC_SendCommand (XMC_SDMMC_t *const sdmmc, const XMC_SDMMC_COMMAND_t *command, uint32_t arg)
 
void XMC_SDMMC_SetBusVoltage (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_BUS_VOLTAGE_t bus_voltage)
 
void XMC_SDMMC_SetCardDetectionSource (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_CD_SOURCE_t source)
 
void XMC_SDMMC_SetCardDetectionStatus (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_CD_STATUS_t status)
 
void XMC_SDMMC_SetContinueRequest (XMC_SDMMC_t *const sdmmc, bool enabled)
 
void XMC_SDMMC_SetDataLineTimeout (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_DAT_TIMEOUT_COUNTER_t timeout)
 
void XMC_SDMMC_SetDataTransferDirection (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_DATA_TRANSFER_DIR_t dir)
 
void XMC_SDMMC_SetDataTransferMode (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_TRANSFER_MODE_t *const transfer_mode)
 
void XMC_SDMMC_SetDataTransferWidth (XMC_SDMMC_t *const sdmmc, XMC_SDMMC_DATA_LINES_t lines)
 
void XMC_SDMMC_SetDelay (uint8_t tapdel)
 
void XMC_SDMMC_SetReadWaitControl (XMC_SDMMC_t *const sdmmc, bool enabled)
 
void XMC_SDMMC_SetStopAtBlockGap (XMC_SDMMC_t *const sdmmc, bool enabled)
 
void XMC_SDMMC_SetSWReset (XMC_SDMMC_t *const sdmmc, uint32_t reset_mode)
 
void XMC_SDMMC_Start (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_Stop (XMC_SDMMC_t *const sdmmc)
 
void XMC_SDMMC_TriggerACMDErr (XMC_SDMMC_t *const sdmmc, uint32_t error)
 
void XMC_SDMMC_TriggerEvent (XMC_SDMMC_t *const sdmmc, uint32_t event)
 
void XMC_SDMMC_WriteFIFO (XMC_SDMMC_t *const sdmmc, uint32_t *data)
 

Detailed Description

The SDMMC peripheral provides an interface between SD/SDIO/MMC cards and the AHB. It handles the SD/SDIO protocol at transmission level. It automatically packs data and checks for CRC, start/end bits and format correctness. For SD cards, a maximum transfer rate of 24MB/sec is supported and for MMC cards, 48MB/sec.

The peripheral can be used for applications that require large storage memory; e.g. Data logging, firmware updates or an embedded database.

The SDMMC low level driver provides functions to configure and initialize the SDMMC hardware peripheral.

Macro Definition Documentation

#define XMC_SDMMC   ((XMC_SDMMC_t *)SDMMC_BASE)

A convenient symbol for the SDMMC peripheral base address

Enumeration Type Documentation

CMD12 response errors of Auto CMD12

Enumerator
XMC_SDMMC_ACMD12_NOT_EXEC_ERR 

ACMD12 not executed error

XMC_SDMMC_ACMD_TIMEOUT_ERR 

ACMD timeout error

XMC_SDMMC_ACMD_CRC_ERR 

ACMD CRC error

XMC_SDMMC_ACMD_END_BIT_ERR 

ACMD end bit error

XMC_SDMMC_ACMD_IND_ERR 

ACMD IND error

XMC_SDMMC_CMD_NOT_ISSUED_BY_ACMD12_ERR 

CMD not issued by ACMD12

SDMMC bus voltage level

SDMMC card detection signal source

SDMMC card detection status

Command response selection

Enumerator
XMC_SDMMC_COMMAND_RESPONSE_NONE 

No Response

XMC_SDMMC_COMMAND_RESPONSE_LONG 

Response length 136

XMC_SDMMC_COMMAND_RESPONSE_SHORT 

Response length 48

XMC_SDMMC_COMMAND_RESPONSE_SHORT_BUSY 

Response length 48 check Busy after response

Types of SDMMC commands

Enumerator
XMC_SDMMC_COMMAND_TYPE_NORMAL 

Command normal

XMC_SDMMC_COMMAND_TYPE_SUSPEND 

Command suspend

XMC_SDMMC_COMMAND_TYPE_RESUME 

Command resume

XMC_SDMMC_COMMAND_TYPE_ABORT 

Command abort

Data line timeout counter values

Enumerator
XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_14 

SDCLK * (2 ^ 13)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_15 

SDCLK * (2 ^ 14)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_16 

SDCLK * (2 ^ 15)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_17 

SDCLK * (2 ^ 16)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_18 

SDCLK * (2 ^ 17)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_19 

SDCLK * (2 ^ 18)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_20 

SDCLK * (2 ^ 19)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_21 

SDCLK * (2 ^ 20)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_22 

SDCLK * (2 ^ 21)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_23 

SDCLK * (2 ^ 22)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_24 

SDCLK * (2 ^ 23)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_25 

SDCLK * (2 ^ 24)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_26 

SDCLK * (2 ^ 25)

XMC_SDMMC_DAT_TIMEOUT_COUNTER_2_POW_27 

SDCLK * (2 ^ 26)

Number of data lines for SDMMC data transfer

Enumerator
XMC_SDMMC_DATA_LINES_1 

Single data line mode

XMC_SDMMC_DATA_LINES_4 

4-bit mode

XMC_SDMMC_DATA_LINES_8 

SD 8-bit mode

SDMMC data transfer direction

Enumerator
XMC_SDMMC_DATA_TRANSFER_CARD_TO_HOST 

Host to card Card to host

SDMMC events (Normal and error events)

Enumerator
XMC_SDMMC_CMD_COMPLETE 

Command complete event

XMC_SDMMC_TX_COMPLETE 

Transmit complete event

XMC_SDMMC_BLOCK_GAP_EVENT 

Block gap event

XMC_SDMMC_BUFFER_WRITE_READY 

Buffer write ready event

XMC_SDMMC_BUFFER_READ_READY 

Buffer read ready event

XMC_SDMMC_CARD_INS 

Card insert event

XMC_SDMMC_CARD_REMOVAL 

Card removal event

XMC_SDMMC_CARD_INT 

Card INT event

XMC_SDMMC_CARD_ERR 

Card error interrupt

XMC_SDMMC_CMD_TIMEOUT_ERR 

Command time-out error

XMC_SDMMC_CMD_CRC_ERR 

Command CRC error

XMC_SDMMC_CMD_END_BIT_ERR 

Command end bit error

XMC_SDMMC_CMD_IND_ERR 

Command index error

XMC_SDMMC_DATA_TIMEOUT_ERR 

Data time-out error

XMC_SDMMC_DATA_CRC_ERR 

Data CRC error

XMC_SDMMC_DATA_END_BIT_ERR 

Data end bit error

XMC_SDMMC_CURRENT_LIMIT_ERR 

Current limit error

XMC_SDMMC_ACMD_ERR 

ACMD error

XMC_SDMMC_TARGET_RESP_ERR 

Target response error

SDMMC response types

Enumerator
XMC_SDMMC_RESPONSE_TYPE_NO_RESPONSE 

No response

XMC_SDMMC_RESPONSE_TYPE_R1 

Response type: R1

XMC_SDMMC_RESPONSE_TYPE_R1b 

Response type: R1b

XMC_SDMMC_RESPONSE_TYPE_R2 

Response type: R2

XMC_SDMMC_RESPONSE_TYPE_R3 

Response type: R3

XMC_SDMMC_RESPONSE_TYPE_R6 

Response type: R6

XMC_SDMMC_RESPONSE_TYPE_R7 

Response type: R7

Valid SD clock frequency divider selection

Enumerator
XMC_SDMMC_CLK_DIV_1 

Base clock (10 Mhz -> 63 Mhz)

XMC_SDMMC_CLK_DIV_2 

Base clock divided by 2

XMC_SDMMC_CLK_DIV_4 

Base clock divided by 4

XMC_SDMMC_CLK_DIV_8 

Base clock divided by 8

XMC_SDMMC_CLK_DIV_16 

Base clock divided by 16

XMC_SDMMC_CLK_DIV_32 

Base clock divided by 32

XMC_SDMMC_CLK_DIV_64 

Base clock divided by 64

XMC_SDMMC_CLK_DIV_128 

Base clock divided by 128

XMC_SDMMC_CLK_DIV_256 

Base clock divided by 256

Status return values for the SDMMC low level driver

Enumerator
XMC_SDMMC_STATUS_SUCCESS 

Operation successful

XMC_SDMMC_STATUS_CMD_LINE_BUSY 

Command line busy

XMC_SDMMC_STATUS_DAT_LINE_BUSY 

Data line busy

SDMMC software reset modes

Enumerator
XMC_SDMMC_SW_RESET_ALL 

Software reset all

XMC_SDMMC_SW_RST_CMD_LINE 

Software reset command line

XMC_SDMMC_SW_RST_DAT_LINE 

Software reset data line

Auto command transfer modes

Enumerator
XMC_SDMMC_TRANSFER_MODE_AUTO_CMD_DISABLED 

ACMD mode disabled

XMC_SDMMC_TRANSFER_MODE_AUTO_CMD_12 

ACMD12 mode

SDMMC transfer modes

Enumerator
XMC_SDMMC_TRANSFER_MODE_TYPE_SINGLE 

Transfer mode type: single

XMC_SDMMC_TRANSFER_MODE_TYPE_INFINITE 

Transfer mode type: infinite

XMC_SDMMC_TRANSFER_MODE_TYPE_MULTIPLE 

Transfer mode type: multiple

XMC_SDMMC_TRANSFER_MODE_TYPE_STOP_MULTIPLE 

Transfer mode type: multiple stop

SDMMC wakeup events

Enumerator
XMC_SDMMC_WAKEUP_EN_CARD_INT 

Wakeup on card interrupt

XMC_SDMMC_WAKEUP_EN_CARD_INS 

Wakeup on SD card insertion

XMC_SDMMC_WAKEUP_EN_CARD_REM 

Wakeup SD card removal

Function Documentation

void XMC_SDMMC_BusPowerOff ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
None
Description:
Disable SDMMC bus power
The function resets the SD_BUS_POWER bit-field in the POWER_CTRL register, disabling the bus power.
void XMC_SDMMC_BusPowerOn ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
None
Description:
Enable SDMMC bus power
The function sets the SD_BUS_POWER bit-field in the POWER_CTRL register, enabling the bus power. It may be invoked after enabling the SD clock (XMC_SDMMC_SDClockEnable()).
void XMC_SDMMC_ClearEvent ( XMC_SDMMC_t *const  sdmmc,
uint32_t  event 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
eventA valid SDMMC event (XMC_SDMMC_EVENT_t) or a valid combination of logically OR'd events
Returns
None
Description:
Clear SDMMC event(s)
The function clears requested normal/error events by settings the bit-fields of the INT_STATUS register. Please check SDMMC_INT_STATUS_NORM in the XMC45000 manual for more details.
void XMC_SDMMC_Disable ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
None
Description:
Disable SDMMC peripheral
The function asserts the peripheral reset.
void XMC_SDMMC_DisableDelayCmdDatLines ( void  )
Parameters
None
Returns
None
Description:
Disable delay on the command/data out lines
Use the function to disable delay on the command/data out lines.
void XMC_SDMMC_DisableEvent ( XMC_SDMMC_t *const  sdmmc,
uint32_t  event 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
eventA valid SDMMC event (XMC_SDMMC_EVENT_t) or a valid combination of logically OR'd events
Returns
None
Description:
Disable normal and error SDMMC event(s)
The function disables the interrupt generation for the requested events by clearing the bit-fields of EN_INT_SIGNAL_NORM and EN_INT_SIGNAL_ERR registers.
Note:
The XMC_SDMMC_DisableEvent() function doesn't reset the the interrupt status. One may still use XMC_SDMMC_GetEvent() to check the status of requested events even if the interrupt generation is already disabled.
void XMC_SDMMC_DisableEventStatus ( XMC_SDMMC_t *const  sdmmc,
uint32_t  event 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
eventA valid SDMMC event (XMC_SDMMC_EVENT_t) or a valid combination of logically OR'd events
Returns
None
Description:
Disable event status
The function resets the bit-fields of EN_INT_STATUS_NORM and EN_INT_STATUS_ERR registers to disable interrupt status for requested normal/error SDMMC events.
void XMC_SDMMC_DisableHighSpeed ( XMC_SDMMC_t *const  sdmmc)
Parameters
None
Returns
None
Description:
High speed disable
Use the function to disable high speed operation. The host controller will switch back to a normal speed mode. In this mode, the host controller outputs command and data lines at 25 MHz for SD.
void XMC_SDMMC_DisableInterruptAtBlockGap ( XMC_SDMMC_t *const  sdmmc,
const XMC_SDMMC_CONFIG_t config 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
configA pointer to the SDMMC configuration structure (XMC_SDMMC_CONFIG_t)
Returns
None
Description:
Disable interrupt at block gap
The function resets the BLOCK_GAP_CTRL.INT_AT_BLOCK_GAP bit-field to disable interrupt at block gap. This bit is only valid in a 4-bit mode of the SDIO card.
void XMC_SDMMC_DisableWakeupEvent ( XMC_SDMMC_t *const  sdmmc,
uint32_t  event 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
eventA valid SDMMC wakeup event (XMC_SDMMC_WAKEUP_EVENT_t) or a valid combination of logically OR'd wakeup events
Returns
None
Description:
Disable wakeup event(s)
The function disables SDMMC wakeup events by clearing appropriate bit-fields of the WAKEUP_CTRL register.

List of supported wakeup events -> Wakeup on:
1) Card interrupt
2) SD card insertion
3) SD card removal

void XMC_SDMMC_Enable ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
None
Description:
Enable SDMMC peripheral
The function de-asserts the peripheral reset. The peripheral needs to be initialized.
void XMC_SDMMC_EnableDelayCmdDatLines ( void  )
Parameters
None
Returns
None
Description:
Enable delay on the command/data out lines
Use the function to enable delay on the command/data out lines. Invoke this function before selecting the number of delay elements.
void XMC_SDMMC_EnableEvent ( XMC_SDMMC_t *const  sdmmc,
uint32_t  event 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
eventA valid SDMMC event (XMC_SDMMC_EVENT_t) or a valid combination of logically OR'd events
Returns
None
Description:
Enable SDMMC normal and error event(s)
The function first sets the bit-fields of EN_INT_STATUS_NORM and EN_INT_STATUS_ERR registers to enable interrupt status for requested normal/error SDMMC events. It then sets the bit-fields of EN_INT_SIGNAL_NORM and EN_INT_SIGNAL_ERR to enable the interrupt generation for the requested events.
void XMC_SDMMC_EnableEventStatus ( XMC_SDMMC_t *const  sdmmc,
uint32_t  event 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
eventA valid SDMMC event (XMC_SDMMC_EVENT_t) or a valid combination of logically OR'd events
Returns
None
Description:
Enable event status
The function sets the bit-fields of EN_INT_STATUS_NORM and EN_INT_STATUS_ERR registers to enable interrupt status for requested normal/error SDMMC events.
void XMC_SDMMC_EnableHighSpeed ( XMC_SDMMC_t *const  sdmmc)
Parameters
None
Returns
None
Description:
High speed enable
Use the function to enable high speed operation. The default is a normal speed operation. Once enabled, the host controller outputs command and data lines at the rising edge of the SD clock (up to 50 MHz for SD).
void XMC_SDMMC_EnableInterruptAtBlockGap ( XMC_SDMMC_t *const  sdmmc,
const XMC_SDMMC_CONFIG_t config 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
configA pointer to the SDMMC configuration structure (XMC_SDMMC_CONFIG_t)
Returns
None
Description:
Enable interrupt at block gap
The function sets the BLOCK_GAP_CTRL.INT_AT_BLOCK_GAP bit-field to enable interrupt at block gap for a multi-block transfer. This bit is only valid in a 4-bit mode of the SDIO card.
void XMC_SDMMC_EnableWakeupEvent ( XMC_SDMMC_t *const  sdmmc,
uint32_t  event 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
eventA valid SDMMC wakeup event (XMC_SDMMC_WAKEUP_EVENT_t) or a valid combination of logically OR'd wakeup events
Returns
None
Description:
Enable wakeup event(s)
The function enables SDMMC wakeup events by setting appropriate bit-fields of the WAKEUP_CTRL register.

List of supported wakeup events -> Wakeup on:
1) Card interrupt
2) SD card insertion
3) SD card removal

bool XMC_SDMMC_GetACMDErrStatus ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_ACMD_ERR_t  error 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
errorA valid SDMMC ACMD error (XMC_SDMMC_ACMD_ERR_t)
Returns
bool
Description:
Get status of Auto CMD12 errors
The function detects the presence of an Auto CMD12 error. A boolean is returned to indicate if an error is detected.
uint32_t XMC_SDMMC_GetAutoCommandResponse ( const XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
uint32_t Auto command response value
Description:
Get card response of Auto commands
This function returns card response [39:8] bits of auto commands: R1 of Auto CMD 23 and R1b of Auto CMD 12.
bool XMC_SDMMC_GetClockStability ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
bool
Description:
Check internal clock stability
Use this function to check the internal SDMMC clock stability. The function returns a boolean value indicating internal clock stability (true = stable)
uint32_t XMC_SDMMC_GetCommandResponse ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
uint32_t SDMMC command response
Description:
Get card response (no Auto command)
This function returns [39:8] bits of the card response. The others are checked automatically by the peripheral. This function can be used with response type R1, R1b, R3, R4, R5, R5b, R6 but it doesn't support the retrieving of R1 of Auto CMD 23 and R1b of Auto CMD 12. To get these responses, use XMC_SDMMC_GetAutoCommandResponse().
bool XMC_SDMMC_GetContinueRequest ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
bool
Description:
Get continue request
The function returns the status of the BLOCK_GAP_CTRL.CONTINUE_REQ bit-field. It returns "true" if the transaction is restarted after a "stop at block gap" request.
bool XMC_SDMMC_GetEvent ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_EVENT_t  event 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
eventA valid SDMMC event (XMC_SDMMC_EVENT_t)
Returns
bool
Description:
Get SDMMC event status
The function returns the status of a single requested (normal/error) event by reading the appropriate bit-fields of the INT_STATUS register.
bool XMC_SDMMC_GetPowerStatus ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
bool
Description:
Get power status of the SDMMC peripheral
The function checks the SD_BUS_POWER bit-field of the POWER_CTRL register and returns a boolean value - "on" or "off".
XMC_SDMMC_PRESENT_STATE_t XMC_SDMMC_GetPresentState ( const XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
XMC_SDMMC_PRESENT_STATE_t A structure storing the present state of the host controller
Description:
Get the present state of the SDMMC host controller
Get the values of each bit-field in SDMMC_PRESENT_STATE register The function call populates an instance of the XMC_SDMMC_PRESENT_STATE_t structure with the state of the SD host controller and returns it to the caller.
void XMC_SDMMC_GetR2Response ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_RESPONSE_t *const  response 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
responsePointer to structure type XMC_SDMMC_RESPONSE_t to store the full response
Returns
None
Description:
Get card R2 response
The R2 response is 120 bits wide. The function reads all peripheral registers and store in the response data structure.
uint32_t XMC_SDMMC_GetSWResetStatus ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
Software reset status
Description:
Get SDMMC software reset status
The SD host takes some time to reset its registers after invoking XMC_SDMMC_SetSWReset(). Since XMC_SDMMC_SetSWReset() is a non-blocking function, XMC_SDMMC_GetSWResetStatus() has been provided to check the software reset status. The return value needs to be masked with the reset mode (XMC_SDMMC_SW_RESET_t) to get a specific software reset status value.
uint32_t XMC_SDMMC_GetTransferBlocksNum ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
uint32_t Number of blocks that need to be transferred
Description:
Get the number of blocks that need to be transferred
This function is valid only for multiple block transfers. The host controller decrements the block count after each block transfer and stops when the count reaches zero. It can only be accessed when no transaction is happening (i.e after a transaction has stopped). This function returns an invalid value during the transfer.

When saving transfer context as a result of the suspend command, the number of blocks yet to be transferred can be determined by using this function.

XMC_SDMMC_STATUS_t XMC_SDMMC_Init ( XMC_SDMMC_t *const  sdmmc,
const XMC_SDMMC_CONFIG_t config 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
configA pointer to a constant XMC_SDMMC_CONFIG_t structure containing the bus width and clock divider configuration
Returns
XMC_SDMMC_STATUS_SUCCESS
Description:
Initialize the SDMMC peripheral
The function enables the SDMMC peripheral, sets the internal clock divider register and sets the bus width.
bool XMC_SDMMC_IsAllDataLinesHigh ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
bool Status of all data lines
Description:
Check if all data line are high
The function reads the SDMMC PRESENT_STATE register and returns "true" if all data lines are high. It can be used to handle SDMMC error conditions. For example, if an error event (XMC_SDMMC_IsAnyErrorEvent()) is detected and all data lines are high, the user code can conclude that the error is of a "recoverable" type.
bool XMC_SDMMC_IsAnyErrorEvent ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
bool
Description:
Check if any error event has occured
The function can typically be used for writing an error interrupt recovery routine. Should any error be indicated (If XMC_SDMMC_IsAnyErrorEvent() returns true), the routine may then clear the event after indicating the error event and reset the SDMMC command and data lines.
bool XMC_SDMMC_IsCommandLineBusy ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
bool SDMMC command line status
Description:
Check if the command line is busy
The function reads the SDMMC PRESENT_STATE register and returns "true" if the command line is busy ("false" otherwise). The command line must be free before sending an SDMMC command with XMC_SDMMC_SendCommand().
bool XMC_SDMMC_IsDataLineBusy ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
bool SDMMC data line status
Description:
Check if the data line is busy
The function reads the SDMMC PRESENT_STATE register and returns "true" if the data line is busy ("false" otherwise). The data line must be free before sending an SDMMC command with XMC_SDMMC_SendCommand().
uint32_t XMC_SDMMC_ReadFIFO ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
uint32_t The value held in the SDMMC FIFO
Description:
Use this function to read a single word (32 bits) from the SDMMC FIFO.
void XMC_SDMMC_SDClockDisable ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
None
Description:
Disable the SD clock
The function resets the SDCLOCK_EN bit-field of the CLOCK_CTRL register, disabling the SD clock. It can be used alongside a SD card information reset routine (if required).
void XMC_SDMMC_SDClockEnable ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
None
Description:
Enable the SD clock
The function sets the SDCLOCK_EN bit-field of the CLOCK_CTRL register, enabling the SD clock. It can be invoked after the internal clock has achieved stability. SD card initialization process may then follow.
void XMC_SDMMC_SDClockFreqSelect ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_SDCLK_FREQ_SEL_t  clk 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
clkDesired clock frequency (XMC_SDMMC_SDCLK_FREQ_SEL_t)
Returns
None
Description:
Set SD clock frequency
The function sets the CLOCK_CTRL register to configure the frequency of the SD clock pin. The register is programmed with the divisor of the base clock frequency (clk).

The following settings are permitted (8-bit divided clock mode):
00H: base clock (10MHz->63MHz)
01H: base clock divided by 2
10H: base clock divided by 32
02H: base clock divided by 4
04H: base clock divided by 8
08H: base clock divided by 16
20H: base clock divided by 64
40H: base clock divided by 128
80H: base clock divided by 256

Note:
The internal clock should be disabled before updating frequency clock select. Please see section 2.2.14 -> "Clock Control Register" in the SD HOST specification for more information.
XMC_SDMMC_STATUS_t XMC_SDMMC_SendCommand ( XMC_SDMMC_t *const  sdmmc,
const XMC_SDMMC_COMMAND_t command,
uint32_t  arg 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
commandA pointer to a constant of type XMC_SDMMC_COMMAND_t, pointing to the command configuration
argCommand argument
Returns
XMC_SDMMC_STATUS_SUCCESS
Description:
Send normal SDMMC command
Use this function to send a normal SDMMC command. This non-blocking function sets the ARGUMENT1 and COMMAND registers. It is the user's responsibility to check if the command and data lines are busy (XMC_SDMMC_IsDataLineBusy(), XMC_SDMMC_IsCommandLineBusy()).
void XMC_SDMMC_SetBusVoltage ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_BUS_VOLTAGE_t  bus_voltage 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
bus_voltageDesired bus voltage (XMC_SDMMC_BUS_VOLTAGE_t)
Returns
None
Description:
Set SDMMC bus voltage
The function sets the CLOCK_CTRL register to configure the bus voltage. Currently, 3.3 volts is the supported voltage level. This function is relevant within the host controller initialization routine.
void XMC_SDMMC_SetCardDetectionSource ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_CD_SOURCE_t  source 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
sourceA valid SDMMC card detection signal source (XMC_SDMMC_CD_SOURCE_t)
Returns
None
Description:
Selects source for card detection
void XMC_SDMMC_SetCardDetectionStatus ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_CD_STATUS_t  status 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
statusA valid SDMMC card detection status (XMC_SDMMC_CD_STATUS_t)
Returns
None
Description:
Sets the card detection status indicating whether card is inserted or not. Generates (card ins or card removal) interrupt when the normal interrupt is enabled.
Note
Only valid if SDMMC card detection signal source is set to XMC_SDMMC_CD_SOURCE_SW
void XMC_SDMMC_SetContinueRequest ( XMC_SDMMC_t *const  sdmmc,
bool  enabled 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
enabled"true" to restart transaction, "false" is ignored
Returns
None
Description:
Issue a continue request
The function is used to restart a transaction which was stopped using the "Stop at block gap" request. (XMC_SDMMC_SetStopAtBlockGap())
void XMC_SDMMC_SetDataLineTimeout ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_DAT_TIMEOUT_COUNTER_t  timeout 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
timeoutData line timeout value
Returns
None
Description:
Set data line timeout
Use the function to set the interval by which the data line timeouts are detected. The timeout clock frequency is generated by dividing the SD clock (TMCLK) by the timeout argument. This function must be called before setting the bus voltage (XMC_SDMMC_SetBusVoltage()).
void XMC_SDMMC_SetDataTransferDirection ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_DATA_TRANSFER_DIR_t  dir 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
dirTransfer direction (XMC_SDMMC_DATA_TRANSFER_DIR_t)
Returns
None
Description:
Set data transfer direction
Use the function to set the data transfer direction: host to card OR card to host. It is typically used to configure block operations (read/write) on the SD card. For example, XMC_SDMMC_DATA_TRANSFER_HOST_TO_CARD must be used for a write block operation.
void XMC_SDMMC_SetDataTransferMode ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_TRANSFER_MODE_t *const  transfer_mode 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
transfer_modeTransfer mode configuration
Returns
None
Description:
Configure data transfer mode
The function configures block size, block count, type of data transfer, response type and sets the auto command configuration. Use this function to configure a multi-block SDMMC transfer.
void XMC_SDMMC_SetDataTransferWidth ( XMC_SDMMC_t *const  sdmmc,
XMC_SDMMC_DATA_LINES_t  lines 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
linesNumber of data lines to use (XMC_SDMMC_DATA_LINES_t)
Returns
None
Description:
Set data transfer width
Use the function to set the data transfer width. Before using this function, an ACMD6 command (with R1 response type) must be sent to switch the bus width.
void XMC_SDMMC_SetDelay ( uint8_t  tapdel)
Parameters
tapdelNumber of delay elements to select
Returns
None
Description:
Set number of delay elements on the command/data out lines
Use the function to set the number of delay elements on the command/data out lines. The function writes the delay value to the SDMMC delay control register (SDMMCDEL) within the realm of the SCU peripheral. A delay of tapdel + 1 is considered as the final selected number of delay elements.
void XMC_SDMMC_SetReadWaitControl ( XMC_SDMMC_t *const  sdmmc,
bool  enabled 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
enabled"true" to enable read wait control, "false" to disable read wait control.
Returns
None
Description:
Configure read wait control
The read wait function is optional for SDIO cards. If the card supports read wait and XMC_SDMMC_GetTransferBlocksNum() is executed, the SDMMC peripheral will stop read data using DAT[2] line. If this feature is not enabled the peripheral has to stop the SD clock to hold read data, restricting commands generation.

When the host driver detects an SD card insertion, it sets this bit according to the CCCR of the SDIO card. If the card does not support read wait, this feature shall never be enabled otherwise a DAT line conflict may occur. If this feature is disabled, Suspend/Resume cannot be supported.

void XMC_SDMMC_SetStopAtBlockGap ( XMC_SDMMC_t *const  sdmmc,
bool  enabled 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
enabled"true" to set stop at block gap, "false" for transfer
Returns
None
Description:
Stop at block gap request
The function is used to terminate a transaction execution at the next block gap for non-DMA transfers.
void XMC_SDMMC_SetSWReset ( XMC_SDMMC_t *const  sdmmc,
uint32_t  reset_mode 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
reset_modeReset mode or a bitwise combination of modes
Returns
None
Description:
Set SDMMC software reset request
The function sets in the SDMMC SW_RESET register:
1) bit 0 to reset all
2) bit 1 to reset CMD line
3) bit 2 reset DAT line

It is typically used to reset the SD HOST controller's registers.

void XMC_SDMMC_Start ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
None
Description:
Enable the internal SDMMC clock
The function enables the internal clock of the SDMMC peripheral. To check if the clock is stable, use XMC_SDMMC_GetClockStability().
Note:
Invoke XMC_SDMMC_Init() before using this function.
void XMC_SDMMC_Stop ( XMC_SDMMC_t *const  sdmmc)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
Returns
None
Description:
Disable internal SDMMC clock
The function disables the internal clock of the SDMMC peripheral. The SDMMC registers can still be read and written even if the internal clock is disabled.
void XMC_SDMMC_TriggerACMDErr ( XMC_SDMMC_t *const  sdmmc,
uint32_t  error 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
errorA valid SDMMC ACMD error (XMC_SDMMC_ACMD_ERR_t) or a valid combination of logically OR'd ACMD error events
Returns
None
Description:
Triggers Auto CMD12 error(s)
This function triggers Auto CMD12 error(s) by setting appropriate bit-fields of the FORCE_EVENT_ACMD_ERR_STATUS register.
Related APIs:
XMC_SDMMC_TriggerEvent()
void XMC_SDMMC_TriggerEvent ( XMC_SDMMC_t *const  sdmmc,
uint32_t  event 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
eventA valid SDMMC event (XMC_SDMMC_EVENT_t) or a valid combination of logically OR'd events
Returns
None
Description:
Trigger SDMMC error events
The SDMMC peripheral supports triggering of following error events:

XMC_SDMMC_CMD_TIMEOUT_ERR, XMC_SDMMC_CMD_CRC_ERR, XMC_SDMMC_CMD_END_BIT_ERR, XMC_SDMMC_CMD_IND_ERR, XMC_SDMMC_DATA_TIMEOUT_ERR, XMC_SDMMC_DATA_CRC_ERR, XMC_SDMMC_DATA_END_BIT_ERR, XMC_SDMMC_CURRENT_LIMIT_ERR, XMC_SDMMC_ACMD_ERR, XMC_SDMMC_TARGET_RESP_ERR

For triggering Auto CMD12 error, see XMC_SDMMC_TriggerACMDErr()

void XMC_SDMMC_WriteFIFO ( XMC_SDMMC_t *const  sdmmc,
uint32_t *  data 
)
Parameters
sdmmcA constant pointer to XMC_SDMMC_t, pointing to the SDMMC base address
dataPointer to a data word (32 bits) that needs to be written to the FIFO
Returns
None
Description:
Use this function to write a single word (32 bits) to the SDMMC FIFO.
Generated on Mon Aug 7 2017 11:33:57 for XMC Peripheral Library for XMC4000 Family by   doxygen 1.8.11