libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
FLASH peripheral API

libopencm3 STM32G0xx FLASH More...

Collaboration diagram for FLASH peripheral API:

Functions

void flash_prefetch_enable (void)
 This buffer is used for instruction fetches and may or may not be enabled by default, depending on platform. More...
 
void flash_prefetch_disable (void)
 Note carefully the clock restrictions under which the prefetch buffer may be set to disabled. More...
 
void flash_set_ws (uint32_t ws)
 Set the Number of Wait States. More...
 
void flash_unlock_option_bytes (void)
 Unlock the Option Byte Access. More...
 
void flash_wait_for_last_operation (void)
 Wait until Last Flash Operation has Ended. More...
 
void flash_program_double_word (uint32_t address, uint64_t data)
 Program a 64bits word to FLASH. More...
 
void flash_program (uint32_t address, uint8_t *data, uint32_t len)
 Program a Data Block to FLASH. More...
 
void flash_erase_page (uint32_t page)
 Erase a page of FLASH. More...
 
void flash_erase_all_pages (void)
 Erase All FLASH This performs all operations necessary to erase all sectors in the FLASH memory. More...
 
void flash_clear_pgserr_flag (void)
 Clear the Programming Sequence Error Flag. More...
 
void flash_clear_eop_flag (void)
 Clear the End of Operation Flag. More...
 
void flash_clear_size_flag (void)
 Clear programming size error flag. More...
 
void flash_clear_pgaerr_flag (void)
 Clear the Programming Alignment Error Flag. More...
 
void flash_clear_wrperr_flag (void)
 Clear the Write Protected Error Flag. More...
 
void flash_clear_progerr_flag (void)
 Clear the Programming Error Status Flag. More...
 
void flash_clear_operr_flag (void)
 Clear the Operation Error Status Flag. More...
 
void flash_clear_status_flags (void)
 Clear All Status Flags. More...
 
void flash_icache_enable (void)
 Enable instruction cache. More...
 
void flash_icache_disable (void)
 Disable instruction cache. More...
 
void flash_icache_reset (void)
 Reset instruction cache. More...
 
void flash_unlock_progmem (void)
 Unlock program memory. More...
 
void flash_lock_progmem (void)
 lock program memory More...
 
void flash_lock_option_bytes (void)
 Lock Option Byte Access. More...
 
void flash_unlock (void)
 Unlock the Flash Program and Erase Controller This enables write access to the Flash memory. More...
 
void flash_lock (void)
 Lock the Flash Program and Erase Controller Used to prevent spurious writes to FLASH. More...
 

Detailed Description

libopencm3 STM32G0xx FLASH

Version
1.0.0

LGPL License Terms libopencm3 License

Function Documentation

◆ flash_clear_eop_flag()

void flash_clear_eop_flag ( void  )

Clear the End of Operation Flag.

Definition at line 121 of file flash.c.

References FLASH_SR, and FLASH_SR_EOP.

Referenced by flash_clear_status_flags().

Here is the caller graph for this function:

◆ flash_clear_operr_flag()

void flash_clear_operr_flag ( void  )

Clear the Operation Error Status Flag.

Definition at line 155 of file flash.c.

References FLASH_SR, and FLASH_SR_OPERR.

Referenced by flash_clear_status_flags().

Here is the caller graph for this function:

◆ flash_clear_pgaerr_flag()

void flash_clear_pgaerr_flag ( void  )

Clear the Programming Alignment Error Flag.

Definition at line 134 of file flash.c.

References FLASH_SR, and FLASH_SR_PGAERR.

Referenced by flash_clear_status_flags().

Here is the caller graph for this function:

◆ flash_clear_pgserr_flag()

void flash_clear_pgserr_flag ( void  )

Clear the Programming Sequence Error Flag.

Definition at line 115 of file flash.c.

References FLASH_SR, and FLASH_SR_PGSERR.

Referenced by flash_clear_status_flags().

Here is the caller graph for this function:

◆ flash_clear_progerr_flag()

void flash_clear_progerr_flag ( void  )

Clear the Programming Error Status Flag.

Definition at line 148 of file flash.c.

References FLASH_SR, and FLASH_SR_PROGERR.

Referenced by flash_clear_status_flags().

Here is the caller graph for this function:

◆ flash_clear_size_flag()

void flash_clear_size_flag ( void  )

Clear programming size error flag.

Definition at line 127 of file flash.c.

References FLASH_SR, and FLASH_SR_SIZERR.

Referenced by flash_clear_status_flags().

Here is the caller graph for this function:

◆ flash_clear_status_flags()

void flash_clear_status_flags ( void  )

Clear All Status Flags.

Definition at line 161 of file flash.c.

References flash_clear_eop_flag(), flash_clear_operr_flag(), flash_clear_pgaerr_flag(), flash_clear_pgserr_flag(), flash_clear_progerr_flag(), flash_clear_size_flag(), and flash_clear_wrperr_flag().

Here is the call graph for this function:

◆ flash_clear_wrperr_flag()

void flash_clear_wrperr_flag ( void  )

Clear the Write Protected Error Flag.

Definition at line 141 of file flash.c.

References FLASH_SR, and FLASH_SR_WRPERR.

Referenced by flash_clear_status_flags().

Here is the caller graph for this function:

◆ flash_erase_all_pages()

void flash_erase_all_pages ( void  )

Erase All FLASH This performs all operations necessary to erase all sectors in the FLASH memory.

Definition at line 103 of file flash.c.

References FLASH_CR, FLASH_CR_MER, FLASH_CR_STRT, and flash_wait_for_last_operation().

Here is the call graph for this function:

◆ flash_erase_page()

void flash_erase_page ( uint32_t  page)

Erase a page of FLASH.

Parameters
[in]page

Definition at line 82 of file flash.c.

References FLASH_CR, FLASH_CR_PER, FLASH_CR_PNB_MASK, FLASH_CR_PNB_SHIFT, FLASH_CR_STRT, and flash_wait_for_last_operation().

Here is the call graph for this function:

◆ flash_icache_disable()

void flash_icache_disable ( void  )

Disable instruction cache.

Definition at line 177 of file flash.c.

References FLASH_ACR.

◆ flash_icache_enable()

void flash_icache_enable ( void  )

Enable instruction cache.

Definition at line 172 of file flash.c.

References FLASH_ACR, and FLASH_ACR_ICEN.

◆ flash_icache_reset()

void flash_icache_reset ( void  )

Reset instruction cache.

Definition at line 182 of file flash.c.

References FLASH_ACR, and FLASH_ACR_ICRST.

◆ flash_lock()

void flash_lock ( void  )

Lock the Flash Program and Erase Controller Used to prevent spurious writes to FLASH.

Definition at line 209 of file flash.c.

References flash_lock_option_bytes(), and flash_lock_progmem().

Here is the call graph for this function:

◆ flash_lock_option_bytes()

void flash_lock_option_bytes ( void  )

Lock Option Byte Access.

Definition at line 198 of file flash.c.

References FLASH_CR, and FLASH_CR_OPTLOCK.

Referenced by flash_lock().

Here is the caller graph for this function:

◆ flash_lock_progmem()

void flash_lock_progmem ( void  )

lock program memory

Definition at line 193 of file flash.c.

References FLASH_CR, and FLASH_CR_LOCK.

Referenced by flash_lock().

Here is the caller graph for this function:

◆ flash_prefetch_disable()

void flash_prefetch_disable ( void  )

Note carefully the clock restrictions under which the prefetch buffer may be set to disabled.

See the reference manual for details.

Definition at line 31 of file flash_common_all.c.

References FLASH_ACR.

Referenced by rcc_clock_setup().

Here is the caller graph for this function:

◆ flash_prefetch_enable()

void flash_prefetch_enable ( void  )

This buffer is used for instruction fetches and may or may not be enabled by default, depending on platform.

(F1: yes, most others: no)

Note carefully the clock restrictions under which the prefetch buffer may be enabled or disabled. Changes are normally made while the clock is running in the power-on low frequency mode before being set to a higher speed mode.

Note carefully that prefetch may also results in increased consumption and can only improve performance on "mostly linear" workloads where there is at least one flash wait state.

See the reference manual for your particular target for more details.

Definition at line 26 of file flash_common_all.c.

References FLASH_ACR, and FLASH_ACR_PRFTEN.

Referenced by rcc_clock_setup().

Here is the caller graph for this function:

◆ flash_program()

void flash_program ( uint32_t  address,
uint8_t *  data,
uint32_t  len 
)

Program a Data Block to FLASH.

This programs an arbitrary length data block to FLASH memory. The program error flag should be checked separately for the event that memory was not properly erased.

Parameters
[in]addressStarting address in Flash.
[in]dataPointer to start of data block.
[in]lenLength of data block in bytes (multiple of 8).

Definition at line 72 of file flash.c.

References flash_program_double_word().

Here is the call graph for this function:

◆ flash_program_double_word()

void flash_program_double_word ( uint32_t  address,
uint64_t  data 
)

Program a 64bits word to FLASH.

Program a 64bit word to FLASH memory. Flash programing error must be checked and cleared if needed before starting programming.

Parameters
[in]addressAddress in FLASH
[in]dataDouble word to write

Definition at line 48 of file flash.c.

References FLASH_CR, FLASH_CR_PG, flash_wait_for_last_operation(), and MMIO32.

Referenced by flash_program().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flash_set_ws()

void flash_set_ws ( uint32_t  ws)

Set the Number of Wait States.

Used to match the system clock to the FLASH memory access time. See the programming manual for more information on clock speed ranges. The latency must be changed to the appropriate value before any increase in clock speed, or after any decrease in clock speed.

Parameters
[in]wsvalues from FLASH Wait States.

Definition at line 36 of file flash_common_all.c.

References FLASH_ACR, FLASH_ACR_LATENCY_MASK, and FLASH_ACR_LATENCY_SHIFT.

Referenced by rcc_clock_setup().

Here is the caller graph for this function:

◆ flash_unlock()

void flash_unlock ( void  )

Unlock the Flash Program and Erase Controller This enables write access to the Flash memory.

It is locked by default on reset.

Definition at line 203 of file flash.c.

References flash_unlock_option_bytes(), and flash_unlock_progmem().

Here is the call graph for this function:

◆ flash_unlock_option_bytes()

void flash_unlock_option_bytes ( void  )

Unlock the Option Byte Access.

This enables write access to the option bytes. It is locked by default on reset.

Definition at line 46 of file flash_common_all.c.

References FLASH_OPTKEYR, FLASH_OPTKEYR_KEY1, and FLASH_OPTKEYR_KEY2.

Referenced by flash_unlock().

Here is the caller graph for this function:

◆ flash_unlock_progmem()

void flash_unlock_progmem ( void  )

Unlock program memory.

Definition at line 187 of file flash.c.

References FLASH_KEYR, FLASH_KEYR_KEY1, and FLASH_KEYR_KEY2.

Referenced by flash_unlock().

Here is the caller graph for this function:

◆ flash_wait_for_last_operation()

void flash_wait_for_last_operation ( void  )

Wait until Last Flash Operation has Ended.

Definition at line 34 of file flash.c.

References FLASH_SR, and FLASH_SR_BSY.

Referenced by flash_erase_all_pages(), flash_erase_page(), and flash_program_double_word().

Here is the caller graph for this function: