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
71 lines
1.2 KiB
C
71 lines
1.2 KiB
C
/** @file stk_regs.h
|
|
* Module defining systick (STK) registers.
|
|
*
|
|
* Mainly made to be used by the stk module. It is recommanded to go through
|
|
* the functions provided by that module instead of directly using the registers
|
|
* defined here.
|
|
*/
|
|
|
|
#ifndef _STK_REGS_H_
|
|
#define _STK_REGS_H_
|
|
|
|
//--includes--------------------------------------------------------------------
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
//--type definitions------------------------------------------------------------
|
|
|
|
#define STK_BASE_ADDRESS 0xE000E010
|
|
|
|
union STK_CTRL {
|
|
struct {
|
|
uint32_t ENABLE:1;
|
|
uint32_t TICKINT:1;
|
|
uint32_t CLKSOURCE:1;
|
|
uint32_t reserved1:13;
|
|
uint32_t COUNTFLAG:1;
|
|
uint32_t reserved2:15;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union STK_LOAD {
|
|
struct {
|
|
uint32_t RELOAD:24;
|
|
uint32_t reserved1:8;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union STK_VAL {
|
|
struct {
|
|
uint32_t CURRENT:24;
|
|
uint32_t reserved1:8;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union STK_CALIB {
|
|
struct {
|
|
uint32_t TENMS:24;
|
|
uint32_t reserved1:6;
|
|
uint32_t SKEW:1;
|
|
uint32_t NOREF:1;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
struct STK {
|
|
union STK_CTRL CTRL;
|
|
union STK_LOAD LOAD;
|
|
union STK_VAL VAL;
|
|
union STK_CALIB CALIB;
|
|
};
|
|
|
|
|
|
//--functions-------------------------------------------------------------------
|
|
|
|
#endif //_STK_REGS_H_
|
|
|