Synergy Software Package User's Manual

Driver for the High-performance Flash Memory (S7G2 and S5D9). More...

Data Structures

struct  flash_hp_instance_ctrl_t
 

Functions

ssp_err_t R_FLASH_HP_Open (flash_ctrl_t *const p_api_ctrl, flash_cfg_t const *const p_cfg)
 Initializes the flash peripheral. Implements flash_api_t::open. More...
 
ssp_err_t R_FLASH_HP_Write (flash_ctrl_t *const p_api_ctrl, uint32_t const src_address, uint32_t flash_address, uint32_t const num_bytes)
 Writes to the specified Code or Data Flash memory area. Implements flash_api_t::write. More...
 
ssp_err_t R_FLASH_HP_Read (flash_ctrl_t *const p_api_ctrl, uint8_t *p_dest_address, uint32_t const flash_address, uint32_t const num_bytes)
 Reads the requested number of bytes from the supplied Data or Code Flash memory address. Implements flash_api_t::read. More...
 
ssp_err_t R_FLASH_HP_Erase (flash_ctrl_t *const p_api_ctrl, uint32_t const address, uint32_t const num_blocks)
 Erases the specified Code or Data Flash blocks. Implements flash_api_t::erase by the block_erase_address. More...
 
ssp_err_t R_FLASH_HP_BlankCheck (flash_ctrl_t *const p_api_ctrl, uint32_t const address, uint32_t num_bytes, flash_result_t *p_blank_check_result)
 Performs a blank check on the specified address area. Implements flash_api_t::blankCheck. More...
 
ssp_err_t R_FLASH_HP_StatusGet (flash_ctrl_t *const p_api_ctrl)
 Query the FLASH peripheral for its status. Implements flash_api_t::statusGet. More...
 
ssp_err_t R_FLASH_HP_IdCodeSet (flash_ctrl_t *const p_api_ctrl, uint8_t const *const p_id_code, flash_id_code_mode_t mode)
 Implements flash_api_t::idCodeSet. More...
 
ssp_err_t R_FLASH_HP_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 using the provided start and end address. 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. More...
 
ssp_err_t R_FLASH_HP_AccessWindowClear (flash_ctrl_t *const p_api_ctrl)
 Remove any access window that is currently configured in the Code Flash. Subsequent to this call all Code Flash is writable. Implements flash_api_t::accessWindowClear. More...
 
ssp_err_t R_FLASH_HP_Reset (flash_ctrl_t *const p_api_ctrl)
 Resets 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. More...
 
ssp_err_t R_FLASH_HP_StartUpAreaSelect (flash_ctrl_t *const p_api_ctrl, flash_startup_area_swap_t swap_type, bool is_temporary)
 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. Implements flash_api_t::startupAreaSelect. More...
 
ssp_err_t R_FLASH_HP_UpdateFlashClockFreq (flash_ctrl_t *const p_api_ctrl)
 Indicate to the already open Flash API, that the FCLK has changed since the Open(). 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. Implements flash_api_t::updateFlashClockFreq. More...
 
ssp_err_t R_FLASH_HP_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_HP_Close (flash_ctrl_t *const p_api_ctrl)
 Releases any resources that were allocated by the Open() or any subsequent Flash operations. Implements flash_api_t::close. More...
 
ssp_err_t R_FLASH_HP_VersionGet (ssp_version_t *const p_version)
 This function gets FLASH HAL driver version. More...
 

Detailed Description

Driver for the High-performance Flash Memory (S7G2 and S5D9).

This module supports the Flash interface for the High Performance FLASH peripheral.

Function Documentation

◆ R_FLASH_HP_AccessWindowClear()

ssp_err_t R_FLASH_HP_AccessWindowClear ( flash_ctrl_t *const  p_api_ctrl)

Remove any access window that is currently configured in the Code Flash. Subsequent to this call all Code Flash is writable. Implements flash_api_t::accessWindowClear.

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.
SSP_ERR_INVALID_HW_CONDITIONThe configuration area cannot be written while DTC/DMAC, EDMAC, LCDC/2DG/JPEG are enabled. This is to prevent prohibited memory accesses while the flash sequencer is running. Refer to the technical update number TN-SY*-A033A/E. This check can be disabled by defining R_FLASH_HP_CHECK_MODULE_STOP_BITS to 0. To disable DMAC/DTC, close all modules using DMAC/DTC and call the following: ssp_err_t err; ssp_feature_t ssp_feature = {{(ssp_ip_t) 0U}}; ssp_feature.id = SSP_IP_DTC; err = R_BSP_ModuleStopAlways(&ssp_feature);
SSP_ERR_INVALID_LINKED_ADDRESSHW_FLASH_HP_configurationSet is linked to an invalid region of memory. This function must not reside in prohibited regions of memory. It is recommended that the following changes be made to the linker script. For information about prohibited regions refer to the S5 series flash technical update. Technical Update number TN-SY*-A033A/E Recommended Changes: For GCC: Add the following immediately after "__data_start__ = .": . = ALIGN(4); __Code_In_RAM_Start = .; KEEP(*(.code_in_ram*)) __Code_In_RAM_End = .; For IAR: Change: place at start of RAM_region { block START_OF_RAM }; To: define block START_OF_RAM with fixed order { rw section .ssp_dtc_vector_table, block RAM_CODE }; place at start of RAM_region { block START_OF_RAM };

< For consistency with _LP API we return error if Code Flash not enabled

◆ R_FLASH_HP_AccessWindowSet()

ssp_err_t R_FLASH_HP_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 using the provided start and end address. 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.

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

Implements flash_api_t::accessWindowSet.

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.
SSP_ERR_INVALID_HW_CONDITIONThe configuration area cannot be written while DTC/DMAC, EDMAC, LCDC/2DG/JPEG are enabled. This is to prevent prohibited memory accesses while the flash sequencer is running. Refer to the technical update number TN-SY*-A033A/E. This check can be disabled by defining R_FLASH_HP_CHECK_MODULE_STOP_BITS to 0. To disable DMAC/DTC, close all modules using DMAC/DTC and call the following: ssp_err_t err; ssp_feature_t ssp_feature = {{(ssp_ip_t) 0U}}; ssp_feature.id = SSP_IP_DTC; err = R_BSP_ModuleStopAlways(&ssp_feature);
SSP_ERR_INVALID_LINKED_ADDRESSHW_FLASH_HP_configurationSet is linked to an invalid region of memory. This function must not reside in prohibited regions of memory. It is recommended that the following changes be made to the linker script. For information about prohibited regions refer to the S5 series flash technical update. Technical Update number TN-SY*-A033A/E Recommended Changes: For GCC: Add the following immediately after "__data_start__ = .": . = ALIGN(4); __Code_In_RAM_Start = .; KEEP(*(.code_in_ram*)) __Code_In_RAM_End = .; For IAR: Change: place at start of RAM_region { block START_OF_RAM }; To: define block START_OF_RAM with fixed order { rw section .ssp_dtc_vector_table, block RAM_CODE }; place at start of RAM_region { block START_OF_RAM };

< For consistency with _LP API we return error if Code Flash not enabled

Return status.

◆ R_FLASH_HP_BlankCheck()

ssp_err_t R_FLASH_HP_BlankCheck ( flash_ctrl_t *const  p_api_ctrl,
uint32_t const  address,
uint32_t  num_bytes,
flash_result_t p_blank_check_result 
)

Performs a blank check on the specified address area. Implements flash_api_t::blankCheck.

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_USEOther flash operation in progress or API not initialized.
SSP_ERR_ASSERTIONNULL provided for p_ctrl.

Get the block information for this address. If failure return error.

Setup blank check. If failure return error.

Initiate the Blank Check operation

Complete the flash operation.

◆ R_FLASH_HP_Close()

ssp_err_t R_FLASH_HP_Close ( flash_ctrl_t *const  p_api_ctrl)

Releases any resources that were allocated by the Open() or any subsequent Flash operations. Implements flash_api_t::close.

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

Return the hardware lock for the Flash

Disable interrupts

Release the lock

Close the API

◆ R_FLASH_HP_Erase()

ssp_err_t R_FLASH_HP_Erase ( flash_ctrl_t *const  p_api_ctrl,
uint32_t const  address,
uint32_t const  num_blocks 
)

Erases the specified Code or Data Flash blocks. Implements flash_api_t::erase by the block_erase_address.

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 failure return error.

Configure current operation parameters based on user input.

Erase the Blocks. If not a DF BGO erase then exit PE mode and return status.

Complete the flash operation.

◆ R_FLASH_HP_IdCodeSet()

ssp_err_t R_FLASH_HP_IdCodeSet ( flash_ctrl_t *const  p_api_ctrl,
uint8_t const *const  p_id_code,
flash_id_code_mode_t  mode 
)

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_INVALID_HW_CONDITIONThe configuration area cannot be written while DTC/DMAC, EDMAC, LCDC/2DG/JPEG are enabled. This is to prevent prohibited memory accesses while the flash sequencer is running. Refer to the technical update number TN-SY*-A033A/E. This check can be disabled by defining R_FLASH_HP_CHECK_MODULE_STOP_BITS to 0. To disable DMAC/DTC, close all modules using DMAC/DTC and call the following: ssp_err_t err; ssp_feature_t ssp_feature = {{(ssp_ip_t) 0U}}; ssp_feature.id = SSP_IP_DTC; err = R_BSP_ModuleStopAlways(&ssp_feature);
SSP_ERR_INVALID_LINKED_ADDRESSHW_FLASH_HP_configurationSet is linked to an invalid region of memory. This function must not reside in prohibited regions of memory. It is recommended that the following changes be made to the linker script. For information about prohibited regions refer to the S5 series flash technical update. Technical Update number TN-SY*-A033A/E Recommended Changes: For GCC: Add the following immediately after "__data_start__ = .": . = ALIGN(4); __Code_In_RAM_Start = .; KEEP(*(.code_in_ram*)) __Code_In_RAM_End = .; For IAR: Change: place at start of RAM_region { block START_OF_RAM }; To: define block START_OF_RAM with fixed order { rw section .ssp_dtc_vector_table, block RAM_CODE }; place at start of RAM_region { block START_OF_RAM };

Return status.

◆ R_FLASH_HP_InfoGet()

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

Eliminate warning if parameter checking is disabled.

Copy information about the code and data flash to the user structure.

◆ R_FLASH_HP_Open()

ssp_err_t R_FLASH_HP_Open ( flash_ctrl_t *const  p_api_ctrl,
flash_cfg_t const *const  p_cfg 
)

Initializes the 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 and Error interrupts will be configured to call the users callback routine with an Event type describing the source of the interrupt.

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 4 MHz for Flash operations.
SSP_ERR_HW_LOCKEDFLASH peripheral has already been initialized and is in use.

Setup the flash FMI and acquire the hardware lock. If failure return error.

Allow Initialization if not initialized or if no operation is ongoing and re-initialization is desired

Acquire the flash hp software lock.

Set the parameters struct based on the user supplied settings

If BGO is enabled for data flash configure the callback and enable flash iterrupts. Otherwise disable interrupts.

Flash open setup.

Save callback function pointer

◆ R_FLASH_HP_Read()

ssp_err_t R_FLASH_HP_Read ( flash_ctrl_t *const  p_api_ctrl,
uint8_t *  p_dest_address,
uint32_t const  flash_address,
uint32_t const  num_bytes 
)

Reads the requested number of bytes from the supplied Data or Code Flash memory address. Implements flash_api_t::read.

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

Eliminate warning if parameter checking is disabled.

Copy data to the destination buffer.

◆ R_FLASH_HP_Reset()

ssp_err_t R_FLASH_HP_Reset ( flash_ctrl_t *const  p_api_ctrl)

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

Reset the flash.

Release the flash.

◆ R_FLASH_HP_StartUpAreaSelect()

ssp_err_t R_FLASH_HP_StartUpAreaSelect ( flash_ctrl_t *const  p_api_ctrl,
flash_startup_area_swap_t  swap_type,
bool  is_temporary 
)

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. Implements flash_api_t::startupAreaSelect.

Return values
SSP_SUCCESSStart-up area successfully toggled.
SSP_ERR_IN_USEFLASH peripheral is busy with a prior operation.
SSP_ERR_ASSERTIONNULL provided for p_ctrl.
SSP_ERR_INVALID_HW_CONDITIONThe configuration area cannot be written while DTC/DMAC, EDMAC, LCDC/2DG/JPEG are enabled. This is to prevent prohibited memory accesses while the flash sequencer is running. Refer to the technical update number TN-SY*-A033A/E. This check can be disabled by defining R_FLASH_HP_CHECK_MODULE_STOP_BITS to 0. To disable DMAC/DTC, close all modules using DMAC/DTC and call the following: ssp_err_t err; ssp_feature_t ssp_feature = {{(ssp_ip_t) 0U}}; ssp_feature.id = SSP_IP_DTC; err = R_BSP_ModuleStopAlways(&ssp_feature);
SSP_ERR_INVALID_LINKED_ADDRESSHW_FLASH_HP_configurationSet is linked to an invalid region of memory. This function must not reside in prohibited regions of memory. It is recommended that the following changes be made to the linker script. For information about prohibited regions refer to the S5 series flash technical update. Technical Update number TN-SY*-A033A/E Recommended Changes: For GCC: Add the following immediately after "__data_start__ = .": . = ALIGN(4); __Code_In_RAM_Start = .; KEEP(*(.code_in_ram*)) __Code_In_RAM_End = .; For IAR: Change: place at start of RAM_region { block START_OF_RAM }; To: define block START_OF_RAM with fixed order { rw section .ssp_dtc_vector_table, block RAM_CODE }; place at start of RAM_region { block START_OF_RAM };

Enter PE Mode.

Swap the block temporarily or permantly based on caller.

If failure reset the flash.

Release the flash and return status.

◆ R_FLASH_HP_StatusGet()

ssp_err_t R_FLASH_HP_StatusGet ( flash_ctrl_t *const  p_api_ctrl)

Query the FLASH peripheral for its status. Implements flash_api_t::statusGet.

Return values
SSP_SUCCESSFLASH peripheral is ready to use.
SSP_ERR_IN_USEFLASH peripheral is busy with a prior operation.
SSP_ERR_ASSERTIONNULL provided for p_ctrl.

Eliminate warning if parameter checking is disabled.

Return flash status

◆ R_FLASH_HP_UpdateFlashClockFreq()

ssp_err_t R_FLASH_HP_UpdateFlashClockFreq ( flash_ctrl_t *const  p_api_ctrl)

Indicate to the already open Flash API, that the FCLK has changed since the Open(). 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. Implements flash_api_t::updateFlashClockFreq.

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.

Flash Setup

Release the flash.

◆ R_FLASH_HP_VersionGet()

ssp_err_t R_FLASH_HP_VersionGet ( ssp_version_t *const  p_version)

This function gets FLASH HAL driver version.

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

Copy the version information.

◆ R_FLASH_HP_Write()

ssp_err_t R_FLASH_HP_Write ( flash_ctrl_t *const  p_api_ctrl,
uint32_t const  src_address,
uint32_t  flash_address,
uint32_t const  num_bytes 
)

Writes to the specified Code or Data Flash memory area. Implements flash_api_t::write.

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, may return SSP_ERR_IN_USE via setup_for_pe_mode()

Execute a reset if any error, release the state if not BGO