libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
libopencm3 STM32L1xx 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_pecr (void) |
Unlock primary access to the flash control/erase block You must call this before using any of the low level routines yourself. More... | |
void | flash_lock_pecr (void) |
void | flash_unlock_progmem (void) |
Unlock program memory itself. More... | |
void | flash_lock_progmem (void) |
void | flash_lock_option_bytes (void) |
void | flash_unlock (void) |
Unlock all segments of flash. More... | |
void | flash_lock (void) |
Lock all segments of flash. More... | |
void | flash_unlock_acr (void) |
Unlock RUN_PD bit from FLASH_ACR register. More... | |
void | flash_erase_page (uint32_t page_address) |
Erase a page in flash. More... | |
void | flash_program_half_page (uint32_t *dst, void *buf) |
Write a half page from buf to dst. More... | |
void | eeprom_program_word (uint32_t address, uint32_t data) |
Write a word to eeprom. More... | |
void | eeprom_program_words (uint32_t address, uint32_t *data, int length_in_words) |
Write a block of words to eeprom. More... | |
void | flash_64bit_enable (void) |
Enable 64 Bit Programming Mode. More... | |
void | flash_64bit_disable (void) |
Enable 32 Bit Programming Mode. More... | |
libopencm3 STM32L1xx FLASH
For the STM32L1xx, accessing FLASH memory is described briefly in section 2.3.3 of the STM32L1xx Reference Manual. For detailed programming information see: PM0062 programming manual: STM32L1xxxx Flash and EEPROM programming March 2012, Doc ID 16024 Rev 5
LGPL License Terms libopencm3 License
void eeprom_program_word | ( | uint32_t | address, |
uint32_t | data | ||
) |
Write a word to eeprom.
address | assumed to be in the eeprom space, no checking |
data | word to write |
Definition at line 131 of file flash_common_l01.c.
References flash_lock_pecr(), FLASH_PECR, flash_unlock_pecr(), and MMIO32.
void eeprom_program_words | ( | uint32_t | address, |
uint32_t * | data, | ||
int | length_in_words | ||
) |
Write a block of words to eeprom.
Writes a block of words to EEPROM at the requested address, erasing if necessary, and locking afterwards. Only wordwise writing is safe for writing any value
[in] | address | must point to EEPROM space, no checking! |
[in] | data | pointer to data to write |
[in] | length_in_words | size of of data in WORDS! |
Definition at line 150 of file flash_common_l01.c.
References flash_lock_pecr(), FLASH_PECR, FLASH_SR, FLASH_SR_BSY, flash_unlock_pecr(), and MMIO32.
void flash_64bit_disable | ( | void | ) |
void flash_64bit_enable | ( | void | ) |
Enable 64 Bit Programming Mode.
Definition at line 57 of file flash.c.
References FLASH_ACR, and FLASH_ACR_ACC64.
Referenced by rcc_clock_setup_hsi(), rcc_clock_setup_msi(), and rcc_clock_setup_pll().
void flash_erase_page | ( | uint32_t | page_address | ) |
Erase a page in flash.
page_address | For L1, must be first word in page, L0 doesn't care Takes 1 tprog. Flash must already be unlocked! |
Definition at line 100 of file flash_common_l01.c.
References FLASH_PECR, FLASH_PECR_ERASE, FLASH_PECR_PROG, FLASH_SR, FLASH_SR_BSY, and MMIO32.
void flash_lock | ( | void | ) |
Lock all segments of flash.
Lock the Flash Program and Erase Controller Used to prevent spurious writes to FLASH.
Definition at line 85 of file flash_common_l01.c.
References flash_lock_option_bytes(), flash_lock_pecr(), and flash_lock_progmem().
void flash_lock_option_bytes | ( | void | ) |
Definition at line 67 of file flash_common_l01.c.
References FLASH_PECR, and FLASH_PECR_OPTLOCK.
Referenced by flash_lock().
void flash_lock_pecr | ( | void | ) |
Definition at line 45 of file flash_common_l01.c.
References FLASH_PECR, and FLASH_PECR_PELOCK.
Referenced by eeprom_program_word(), eeprom_program_words(), and flash_lock().
void flash_lock_progmem | ( | void | ) |
Definition at line 62 of file flash_common_l01.c.
References FLASH_PECR, and FLASH_PECR_PRGLOCK.
Referenced by flash_lock().
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.
Referenced by rcc_clock_setup_hsi(), rcc_clock_setup_msi(), and rcc_clock_setup_pll().
void flash_program_half_page | ( | uint32_t * | dst, |
void * | buf | ||
) |
Write a half page from buf to dst.
This function must be in ram! (See the Ref Man for more details)
dst | where to write to, expected to be aligned and erased. |
buf | the half page to write, size required depends on target |
Definition at line 111 of file flash_common_l01.c.
References FLASH_HALF_PAGE_SIZE, FLASH_PECR, FLASH_PECR_FPRG, FLASH_PECR_PROG, FLASH_SR, and FLASH_SR_BSY.
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 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(), rcc_clock_setup_msi(), and rcc_clock_setup_pll().
void flash_unlock | ( | void | ) |
Unlock all segments of flash.
Unlock the Flash Program and Erase Controller This enables write access to the Flash memory.
Definition at line 75 of file flash_common_l01.c.
References flash_unlock_option_bytes(), flash_unlock_pecr(), and flash_unlock_progmem().
void flash_unlock_acr | ( | void | ) |
Unlock RUN_PD bit from FLASH_ACR register.
Definition at line 94 of file flash_common_l01.c.
References FLASH_PDKEYR, FLASH_PDKEYR_PDKEY1, and FLASH_PDKEYR_PDKEY2.
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().
void flash_unlock_pecr | ( | void | ) |
Unlock primary access to the flash control/erase block You must call this before using any of the low level routines yourself.
Definition at line 39 of file flash_common_l01.c.
References FLASH_PEKEYR, FLASH_PEKEYR_PEKEY1, and FLASH_PEKEYR_PEKEY2.
Referenced by eeprom_program_word(), eeprom_program_words(), and flash_unlock().
void flash_unlock_progmem | ( | void | ) |
Unlock program memory itself.
Writes the magic sequence to unlock the program memory you must have already unlocked access to this register!
Definition at line 56 of file flash_common_l01.c.
References FLASH_PRGKEYR, FLASH_PRGKEYR_PRGKEY1, and FLASH_PRGKEYR_PRGKEY2.
Referenced by flash_unlock().