libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Defined Constants and Types for the STM32L1xx FLASH Memory. More...
Modules | |
FLASH Wait States | |
Functions | |
void | flash_64bit_enable (void) |
Enable 64 Bit Programming Mode. More... | |
void | flash_64bit_disable (void) |
Enable 32 Bit Programming Mode. 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_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... | |
Defined Constants and Types for the STM32L1xx FLASH Memory.
LGPL License Terms libopencm3 License
#define FLASH_ACR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x00) |
Definition at line 36 of file flash_common_l01.h.
#define FLASH_ACR_ACC64 (1 << 2) |
Definition at line 54 of file l1/flash.h.
#define FLASH_ACR_LATENCY_MASK 1 |
Definition at line 52 of file flash_common_l01.h.
#define FLASH_ACR_LATENCY_SHIFT 0 |
Definition at line 51 of file flash_common_l01.h.
#define FLASH_ACR_PRFTEN (1 << 1) |
Definition at line 50 of file flash_common_l01.h.
#define FLASH_ACR_RUNPD (1 << 4) |
Definition at line 48 of file flash_common_l01.h.
#define FLASH_ACR_SLEEPPD (1 << 3) |
Definition at line 49 of file flash_common_l01.h.
#define FLASH_HALF_PAGE_SIZE 32 |
Definition at line 59 of file l1/flash.h.
#define FLASH_OBR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x1c) |
Definition at line 43 of file flash_common_l01.h.
#define FLASH_OBR_BFB2 (1 << 23) |
Definition at line 101 of file flash_common_l01.h.
#define FLASH_OBR_BOR_LEVEL_1 (0x8 << 16) |
Definition at line 106 of file flash_common_l01.h.
#define FLASH_OBR_BOR_LEVEL_2 (0x9 << 16) |
Definition at line 107 of file flash_common_l01.h.
#define FLASH_OBR_BOR_LEVEL_3 (0xa << 16) |
Definition at line 108 of file flash_common_l01.h.
#define FLASH_OBR_BOR_LEVEL_4 (0xb << 16) |
Definition at line 109 of file flash_common_l01.h.
#define FLASH_OBR_BOR_LEVEL_5 (0xc << 16) |
Definition at line 110 of file flash_common_l01.h.
#define FLASH_OBR_BOR_OFF (0x0 << 16) |
Definition at line 105 of file flash_common_l01.h.
#define FLASH_OBR_IWDG_SW (1 << 20) |
Definition at line 104 of file flash_common_l01.h.
#define FLASH_OBR_NRST_STDBY (1 << 22) |
Definition at line 102 of file flash_common_l01.h.
#define FLASH_OBR_NRST_STOP (1 << 21) |
Definition at line 103 of file flash_common_l01.h.
#define FLASH_OBR_RDPRT_LEVEL_0 (0xaa) |
Definition at line 111 of file flash_common_l01.h.
#define FLASH_OBR_RDPRT_LEVEL_1 (0x00) |
Definition at line 112 of file flash_common_l01.h.
#define FLASH_OBR_RDPRT_LEVEL_2 (0xcc) |
Definition at line 113 of file flash_common_l01.h.
#define FLASH_OPTKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x14) |
Definition at line 41 of file flash_common_l01.h.
#define FLASH_OPTKEYR_KEY1 ((uint32_t)0xFBEAD9C8) |
Definition at line 87 of file flash_common_l01.h.
#define FLASH_OPTKEYR_KEY2 ((uint32_t)0x24252627) |
Definition at line 88 of file flash_common_l01.h.
#define FLASH_PDKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x08) |
Definition at line 38 of file flash_common_l01.h.
#define FLASH_PDKEYR_PDKEY1 ((uint32_t)0x04152637) |
Definition at line 75 of file flash_common_l01.h.
#define FLASH_PDKEYR_PDKEY2 ((uint32_t)0xFAFBFCFD) |
Definition at line 76 of file flash_common_l01.h.
#define FLASH_PECR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x04) |
Definition at line 37 of file flash_common_l01.h.
#define FLASH_PECR_DATA (1 << 4) |
Definition at line 68 of file flash_common_l01.h.
#define FLASH_PECR_EOPIE (1 << 16) |
Definition at line 63 of file flash_common_l01.h.
#define FLASH_PECR_ERASE (1 << 9) |
Definition at line 66 of file flash_common_l01.h.
#define FLASH_PECR_ERRIE (1 << 17) |
Definition at line 62 of file flash_common_l01.h.
#define FLASH_PECR_FPRG (1 << 10) |
Definition at line 65 of file flash_common_l01.h.
#define FLASH_PECR_FTDW (1 << 8) |
Definition at line 67 of file flash_common_l01.h.
#define FLASH_PECR_OBL_LAUNCH (1 << 18) |
Definition at line 61 of file flash_common_l01.h.
#define FLASH_PECR_OPTLOCK (1 << 2) |
Definition at line 70 of file flash_common_l01.h.
#define FLASH_PECR_PARALLBANK (1 << 15) |
Definition at line 64 of file flash_common_l01.h.
#define FLASH_PECR_PELOCK (1 << 0) |
Definition at line 72 of file flash_common_l01.h.
#define FLASH_PECR_PRGLOCK (1 << 1) |
Definition at line 71 of file flash_common_l01.h.
#define FLASH_PECR_PROG (1 << 3) |
Definition at line 69 of file flash_common_l01.h.
#define FLASH_PEKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x0C) |
Definition at line 39 of file flash_common_l01.h.
#define FLASH_PEKEYR_PEKEY1 ((uint32_t)0x89ABCDEF) |
Definition at line 79 of file flash_common_l01.h.
#define FLASH_PEKEYR_PEKEY2 ((uint32_t)0x02030405) |
Definition at line 80 of file flash_common_l01.h.
#define FLASH_PRGKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x10) |
Definition at line 40 of file flash_common_l01.h.
#define FLASH_PRGKEYR_PRGKEY1 ((uint32_t)0x8C9DAEBF) |
Definition at line 83 of file flash_common_l01.h.
#define FLASH_PRGKEYR_PRGKEY2 ((uint32_t)0x13141516) |
Definition at line 84 of file flash_common_l01.h.
#define FLASH_SR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x18) |
Definition at line 42 of file flash_common_l01.h.
#define FLASH_SR_BSY (1 << 0) |
Definition at line 98 of file flash_common_l01.h.
#define FLASH_SR_ENDHV (1 << 2) |
Definition at line 96 of file flash_common_l01.h.
#define FLASH_SR_EOP (1 << 1) |
Definition at line 97 of file flash_common_l01.h.
#define FLASH_SR_OPTVERR (1 << 11) |
Definition at line 91 of file flash_common_l01.h.
#define FLASH_SR_OPTVERRUSR (1 << 12) |
Definition at line 57 of file l1/flash.h.
#define FLASH_SR_PGAERR (1 << 9) |
Definition at line 93 of file flash_common_l01.h.
#define FLASH_SR_READY (1 << 3) |
Definition at line 95 of file flash_common_l01.h.
#define FLASH_SR_SIZEERR (1 << 10) |
Definition at line 92 of file flash_common_l01.h.
#define FLASH_SR_WRPERR (1 << 8) |
Definition at line 94 of file flash_common_l01.h.
#define FLASH_WRPR1 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x20) |
Definition at line 44 of file flash_common_l01.h.
#define FLASH_WRPR2 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x80) |
Definition at line 45 of file flash_common_l01.h.
#define FLASH_WRPR3 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x84) |
Definition at line 51 of file l1/flash.h.
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_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_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_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_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().