Macros | Functions | Variables
Embedded Flash Service

Macros

#define GPNVM_NUM_MAX   2
 

Functions

static void compute_address (Efc *p_efc, uint16_t us_page, uint16_t us_offset, uint32_t *pul_addr)
 Compute the address of a flash by the given page and offset. More...
 
static void compute_lock_range (uint32_t ul_start, uint32_t ul_end, uint32_t *pul_actual_start, uint32_t *pul_actual_end)
 Compute the lock range associated with the given address range. More...
 
uint32_t flash_clear_gpnvm (uint32_t ul_gpnvm)
 Clear the given GPNVM bit. More...
 
uint32_t flash_enable_security_bit (void)
 Set security bit. More...
 
uint32_t flash_erase_all (uint32_t ul_address)
 Erase the entire flash. More...
 
uint32_t flash_get_descriptor (uint32_t ul_address, uint32_t *pul_flash_descriptor, uint32_t ul_size)
 Get flash descriptor. More...
 
uint32_t flash_get_page_count (const uint32_t *pul_flash_descriptor)
 Get flash total page count for the specified bank. More...
 
uint32_t flash_get_page_count_per_region (const uint32_t *pul_flash_descriptor)
 Get flash page count per region (plane) for the specified bank. More...
 
uint32_t flash_get_region_count (const uint32_t *pul_flash_descriptor)
 Get flash region (plane) count for the specified bank. More...
 
uint32_t flash_get_wait_state (uint32_t ul_address)
 Get flash wait state. More...
 
uint32_t flash_init (uint32_t ul_mode, uint32_t ul_fws)
 Initialize the flash service. More...
 
uint32_t flash_is_gpnvm_set (uint32_t ul_gpnvm)
 Check if the given GPNVM bit is set or not. More...
 
uint32_t flash_is_locked (uint32_t ul_start, uint32_t ul_end)
 Get the number of locked regions inside the given address range. More...
 
uint32_t flash_is_security_bit_enabled (void)
 Check if the security bit is set or not. More...
 
uint32_t flash_lock (uint32_t ul_start, uint32_t ul_end, uint32_t *pul_actual_start, uint32_t *pul_actual_end)
 Lock all the regions in the given address range. The actual lock range is reported through two output parameters. More...
 
uint32_t flash_read_unique_id (uint32_t *pul_data, uint32_t ul_size)
 Read the flash unique ID. More...
 
uint32_t flash_set_gpnvm (uint32_t ul_gpnvm)
 Set the given GPNVM bit. More...
 
uint32_t flash_set_wait_state (uint32_t ul_address, uint32_t ul_fws)
 Set flash wait state. More...
 
uint32_t flash_set_wait_state_adaptively (uint32_t ul_address)
 Set flash wait state. More...
 
uint32_t flash_unlock (uint32_t ul_start, uint32_t ul_end, uint32_t *pul_actual_start, uint32_t *pul_actual_end)
 Unlock all the regions in the given address range. The actual unlock range is reported through two output parameters. More...
 
uint32_t flash_write (uint32_t ul_address, const void *p_buffer, uint32_t ul_size, uint32_t ul_erase_flag)
 Write a data buffer on flash. More...
 
static void translate_address (Efc **pp_efc, uint32_t ul_addr, uint16_t *pus_page, uint16_t *pus_offset)
 Translate the given flash address to page and offset values. More...
 

Variables

static uint32_t gs_ul_page_buffer [IFLASH_PAGE_SIZE/sizeof(uint32_t)]
 

Detailed Description

The Embedded Flash service provides functions for internal flash operations.

Macro Definition Documentation

◆ GPNVM_NUM_MAX

#define GPNVM_NUM_MAX   2

Definition at line 132 of file flash_efc.c.

Function Documentation

◆ compute_address()

static void compute_address ( Efc p_efc,
uint16_t  us_page,
uint16_t  us_offset,
uint32_t *  pul_addr 
)
static

Compute the address of a flash by the given page and offset.

Parameters
p_efcPointer to an EFC instance.
us_pagePage number.
us_offsetByte offset inside page.
pul_addrComputed address (optional).

Definition at line 236 of file flash_efc.c.

◆ compute_lock_range()

static void compute_lock_range ( uint32_t  ul_start,
uint32_t  ul_end,
uint32_t *  pul_actual_start,
uint32_t *  pul_actual_end 
)
static

Compute the lock range associated with the given address range.

Parameters
ul_startStart address of lock range.
ul_endEnd address of lock range.
pul_actual_startActual start address of lock range.
pul_actual_endActual end address of lock range.

Definition at line 287 of file flash_efc.c.

◆ flash_clear_gpnvm()

uint32_t flash_clear_gpnvm ( uint32_t  ul_gpnvm)

Clear the given GPNVM bit.

Parameters
ul_gpnvmGPNVM bit index.
Returns
0 if successful; otherwise returns an error code.

Definition at line 897 of file flash_efc.c.

◆ flash_enable_security_bit()

uint32_t flash_enable_security_bit ( void  )

Set security bit.

Returns
0 if successful; otherwise returns an error code.

Definition at line 948 of file flash_efc.c.

◆ flash_erase_all()

uint32_t flash_erase_all ( uint32_t  ul_address)

Erase the entire flash.

Note
Only the flash bank including ul_address will be erased. If there are two flash banks, we need to call this function twice with each bank start address.
Parameters
ul_addressFlash bank start address.
Returns
0 if successful; otherwise returns an error code.

Definition at line 495 of file flash_efc.c.

◆ flash_get_descriptor()

uint32_t flash_get_descriptor ( uint32_t  ul_address,
uint32_t *  pul_flash_descriptor,
uint32_t  ul_size 
)

Get flash descriptor.

Parameters
ul_addressFlash bank start address.
pul_flash_descriptorPointer to a data buffer to store flash descriptor.
ul_sizeData buffer size in DWORD.
Returns
The actual descriptor length.

Definition at line 412 of file flash_efc.c.

◆ flash_get_page_count()

uint32_t flash_get_page_count ( const uint32_t *  pul_flash_descriptor)

Get flash total page count for the specified bank.

Note
The flash descriptor must be fetched from flash_get_descriptor function first.
Parameters
pul_flash_descriptorPointer to a flash descriptor.
Returns
The flash total page count.

Definition at line 449 of file flash_efc.c.

◆ flash_get_page_count_per_region()

uint32_t flash_get_page_count_per_region ( const uint32_t *  pul_flash_descriptor)

Get flash page count per region (plane) for the specified bank.

Note
The flash descriptor must be fetched from flash_get_descriptor function first.
Parameters
pul_flash_descriptorPointer to a flash descriptor.
Returns
The flash page count per region (plane).

Definition at line 464 of file flash_efc.c.

◆ flash_get_region_count()

uint32_t flash_get_region_count ( const uint32_t *  pul_flash_descriptor)

Get flash region (plane) count for the specified bank.

Note
The flash descriptor must be fetched from flash_get_descriptor function first.
Parameters
pul_flash_descriptorPointer to a flash descriptor.
Returns
The flash region (plane) count.

Definition at line 479 of file flash_efc.c.

◆ flash_get_wait_state()

uint32_t flash_get_wait_state ( uint32_t  ul_address)

Get flash wait state.

Parameters
ul_addressFlash bank start address.
Returns
The number of wait states in cycle (no shift).

Definition at line 395 of file flash_efc.c.

◆ flash_init()

uint32_t flash_init ( uint32_t  ul_mode,
uint32_t  ul_fws 
)

Initialize the flash service.

Parameters
ul_modeFLASH_ACCESS_MODE_128 or FLASH_ACCESS_MODE_64.
ul_fwsThe number of wait states in cycle (no shift).
Returns
0 if successful; otherwise returns an error code.

Definition at line 313 of file flash_efc.c.

◆ flash_is_gpnvm_set()

uint32_t flash_is_gpnvm_set ( uint32_t  ul_gpnvm)

Check if the given GPNVM bit is set or not.

Parameters
ul_gpnvmGPNVM bit index.
Return values
1If the given GPNVM bit is currently set.
0If the given GPNVM bit is currently cleared. otherwise returns an error code.

Definition at line 923 of file flash_efc.c.

◆ flash_is_locked()

uint32_t flash_is_locked ( uint32_t  ul_start,
uint32_t  ul_end 
)

Get the number of locked regions inside the given address range.

Parameters
ul_startStart address of range
ul_endEnd address of range.
Returns
The number of locked regions inside the given address range.

Definition at line 796 of file flash_efc.c.

◆ flash_is_security_bit_enabled()

uint32_t flash_is_security_bit_enabled ( void  )

Check if the security bit is set or not.

Return values
1If the security bit is currently set.
0If the security bit is currently cleared. otherwise returns an error code.

Definition at line 960 of file flash_efc.c.

◆ flash_lock()

uint32_t flash_lock ( uint32_t  ul_start,
uint32_t  ul_end,
uint32_t *  pul_actual_start,
uint32_t *  pul_actual_end 
)

Lock all the regions in the given address range. The actual lock range is reported through two output parameters.

Parameters
ul_startStart address of lock range.
ul_endEnd address of lock range.
pul_actual_startStart address of the actual lock range (optional).
pul_actual_endEnd address of the actual lock range (optional).
Returns
0 if successful, otherwise returns an error code.

Definition at line 703 of file flash_efc.c.

◆ flash_read_unique_id()

uint32_t flash_read_unique_id ( uint32_t *  pul_data,
uint32_t  ul_size 
)

Read the flash unique ID.

Parameters
pul_dataPointer to a data buffer to store 128-bit unique ID.
ul_sizeData buffer size in DWORD.
Returns
0 if successful; otherwise returns an error code.

Definition at line 973 of file flash_efc.c.

◆ flash_set_gpnvm()

uint32_t flash_set_gpnvm ( uint32_t  ul_gpnvm)

Set the given GPNVM bit.

Parameters
ul_gpnvmGPNVM bit index.
Returns
0 if successful; otherwise returns an error code.

Definition at line 873 of file flash_efc.c.

◆ flash_set_wait_state()

uint32_t flash_set_wait_state ( uint32_t  ul_address,
uint32_t  ul_fws 
)

Set flash wait state.

Parameters
ul_addressFlash bank start address.
ul_fwsThe number of wait states in cycle (no shift).
Returns
0 if successful; otherwise returns an error code.

Definition at line 332 of file flash_efc.c.

◆ flash_set_wait_state_adaptively()

uint32_t flash_set_wait_state_adaptively ( uint32_t  ul_address)

Set flash wait state.

Parameters
ul_addressFlash bank start address.
ul_fwsThe number of wait states in cycle (no shift).
Returns
0 if successful; otherwise returns an error code.

Definition at line 350 of file flash_efc.c.

◆ flash_unlock()

uint32_t flash_unlock ( uint32_t  ul_start,
uint32_t  ul_end,
uint32_t *  pul_actual_start,
uint32_t *  pul_actual_end 
)

Unlock all the regions in the given address range. The actual unlock range is reported through two output parameters.

Parameters
ul_startStart address of unlock range.
ul_endEnd address of unlock range.
pul_actual_startStart address of the actual unlock range (optional).
pul_actual_endEnd address of the actual unlock range (optional).
Returns
0 if successful, otherwise returns an error code.

Definition at line 752 of file flash_efc.c.

◆ flash_write()

uint32_t flash_write ( uint32_t  ul_address,
const void *  p_buffer,
uint32_t  ul_size,
uint32_t  ul_erase_flag 
)

Write a data buffer on flash.

Note
This function works in polling mode, and thus only returns when the data has been effectively written.
For dual bank flash, this function doesn't support cross write from bank 0 to bank 1. In this case, flash_write must be called twice (ie for each bank).
Parameters
ul_addressWrite address.
p_bufferData buffer.
ul_sizeSize of data buffer in bytes.
ul_erase_flagFlag to set if erase first.
Returns
0 if successful, otherwise returns an error code.

Definition at line 607 of file flash_efc.c.

◆ translate_address()

static void translate_address ( Efc **  pp_efc,
uint32_t  ul_addr,
uint16_t *  pus_page,
uint16_t *  pus_offset 
)
static

Translate the given flash address to page and offset values.

Note
pus_page and pus_offset must not be null in order to store the corresponding values.
Parameters
pp_efcPointer to an EFC pointer.
ul_addrAddress to translate.
pus_pageThe first page accessed.
pus_offsetByte offset in the first page.

Definition at line 164 of file flash_efc.c.

Variable Documentation

◆ gs_ul_page_buffer

uint32_t gs_ul_page_buffer[IFLASH_PAGE_SIZE/sizeof(uint32_t)]
static

Definition at line 152 of file flash_efc.c.



inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:07