Add flash.h
This commit is contained in:
35
src/flash.h
Normal file
35
src/flash.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef FLASH_H_
|
||||
#define FLASH_H_
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
struct flash {
|
||||
volatile uint32_t ACR; // Flash access control register
|
||||
volatile uint32_t KEYR; // Flash key register
|
||||
volatile uint32_t OPTKEYR; // Flash option key register
|
||||
volatile uint32_t SR; // Flash status register
|
||||
volatile uint32_t CR; // Flash control register
|
||||
volatile uint32_t OPTCR; // Flash option control register
|
||||
};
|
||||
|
||||
#define FLASH_BASE_ADDR (0x40023C00U)
|
||||
#define FLASH ((struct flash *) FLASH_BASE_ADDR)
|
||||
|
||||
// ACR Register
|
||||
// Data cache enable
|
||||
|
||||
#define FLASH_ACR_DCEN_BIT 10
|
||||
#define FLASH_ACR_DCEN_ENABLE (1 <<FLASH_ACR_DCEN_BIT)
|
||||
|
||||
// Instruction cache enable
|
||||
#define FLASH_ACR_ICEN_BIT 9
|
||||
#define FLASH_ACR_ICEN_ENABLE (1 <<FLASH_ACR_ICEN_BIT)
|
||||
|
||||
// Latency
|
||||
#define FLASH_ACR_LATENCY_3_WAIT_STATES (0x0111)
|
||||
|
||||
#define FLASH_ACR_LATENCY_BIT 0 // Bits [3:0]
|
||||
#define FLASH_ACR_LATENCY_MASK (0b1111)
|
||||
#define FLASH_ACR_LATENCY(latency) ((latency & FLASH_ACR_LATENCY_MASK) << FLASH_ACR_LATENCY_BIT)
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user