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
|
//apply new configuration
|
||||||
switch (preset) {
|
switch (preset) {
|
||||||
case FLASH_PRESET_LOW_CLOCK_SPEED:
|
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;
|
break;
|
||||||
case FLASH_PRESET_MEDIUM_CLOCK_SPEED:
|
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;
|
break;
|
||||||
case FLASH_PRESET_HIGH_CLOCK_SPEED:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
//--includes--------------------------------------------------------------------
|
//--includes--------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "reg.h"
|
||||||
|
|
||||||
#include "stdint.h"
|
#include "stdint.h"
|
||||||
|
|
||||||
|
|
||||||
@ -29,6 +31,12 @@ union FLASH_ACR {
|
|||||||
uint32_t word;
|
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 {
|
union FLASH_KEYR {
|
||||||
struct __attribute__((packed)) {
|
struct __attribute__((packed)) {
|
||||||
uint32_t reserved1; //TODO
|
uint32_t reserved1; //TODO
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user