|
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) |
|
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:
- Reading, writing, and erasing data from an SD card
- Callback called when card insertion or removal is detected
- Provides media information such as sector size and total number of sectors.
Configuration
Build Time Configurations for rm_block_media_sdmmc
The following build time configurations are defined in driver/rm_block_media_sdmmc_cfg.h:
Configuration | Options | Default | Description |
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.
Configuration | Options | Default | Description |
Name | Name must be a valid C symbol | g_rm_block_media0 | Module name. |
Callback | Name must be a valid C symbol | NULL | 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)
{
for (uint32_t i = 0; i < RM_BLOCK_MEDIA_SDMMC_BLOCK_SIZE; i++)
{
g_src[i] = (uint8_t) ('A' + (i % 26));
}
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
assert(FSP_SUCCESS == err);
}
◆ RM_BLOCK_MEDIA_SDMMC_Open()
Opens the module.
Implements rm_block_media_api_t::open().
- Return values
-
FSP_SUCCESS | Module is available and is now open. |
FSP_ERR_ASSERTION | An input parameter is invalid. |
FSP_ERR_ALREADY_OPEN | Module 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()
Initializes the SD or eMMC 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_SUCCESS | Module is initialized and ready to access the memory device. |
FSP_ERR_ASSERTION | An input parameter is invalid. |
FSP_ERR_NOT_OPEN | Module 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 or eMMC device. Up to 0x10000 sectors can be read at a time. Implements rm_block_media_api_t::read().
- Return values
-
FSP_SUCCESS | Data read successfully. |
FSP_ERR_ASSERTION | An input parameter is invalid. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_NOT_INITIALIZED | Module 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 or eMMC device. Up to 0x10000 sectors can be written at a time. Implements rm_block_media_api_t::write().
- Return values
-
FSP_SUCCESS | Write finished successfully. |
FSP_ERR_ASSERTION | An input parameter is invalid. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_NOT_INITIALIZED | Module 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()
Erases sectors of an SD card or eMMC device. Implements rm_block_media_api_t::erase().
- Return values
-
FSP_SUCCESS | Erase operation requested. |
FSP_ERR_ASSERTION | An input parameter is invalid. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_NOT_INITIALIZED | Module 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()
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_SUCCESS | Callback updated successfully. |
FSP_ERR_ASSERTION | A required pointer is NULL. |
FSP_ERR_NOT_OPEN | The control block has not been opened. |
FSP_ERR_NO_CALLBACK_MEMORY | p_callback is non-secure and p_callback_memory is either secure or NULL. |
◆ RM_BLOCK_MEDIA_SDMMC_StatusGet()
Provides driver status. Implements rm_block_media_api_t::statusGet().
- Return values
-
FSP_SUCCESS | Status stored in p_status. |
FSP_ERR_ASSERTION | NULL pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
◆ RM_BLOCK_MEDIA_SDMMC_InfoGet()
Retrieves module information. Implements rm_block_media_api_t::infoGet().
- Return values
-
FSP_SUCCESS | Erase operation requested. |
FSP_ERR_ASSERTION | An input parameter is invalid. |
FSP_ERR_NOT_OPEN | Module is not open. |
FSP_ERR_NOT_INITIALIZED | Module has not been initialized. |
◆ RM_BLOCK_MEDIA_SDMMC_Close()
Closes an open SD/MMC device. Implements rm_block_media_api_t::close().
- Return values
-
FSP_SUCCESS | Successful close. |
FSP_ERR_ASSERTION | An input parameter is invalid. |
FSP_ERR_NOT_OPEN | Module is not open. |