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
126 lines
2.2 KiB
C
126 lines
2.2 KiB
C
/** @file afio_regs.h
|
|
* Module defining the AFIO registers.
|
|
*
|
|
* Mainly made to be used by the afio module. It is recommanded to go through
|
|
* the functions provided by that module instead of directly using the registers
|
|
* defined here.
|
|
*/
|
|
|
|
#ifndef _AFIO_REGS_H_
|
|
#define _AFIO_REGS_H_
|
|
|
|
//--includes--------------------------------------------------------------------
|
|
|
|
#include "stdint.h"
|
|
|
|
|
|
//--type definitions------------------------------------------------------------
|
|
|
|
#define AFIO_BASE_ADDRESS 0x40010000
|
|
|
|
union EVCR {
|
|
struct {
|
|
uint32_t PIN:4;
|
|
uint32_t PORT:3;
|
|
uint32_t EVOE:1;
|
|
uint32_t reserved1:24;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union MAPR {
|
|
struct {
|
|
uint32_t SPI1_REMAP:1;
|
|
uint32_t I2C1_REMAP:1;
|
|
uint32_t USART1_REMAP:1;
|
|
uint32_t USART2_REMAP:1;
|
|
uint32_t USART3_REMAP:2;
|
|
uint32_t TIM1_REMAP:2;
|
|
uint32_t TIM2_REMAP:2;
|
|
uint32_t TIM3_REMAP:2;
|
|
uint32_t TIM4_REMAP:1;
|
|
uint32_t CAN_REMAP:2;
|
|
uint32_t PD01_REMAP:1;
|
|
uint32_t TIM5CH4_REMAP:1;
|
|
uint32_t ADC1_ETRGINJ_REMAP:1;
|
|
uint32_t ADC1_ETRGREG_REMAP:1;
|
|
uint32_t ADC2_ETRGINJ_REMAP:1;
|
|
uint32_t ADC2_ETRGREG_REMAP:1;
|
|
uint32_t reserved1:3;
|
|
uint32_t SWJ_CFG:3;
|
|
uint32_t reserved2:5;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union EXTICR1 {
|
|
struct {
|
|
uint32_t EXTI0:4;
|
|
uint32_t EXTI1:4;
|
|
uint32_t EXTI2:4;
|
|
uint32_t EXTI3:4;
|
|
uint32_t reserved1:16;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union EXTICR2 {
|
|
struct {
|
|
uint32_t EXTI4:4;
|
|
uint32_t EXTI5:4;
|
|
uint32_t EXTI6:4;
|
|
uint32_t EXTI7:4;
|
|
uint32_t reserved1:16;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union EXTICR3 {
|
|
struct {
|
|
uint32_t EXTI8:4;
|
|
uint32_t EXTI9:4;
|
|
uint32_t EXTI10:4;
|
|
uint32_t EXTI11:4;
|
|
uint32_t reserved1:16;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union EXTICR4 {
|
|
struct {
|
|
uint32_t EXTI12:4;
|
|
uint32_t EXTI13:4;
|
|
uint32_t EXTI14:4;
|
|
uint32_t EXTI15:4;
|
|
uint32_t reserved1:16;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
union MAPR2 {
|
|
struct {
|
|
uint32_t reserved1:5;
|
|
uint32_t TIM9_REMAP:1;
|
|
uint32_t TIM10_REMAP:1;
|
|
uint32_t TIM11_REMAP:1;
|
|
uint32_t TIM13_REMAP:1;
|
|
uint32_t TIM14_REMAP:1;
|
|
uint32_t FSMC_NADV:1;
|
|
uint32_t reserved2:21;
|
|
};
|
|
uint32_t word;
|
|
};
|
|
|
|
struct AFIO {
|
|
union EVCR EVCR;
|
|
union MAPR MAPR;
|
|
union EXTICR1 EXTICR1;
|
|
union EXTICR2 EXTICR2;
|
|
union EXTICR3 EXTICR3;
|
|
union EXTICR4 EXTICR4;
|
|
union MAPR2 MAPR2;
|
|
};
|
|
|
|
#endif //_AFIO_REGS_H_
|
|
|