Synergy Software Package User's Manual

Driver for the SD/MMC Host Interface (SDHI). More...

Data Structures

struct  sdmmc_instance_ctrl_t
 
struct  sdmmc_extended_cfg_t
 

Enumerations

enum  sdmmc_card_detect_t { SDMMC_CARD_DETECT_NONE, SDMMC_CARD_DETECT_CD }
 
enum  sdmmc_write_protect_t { SDMMC_WRITE_PROTECT_NONE, SDMMC_WRITE_PROTECT_WP }
 

Functions

ssp_err_t R_SDMMC_Open (sdmmc_ctrl_t *const p_api_ctrl, sdmmc_cfg_t const *const p_cfg)
 
ssp_err_t R_SDMMC_Close (sdmmc_ctrl_t *const p_api_ctrl)
 
ssp_err_t R_SDMMC_Read (sdmmc_ctrl_t *const p_api_ctrl, uint8_t *const p_dest, uint32_t const start_sector, uint32_t const sector_count)
 
ssp_err_t R_SDMMC_Write (sdmmc_ctrl_t *const p_api_ctrl, uint8_t const *const p_source, uint32_t const start_sector, uint32_t const sector_count)
 
ssp_err_t R_SDMMC_Control (sdmmc_ctrl_t *const p_api_ctrl, ssp_command_t const command, void *p_data)
 
ssp_err_t R_SDMMC_ReadIo (sdmmc_ctrl_t *const p_api_ctrl, uint8_t *const p_data, uint32_t const function, uint32_t const address)
 
ssp_err_t R_SDMMC_WriteIo (sdmmc_ctrl_t *const p_api_ctrl, uint8_t *const p_data, uint32_t const function, uint32_t const address, sdmmc_io_write_mode_t const read_after_write)
 
ssp_err_t R_SDMMC_ReadIoExt (sdmmc_ctrl_t *const p_api_ctrl, uint8_t *const p_dest, uint32_t const function, uint32_t const address, uint32_t *const count, sdmmc_io_transfer_mode_t transfer_mode, sdmmc_io_address_mode_t address_mode)
 
ssp_err_t R_SDMMC_WriteIoExt (sdmmc_ctrl_t *const p_api_ctrl, uint8_t const *const p_source, uint32_t const function, uint32_t const address, uint32_t const count, sdmmc_io_transfer_mode_t transfer_mode, sdmmc_io_address_mode_t address_mode)
 
ssp_err_t R_SDMMC_IoIntEnable (sdmmc_ctrl_t *const p_api_ctrl, bool enable)
 
ssp_err_t R_SDMMC_VersionGet (ssp_version_t *const p_version)
 
ssp_err_t R_SDMMC_InfoGet (sdmmc_ctrl_t *const p_api_ctrl, sdmmc_info_t *const p_info)
 
ssp_err_t R_SDMMC_Erase (sdmmc_ctrl_t *const p_api_ctrl, uint32_t const start_sector, uint32_t const sector_count)
 

Detailed Description

Driver for the SD/MMC Host Interface (SDHI).

SD/MMC driver to access SD, eMMC, and SDIO devices.

Enumeration Type Documentation

◆ sdmmc_card_detect_t

Card detection configuration options.

Enumerator
SDMMC_CARD_DETECT_NONE 

Card detection unused.

SDMMC_CARD_DETECT_CD 

Card detection using the SDnCD pin.

◆ sdmmc_write_protect_t

Write protection configuration option

Enumerator
SDMMC_WRITE_PROTECT_NONE 

Write protection unused.

SDMMC_WRITE_PROTECT_WP 

write protection using SDnWP pin

Function Documentation

◆ R_SDMMC_Close()

ssp_err_t R_SDMMC_Close ( sdmmc_ctrl_t *const  p_api_ctrl)

Closes an open SD/MMC device. Implements sdmmc_api_t::close().

Return values
SSP_SUCCESSSuccessful close.
SSP_ERR_ASSERTIONThe parameter p_ctrl is NULL.
SSP_ERR_NOT_OPENDriver has not been initialized.
Note
This function is reentrant for different channels. It is not reentrant for the same channel.

Disable SDHI interrupts.

Close the transfer driver.

Turn on module stop bit (turn module off).

Release hardware lock.

◆ R_SDMMC_Control()

ssp_err_t R_SDMMC_Control ( sdmmc_ctrl_t *const  p_api_ctrl,
ssp_command_t const  command,
void *  p_data 
)

Sends control commands to and receives the status of the SD/MMC device. Implements sdmmc_api_t::control().

Return values
SSP_SUCCESSCommand executed successfully.
SSP_ERR_ASSERTIONNull Pointer.
SSP_ERR_INVALID_ARGUMENTCommand is invalid.
SSP_ERR_INVALID_SIZEBlock size not in valid range of 1-512 for SDIO or 512 only for SD cards and eMMC.
Note
This function is reentrant for different channels. It is not reentrant for the same channel.

Get the command status and return to called function.

◆ R_SDMMC_Erase()

ssp_err_t R_SDMMC_Erase ( sdmmc_ctrl_t *const  p_api_ctrl,
uint32_t const  start_sector,
uint32_t const  sector_count 
)

Erases sectors of an SD card or eMMC device. Implements sdmmc_api_t::erase().

This function blocks until erase is complete.

Return values
SSP_SUCCESSErase operation requested.
SSP_ERR_ASSERTIONA required pointer is NULL.
SSP_ERR_NOT_OPENDriver has not been initialized.
SSP_ERR_CARD_NOT_READYCard was unplugged.
SSP_ERR_TRANSFER_BUSYDriver is busy with a previous operation.
SSP_ERR_WRITE_PROTECTEDSD card is Write Protected.
SSP_ERR_ERASE_FAILEDErase operation unsuccessful.
Note
This function is reentrant for different channels.

Send command to set start erase address (CMD35 for eMMC, CMD32 for SD).

Send command to set end erase address (CMD36 for eMMC, CMD33 for SD).

Send erase command (CMD38).

◆ R_SDMMC_InfoGet()

ssp_err_t R_SDMMC_InfoGet ( sdmmc_ctrl_t *const  p_api_ctrl,
sdmmc_info_t *const  p_info 
)

Provides information about the connected device and driver status. Implements sdmmc_api_t::infoGet().

Return values
SSP_SUCCESSFunction executed successfully.
SSP_ERR_ASSERTIONNull Pointer.
SSP_ERR_NOT_OPENDriver has not been initialized.
Note
This function is reentrant.

Copy information stored during open.

Check if the card is busy.

◆ R_SDMMC_IoIntEnable()

ssp_err_t R_SDMMC_IoIntEnable ( sdmmc_ctrl_t *const  p_api_ctrl,
bool  enable 
)

Enables or disables the SDIO Interrupt. Implements sdmmc_api_t::ioIntEnable().

Return values
SSP_SUCCESSCard enabled or disabled SDIO interrupts successfully.
SSP_ERR_ASSERTIONNULL pointer.
SSP_ERR_TRANSFER_BUSYDriver is busy with a previous operation.
Note
This function is reentrant for different channels.

Make sure the card is not busy.

Enable or disable interrupt.

◆ R_SDMMC_Open()

ssp_err_t R_SDMMC_Open ( sdmmc_ctrl_t *const  p_api_ctrl,
sdmmc_cfg_t const *const  p_cfg 
)

Initializes the SDHI hardware and completes identification and configuration for the SD or eMMC device. This procedure requires several sequential commands. This API blocks until all identification and configuration commands are complete.

For SDIO, SDIO interrupts are enabled after card identification is complete. SDIO interrupts can be disabled using sdmmc_api_t::ioIntEnable().

Implements sdmmc_api_t::open().

Return values
SSP_SUCCESSPort is available and is now open for read/write/control access.
SSP_ERR_ASSERTIONNull Pointer or block size is not in the valid range of 1-512.
SSP_ERR_INVALID_ARGUMENTBlock size must be 512 bytes for SD cards and eMMC devices. It is configurable for SDIO only.
SSP_ERR_ALREADY_OPENDriver has already been opened with this instance of the control structure.
SSP_ERR_HW_LOCKEDThe channel specified has already been opened.
SSP_ERR_CARD_INIT_FAILEDHardware related failure occurred, with the MCU or with the card itself.
SSP_ERR_IRQ_BSP_DISABLEDAccess interrupt is not enabled.
SSP_ERR_CARD_NOT_INSERTEDCard detection is enabled and no card is plugged in.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:
Note
This function is reentrant for different channels. It is not reentrant for the same channel.

Verify the requested hardware channel exists on the MCU.

Configure interrupts.

Acquire lock before changing vector table or p_ctrl.

Turn off module stop bit (turn module on).

Perform the identification procedure for SD card or eMMC device.

Configure bus clock, block size, and bus width.

Check to see if the card is write protected (SD cards only).

◆ R_SDMMC_Read()

ssp_err_t R_SDMMC_Read ( sdmmc_ctrl_t *const  p_api_ctrl,
uint8_t *const  p_dest,
uint32_t const  start_sector,
uint32_t const  sector_count 
)

Reads data from an SD or eMMC device. Up to 0x10000 sectors can be read at a time. Implements sdmmc_api_t::read().

This function blocks until the command is sent and the response is received. A callback with the event SDMMC_EVENT_TRANSFER_COMPLETE is called when the read data is available.

Return values
SSP_SUCCESSData read successfully.
SSP_ERR_ASSERTIONNULL pointer.
SSP_ERR_NOT_OPENDriver has not been initialized.
SSP_ERR_CARD_NOT_READYCard was unplugged.
SSP_ERR_TRANSFER_BUSYDriver is busy with a previous operation.
SSP_ERR_READ_FAILEDRead operation failed.
Note
This function is reentrant for different channels. It is not reentrant for the same channel.

Configure the transfer interface for reading.

Read data from SD or eMMC device.

◆ R_SDMMC_ReadIo()

ssp_err_t R_SDMMC_ReadIo ( sdmmc_ctrl_t *const  p_api_ctrl,
uint8_t *const  p_data,
uint32_t const  function,
uint32_t const  address 
)

The Read function reads a one byte register from an SDIO card. Implements sdmmc_api_t::readIo().

This function blocks until the command is sent and the response is received. p_data contains the register value read when this function returns.

Return values
SSP_SUCCESSData read successfully.
SSP_ERR_ASSERTIONNULL pointer.
SSP_ERR_NOT_OPENDriver has not been initialized.
SSP_ERR_CARD_NOT_READYCard was unplugged.
SSP_ERR_TRANSFER_BUSYDriver is busy with a previous operation.
SSP_ERR_READ_FAILEDRead operation failed.
Note
This function is reentrant for different channels. It is not reentrant for the same channel.

Call SDMMC protocol read function

◆ R_SDMMC_ReadIoExt()

ssp_err_t R_SDMMC_ReadIoExt ( sdmmc_ctrl_t *const  p_api_ctrl,
uint8_t *const  p_dest,
uint32_t const  function,
uint32_t const  address,
uint32_t *const  count,
sdmmc_io_transfer_mode_t  transfer_mode,
sdmmc_io_address_mode_t  address_mode 
)

Reads data from an SDIO card function. Implements sdmmc_api_t::readIoExt().

This function blocks until the command is sent and the response is received. A callback with the event SDMMC_EVENT_TRANSFER_COMPLETE is called when the read data is available.

Return values
SSP_SUCCESSData read successfully.
SSP_ERR_ASSERTIONNULL pointer, or count is not in the valid range of 1-512 for byte mode or 1-511 for block mode.
SSP_ERR_NOT_OPENDriver has not been initialized.
SSP_ERR_CARD_NOT_READYCard was unplugged.
SSP_ERR_TRANSFER_BUSYDriver is busy with a previous operation.
SSP_ERR_READ_FAILEDRead operation failed.
Note
This function is reentrant for different channels. It is not reentrant for the same channel.

Configure the transfer interface for reading.

Read data from SDIO device.

◆ R_SDMMC_VersionGet()

ssp_err_t R_SDMMC_VersionGet ( ssp_version_t *const  p_version)

Returns the version of the firmware and API. Implements sdmmc_api_t::versionGet().

Return values
SSP_SUCCESSFunction executed successfully.
SSP_ERR_ASSERTIONNull Pointer.
Note
This function is reentrant.

◆ R_SDMMC_Write()

ssp_err_t R_SDMMC_Write ( sdmmc_ctrl_t *const  p_api_ctrl,
uint8_t const *const  p_source,
uint32_t const  start_sector,
uint32_t const  sector_count 
)

Writes data to an SD or eMMC device. Up to 0x10000 sectors can be written at a time. Implements sdmmc_api_t::write().

This function blocks until the command is sent and the response is received. A callback with the event SDMMC_EVENT_TRANSFER_COMPLETE is called when the all data has been written.

Return values
SSP_SUCCESSCard write finished successfully.
SSP_ERR_ASSERTIONHandle or Source address is NULL.
SSP_ERR_NOT_OPENDriver has not been initialized.
SSP_ERR_CARD_NOT_READYCard was unplugged.
SSP_ERR_TRANSFER_BUSYDriver is busy with a previous operation.
SSP_ERR_WRITE_PROTECTEDSD card is Write Protected.
SSP_ERR_WRITE_FAILEDWrite operation failed.
Note
This function is reentrant for different channels.

Configure the transfer interface for writing.

Call SDMMC protocol write function

Write data to SD or eMMC device.

◆ R_SDMMC_WriteIo()

ssp_err_t R_SDMMC_WriteIo ( sdmmc_ctrl_t *const  p_api_ctrl,
uint8_t *const  p_data,
uint32_t const  function,
uint32_t const  address,
sdmmc_io_write_mode_t const  read_after_write 
)

Writes a one byte register to an SDIO card. Implements sdmmc_api_t::writeIo().

This function blocks until the command is sent and the response is received. The register has been written when this function returns. If read_after_write is true, p_data contains the register value read when this function returns.

Return values
SSP_SUCCESSCard write finished successfully.
SSP_ERR_ASSERTIONHandle or Source address is NULL.
SSP_ERR_NOT_OPENDriver has not been initialized.
SSP_ERR_CARD_NOT_READYCard was unplugged.
SSP_ERR_TRANSFER_BUSYDriver is busy with a previous operation.
SSP_ERR_WRITE_FAILEDWrite operation failed.
Note
This function is reentrant for different channels.

Call SDMMC protocol write function with valid parameters

◆ R_SDMMC_WriteIoExt()

ssp_err_t R_SDMMC_WriteIoExt ( sdmmc_ctrl_t *const  p_api_ctrl,
uint8_t const *const  p_source,
uint32_t const  function,
uint32_t const  address,
uint32_t const  count,
sdmmc_io_transfer_mode_t  transfer_mode,
sdmmc_io_address_mode_t  address_mode 
)

Writes data to an SDIO card function. Implements sdmmc_api_t::writeIoExt().

This function blocks until the command is sent and the response is received. A callback with the event SDMMC_EVENT_TRANSFER_COMPLETE is called when the all data has been written.

Return values
SSP_SUCCESSCard write finished successfully.
SSP_ERR_ASSERTIONNULL pointer, or count is not in the valid range of 1-512 for byte mode or 1-511 for block mode.
SSP_ERR_NOT_OPENDriver has not been initialized.
SSP_ERR_CARD_NOT_READYCard was unplugged.
SSP_ERR_TRANSFER_BUSYDriver is busy with a previous operation.
SSP_ERR_WRITE_FAILEDWrite operation failed.
Note
This function is reentrant for different channels.

Configure the transfer interface for writing.

Write data to SDIO device.