![]() |
Synergy Software Package User's Manual
|
Driver for the Low power Flash Memory (S3A7 and S124). More...
Data Structures | |
| struct | flash_lp_instance_ctrl_t |
Functions | |
| ssp_err_t | R_FLASH_LP_Open (flash_ctrl_t *const p_api_ctrl, flash_cfg_t const *const p_cfg) |
| Initialize the Low Power flash peripheral. Implements flash_api_t::open. More... | |
| ssp_err_t | R_FLASH_LP_Write (flash_ctrl_t *const p_api_ctrl, uint32_t const src_address, uint32_t flash_address, uint32_t const num_bytes) |
| Write to the specified Code or Data Flash memory area. Implements flash_api_t::write. More... | |
| ssp_err_t | R_FLASH_LP_Read (flash_ctrl_t *const p_api_ctrl, uint8_t *p_dest_address, uint32_t const flash_address, uint32_t const num_bytes) |
| Read the requested number of bytes from the supplied Data or Code Flash address. Implements flash_api_t::read. More... | |
| ssp_err_t | R_FLASH_LP_Erase (flash_ctrl_t *const p_api_ctrl, uint32_t const address, uint32_t const num_blocks) |
| Erase the specified Code or Data Flash blocks. Implements flash_api_t::erase. More... | |
| ssp_err_t | R_FLASH_LP_BlankCheck (flash_ctrl_t *const p_api_ctrl, uint32_t const address, uint32_t num_bytes, flash_result_t *p_blank_check_result) |
| Perform a blank check on the specified address area. Implements flash_api_t::blankCheck. More... | |
| ssp_err_t | R_FLASH_LP_StatusGet (flash_ctrl_t *const p_api_ctrl) |
| Query the FLASH for its status. Implements flash_api_t::statusGet. More... | |
| ssp_err_t | R_FLASH_LP_AccessWindowSet (flash_ctrl_t *const p_api_ctrl, uint32_t const start_addr, uint32_t const end_addr) |
| Configure an access window for the Code Flash memory. Implements flash_api_t::accessWindowSet. More... | |
| ssp_err_t | R_FLASH_LP_AccessWindowClear (flash_ctrl_t *const p_api_ctrl) |
| Remove any access window that is configured in the Code Flash. Implements flash_api_t::accessWindowClear. On successful return from this call all Code Flash is writable. More... | |
| ssp_err_t | R_FLASH_LP_IdCodeSet (flash_ctrl_t *const p_api_ctrl, uint8_t const *const p_id_code, flash_id_code_mode_t mode) |
| Write the ID code provided to the id code registers. Implements flash_api_t::idCodeSet. More... | |
| ssp_err_t | R_FLASH_LP_Reset (flash_ctrl_t *const p_api_ctrl) |
| Reset the FLASH peripheral. Implements flash_api_t::reset. More... | |
| ssp_err_t | R_FLASH_LP_StartUpAreaSelect (flash_ctrl_t *const p_api_ctrl, flash_startup_area_swap_t swap_type, bool is_temporary) |
| Select which block is used as the startup area block. Implements flash_api_t::startupAreaSelect. More... | |
| ssp_err_t | R_FLASH_LP_UpdateFlashClockFreq (flash_ctrl_t *const p_api_ctrl) |
| Indicate to the already open Flash API that the FCLK has changed. Implements r_flash_t::updateFlashClockFreq. More... | |
| ssp_err_t | R_FLASH_LP_InfoGet (flash_ctrl_t *const p_api_ctrl, flash_info_t *const p_info) |
| Returns the information about the flash regions. Implements flash_api_t::infoGet. More... | |
| ssp_err_t | R_FLASH_LP_Close (flash_ctrl_t *const p_api_ctrl) |
| Release any resources that were allocated by the Flash API. Implements flash_api_t::close. More... | |
| ssp_err_t | R_FLASH_LP_VersionGet (ssp_version_t *const p_version) |
| Get FLASH HAL driver version. More... | |
Driver for the Low power Flash Memory (S3A7 and S124).
This module supports the Flash interface for the Low-power FLASH peripheral.
| ssp_err_t R_FLASH_LP_AccessWindowClear | ( | flash_ctrl_t *const | p_api_ctrl | ) |
Remove any access window that is configured in the Code Flash. Implements flash_api_t::accessWindowClear. On successful return from this call all Code Flash is writable.
| SSP_SUCCESS | Access window successfully removed. |
| SSP_ERR_IN_USE | FLASH peripheral is busy with a prior operation. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl. |
| SSP_ERR_INVALID_ARGUMENT | Code Flash Programming is not enabled. |
| SSP_ERR_NOT_OPEN | Flash API has not yet been opened. |
< Return error if Code Flash not enabled
| ssp_err_t R_FLASH_LP_AccessWindowSet | ( | flash_ctrl_t *const | p_api_ctrl, |
| uint32_t const | start_addr, | ||
| uint32_t const | end_addr | ||
| ) |
Configure an access window for the Code Flash memory. Implements flash_api_t::accessWindowSet.
An access window defines a contiguous area in Code Flash for which programming/erase is enabled. This area is on block boundaries. The block containing start_addr is the first block. The block containing end_addr is the last block. The access window then becomes first block –> last block inclusive. Anything outside this range of Code Flash is then write protected. As an example, if you wanted to place an accesswindow on Code Flash Blocks 0 and 1, such that only those two blocks were writable, you would need to specify (address in block 0, address in block 2) as the respective start and end address.
The invalid address and programming boundaries supported and enforced by this function are dependent on the MCU in use as well as the part package size. Please see the User manual and/or requirements document for additional information.
| SSP_SUCCESS | Access window successfully configured. |
| SSP_ERR_INVALID_ADDRESS | Invalid settings for start_addr and/or end_addr. |
| SSP_ERR_IN_USE | FLASH peripheral is busy with a prior operation. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl. |
| SSP_ERR_INVALID_ARGUMENT | Code Flash Programming is not enabled. |
| SSP_ERR_NOT_OPEN | Flash API has not yet been opened. |
If not code flash return error.
| ssp_err_t R_FLASH_LP_BlankCheck | ( | flash_ctrl_t *const | p_api_ctrl, |
| uint32_t const | address, | ||
| uint32_t | num_bytes, | ||
| flash_result_t * | p_blank_check_result | ||
| ) |
Perform a blank check on the specified address area. Implements flash_api_t::blankCheck.
The minimum/maximum number of bytes, as well as the invalid address and programming boundaries supported and enforced by this function are dependent on the MCU in use as well as the part package size. Please see the User manual and/or requirements document for additional information. The number of bytes for Data Flash blank checking must be between (1 and FLASH_DATA_BLANK_CHECK_MAX). The number of bytes for Code Flash blank checking must be between (1 and FLASH_CODE_BLANK_CHECK_MAX).
| SSP_SUCCESS | Blankcheck operation completed with result in p_blank_check_result, or blankcheck started and in-progess (BGO mode). |
| SSP_ERR_INVALID_ADDRESS | Invalid data flash address was input |
| SSP_ERR_INVALID_SIZE | 'num_bytes' was either too large or not aligned for the CF/DF boundary size. |
| SSP_ERR_IN_USE | Flash is busy with an on-going operation. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl |
| SSP_ERR_NOT_OPEN | Flash API has not yet been opened. |
| SSP_ERR_INVALID_ARGUMENT | Code Flash Programming is not enabled and a request to Blank Check CF was requested. |
Get the block information for this address. If failure return error.
Update Flash state and enter the respective Code or Data Flash P/E mode, may return SSP_ERR_IN_USE
Initiate the Blank Check operation
If failure reset the flash.
If the current operation is not a BGO blank check release the flash.
| ssp_err_t R_FLASH_LP_Close | ( | flash_ctrl_t *const | p_api_ctrl | ) |
Release any resources that were allocated by the Flash API. Implements flash_api_t::close.
| SSP_SUCCESS | Successful close. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl or p_cfg. |
Unlock the flash hardware.
Disable the flash interrupt.
Mark the control block as closed.
Release the lock
| ssp_err_t R_FLASH_LP_Erase | ( | flash_ctrl_t *const | p_api_ctrl, |
| uint32_t const | address, | ||
| uint32_t const | num_blocks | ||
| ) |
Erase the specified Code or Data Flash blocks. Implements flash_api_t::erase.
The minimum/maximum number of blocks, as well as the invalid address and programming boundaries supported and enforced by this function are dependent on the MCU in use as well as the part package size. Please see the User manual and/or requirements document for additional information.
| SSP_SUCCESS | Successful open. |
| SSP_ERR_INVALID_BLOCKS | Invalid number of blocks specified |
| SSP_ERR_INVALID_ADDRESS | Invalid address specified |
| SSP_ERR_IN_USE | Other flash operation in progress, or API not initialized |
| SSP_ERR_CMD_LOCKED | FCU is in locked state, typically as a result of attempting to Erase an area that is protected by an Access Window. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl |
| SSP_ERR_NOT_OPEN | The Flash API is not Open. |
| SSP_ERR_INVALID_ARGUMENT | Code Flash Programming is not enabled and a request to erase CF was requested. |
Get the block information for this address. If failure return error.
Update Flash state and enter the respective Code or Data Flash P/E mode, may return SSP_ERR_IN_USE
If successful
Configure the current parameters based on if the operation is for code flash or data flash.
If this is a request to erase Data Flash configure BGO mode if it is enabled.
Initiate the flash erase.
If in non-BGO mode, the current operation is complete. Exit PE mode and return status
Complete the flash operation.
| ssp_err_t R_FLASH_LP_IdCodeSet | ( | flash_ctrl_t *const | p_api_ctrl, |
| uint8_t const *const | p_id_code, | ||
| flash_id_code_mode_t | mode | ||
| ) |
Write the ID code provided to the id code registers. Implements flash_api_t::idCodeSet.
| SSP_SUCCESS | ID code successfully configured. |
| SSP_ERR_IN_USE | FLASH peripheral is busy with a prior operation. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl. |
| SSP_ERR_INVALID_ARGUMENT | Code Flash Programming is not enabled. |
| SSP_ERR_NOT_OPEN | Flash API has not yet been opened. |
| SSP_ERR_WRITE_FAILED | Status is indicating a Programming error for the requested operation. |
| SSP_ERR_TIMEOUT | Timed out waiting for completion of extra command. |
Return status.
| ssp_err_t R_FLASH_LP_InfoGet | ( | flash_ctrl_t *const | p_api_ctrl, |
| flash_info_t *const | p_info | ||
| ) |
Returns the information about the flash regions. Implements flash_api_t::infoGet.
| SSP_SUCCESS | Successful retrieved the request information. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl or p_info. |
Copy the region data to the info structure.
| ssp_err_t R_FLASH_LP_Open | ( | flash_ctrl_t *const | p_api_ctrl, |
| flash_cfg_t const *const | p_cfg | ||
| ) |
Initialize the Low Power flash peripheral. Implements flash_api_t::open.
The Open function initializes the Flash. It first copies the FCU firmware to FCURAM and sets the FCU Clock based on the current FCLK frequency. In addition, if Code Flash programming is enabled, the API code responsible for Code Flash programming will be copied to RAM.
This function must be called once prior to calling any other FLASH API functions. If a user supplied callback function is supplied, then the Flash Ready interrupt will be configured to call the users callback routine with an Event type describing the source of the interrupt for Data Flash operations. Subsequent to successfully completing this call p_ctrl->opened will be true.
Subsequent to a successful Open(), the Flash is ready to process additional Flash commands.
| SSP_SUCCESS | Initialization was successful and timer has started. |
| SSP_FLASH_ERR_FAILURE | Failed to successfully enter Programming/Erase mode. |
| SSP_ERR_TIMEOUT | Timed out waiting for FCU to be ready. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl or p_cfg or problem getting FMI info. |
| SSP_ERR_IRQ_BSP_DISABLED | Caller is requesting BGO but the Flash interrupts are not enabled. |
| SSP_ERR_FCLK | FCLK must be a minimum of 1 MHz for Flash operations. |
| SSP_ERR_IN_USE | Flash Open() has already been called. |
| SSP_ERR_HW_LOCKED | Flash module unable to get the Hardware lock for the Flash LP Periperhal. |
If null pointers return error.
If open return error.
Setup flash FMI. If failure return error.
Allow Initialization if not initialized or if no operation is ongoing and re-initialization is desired
Acquire the software lock. If failure return error.
Set the parameters struct based on the user supplied settings
Setup the Flash interrupt callback based on the caller's info. If the Flash interrupt is not enabled in the BSP then this will return SSP_ERR_IRQ_BSP_DISABLED
Make sure Flash interrupts are disabled, they are only used in BGO mode
Setup the flash.
Save callback function pointer
| ssp_err_t R_FLASH_LP_Read | ( | flash_ctrl_t *const | p_api_ctrl, |
| uint8_t * | p_dest_address, | ||
| uint32_t const | flash_address, | ||
| uint32_t const | num_bytes | ||
| ) |
Read the requested number of bytes from the supplied Data or Code Flash address. Implements flash_api_t::read.
The minimum/maximum number of blocks, as well as the invalid address and programming boundaries supported and enforced by this function are dependent on the MCU in use as well as the part package size. Please see the User manual and/or requirements document for additional information.
| SSP_SUCCESS | Operation successful. |
| SSP_ERR_INVALID_ADDRESS | Invalid Flash address was supplied. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl or p_dest_address |
| SSP_ERR_NOT_OPEN | Flash API has not yet been opened. |
Copy the data to the destination buffer.
| ssp_err_t R_FLASH_LP_Reset | ( | flash_ctrl_t *const | p_api_ctrl | ) |
Reset the FLASH peripheral. Implements flash_api_t::reset.
No attempt is made to grab the Flash software lock before executing the reset since the assumption is that a reset will terminate any existing operation.
| SSP_SUCCESS | Flash circuit successfully reset. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl |
| SSP_ERR_NOT_OPEN | Flash API has not yet been opened. |
Reset the flash.
Release the flash.
| ssp_err_t R_FLASH_LP_StartUpAreaSelect | ( | flash_ctrl_t *const | p_api_ctrl, |
| flash_startup_area_swap_t | swap_type, | ||
| bool | is_temporary | ||
| ) |
Select which block is used as the startup area block. Implements flash_api_t::startupAreaSelect.
Selects which block - Default (Block 0) or Alternate (Block 1) is used as the startup area block. The provided parameters determine which block will become the active startup block and whether that action will be immediate (but temporary), or permanent subsequent to the next reset. Doing a temporary switch might appear to have limited usefulness. If there is an access window in place such that Block 0 is write protected, then one could do a temporary switch, update the block and switch them back without having to touch the access window.
| SSP_SUCCESS | Start-up area successfully toggled. |
| SSP_ERR_IN_USE | Flash is busy with an on-going operation. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl |
| SSP_ERR_NOT_OPEN | Flash API has not yet been opened. |
If the swap type is BTFLG and the operation is temporary there's nothing to do. Return success.
Update Flash state and enter the respective Code or Data Flash P/E mode.
If successful call the temporary or boot startup area set functions depending on the users flag.
If successful return to read mode otherwise reset the flash.
Release the flash.
| ssp_err_t R_FLASH_LP_StatusGet | ( | flash_ctrl_t *const | p_api_ctrl | ) |
Query the FLASH for its status. Implements flash_api_t::statusGet.
| SSP_SUCCESS | Flash is ready and available to accept commands. |
| SSP_ERR_IN_USE | Flash is busy with an on-going operation. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl |
| SSP_ERR_NOT_OPEN | Flash API has not yet been opened. |
Return flash status
| ssp_err_t R_FLASH_LP_UpdateFlashClockFreq | ( | flash_ctrl_t *const | p_api_ctrl | ) |
Indicate to the already open Flash API that the FCLK has changed. Implements r_flash_t::updateFlashClockFreq.
This could be the case if the application has changed the system clock, and therefore the FCLK. Failure to call this function subsequent to changing the FCLK could result in damage to the flash macro. This function uses R_CGC_SystemClockFreqGet() to get the current FCLK frequency.
| SSP_SUCCESS | Start-up area successfully toggled. |
| SSP_ERR_IN_USE | Flash is busy with an on-going operation. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl |
| SSP_ERR_NOT_OPEN | Flash API has not yet been opened. |
Lock the flash state. If failure return error.
Setup the Flash.
Release the flash.
| ssp_err_t R_FLASH_LP_VersionGet | ( | ssp_version_t *const | p_version | ) |
Get FLASH HAL driver version.
| SSP_SUCCESS | - operation performed successfully |
Return the version id of the flash lp module.
| ssp_err_t R_FLASH_LP_Write | ( | flash_ctrl_t *const | p_api_ctrl, |
| uint32_t const | src_address, | ||
| uint32_t | flash_address, | ||
| uint32_t const | num_bytes | ||
| ) |
Write to the specified Code or Data Flash memory area. Implements flash_api_t::write.
The minimum/maximum number of bytes, as well as the invalid address and programming boundaries supported and enforced by this function are dependent on the MCU in use as well as the part package size. Please see the User manual and/or requirements document for additional information.
| SSP_SUCCESS | Operation successful. If BGO is enabled this means the operation was started successfully. |
| SSP_ERR_IN_USE | The Flash peripheral is busy with a prior on-going transaction. |
| SSP_ERR_NOT_OPEN | The Flash API is not Open. |
| SSP_ERR_CMD_LOCKED | FCU is in locked state, typically as a result of attempting to Write an area that is protected by an Access Window. |
| SSP_ERR_WRITE_FAILED | Status is indicating a Programming error for the requested operation. This may be returned if the requested Flash area is not blank. |
| SSP_ERR_TIMEOUT | Timed out waiting for FCU operation to complete. |
| SSP_ERR_INVALID_SIZE | Number of bytes provided was not a multiple of the programming size or exceeded the maximum range. |
| SSP_ERR_INVALID_ADDRESS | Invalid address was input or address not on programming boundary. |
| SSP_ERR_ASSERTION | NULL provided for p_ctrl. |
| SSP_ERR_INVALID_ARGUMENT | Code Flash Programming is not enabled and a request to write CF was requested. |
Get the block information for this address. If failure return error.
Initiate the write operation.
Return status.