Replace flash's bitfields with macros
This commit is contained in:
parent
ebe30a4a7a
commit
dfccfd9591
@ -34,13 +34,15 @@ void flash_configure(enum FlashPreset preset)
|
||||
//apply new configuration
|
||||
switch (preset) {
|
||||
case FLASH_PRESET_LOW_CLOCK_SPEED:
|
||||
regs->ACR.HLFCYA = 0x1; //half cycle for power saving
|
||||
reg_set(regs->ACR, FLASH_ACR_HLFCYA); //half cycle for power saving
|
||||
break;
|
||||
case FLASH_PRESET_MEDIUM_CLOCK_SPEED:
|
||||
regs->ACR.LATENCY = 0x1;
|
||||
reg_reset(regs->ACR, FLASH_ACR_LATENCY);
|
||||
reg_write(regs->ACR, FLASH_ACR_LATENCY, 0x1);
|
||||
break;
|
||||
case FLASH_PRESET_HIGH_CLOCK_SPEED:
|
||||
regs->ACR.LATENCY = 0x2;
|
||||
reg_reset(regs->ACR, FLASH_ACR_LATENCY);
|
||||
reg_write(regs->ACR, FLASH_ACR_LATENCY, 0x2);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@ -11,6 +11,8 @@
|
||||
|
||||
//--includes--------------------------------------------------------------------
|
||||
|
||||
#include "reg.h"
|
||||
|
||||
#include "stdint.h"
|
||||
|
||||
|
||||
@ -29,6 +31,12 @@ union FLASH_ACR {
|
||||
uint32_t word;
|
||||
};
|
||||
|
||||
#define FLASH_ACR_LATENCY reg_def(0, 3)
|
||||
#define FLASH_ACR_HLFCYA reg_def(3, 1)
|
||||
#define FLASH_ACR_PRFTBE reg_def(4, 1)
|
||||
#define FLASH_ACR_PRFTBS reg_def(5, 1)
|
||||
#define FLASH_ACR_reserved1 reg_def(6, 26)
|
||||
|
||||
union FLASH_KEYR {
|
||||
struct __attribute__((packed)) {
|
||||
uint32_t reserved1; //TODO
|
||||
|
||||
Loading…
Reference in New Issue
Block a user