RZ/A Flexible Software Package Documentation  Release v3.0.0

 
SD/MMC Block Media Implementation (rm_block_media_sdmmc)

Functions

fsp_err_t RM_BLOCK_MEDIA_SDMMC_Open (rm_block_media_ctrl_t *const p_ctrl, rm_block_media_cfg_t const *const p_cfg)
 
fsp_err_t RM_BLOCK_MEDIA_SDMMC_MediaInit (rm_block_media_ctrl_t *const p_ctrl)
 
fsp_err_t RM_BLOCK_MEDIA_SDMMC_Read (rm_block_media_ctrl_t *const p_ctrl, uint8_t *const p_dest_address, uint32_t const block_address, uint32_t const num_blocks)
 
fsp_err_t RM_BLOCK_MEDIA_SDMMC_Write (rm_block_media_ctrl_t *const p_ctrl, uint8_t const *const p_src_address, uint32_t const block_address, uint32_t const num_blocks)
 
fsp_err_t RM_BLOCK_MEDIA_SDMMC_Erase (rm_block_media_ctrl_t *const p_ctrl, uint32_t const block_address, uint32_t const num_blocks)
 
fsp_err_t RM_BLOCK_MEDIA_SDMMC_CallbackSet (rm_block_media_ctrl_t *const p_ctrl, void(*p_callback)(rm_block_media_callback_args_t *), void const *const p_context, rm_block_media_callback_args_t *const p_callback_memory)
 
fsp_err_t RM_BLOCK_MEDIA_SDMMC_StatusGet (rm_block_media_ctrl_t *const p_api_ctrl, rm_block_media_status_t *const p_status)
 
fsp_err_t RM_BLOCK_MEDIA_SDMMC_InfoGet (rm_block_media_ctrl_t *const p_ctrl, rm_block_media_info_t *const p_info)
 
fsp_err_t RM_BLOCK_MEDIA_SDMMC_Close (rm_block_media_ctrl_t *const p_ctrl)
 

Detailed Description

Middleware to implement the block media interface on SD cards. This module implements the Block Media Interface.

Overview

Features

The SD/MMC implementation of the block media interface has the following key features:

Configuration

Build Time Configurations for rm_block_media_sdmmc

The following build time configurations are defined in driver/rm_block_media_sdmmc_cfg.h:

ConfigurationOptionsDefaultDescription
Parameter Checking
  • Default (BSP)
  • Enabled
  • Disabled
Default (BSP) If selected code for parameter checking is included in the build.

Configurations for Storage > Block Media SD/MMC (rm_block_media_sdmmc)

This module can be added to the Stacks tab via New Stack > Storage > Block Media SD/MMC (rm_block_media_sdmmc). Non-secure callable guard functions can be generated for this module by right clicking the module in the RA Configuration tool and checking the "Non-secure Callable" box.

ConfigurationOptionsDefaultDescription
NameName must be a valid C symbolg_rm_block_media0 Module name.
CallbackName must be a valid C symbolNULL A user callback function can be provided. If this callback function is provided, it will be called when a card is inserted or removed.

Clock Configuration

This module has no required clock configurations.

Pin Configuration

This module does not use I/O pins.

Examples

Basic Example

This is a basic example of minimal use of the SD/MMC block media implementation in an application.

#define RM_BLOCK_MEDIA_SDMMC_BLOCK_SIZE (512)
uint8_t g_dest[RM_BLOCK_MEDIA_SDMMC_BLOCK_SIZE] BSP_ALIGN_VARIABLE(4);
uint8_t g_src[RM_BLOCK_MEDIA_SDMMC_BLOCK_SIZE] BSP_ALIGN_VARIABLE(4);
uint32_t g_transfer_complete = 0;
void rm_block_media_sdmmc_basic_example (void)
{
/* Initialize g_src to known data */
for (uint32_t i = 0; i < RM_BLOCK_MEDIA_SDMMC_BLOCK_SIZE; i++)
{
g_src[i] = (uint8_t) ('A' + (i % 26));
}
/* Open the RM_BLOCK_MEDIA_SDMMC driver. */
fsp_err_t err = RM_BLOCK_MEDIA_SDMMC_Open(&g_rm_block_media0_ctrl, &g_rm_block_media0_cfg);
/* Handle any errors. This function should be defined by the user. */
assert(FSP_SUCCESS == err);
/* A device shall be ready to accept the first command within 1ms from detecting VDD min. Reference section 6.4.1.1
* "Power Up Time of Card" in the SD Physical Layer Simplified Specification Version 6.00. */
/* Initialize the SD card. This should not be done until the card is plugged in for SD devices. */
err = RM_BLOCK_MEDIA_SDMMC_MediaInit(&g_rm_block_media0_ctrl);
assert(FSP_SUCCESS == err);
/* Write a block of data to sector 3 of an SD card. */
err = RM_BLOCK_MEDIA_SDMMC_Write(&g_rm_block_media0_ctrl, g_src, 3, 1);
assert(FSP_SUCCESS == err);
/* Read a block of data from sector 3 of an SD card. */
err = RM_BLOCK_MEDIA_SDMMC_Read(&g_rm_block_media0_ctrl, g_dest, 3, 1);
assert(FSP_SUCCESS == err);
}

Function Documentation

◆ RM_BLOCK_MEDIA_SDMMC_Open()

fsp_err_t RM_BLOCK_MEDIA_SDMMC_Open ( rm_block_media_ctrl_t *const  p_ctrl,
rm_block_media_cfg_t const *const  p_cfg 
)

Opens the module.

Implements rm_block_media_api_t::open().

Return values
FSP_SUCCESSModule is available and is now open.
FSP_ERR_ASSERTIONAn input parameter is invalid.
FSP_ERR_ALREADY_OPENModule has already been opened with this instance of the control structure.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

◆ RM_BLOCK_MEDIA_SDMMC_MediaInit()

fsp_err_t RM_BLOCK_MEDIA_SDMMC_MediaInit ( rm_block_media_ctrl_t *const  p_ctrl)

Initializes the SD device. This procedure requires several sequential commands. This function blocks until all identification and configuration commands are complete.

Implements rm_block_media_api_t::mediaInit().

Return values
FSP_SUCCESSModule is initialized and ready to access the memory device.
FSP_ERR_ASSERTIONAn input parameter is invalid.
FSP_ERR_NOT_OPENModule is not open.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

◆ RM_BLOCK_MEDIA_SDMMC_Read()

fsp_err_t RM_BLOCK_MEDIA_SDMMC_Read ( rm_block_media_ctrl_t *const  p_ctrl,
uint8_t *const  p_dest_address,
uint32_t const  block_address,
uint32_t const  num_blocks 
)

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

Return values
FSP_SUCCESSData read successfully.
FSP_ERR_ASSERTIONAn input parameter is invalid.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_NOT_INITIALIZEDModule has not been initialized.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

◆ RM_BLOCK_MEDIA_SDMMC_Write()

fsp_err_t RM_BLOCK_MEDIA_SDMMC_Write ( rm_block_media_ctrl_t *const  p_ctrl,
uint8_t const *const  p_src_address,
uint32_t const  block_address,
uint32_t const  num_blocks 
)

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

Return values
FSP_SUCCESSWrite finished successfully.
FSP_ERR_ASSERTIONAn input parameter is invalid.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_NOT_INITIALIZEDModule has not been initialized.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

◆ RM_BLOCK_MEDIA_SDMMC_Erase()

fsp_err_t RM_BLOCK_MEDIA_SDMMC_Erase ( rm_block_media_ctrl_t *const  p_ctrl,
uint32_t const  block_address,
uint32_t const  num_blocks 
)

Erases sectors of an SD card device. Implements rm_block_media_api_t::erase().

Return values
FSP_SUCCESSErase operation requested.
FSP_ERR_ASSERTIONAn input parameter is invalid.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_NOT_INITIALIZEDModule has not been initialized.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

◆ RM_BLOCK_MEDIA_SDMMC_CallbackSet()

fsp_err_t RM_BLOCK_MEDIA_SDMMC_CallbackSet ( rm_block_media_ctrl_t *const  p_ctrl,
void(*)(rm_block_media_callback_args_t *)  p_callback,
void const *const  p_context,
rm_block_media_callback_args_t *const  p_callback_memory 
)

Updates the user callback with the option to provide memory for the callback argument structure. Implements rm_block_media_api_t::callbackSet.

Return values
FSP_SUCCESSCallback updated successfully.
FSP_ERR_ASSERTIONA required pointer is NULL.
FSP_ERR_NOT_OPENThe control block has not been opened.
FSP_ERR_NO_CALLBACK_MEMORYp_callback is non-secure and p_callback_memory is either secure or NULL.

◆ RM_BLOCK_MEDIA_SDMMC_StatusGet()

fsp_err_t RM_BLOCK_MEDIA_SDMMC_StatusGet ( rm_block_media_ctrl_t *const  p_api_ctrl,
rm_block_media_status_t *const  p_status 
)

Provides driver status. Implements rm_block_media_api_t::statusGet().

Return values
FSP_SUCCESSStatus stored in p_status.
FSP_ERR_ASSERTIONNULL pointer.
FSP_ERR_NOT_OPENModule is not open.

◆ RM_BLOCK_MEDIA_SDMMC_InfoGet()

fsp_err_t RM_BLOCK_MEDIA_SDMMC_InfoGet ( rm_block_media_ctrl_t *const  p_ctrl,
rm_block_media_info_t *const  p_info 
)

Retrieves module information. Implements rm_block_media_api_t::infoGet().

Return values
FSP_SUCCESSErase operation requested.
FSP_ERR_ASSERTIONAn input parameter is invalid.
FSP_ERR_NOT_OPENModule is not open.
FSP_ERR_NOT_INITIALIZEDModule has not been initialized.

◆ RM_BLOCK_MEDIA_SDMMC_Close()

fsp_err_t RM_BLOCK_MEDIA_SDMMC_Close ( rm_block_media_ctrl_t *const  p_ctrl)

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

Return values
FSP_SUCCESSSuccessful close.
FSP_ERR_ASSERTIONAn input parameter is invalid.
FSP_ERR_NOT_OPENModule is not open.