libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
g0/flash.h File Reference
Include dependency graph for g0/flash.h:

Go to the source code of this file.

Macros

#define FLASH_ACR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x00)
 
#define FLASH_KEYR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x08)
 
#define FLASH_OPTKEYR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x0c)
 
#define FLASH_SR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x10)
 
#define FLASH_CR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x14)
 
#define FLASH_ECCR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x18)
 
#define FLASH_OPTR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x20)
 
#define FLASH_PCROP1ASR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x24)
 
#define FLASH_PCROP1AER   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x28)
 
#define FLASH_WRP1AR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x2c)
 
#define FLASH_WRP1BR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x30)
 
#define FLASH_PCROP1BSR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x34)
 
#define FLASH_PCROP1BER   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x38)
 
#define FLASH_SECR   MMIO32(FLASH_MEM_INTERFACE_BASE + 0x80)
 
#define FLASH_ACR_DBG_SWEN   (1 << 18)
 FLASH_ACR_DBG_SWEN Debug access software enable. More...
 
#define FLASH_ACR_EMPTY   (1 << 16)
 FLASH_ACR_EMPTY Flash User area empty. More...
 
#define FLASH_ACR_ICRST   (1 << 11)
 FLASH_ACR_ICRST Instruction cache reset. More...
 
#define FLASH_ACR_ICEN   (1 << 9)
 FLASH_ACR_ICEN Instruction cache enable. More...
 
#define FLASH_ACR_PRFTEN   (1 << 8)
 FLASH_ACR_PRFTEN Prefetch enable. More...
 
#define FLASH_ACR_LATENCY_SHIFT   0
 
#define FLASH_ACR_LATENCY_MASK   0x7
 
#define FLASH_ACR_LATENCY_0WS   0x00
 
#define FLASH_ACR_LATENCY_1WS   0x01
 
#define FLASH_ACR_LATENCY_2WS   0x02
 
#define FLASH_KEYR_KEY1   ((uint32_t)0x45670123)
 FLASH_KEYR_KEY1 Flash key 1. More...
 
#define FLASH_KEYR_KEY2   ((uint32_t)0xcdef89ab)
 FLASH_KEYR_KEY2 Flash key 2. More...
 
#define FLASH_OPTKEYR_KEY1   ((uint32_t)0x08192a3b)
 FLASH_OPTKEYR_KEY1 Option key 1. More...
 
#define FLASH_OPTKEYR_KEY2   ((uint32_t)0x4c5d6e7f)
 FLASH_OPTKEYR_KEY2 Option key 2. More...
 
#define FLASH_SR_CFGBSY   (1 << 18)
 FLASH_SR_CFGBSY Programming or erase configuration busy. More...
 
#define FLASH_SR_BSY   (1 << 16)
 FLASH_SR_BSY Busy. More...
 
#define FLASH_SR_OPTVERR   (1 << 15)
 FLASH_SR_OPTVERR Option and Engineering bits loading validity error. More...
 
#define FLASH_SR_RDERR   (1 << 14)
 FLASH_SR_RDERR PCROP read error. More...
 
#define FLASH_SR_FASTERR   (1 << 9)
 FLASH_SR_FASTERR Fast programming error. More...
 
#define FLASH_SR_MISERR   (1 << 8)
 FLASH_SR_MISERR Fast programming data miss error. More...
 
#define FLASH_SR_PGSERR   (1 << 7)
 FLASH_SR_PGSERR Programming sequence error. More...
 
#define FLASH_SR_SIZERR   (1 << 6)
 FLASH_SR_SIZERR Size error. More...
 
#define FLASH_SR_PGAERR   (1 << 5)
 FLASH_SR_PGAERR Programming alignment error. More...
 
#define FLASH_SR_WRPERR   (1 << 4)
 FLASH_SR_WRPERR Write protected error. More...
 
#define FLASH_SR_PROGERR   (1 << 3)
 FLASH_SR_PROGERR Programming error. More...
 
#define FLASH_SR_OPERR   (1 << 1)
 FLASH_SR_OPERR Operation error. More...
 
#define FLASH_SR_EOP   (1 << 0)
 FLASH_SR_EOP End of operation. More...
 
#define FLASH_CR_LOCK   (1 << 31)
 FLASH_CR_LOCK FLASH_CR Lock. More...
 
#define FLASH_CR_OPTLOCK   (1 << 30)
 FLASH_CR_OPTLOCK Options Lock. More...
 
#define FLASH_CR_SEC_PROT   (1 << 28)
 FLASH_CR_SEC_PROT Securable memory area protection enable. More...
 
#define FLASH_CR_OBL_LAUNCH   (1 << 27)
 FLASH_CR_OBL_LAUNCH Force the option byte loading. More...
 
#define FLASH_CR_RDERRIE   (1 << 26)
 FLASH_CR_RDERRIE PCROP read error interrupt enable. More...
 
#define FLASH_CR_ERRIE   (1 << 25)
 FLASH_CR_ERRIE Error interrupt enable. More...
 
#define FLASH_CR_EOPIE   (1 << 24)
 FLASH_CR_EOPIE End of operation interrupt enable. More...
 
#define FLASH_CR_FSTPG   (1 << 18)
 FLASH_CR_FSTPG Fast programming. More...
 
#define FLASH_CR_OPTSTRT   (1 << 17)
 FLASH_CR_OPTSTRT Options modification start. More...
 
#define FLASH_CR_STRT   (1 << 16)
 FLASH_CR_STRT Start. More...
 
#define FLASH_CR_PNB_SHIFT   3
 
#define FLASH_CR_PNB_MASK   0x3f
 
#define FLASH_CR_MER   (1 << 2)
 FLASH_CR_MER Mass erase. More...
 
#define FLASH_CR_PER   (1 << 1)
 FLASH_CR_PER Page erase. More...
 
#define FLASH_CR_PG   (1 << 0)
 FLASH_CR_PG Programming. More...
 
#define FLASH_ECCR_ECCD   (1 << 31)
 FLASH_ECCR_ECCD ECC detection. More...
 
#define FLASH_ECCR_ECCC   (1 << 30)
 FLASH_ECCR_ECCC ECC correction. More...
 
#define FLASH_ECCR_ECCIE   (1 << 24)
 FLASH_ECCR_ECCIE ECC correction interrupt enable. More...
 
#define FLASH_ECCR_SYSF_ECC   (1 << 20)
 FLASH_ECCR_SYSF_ECC ECC fail for Corrected ECC Error or Double ECC Error in info block. More...
 
#define FLASH_ECCR_ADDR_ECC_SHIFT   0
 
#define FLASH_ECCR_ADDR_ECC_MASK   0x3fff
 
#define FLASH_OPTR_IRHEN   (1 << 29)
 FLASH_OPTR_IRHEN Internal reset holder enable bit. More...
 
#define FLASH_OPTR_NRST_MODE_SHIFT   27
 
#define FLASH_OPTR_NRST_MODE_MASK   0x03
 
#define FLASH_OPTR_NRST_MODE_RESET   1
 
#define FLASH_OPTR_NRST_MODE_GPIO   2
 
#define FLASH_OPTR_NRST_MODE_BIDIR   3
 
#define FLASH_OPTR_nBOOT0   (1 << 26)
 FLASH_OPTR_nBOOT0 nBOOT0 option bit. More...
 
#define FLASH_OPTR_nBOOT1   (1 << 25)
 FLASH_OPTR_nBOOT1 Boot configuration. More...
 
#define FLASH_OPTR_nBOOT_SEL   (1 << 24)
 FLASH_OPTR_nBOOT_SEL nBOOT_SEL. More...
 
#define FLASH_OPTR_RAM_PARITY_CHECK   (1 << 22)
 FLASH_OPTR_RAM_PARITY_CHECK SRAM parity check control. More...
 
#define FLASH_OPTR_WWDG_SW   (1 << 19)
 FLASH_OPTR_WWDG_SW Window watchdog selection. More...
 
#define FLASH_OPTR_IWDG_STDBY   (1 << 18)
 FLASH_OPTR_IWDG_STDBY Independent watchdog counter freeze in Standby mode. More...
 
#define FLASH_OPTR_IWDG_STOP   (1 << 17)
 FLASH_OPTR_IWDG_STOP Independent watchdog counter freeze in Stop mode. More...
 
#define FLASH_OPTR_IDWG_SW   (1 << 16)
 FLASH_OPTR_IDWG_SW Independent watchdog selection. More...
 
#define FLASH_OPTR_nRSTS_HDW   (1 << 15)
 FLASH_OPTR_nRSTS_HDW nRSTS_HDW. More...
 
#define FLASH_OPTR_nRST_STDBY   (1 << 14)
 FLASH_OPTR_nRST_STDBY nRST_STDBY. More...
 
#define FLASH_OPTR_nRST_STOP   (1 << 13)
 FLASH_OPTR_nRST_STOP nRST_STOP. More...
 
#define FLASH_OPTR_BORR_LEV_SHIFT   11
 
#define FLASH_OPTR_BORR_LEV_MASK   0x03
 
#define FLASH_OPTR_BORR_LEV_2V1   0
 
#define FLASH_OPTR_BORR_LEV_2V3   1
 
#define FLASH_OPTR_BORR_LEV_2V6   2
 
#define FLASH_OPTR_BORR_LEV_2V9   3
 
#define FLASH_OPTR_BORF_LEV_SHIFT   9
 
#define FLASH_OPTR_BORF_LEV_MASK   0x03
 
#define FLASH_OPTR_BORF_LEV_2V0   0
 
#define FLASH_OPTR_BORF_LEV_2V2   1
 
#define FLASH_OPTR_BORF_LEV_2V5   2
 
#define FLASH_OPTR_BORF_LEV_2V8   3
 
#define FLASH_OPTR_BOREN   (1 << 8)
 FLASH_OPTR_BOREN BOR reset Level. More...
 
#define FLASH_OPTR_RDP_SHIFT   0
 
#define FLASH_OPTR_RDP_MASK   0xff
 
#define FLASH_OPTR_RDP_LEVEL_0   0xAA
 
#define FLASH_OPTR_RDP_LEVEL_1   0xBB /* or any other value. */
 
#define FLASH_OPTR_RDP_LEVEL_2   0xCC
 

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. 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 Protected Error Flag. More...
 
void flash_clear_operr_flag (void)
 Clear the Operation Error Status Flag. More...
 
void flash_clear_eop_flag (void)
 Clear the End of Operation Flag. More...
 
void flash_clear_status_flags (void)
 Clear All Status Flags. More...
 
void flash_wait_for_last_operation (void)
 Wait until Last Flash Operation has Ended. More...
 
void flash_program_double_word (uint32_t address, uint64_t data)
 Program a 64bits word to FLASH. More...
 
void flash_program (uint32_t address, uint8_t *data, uint32_t len)
 Program a Data Block to FLASH. 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_icache_enable (void)
 Enable instruction cache. More...
 
void flash_icache_disable (void)
 Disable instruction cache. More...
 
void flash_icache_reset (void)
 Reset instruction cache. More...
 
void flash_unlock_progmem (void)
 Unlock program memory. More...
 
void flash_lock_progmem (void)
 lock program memory More...
 
void flash_lock_option_bytes (void)
 Lock Option Byte Access. More...