![]() |
RA Flexible Software Package Documentation
Release v5.8.0
|
|
Middleware to implement the block media interface on SPI flash memory. This module implements the Block Media Interface.
The SPI implementation of the block media interface has the following key features:
Configuration | Options | Default | Description |
---|---|---|---|
Parameter Checking |
| Default (BSP) | If selected, code for parameter checking is included in the build |
Configuration | Options | Default | Description |
---|---|---|---|
Module Instance Name | Name must be a valid C symbol | g_rm_block_media0 | Module name |
Block size (bytes) | Manual Entry | 4096 | Specify the size of a block in bytes. |
Block count | Minimum block count is 1, maximum is defined by hardware and software design. | 8192 | Number of blocks available for use by this driver instance. |
Base Address | Manual Entry | 0 | Base address offset (bytes) for instance memory region. |
Callback Function | Name must be a valid C symbol | NULL | A user callback function can be provided. If this callback is provided, it will be called after the completion of Read, Write, and Erase operations, or anytime these functions are waiting on hardware. |
This module has no required clock configurations.
This module does not use I/O pins.
Developers should be aware of the following limitations when using RM_BLOCK_MEDIA_SPI:
This is a basic example of minimal use of the SPI block media implementation in an application.
This is a basic example of using the optional SPI callback to impliment non-blocking operation.
fsp_err_t RM_BLOCK_MEDIA_SPI_Open | ( | rm_block_media_ctrl_t *const | p_ctrl, |
rm_block_media_cfg_t const *const | p_cfg | ||
) |
Parameter checking and Acquires mutex, then handles driver initialization at the HAL SPI layer and marking the open flag in control block.
Implements rm_block_media_api_t::open.
FSP_SUCCESS | Block media for SPI framework is successfully opened. |
FSP_ERR_ASSERTION | One of the input parameters or their data references may be null. |
FSP_ERR_ALREADY_OPEN | The channel specified has already been opened. See HAL driver for other possible causes. |
fsp_err_t RM_BLOCK_MEDIA_SPI_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.
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. |
fsp_err_t RM_BLOCK_MEDIA_SPI_MediaInit | ( | rm_block_media_ctrl_t *const | p_ctrl | ) |
Initializes the Block Media SPI Flash device.
Implements rm_block_media_api_t::mediaInit.
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. |
fsp_err_t RM_BLOCK_MEDIA_SPI_Read | ( | rm_block_media_ctrl_t *const | p_ctrl, |
uint8_t *const | p_dest, | ||
uint32_t const | start_block, | ||
uint32_t const | num_blocks | ||
) |
Reads a number of blocks from spi flash memory. By default, this is a function is blocking. Non-blocking operation may be achieved by yielding control within the optional callback function.
Implements rm_block_media_api_t::read.
FSP_SUCCESS | SPI data read successfully |
FSP_ERR_ASSERTION | p_ctrl or p_dest is NULL, or num_blocks is zero |
FSP_ERR_NOT_OPEN | Block Media SPI module is not yet open |
FSP_ERR_INVALID_ADDRESS | Invalid address range for read operation |
FSP_ERR_NOT_INITIALIZED | Block Media SPI module is not yet initialized |
fsp_err_t RM_BLOCK_MEDIA_SPI_StatusGet | ( | rm_block_media_ctrl_t *const | p_ctrl, |
rm_block_media_status_t *const | p_status | ||
) |
Provides driver status.
Implements rm_block_media_api_t::statusGet.
FSP_SUCCESS | Status stored in p_status. |
FSP_ERR_ASSERTION | NULL pointer. |
FSP_ERR_NOT_OPEN | Module is not open. |
fsp_err_t RM_BLOCK_MEDIA_SPI_Write | ( | rm_block_media_ctrl_t *const | p_ctrl, |
uint8_t const *const | p_src, | ||
uint32_t const | start_block, | ||
uint32_t const | num_blocks | ||
) |
Writes provided data to a number of blocks of spi flash memory. By default, this is a function is blocking. Non-blocking operation may be achieved by yielding control within the optional callback function.
Implements rm_block_media_api_t::write.
FSP_SUCCESS | Flash write finished successfully. |
FSP_ERR_ASSERTION | p_ctrl or p_src is NULL. Or num_blocks is zero. |
FSP_ERR_NOT_OPEN | Block media SPI Framework module is not yet initialized. |
FSP_ERR_INVALID_ADDRESS | Invalid address range |
FSP_ERR_NOT_INITIALIZED | Block Media SPI module is not yet initialized |
fsp_err_t RM_BLOCK_MEDIA_SPI_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. API not supported.
Implements rm_block_media_api_t::callbackSet.
FSP_ERR_UNSUPPORTED | API not supported by RM_BLOCK_MEDIA_SPI. |
fsp_err_t RM_BLOCK_MEDIA_SPI_Close | ( | rm_block_media_ctrl_t *const | p_ctrl | ) |
Closes the Block Media SPI device. Implements rm_block_media_api_t::close.
FSP_SUCCESS | Successful close. |
FSP_ERR_ASSERTION | One of the following parameters may be null: p_ctrl. |
FSP_ERR_NOT_OPEN | Block media SPI Framework module is not yet initialized. |
fsp_err_t RM_BLOCK_MEDIA_SPI_Erase | ( | rm_block_media_ctrl_t *const | p_ctrl, |
uint32_t const | start_block, | ||
uint32_t const | num_blocks | ||
) |
This function erases blocks of the SPI device. By default, this is a function is blocking. Non-blocking operation may be achieved by yielding control within the optional callback function.
Implements rm_block_media_api_t::erase.
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. |
FSP_ERR_INVALID_ADDRESS | Invalid address range |