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

libopencm3 STM32F3xx 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_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...
 
void flash_clear_eop_flag (void)
 Clear the End of OPeration flag. More...
 
void flash_wait_for_last_operation (void)
 Wait until Last Operation has Ended. More...
 
void flash_clear_pgerr_flag (void)
 
void flash_clear_wrprterr_flag (void)
 
void flash_clear_status_flags (void)
 Clear All Status Flags. More...
 
void flash_program_half_word (uint32_t address, uint16_t data)
 
void flash_erase_page (uint32_t page_address)
 
void flash_erase_all_pages (void)
 

Detailed Description

libopencm3 STM32F3xx FLASH

Version
1.0.0
Author
© 2010 Thomas Otto tommi.nosp@m.@via.nosp@m.dmin..nosp@m.org
© 2010 Mark Butler mbutl.nosp@m.er@p.nosp@m.hysic.nosp@m.s.ot.nosp@m.ago.a.nosp@m.c.nz
Date
14 January 2014

This library supports the FLASH memory controller in the STM32F3 series of ARM Cortex Microcontrollers by ST Microelectronics.

For the STM32F3xx, accessing FLASH memory is described in section 3 of the STM32F3xx Reference Manual.

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 41 of file flash_common_f.c.

References FLASH_SR, and FLASH_SR_EOP.

Referenced by flash_clear_status_flags().

Here is the caller graph for this function:

◆ flash_clear_pgerr_flag()

void flash_clear_pgerr_flag ( void  )

Definition at line 54 of file flash.c.

References FLASH_SR, and FLASH_SR_PGERR.

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.

Clear all status flags.

Clears program error, end of operation, busy flags.

Definition at line 71 of file flash.c.

References flash_clear_eop_flag(), flash_clear_pgerr_flag(), and flash_clear_wrprterr_flag().

Here is the call graph for this function:

◆ flash_clear_wrprterr_flag()

void flash_clear_wrprterr_flag ( void  )

Definition at line 59 of file flash.c.

References FLASH_SR, and FLASH_SR_WRPRTERR.

Referenced by flash_clear_status_flags().

Here is the caller graph for this function:

◆ flash_erase_all_pages()

void flash_erase_all_pages ( void  )

Definition at line 104 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_address)

Definition at line 91 of file flash.c.

References FLASH_AR, FLASH_CR, FLASH_CR_PER, FLASH_CR_STRT, and flash_wait_for_last_operation().

Here is the call graph for this function:

◆ flash_lock()

void flash_lock ( void  )

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

Definition at line 35 of file flash_common_f.c.

References FLASH_CR, and FLASH_CR_LOCK.

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

◆ 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_pll().

Here is the caller graph for this function:

◆ flash_program_half_word()

void flash_program_half_word ( uint32_t  address,
uint16_t  data 
)

Definition at line 78 of file flash.c.

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

Here is the call 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_hsi(), and rcc_clock_setup_pll().

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 28 of file flash_common_f.c.

References FLASH_KEYR, FLASH_KEYR_KEY1, and FLASH_KEYR_KEY2.

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

◆ flash_wait_for_last_operation()

void flash_wait_for_last_operation ( void  )

Wait until Last Operation has Ended.

This loops indefinitely until an operation (write or erase) has completed by testing the busy flag

Definition at line 49 of file flash.c.

References FLASH_SR, and FLASH_SR_BSY.

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

Here is the caller graph for this function: