libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
libopencm3 STM32L4xx FLASH More...
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_dcache_enable (void) |
Enable the data cache. More... | |
void | flash_dcache_disable (void) |
Disable the data cache. More... | |
void | flash_icache_enable (void) |
Enable the Instruction Cache. More... | |
void | flash_icache_disable (void) |
Disable the Instruction Cache. More... | |
void | flash_dcache_reset (void) |
Reset the Data Cache. More... | |
void | flash_icache_reset (void) |
Reset the Instruction Cache. More... | |
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. More... | |
void | flash_clear_pgserr_flag (void) |
Clear the Programming Sequence Error Flag This flag is set when incorrect programming configuration has been made. 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 Protect Error Flag. More... | |
void | flash_clear_progerr_flag (void) |
Clear the Programming Error Status Flag. More... | |
void | flash_clear_status_flags (void) |
Clear All Status Flags Program error, end of operation, write protect error, busy. More... | |
void | flash_lock_option_bytes (void) |
Lock the Option Byte Access This disables write access to the option bytes. More... | |
void | flash_program_double_word (uint32_t address, uint64_t data) |
Program a 64 bit word to FLASH. More... | |
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. 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_program_option_bytes (uint32_t data) |
Program the Option Bytes This performs all operations necessary to program the option bytes. More... | |
libopencm3 STM32L4xx FLASH
Benjamin Levine benja.nosp@m.min@.nosp@m.jesco.nosp@m..kar.nosp@m.oo.co.nosp@m..uk
This library supports the FLASH memory controller in the STM32L4 series of ARM Cortex Microcontrollers by ST Microelectronics.
For the STM32L4xx, accessing FLASH memory is described briefly in section 3 of the STM32L4x6 Reference Manual.
LGPL License Terms libopencm3 License
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().
void flash_clear_pgaerr_flag | ( | void | ) |
Clear the Programming Alignment Error Flag.
Definition at line 70 of file flash.c.
References FLASH_SR, and FLASH_SR_PGAERR.
Referenced by flash_clear_status_flags().
void flash_clear_pgserr_flag | ( | void | ) |
Clear the Programming Sequence Error Flag This flag is set when incorrect programming configuration has been made.
Definition at line 57 of file flash.c.
References FLASH_SR, and FLASH_SR_PGSERR.
Referenced by flash_clear_status_flags().
void flash_clear_progerr_flag | ( | void | ) |
Clear the Programming Error Status Flag.
Definition at line 84 of file flash.c.
References FLASH_SR, and FLASH_SR_PROGERR.
Referenced by flash_clear_status_flags().
void flash_clear_size_flag | ( | void | ) |
Clear programming size error flag.
Definition at line 63 of file flash.c.
References FLASH_SR, and FLASH_SR_SIZERR.
Referenced by flash_clear_status_flags().
void flash_clear_status_flags | ( | void | ) |
Clear All Status Flags Program error, end of operation, write protect error, busy.
Clear all status flags.
Definition at line 92 of file flash.c.
References flash_clear_eop_flag(), flash_clear_pgaerr_flag(), flash_clear_pgserr_flag(), flash_clear_progerr_flag(), flash_clear_size_flag(), and flash_clear_wrperr_flag().
void flash_clear_wrperr_flag | ( | void | ) |
Clear the Write Protect Error Flag.
Definition at line 77 of file flash.c.
References FLASH_SR, and FLASH_SR_WRPERR.
Referenced by flash_clear_status_flags().
void flash_dcache_disable | ( | void | ) |
Disable the data cache.
Definition at line 32 of file flash_common_idcache.c.
References FLASH_ACR.
Referenced by rcc_clock_setup_pll().
void flash_dcache_enable | ( | void | ) |
Enable the data cache.
Definition at line 27 of file flash_common_idcache.c.
References FLASH_ACR, and FLASH_ACR_DCEN.
Referenced by rcc_clock_setup_pll().
void flash_dcache_reset | ( | void | ) |
Reset the Data Cache.
The data cache must be disabled for this to have effect.
Definition at line 48 of file flash_common_idcache.c.
References FLASH_ACR, and FLASH_ACR_DCRST.
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 178 of file flash.c.
References FLASH_CR, FLASH_CR_MER1, FLASH_CR_MER2, FLASH_CR_START, and flash_wait_for_last_operation().
void flash_erase_page | ( | uint32_t | page | ) |
Erase a page of FLASH.
[in] | page | (0 - 255 for bank 1, 256-511 for bank 2) |
Definition at line 157 of file flash.c.
References FLASH_CR, FLASH_CR_BKER, FLASH_CR_PER, FLASH_CR_PNB_MASK, FLASH_CR_PNB_SHIFT, FLASH_CR_START, and flash_wait_for_last_operation().
void flash_icache_disable | ( | void | ) |
Disable the Instruction Cache.
Definition at line 42 of file flash_common_idcache.c.
References FLASH_ACR.
Referenced by rcc_clock_setup_pll().
void flash_icache_enable | ( | void | ) |
Enable the Instruction Cache.
Definition at line 37 of file flash_common_idcache.c.
References FLASH_ACR, and FLASH_ACR_ICEN.
Referenced by rcc_clock_setup_pll().
void flash_icache_reset | ( | void | ) |
Reset the Instruction Cache.
The instruction cache must be disabled for this to have effect.
Definition at line 53 of file flash_common_idcache.c.
References FLASH_ACR, and FLASH_ACR_ICRST.
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.
void flash_lock_option_bytes | ( | void | ) |
Lock the Option Byte Access This disables write access to the option bytes.
It is locked by default on reset.
Definition at line 106 of file flash.c.
References FLASH_CR, and FLASH_CR_OPTLOCK.
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.
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.
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.
[in] | address | Starting address in Flash. |
[in] | data | Pointer to start of data block. |
[in] | len | Length of data block in bytes (multiple of 8). |
Definition at line 147 of file flash.c.
References flash_program_double_word().
void flash_program_double_word | ( | uint32_t | address, |
uint64_t | data | ||
) |
Program a 64 bit word to FLASH.
This performs all operations necessary to program a 64 bit word to FLASH memory. The program error flag should be checked separately for the event that memory was not properly erased.
[in] | address | Starting address in Flash. |
[in] | data | Double word to write |
Definition at line 120 of file flash.c.
References FLASH_CR, FLASH_CR_PG, flash_wait_for_last_operation(), and MMIO32.
Referenced by flash_program().
void flash_program_option_bytes | ( | uint32_t | data | ) |
Program the Option Bytes This performs all operations necessary to program the option bytes.
The option bytes do not need to be erased first.
[in] | data | value to be programmed. |
Definition at line 194 of file flash.c.
References FLASH_CR, FLASH_CR_OPTLOCK, FLASH_CR_OPTSTRT, FLASH_OPTR, flash_unlock_option_bytes(), and flash_wait_for_last_operation().
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.
[in] | ws | values from flash_latency. |
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_pll().
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.
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_program_option_bytes().
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.
Wait until Last Operation has Ended.
Definition at line 49 of file flash.c.
References FLASH_SR, and FLASH_SR_BSY.
Referenced by flash_erase_all_pages(), flash_erase_page(), flash_program_double_word(), and flash_program_option_bytes().