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...
 

Detailed Description

Driver for the Low power Flash Memory (S3A7 and S124).

This module supports the Flash interface for the Low-power FLASH peripheral.

Function Documentation

◆ R_FLASH_LP_AccessWindowClear()

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.

Return values
SSP_SUCCESSAccess window successfully removed.
SSP_ERR_IN_USEFLASH peripheral is busy with a prior operation.
SSP_ERR_ASSERTIONNULL provided for p_ctrl.
SSP_ERR_INVALID_ARGUMENTCode Flash Programming is not enabled.
SSP_ERR_NOT_OPENFlash API has not yet been opened.

< Return error if Code Flash not enabled

◆ R_FLASH_LP_AccessWindowSet()

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.

Note
If the start address and end address are set to the same value, then the access window is effectively removed. This accomplishes the same functionality as R_FLASH_LP_AccessWindowClear().

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.

Return values
SSP_SUCCESSAccess window successfully configured.
SSP_ERR_INVALID_ADDRESSInvalid settings for start_addr and/or end_addr.
SSP_ERR_IN_USEFLASH peripheral is busy with a prior operation.
SSP_ERR_ASSERTIONNULL provided for p_ctrl.
SSP_ERR_INVALID_ARGUMENTCode Flash Programming is not enabled.
SSP_ERR_NOT_OPENFlash API has not yet been opened.

If not code flash return error.

◆ R_FLASH_LP_BlankCheck()

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).

Return values
SSP_SUCCESSBlankcheck operation completed with result in p_blank_check_result, or blankcheck started and in-progess (BGO mode).
SSP_ERR_INVALID_ADDRESSInvalid 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_USEFlash is busy with an on-going operation.
SSP_ERR_ASSERTIONNULL provided for p_ctrl
SSP_ERR_NOT_OPENFlash API has not yet been opened.
SSP_ERR_INVALID_ARGUMENTCode 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.

◆ R_FLASH_LP_Close()

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.

Return values
SSP_SUCCESSSuccessful close.
SSP_ERR_ASSERTIONNULL provided for p_ctrl or p_cfg.

Unlock the flash hardware.

Disable the flash interrupt.

Mark the control block as closed.

Release the lock

◆ R_FLASH_LP_Erase()

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.

Return values
SSP_SUCCESSSuccessful open.
SSP_ERR_INVALID_BLOCKSInvalid number of blocks specified
SSP_ERR_INVALID_ADDRESSInvalid address specified
SSP_ERR_IN_USEOther flash operation in progress, or API not initialized
SSP_ERR_CMD_LOCKEDFCU is in locked state, typically as a result of attempting to Erase an area that is protected by an Access Window.
SSP_ERR_ASSERTIONNULL provided for p_ctrl
SSP_ERR_NOT_OPENThe Flash API is not Open.
SSP_ERR_INVALID_ARGUMENTCode 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.

◆ R_FLASH_LP_IdCodeSet()

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.

Return values
SSP_SUCCESSID code successfully configured.
SSP_ERR_IN_USEFLASH peripheral is busy with a prior operation.
SSP_ERR_ASSERTIONNULL provided for p_ctrl.
SSP_ERR_INVALID_ARGUMENTCode Flash Programming is not enabled.
SSP_ERR_NOT_OPENFlash API has not yet been opened.
SSP_ERR_WRITE_FAILEDStatus is indicating a Programming error for the requested operation.
SSP_ERR_TIMEOUTTimed out waiting for completion of extra command.

Return status.

◆ R_FLASH_LP_InfoGet()

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.

Return values
SSP_SUCCESSSuccessful retrieved the request information.
SSP_ERR_ASSERTIONNULL provided for p_ctrl or p_info.

Copy the region data to the info structure.

◆ R_FLASH_LP_Open()

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.

Note
Providing a callback function in the supplied p_cfg->callback field, automatically configures the Flash for Data Flash to operate in non-blocking (BGO) mode.

Subsequent to a successful Open(), the Flash is ready to process additional Flash commands.

Return values
SSP_SUCCESSInitialization was successful and timer has started.
SSP_FLASH_ERR_FAILUREFailed to successfully enter Programming/Erase mode.
SSP_ERR_TIMEOUTTimed out waiting for FCU to be ready.
SSP_ERR_ASSERTIONNULL provided for p_ctrl or p_cfg or problem getting FMI info.
SSP_ERR_IRQ_BSP_DISABLEDCaller is requesting BGO but the Flash interrupts are not enabled.
SSP_ERR_FCLKFCLK must be a minimum of 1 MHz for Flash operations.
SSP_ERR_IN_USEFlash Open() has already been called.
SSP_ERR_HW_LOCKEDFlash module unable to get the Hardware lock for the Flash LP Periperhal.
Returns
See Common Error Codes or functions called by this function for other possible return codes. This function calls:

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

◆ R_FLASH_LP_Read()

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.

Note
This function is provided simply for the purposes of maintaining a complete interface. It is possible (and recommended), to read Flash memory directly.
Return values
SSP_SUCCESSOperation successful.
SSP_ERR_INVALID_ADDRESSInvalid Flash address was supplied.
SSP_ERR_ASSERTIONNULL provided for p_ctrl or p_dest_address
SSP_ERR_NOT_OPENFlash API has not yet been opened.

Copy the data to the destination buffer.

◆ R_FLASH_LP_Reset()

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.

Return values
SSP_SUCCESSFlash circuit successfully reset.
SSP_ERR_ASSERTIONNULL provided for p_ctrl
SSP_ERR_NOT_OPENFlash API has not yet been opened.

Reset the flash.

Release the flash.

◆ R_FLASH_LP_StartUpAreaSelect()

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.

Return values
SSP_SUCCESSStart-up area successfully toggled.
SSP_ERR_IN_USEFlash is busy with an on-going operation.
SSP_ERR_ASSERTIONNULL provided for p_ctrl
SSP_ERR_NOT_OPENFlash 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.

◆ R_FLASH_LP_StatusGet()

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.

Return values
SSP_SUCCESSFlash is ready and available to accept commands.
SSP_ERR_IN_USEFlash is busy with an on-going operation.
SSP_ERR_ASSERTIONNULL provided for p_ctrl
SSP_ERR_NOT_OPENFlash API has not yet been opened.

Return flash status

◆ R_FLASH_LP_UpdateFlashClockFreq()

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.

Return values
SSP_SUCCESSStart-up area successfully toggled.
SSP_ERR_IN_USEFlash is busy with an on-going operation.
SSP_ERR_ASSERTIONNULL provided for p_ctrl
SSP_ERR_NOT_OPENFlash API has not yet been opened.

Lock the flash state. If failure return error.

Setup the Flash.

Release the flash.

◆ R_FLASH_LP_VersionGet()

ssp_err_t R_FLASH_LP_VersionGet ( ssp_version_t *const  p_version)

Get FLASH HAL driver version.

Return values
SSP_SUCCESS- operation performed successfully
Note
This function is reentrant.

Return the version id of the flash lp module.

◆ R_FLASH_LP_Write()

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.

Return values
SSP_SUCCESSOperation successful. If BGO is enabled this means the operation was started successfully.
SSP_ERR_IN_USEThe Flash peripheral is busy with a prior on-going transaction.
SSP_ERR_NOT_OPENThe Flash API is not Open.
SSP_ERR_CMD_LOCKEDFCU is in locked state, typically as a result of attempting to Write an area that is protected by an Access Window.
SSP_ERR_WRITE_FAILEDStatus is indicating a Programming error for the requested operation. This may be returned if the requested Flash area is not blank.
SSP_ERR_TIMEOUTTimed out waiting for FCU operation to complete.
SSP_ERR_INVALID_SIZENumber of bytes provided was not a multiple of the programming size or exceeded the maximum range.
SSP_ERR_INVALID_ADDRESSInvalid address was input or address not on programming boundary.
SSP_ERR_ASSERTIONNULL provided for p_ctrl.
SSP_ERR_INVALID_ARGUMENTCode 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.