26#ifdef LIBOPENCM3_FLASH_H
28#ifndef LIBOPENCM3_FLASH_COMMON_L01_H
29#define LIBOPENCM3_FLASH_COMMON_L01_H
36#define FLASH_ACR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x00)
37#define FLASH_PECR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x04)
38#define FLASH_PDKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x08)
39#define FLASH_PEKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x0C)
40#define FLASH_PRGKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x10)
41#define FLASH_OPTKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x14)
42#define FLASH_SR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x18)
43#define FLASH_OBR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x1c)
44#define FLASH_WRPR1 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x20)
45#define FLASH_WRPR2 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x80)
48#define FLASH_ACR_RUNPD (1 << 4)
49#define FLASH_ACR_SLEEPPD (1 << 3)
50#define FLASH_ACR_PRFTEN (1 << 1)
51#define FLASH_ACR_LATENCY_SHIFT 0
52#define FLASH_ACR_LATENCY_MASK 1
56#define FLASH_ACR_LATENCY_0WS 0x00
57#define FLASH_ACR_LATENCY_1WS 0x01
61#define FLASH_PECR_OBL_LAUNCH (1 << 18)
62#define FLASH_PECR_ERRIE (1 << 17)
63#define FLASH_PECR_EOPIE (1 << 16)
64#define FLASH_PECR_PARALLBANK (1 << 15)
65#define FLASH_PECR_FPRG (1 << 10)
66#define FLASH_PECR_ERASE (1 << 9)
67#define FLASH_PECR_FTDW (1 << 8)
68#define FLASH_PECR_DATA (1 << 4)
69#define FLASH_PECR_PROG (1 << 3)
70#define FLASH_PECR_OPTLOCK (1 << 2)
71#define FLASH_PECR_PRGLOCK (1 << 1)
72#define FLASH_PECR_PELOCK (1 << 0)
75#define FLASH_PDKEYR_PDKEY1 ((uint32_t)0x04152637)
76#define FLASH_PDKEYR_PDKEY2 ((uint32_t)0xFAFBFCFD)
79#define FLASH_PEKEYR_PEKEY1 ((uint32_t)0x89ABCDEF)
80#define FLASH_PEKEYR_PEKEY2 ((uint32_t)0x02030405)
83#define FLASH_PRGKEYR_PRGKEY1 ((uint32_t)0x8C9DAEBF)
84#define FLASH_PRGKEYR_PRGKEY2 ((uint32_t)0x13141516)
87#define FLASH_OPTKEYR_KEY1 ((uint32_t)0xFBEAD9C8)
88#define FLASH_OPTKEYR_KEY2 ((uint32_t)0x24252627)
91#define FLASH_SR_OPTVERR (1 << 11)
92#define FLASH_SR_SIZEERR (1 << 10)
93#define FLASH_SR_PGAERR (1 << 9)
94#define FLASH_SR_WRPERR (1 << 8)
95#define FLASH_SR_READY (1 << 3)
96#define FLASH_SR_ENDHV (1 << 2)
97#define FLASH_SR_EOP (1 << 1)
98#define FLASH_SR_BSY (1 << 0)
101#define FLASH_OBR_BFB2 (1 << 23)
102#define FLASH_OBR_NRST_STDBY (1 << 22)
103#define FLASH_OBR_NRST_STOP (1 << 21)
104#define FLASH_OBR_IWDG_SW (1 << 20)
105#define FLASH_OBR_BOR_OFF (0x0 << 16)
106#define FLASH_OBR_BOR_LEVEL_1 (0x8 << 16)
107#define FLASH_OBR_BOR_LEVEL_2 (0x9 << 16)
108#define FLASH_OBR_BOR_LEVEL_3 (0xa << 16)
109#define FLASH_OBR_BOR_LEVEL_4 (0xb << 16)
110#define FLASH_OBR_BOR_LEVEL_5 (0xc << 16)
111#define FLASH_OBR_RDPRT_LEVEL_0 (0xaa)
112#define FLASH_OBR_RDPRT_LEVEL_1 (0x00)
113#define FLASH_OBR_RDPRT_LEVEL_2 (0xcc)
146#error "flash_common_l01.h should not be included directly, only via flash.h"
void flash_erase_page(uint32_t page_address)
Erase a page in flash.
void flash_lock_pecr(void)
void eeprom_program_words(uint32_t address, uint32_t *data, int length_in_words)
Write a block of words to eeprom.
void flash_unlock_progmem(void)
Unlock program memory itself.
void flash_unlock_acr(void)
Unlock RUN_PD bit from FLASH_ACR register.
void flash_unlock_pecr(void)
Unlock primary access to the flash control/erase block You must call this before using any of the low...
void flash_lock_option_bytes(void)
void flash_lock_progmem(void)
void eeprom_program_word(uint32_t address, uint32_t data)
Write a word to eeprom.
void flash_program_half_page(uint32_t *dst, void *buf)
Write a half page from buf to dst.