libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Defined Constants and Types for the STM32G4xx Flash Control More...
Modules | |
Flash_acr_values | |
Functions | |
void | flash_clear_progerr_flag (void) |
Clear the Programming Error Status 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_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... | |
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... | |
Defined Constants and Types for the STM32G4xx Flash Control
LGPL License Terms libopencm3 License
#define FLASH_ACR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x00) |
Definition at line 52 of file g4/flash.h.
#define FLASH_ACR_DBG_SWEN (1 << 18) |
Definition at line 73 of file g4/flash.h.
#define FLASH_ACR_LATENCY_MASK 0xf |
Definition at line 79 of file g4/flash.h.
#define FLASH_ACR_LATENCY_SHIFT 0 |
Definition at line 78 of file g4/flash.h.
#define FLASH_ACR_PRFTEN (1 << 8) |
Definition at line 76 of file g4/flash.h.
#define FLASH_ACR_RUN_PD (1 << 13) |
Definition at line 75 of file g4/flash.h.
#define FLASH_ACR_SLEEP_PD (1 << 14) |
Definition at line 74 of file g4/flash.h.
#define FLASH_CR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x14) |
Definition at line 57 of file g4/flash.h.
#define FLASH_CR_BKER (1 << 11) |
Definition at line 110 of file g4/flash.h.
#define FLASH_CR_EOPIE (1 << 24) |
Definition at line 105 of file g4/flash.h.
#define FLASH_CR_ERRIE (1 << 25) |
Definition at line 104 of file g4/flash.h.
#define FLASH_CR_FSTPG (1 << 18) |
Definition at line 106 of file g4/flash.h.
#define FLASH_CR_LOCK (1 << 31) |
Definition at line 98 of file g4/flash.h.
#define FLASH_CR_MER1 (1 << 2) |
Definition at line 111 of file g4/flash.h.
#define FLASH_CR_MER2 (1 << 15) |
Definition at line 109 of file g4/flash.h.
#define FLASH_CR_OBL_LAUNCH (1 << 27) |
Definition at line 102 of file g4/flash.h.
#define FLASH_CR_OPTLOCK (1 << 30) |
Definition at line 99 of file g4/flash.h.
#define FLASH_CR_OPTSTRT (1 << 17) |
Definition at line 107 of file g4/flash.h.
#define FLASH_CR_PER (1 << 1) |
Definition at line 112 of file g4/flash.h.
#define FLASH_CR_PG (1 << 0) |
Definition at line 113 of file g4/flash.h.
#define FLASH_CR_PNB_MASK 0x7f |
Definition at line 116 of file g4/flash.h.
#define FLASH_CR_PNB_SHIFT 3 |
Definition at line 115 of file g4/flash.h.
#define FLASH_CR_RDERRIE (1 << 26) |
Definition at line 103 of file g4/flash.h.
#define FLASH_CR_SEC_PROT1 (1 << 28) |
Definition at line 101 of file g4/flash.h.
#define FLASH_CR_SEC_PROT2 (1 << 29) |
Definition at line 100 of file g4/flash.h.
#define FLASH_CR_START (1 << 16) |
Definition at line 108 of file g4/flash.h.
#define FLASH_ECCR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x18) |
Definition at line 58 of file g4/flash.h.
#define FLASH_ECCR_ADDR_ECC_MASK 0x7ffff |
Definition at line 129 of file g4/flash.h.
#define FLASH_ECCR_ADDR_ECC_SHIFT 0 |
Definition at line 128 of file g4/flash.h.
#define FLASH_ECCR_BK_ECC (1 << 21) |
Definition at line 126 of file g4/flash.h.
#define FLASH_ECCR_ECCC (1 << 30) |
Definition at line 121 of file g4/flash.h.
#define FLASH_ECCR_ECCC2 (1 << 30) |
Definition at line 123 of file g4/flash.h.
#define FLASH_ECCR_ECCD (1 << 31) |
Definition at line 120 of file g4/flash.h.
#define FLASH_ECCR_ECCD2 (1 << 31) |
Definition at line 122 of file g4/flash.h.
#define FLASH_ECCR_ECCIE (1 << 24) |
Definition at line 124 of file g4/flash.h.
#define FLASH_ECCR_SYSF_ECC (1 << 22) |
Definition at line 125 of file g4/flash.h.
#define FLASH_KEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x08) |
Definition at line 54 of file g4/flash.h.
#define FLASH_KEYR_KEY1 ((uint32_t)0x45670123) |
Definition at line 240 of file g4/flash.h.
#define FLASH_KEYR_KEY2 ((uint32_t)0xcdef89ab) |
Definition at line 241 of file g4/flash.h.
#define FLASH_OPTKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x0C) |
Definition at line 55 of file g4/flash.h.
#define FLASH_OPTKEYR_KEY1 ((uint32_t)0x08192a3b) |
Definition at line 243 of file g4/flash.h.
#define FLASH_OPTKEYR_KEY2 ((uint32_t)0x4c5d6e7f) |
Definition at line 244 of file g4/flash.h.
#define FLASH_OPTR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x20) |
Definition at line 59 of file g4/flash.h.
#define FLASH_OPTR_BFB2 (1 << 20) |
Definition at line 147 of file g4/flash.h.
#define FLASH_OPTR_BOR_LEVEL_0 0 |
Definition at line 158 of file g4/flash.h.
#define FLASH_OPTR_BOR_LEVEL_1 1 |
Definition at line 159 of file g4/flash.h.
#define FLASH_OPTR_BOR_LEVEL_2 2 |
Definition at line 160 of file g4/flash.h.
#define FLASH_OPTR_BOR_LEVEL_3 3 |
Definition at line 161 of file g4/flash.h.
#define FLASH_OPTR_BOR_LEVEL_4 4 |
Definition at line 162 of file g4/flash.h.
#define FLASH_OPTR_BOR_MASK 0x7 |
Definition at line 157 of file g4/flash.h.
#define FLASH_OPTR_BOR_SHIFT 8 |
Definition at line 156 of file g4/flash.h.
#define FLASH_OPTR_DUALBANK (1 << 21) |
Definition at line 146 of file g4/flash.h.
#define FLASH_OPTR_IDWG_SW (1 << 16) |
Definition at line 151 of file g4/flash.h.
#define FLASH_OPTR_IRHEN (1 << 30) |
Definition at line 133 of file g4/flash.h.
#define FLASH_OPTR_IWDG_STDBY (1 << 18) |
Definition at line 149 of file g4/flash.h.
#define FLASH_OPTR_IWDG_STOP (1 << 17) |
Definition at line 150 of file g4/flash.h.
#define FLASH_OPTR_nBOOT0 (1 << 27) |
Definition at line 141 of file g4/flash.h.
#define FLASH_OPTR_nBOOT1 (1 << 23) |
Definition at line 145 of file g4/flash.h.
#define FLASH_OPTR_NRST_MODE_BIDIR 3 |
Definition at line 139 of file g4/flash.h.
#define FLASH_OPTR_NRST_MODE_GPIO 2 |
Definition at line 138 of file g4/flash.h.
#define FLASH_OPTR_NRST_MODE_MASK 0x3 |
Definition at line 136 of file g4/flash.h.
#define FLASH_OPTR_NRST_MODE_RESET 1 |
Definition at line 137 of file g4/flash.h.
#define FLASH_OPTR_NRST_MODE_SHIFT 28 |
Definition at line 135 of file g4/flash.h.
#define FLASH_OPTR_nRST_SHDW (1 << 14) |
Definition at line 152 of file g4/flash.h.
#define FLASH_OPTR_nRST_STDBY (1 << 13) |
Definition at line 153 of file g4/flash.h.
#define FLASH_OPTR_nRST_STOP (1 << 12) |
Definition at line 154 of file g4/flash.h.
#define FLASH_OPTR_nSWBOOT0 (1 << 26) |
Definition at line 142 of file g4/flash.h.
#define FLASH_OPTR_RDP_LEVEL_0 0xAA |
Definition at line 166 of file g4/flash.h.
#define FLASH_OPTR_RDP_LEVEL_1 0xBB |
Definition at line 167 of file g4/flash.h.
#define FLASH_OPTR_RDP_LEVEL_2 0xCC |
Definition at line 168 of file g4/flash.h.
#define FLASH_OPTR_RDP_MASK 0xff |
Definition at line 165 of file g4/flash.h.
#define FLASH_OPTR_RDP_SHIFT 0 |
Definition at line 164 of file g4/flash.h.
#define FLASH_OPTR_SRAM_PE (1 << 24) |
Definition at line 144 of file g4/flash.h.
#define FLASH_OPTR_SRAM_RST (1 << 25) |
Definition at line 143 of file g4/flash.h.
#define FLASH_OPTR_WWDG_SW (1 << 19) |
Definition at line 148 of file g4/flash.h.
#define FLASH_PCROP1ER MMIO32(FLASH_MEM_INTERFACE_BASE + 0x28) |
Definition at line 61 of file g4/flash.h.
#define FLASH_PCROP1ER_PCROP1_END_MASK 0x7fff |
Definition at line 179 of file g4/flash.h.
#define FLASH_PCROP1ER_PCROP1_END_SHIFT 0 |
Definition at line 178 of file g4/flash.h.
#define FLASH_PCROP1ER_PCROP_RDP (1 << 31) |
Definition at line 177 of file g4/flash.h.
#define FLASH_PCROP1SR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x24) |
Definition at line 60 of file g4/flash.h.
#define FLASH_PCROP1SR_PCROP1_STRT_MASK 0x7fff |
Definition at line 173 of file g4/flash.h.
#define FLASH_PCROP1SR_PCROP1_STRT_SHIFT 0 |
Definition at line 172 of file g4/flash.h.
#define FLASH_PCROP2ER MMIO32(FLASH_MEM_INTERFACE_BASE + 0x48) |
Definition at line 65 of file g4/flash.h.
#define FLASH_PCROP2ER_PCROP2_END_MASK 0x7fff |
Definition at line 205 of file g4/flash.h.
#define FLASH_PCROP2ER_PCROP2_END_SHIFT 0 |
Definition at line 204 of file g4/flash.h.
#define FLASH_PCROP2SR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x44) |
Definition at line 64 of file g4/flash.h.
#define FLASH_PCROP2SR_PCROP2_STRT_MASK 0x7fff |
Definition at line 200 of file g4/flash.h.
#define FLASH_PCROP2SR_PCROP2_STRT_SHIFT 0 |
Definition at line 199 of file g4/flash.h.
#define FLASH_PDKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x04) |
Definition at line 53 of file g4/flash.h.
#define FLASH_PDKEYR_PDKEY1 ((uint32_t)0x04152637) |
Definition at line 237 of file g4/flash.h.
#define FLASH_PDKEYR_PDKEY2 ((uint32_t)0xfafbfcfd) |
Definition at line 238 of file g4/flash.h.
#define FLASH_SEC1R MMIO32(FLASH_MEM_INTERFACE_BASE + 0x70) |
Definition at line 68 of file g4/flash.h.
#define FLASH_SEC1R_BOOT_LOCK (1 << 16) |
Definition at line 225 of file g4/flash.h.
#define FLASH_SEC1R_SEC_SIZE1_MASK 0xff |
Definition at line 228 of file g4/flash.h.
#define FLASH_SEC1R_SEC_SIZE1_SHIFT 0 |
Definition at line 227 of file g4/flash.h.
#define FLASH_SEC2R MMIO32(FLASH_MEM_INTERFACE_BASE + 0x74) |
Definition at line 69 of file g4/flash.h.
#define FLASH_SEC2R_SEC_SIZE2_MASK 0xff |
Definition at line 233 of file g4/flash.h.
#define FLASH_SEC2R_SEC_SIZE2_SHIFT 0 |
Definition at line 232 of file g4/flash.h.
#define FLASH_SR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x10) |
Definition at line 56 of file g4/flash.h.
#define FLASH_SR_BSY (1 << 16) |
Definition at line 83 of file g4/flash.h.
#define FLASH_SR_EOP (1 << 0) |
Definition at line 94 of file g4/flash.h.
#define FLASH_SR_FASTERR (1 << 9) |
Definition at line 86 of file g4/flash.h.
#define FLASH_SR_MISERR (1 << 8) |
Definition at line 87 of file g4/flash.h.
#define FLASH_SR_OPERR (1 << 1) |
Definition at line 93 of file g4/flash.h.
#define FLASH_SR_OPTVERR (1 << 15) |
Definition at line 84 of file g4/flash.h.
#define FLASH_SR_PGAERR (1 << 5) |
Definition at line 90 of file g4/flash.h.
#define FLASH_SR_PGSERR (1 << 7) |
Definition at line 88 of file g4/flash.h.
#define FLASH_SR_PROGERR (1 << 3) |
Definition at line 92 of file g4/flash.h.
#define FLASH_SR_RDERR (1 << 14) |
Definition at line 85 of file g4/flash.h.
#define FLASH_SR_SIZERR (1 << 6) |
Definition at line 89 of file g4/flash.h.
#define FLASH_SR_WRPERR (1 << 4) |
Definition at line 91 of file g4/flash.h.
#define FLASH_WRP1AR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x2C) |
Definition at line 62 of file g4/flash.h.
#define FLASH_WRP1AR_WRP1A_END_MASK 0x7f |
Definition at line 184 of file g4/flash.h.
#define FLASH_WRP1AR_WRP1A_END_SHIFT 16 |
Definition at line 183 of file g4/flash.h.
#define FLASH_WRP1AR_WRP1A_STRT_MASK 0x7f |
Definition at line 187 of file g4/flash.h.
#define FLASH_WRP1AR_WRP1A_STRT_SHIFT 0 |
Definition at line 186 of file g4/flash.h.
#define FLASH_WRP1BR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x30) |
Definition at line 63 of file g4/flash.h.
#define FLASH_WRP1BR_WRP1B_END_MASK 0x7f |
Definition at line 192 of file g4/flash.h.
#define FLASH_WRP1BR_WRP1B_END_SHIFT 16 |
Definition at line 191 of file g4/flash.h.
#define FLASH_WRP1BR_WRP1B_STRT_MASK 0x7f |
Definition at line 195 of file g4/flash.h.
#define FLASH_WRP1BR_WRP1B_STRT_SHIFT 0 |
Definition at line 194 of file g4/flash.h.
#define FLASH_WRP2AR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x4C) |
Definition at line 66 of file g4/flash.h.
#define FLASH_WRP2AR_WRP2A_END_MASK 0x7f |
Definition at line 210 of file g4/flash.h.
#define FLASH_WRP2AR_WRP2A_END_SHIFT 16 |
Definition at line 209 of file g4/flash.h.
#define FLASH_WRP2AR_WRP2A_STRT_MASK 0x7f |
Definition at line 213 of file g4/flash.h.
#define FLASH_WRP2AR_WRP2A_STRT_SHIFT 0 |
Definition at line 212 of file g4/flash.h.
#define FLASH_WRP2BR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x50) |
Definition at line 67 of file g4/flash.h.
#define FLASH_WRP2BR_WRP2B_END_MASK 0xff |
Definition at line 218 of file g4/flash.h.
#define FLASH_WRP2BR_WRP2B_END_SHIFT 16 |
Definition at line 217 of file g4/flash.h.
#define FLASH_WRP2BR_WRP2B_STRT_MASK 0xff |
Definition at line 221 of file g4/flash.h.
#define FLASH_WRP2BR_WRP2B_STRT_SHIFT 0 |
Definition at line 220 of file g4/flash.h.
void flash_clear_pgaerr_flag | ( | void | ) |
Clear the Programming Alignment Error Flag.
Definition at line 72 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 59 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 86 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 65 of file flash.c.
References FLASH_SR, and FLASH_SR_SIZERR.
Referenced by flash_clear_status_flags().
void flash_clear_wrperr_flag | ( | void | ) |
Clear the Write Protect Error Flag.
Definition at line 79 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 180 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 159 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_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 108 of file flash.c.
References FLASH_CR, and FLASH_CR_OPTLOCK.
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 149 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 122 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 196 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().