A while back, macros had to be put in place to avoid letting the compiler directly use the bitfields. This was necessary because the compiler used strb instruction which only write bytes. On the AHB bus, byte writes are transformed into word writes by repeating the byte, which caused mayhem in the registers. After a lot of research, turns out the packed attribute stops the compiler from does optimal (word) writes and isn't needed anyway. Removing them fixes the issue
98 lines
1.6 KiB
C
98 lines
1.6 KiB
C
/** @file flash_regs.h
|
|
* Module defining flash memory interface registers.
|
|
*
|
|
* Mainly made to be used by the rcc module. It is recommanded to go through
|
|
* the functions provided by that module instead of directly using the registers
|
|
* defined here.
|
|
*/
|
|
|
|
#ifndef _FLASH_REGS_H_
|
|
#define _FLASH_REGS_H_
|
|
|
|
//--includes--------------------------------------------------------------------
|
|
|
|
#include "stdint.h"
|
|
|
|
|
|
//--type definitions------------------------------------------------------------
|
|
|
|
#define FLASH_BASE_ADDRESS 0x40022000
|
|
|
|
union FLASH_ACR {
|
|
struct {
|
|
uint32_t LATENCY:3;
|
|
uint32_t HLFCYA:1;
|
|
uint32_t PRFTBE:1;
|
|
uint32_t PRFTBS:1;
|
|
uint32_t reserved1:26;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union FLASH_KEYR {
|
|
struct {
|
|
uint32_t reserved1; //TODO
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union FLASH_OPTKEYR {
|
|
struct {
|
|
uint32_t reserved1; //TODO
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union FLASH_SR {
|
|
struct {
|
|
uint32_t reserved1; //TODO
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union FLASH_CR {
|
|
struct {
|
|
uint32_t reserved1; //TODO
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union FLASH_AR {
|
|
struct {
|
|
uint32_t reserved1; //TODO
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union FLASH_OBR {
|
|
struct {
|
|
uint32_t reserved1; //TODO
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union FLASH_WRPR {
|
|
struct {
|
|
uint32_t reserved1; //TODO
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
struct FLASH {
|
|
union FLASH_ACR ACR;
|
|
union FLASH_KEYR KEYR;
|
|
union FLASH_OPTKEYR OPTKEYR;
|
|
union FLASH_SR SR;
|
|
union FLASH_CR CR;
|
|
union FLASH_AR AR;
|
|
uint32_t reserved1;
|
|
union FLASH_OBR OBR;
|
|
union FLASH_WRPR WRPR;
|
|
};
|
|
|
|
|
|
//--functions-------------------------------------------------------------------
|
|
|
|
#endif //_FLASH_REGS_H_
|
|
|