libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Defined Constants and Types for the STM32F0xx Flash memory More...
Modules | |
Option Byte Addresses | |
FLASH Wait States | |
Functions | |
void | flash_clear_pgerr_flag (void) |
Unlock the Flash Program and Erase Controller. More... | |
void | flash_clear_wrprterr_flag (void) |
Clear the Write Protect Error Status Flag. More... | |
uint32_t | flash_get_status_flags (void) |
Read All Status Flags. More... | |
void | flash_program_word (uint32_t address, uint32_t data) |
Program a 32 bit Word to FLASH. More... | |
void | flash_program_half_word (uint32_t address, uint16_t data) |
Program a Half Word to FLASH. More... | |
void | flash_erase_page (uint32_t page_address) |
Erase a Page of FLASH. More... | |
void | flash_erase_all_pages (void) |
Erase All FLASH. More... | |
void | flash_erase_option_bytes (void) |
Erase All Option Bytes. More... | |
void | flash_program_option_bytes (uint32_t address, uint16_t data) |
Program the Option Bytes. More... | |
Defined Constants and Types for the STM32F0xx Flash memory
LGPL License Terms libopencm3 License
#define FLASH_ACR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x00) |
Definition at line 40 of file flash_common_f01.h.
#define FLASH_ACR_LATENCY_MASK 7 |
Definition at line 61 of file flash_common_f01.h.
#define FLASH_ACR_LATENCY_SHIFT 0 |
Definition at line 60 of file flash_common_f01.h.
#define FLASH_ACR_PRFTBE (1 << 4) |
Definition at line 64 of file flash_common_f01.h.
#define FLASH_ACR_PRFTBS (1 << 5) |
Definition at line 63 of file flash_common_f01.h.
#define FLASH_ACR_PRFTEN FLASH_ACR_PRFTBE |
Compatibility define.
Definition at line 66 of file flash_common_f01.h.
#define FLASH_AR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x14) |
Definition at line 45 of file flash_common_f01.h.
#define FLASH_AR2 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x54) |
Definition at line 52 of file flash_common_f01.h.
#define FLASH_CR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x10) |
Definition at line 44 of file flash_common_f01.h.
#define FLASH_CR2 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x50) |
Definition at line 51 of file flash_common_f01.h.
#define FLASH_CR_EOPIE (1 << 12) |
Definition at line 77 of file flash_common_f01.h.
#define FLASH_CR_ERRIE (1 << 10) |
Definition at line 78 of file flash_common_f01.h.
#define FLASH_CR_LOCK (1 << 7) |
Definition at line 80 of file flash_common_f01.h.
#define FLASH_CR_MER (1 << 2) |
Definition at line 84 of file flash_common_f01.h.
#define FLASH_CR_OBL_LAUNCH (1 << 13) |
Definition at line 80 of file f0/flash.h.
#define FLASH_CR_OPTER (1 << 5) |
Definition at line 82 of file flash_common_f01.h.
#define FLASH_CR_OPTPG (1 << 4) |
Definition at line 83 of file flash_common_f01.h.
#define FLASH_CR_OPTWRE (1 << 9) |
Definition at line 79 of file flash_common_f01.h.
#define FLASH_CR_PER (1 << 1) |
Definition at line 85 of file flash_common_f01.h.
#define FLASH_CR_PG (1 << 0) |
Definition at line 86 of file flash_common_f01.h.
#define FLASH_CR_STRT (1 << 6) |
Definition at line 81 of file flash_common_f01.h.
#define FLASH_KEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x04) |
Definition at line 41 of file flash_common_f01.h.
#define FLASH_KEYR2 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x44) |
Definition at line 49 of file flash_common_f01.h.
#define FLASH_KEYR_KEY1 ((uint32_t)0x45670123) |
Definition at line 95 of file flash_common_f01.h.
#define FLASH_KEYR_KEY2 ((uint32_t)0xcdef89ab) |
Definition at line 96 of file flash_common_f01.h.
#define FLASH_OBR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x1C) |
Definition at line 46 of file flash_common_f01.h.
#define FLASH_OBR_BOOT_SEL (1 << 15) |
Definition at line 89 of file f0/flash.h.
#define FLASH_OBR_DATA0 (0xFF << FLASH_OBR_DATA0_SHIFT) |
Definition at line 87 of file f0/flash.h.
#define FLASH_OBR_DATA0_SHIFT 16 |
Definition at line 86 of file f0/flash.h.
#define FLASH_OBR_DATA1 (0xFF << FLASH_OBR_DATA1_SHIFT) |
Definition at line 85 of file f0/flash.h.
#define FLASH_OBR_DATA1_SHIFT 24 |
Definition at line 84 of file f0/flash.h.
#define FLASH_OBR_NBOOT0 (1 << 11) |
Definition at line 93 of file f0/flash.h.
#define FLASH_OBR_NBOOT1 (1 << 12) |
Definition at line 92 of file f0/flash.h.
#define FLASH_OBR_NRST_STDBY (1 << 10) |
Definition at line 94 of file f0/flash.h.
#define FLASH_OBR_NRST_STOP (1 << 9) |
Definition at line 95 of file f0/flash.h.
#define FLASH_OBR_OPTERR (1 << 0) |
Definition at line 91 of file flash_common_f01.h.
#define FLASH_OBR_RAM_PARITY_CHECK (1 << 14) |
Definition at line 90 of file f0/flash.h.
#define FLASH_OBR_RDPRT (3 << FLASH_OBR_RDPRT_SHIFT) |
Definition at line 97 of file f0/flash.h.
#define FLASH_OBR_RDPRT_L0 (0 << FLASH_OBR_RDPRT_SHIFT) |
Definition at line 98 of file f0/flash.h.
#define FLASH_OBR_RDPRT_L1 (1 << FLASH_OBR_RDPRT_SHIFT) |
Definition at line 99 of file f0/flash.h.
#define FLASH_OBR_RDPRT_L2 (3 << FLASH_OBR_RDPRT_SHIFT) |
Definition at line 100 of file f0/flash.h.
#define FLASH_OBR_RDPRT_SHIFT 1 |
Definition at line 90 of file flash_common_f01.h.
#define FLASH_OBR_VDDA_MONITOR (1 << 13) |
Definition at line 91 of file f0/flash.h.
#define FLASH_OBR_WDG_SW (1 << 8) |
Definition at line 96 of file f0/flash.h.
Definition at line 56 of file flash_common_f01.h.
#define FLASH_OPTKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x08) |
Definition at line 42 of file flash_common_f01.h.
#define FLASH_OPTKEYR_KEY1 FLASH_KEYR_KEY1 |
Definition at line 98 of file flash_common_f01.h.
#define FLASH_OPTKEYR_KEY2 FLASH_KEYR_KEY2 |
Definition at line 99 of file flash_common_f01.h.
#define FLASH_RDP_L0 ((uint8_t)0xaa) |
Definition at line 107 of file f0/flash.h.
#define FLASH_RDP_L1 ((uint8_t)0xf0) /* any value */ |
Definition at line 108 of file f0/flash.h.
#define FLASH_RDP_L2 ((uint8_t)0xcc) |
Definition at line 109 of file f0/flash.h.
#define FLASH_SR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x0C) |
Definition at line 43 of file flash_common_f01.h.
#define FLASH_SR2 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x4C) |
Definition at line 50 of file flash_common_f01.h.
#define FLASH_SR_BSY (1 << 0) |
Definition at line 73 of file flash_common_f01.h.
#define FLASH_SR_BSY (1 << 0) |
Definition at line 76 of file f0/flash.h.
#define FLASH_SR_EOP (1 << 5) |
Definition at line 70 of file flash_common_f01.h.
#define FLASH_SR_EOP (1 << 5) |
Definition at line 73 of file f0/flash.h.
#define FLASH_SR_PGERR (1 << 2) |
Definition at line 72 of file flash_common_f01.h.
#define FLASH_SR_PGERR (1 << 2) |
Definition at line 75 of file f0/flash.h.
#define FLASH_SR_WRPRTERR (1 << 4) |
Definition at line 71 of file flash_common_f01.h.
#define FLASH_SR_WRPRTERR (1 << 4) |
Definition at line 74 of file f0/flash.h.
#define FLASH_WRPR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x20) |
Definition at line 47 of file flash_common_f01.h.
void flash_clear_pgerr_flag | ( | void | ) |
Unlock the Flash Program and Erase Controller.
This enables write access to the Flash memory. It is locked by default on reset.
Clear the Programming Error Status Flag
Definition at line 42 of file flash_common_f01.c.
References FLASH_SR, and FLASH_SR_PGERR.
Referenced by flash_clear_status_flags().
void flash_clear_wrprterr_flag | ( | void | ) |
Clear the Write Protect Error Status Flag.
Definition at line 52 of file flash_common_f01.c.
References FLASH_SR, and FLASH_SR_WRPRTERR.
Referenced by flash_clear_status_flags().
void flash_erase_all_pages | ( | void | ) |
Erase All FLASH.
This performs all operations necessary to erase all user pages in the FLASH memory. The information block is unaffected.
Definition at line 143 of file flash.c.
References FLASH_CR, FLASH_CR_MER, FLASH_CR_STRT, and flash_wait_for_last_operation().
void flash_erase_option_bytes | ( | void | ) |
Erase All Option Bytes.
This performs all operations necessary to erase the option bytes. These must first be fully erased before attempting to program them, therefore it is recommended to check these after an erase attempt.
Definition at line 96 of file flash_common_f01.c.
References FLASH_CR, FLASH_CR_OPTER, FLASH_CR_OPTWRE, FLASH_CR_STRT, flash_unlock_option_bytes(), and flash_wait_for_last_operation().
void flash_erase_page | ( | uint32_t | page_address | ) |
Erase a Page of FLASH.
This performs all operations necessary to erase a page in FLASH memory. The page should be checked to ensure that it was properly erased. A page must first be fully erased before attempting to program it.
Note that the page sizes differ between devices. See the reference manual or the FLASH programming manual for details.
[in] | page_address | Full address of flash page to be erased. |
Definition at line 123 of file flash.c.
References FLASH_AR, FLASH_CR, FLASH_CR_PER, FLASH_CR_STRT, and flash_wait_for_last_operation().
uint32_t flash_get_status_flags | ( | void | ) |
Read All Status Flags.
The programming error, end of operation, write protect error and busy flags are returned in the order of appearance in the status register.
Definition at line 76 of file flash.c.
References FLASH_SR, FLASH_SR_BSY, FLASH_SR_EOP, FLASH_SR_PGERR, and FLASH_SR_WRPRTERR.
Referenced by flash_wait_for_last_operation().
void flash_program_half_word | ( | uint32_t | address, |
uint16_t | data | ||
) |
Program a Half Word to FLASH.
This performs all operations necessary to program a 16 bit word to FLASH memory. The program error flag should be checked separately for the event that memory was not properly erased.
Status bit polling is used to detect end of operation.
[in] | address | Full address of flash half word to be programmed. |
[in] | data | half word to write |
Definition at line 97 of file flash.c.
References FLASH_CR, FLASH_CR_PG, flash_wait_for_last_operation(), and MMIO16.
Referenced by flash_program_word().
void flash_program_option_bytes | ( | uint32_t | address, |
uint16_t | data | ||
) |
Program the Option Bytes.
This performs all operations necessary to program the option bytes. The write protect error flag should be checked separately for the event that an option byte had not been properly erased before calling this function.
Only the lower 8 bits of the data is significant.
[in] | address | Address of option byte from Option Byte Addresses. |
[in] | data | value to write |
Definition at line 123 of file flash_common_f01.c.
References FLASH_CR, FLASH_CR_OPTPG, FLASH_CR_OPTWRE, flash_unlock_option_bytes(), flash_wait_for_last_operation(), and MMIO16.
void flash_program_word | ( | uint32_t | address, |
uint32_t | data | ||
) |
Program a 32 bit Word to FLASH.
This performs all operations necessary to program a 32 bit word to FLASH memory. The program error flag should be checked separately for the event that memory was not properly erased.
Status bit polling is used to detect end of operation.
[in] | address | Full address of flash word to be programmed. |
[in] | data | word to write |
Definition at line 82 of file flash_common_f01.c.
References flash_program_half_word().