From 9052aac1b3f6a0ce4e70409956bd2e773b2b26af Mon Sep 17 00:00:00 2001 From: Steins7 Date: Sat, 13 May 2023 15:42:11 +0200 Subject: [PATCH] Create afio's register map --- drivers/afio_regs.h | 125 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 drivers/afio_regs.h diff --git a/drivers/afio_regs.h b/drivers/afio_regs.h new file mode 100644 index 0000000..55bdde0 --- /dev/null +++ b/drivers/afio_regs.h @@ -0,0 +1,125 @@ +/** @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 _IO_REGS_H_ +#define _IO_REGS_H_ + +//--includes-------------------------------------------------------------------- + +#include "stdint.h" + + +//--type definitions------------------------------------------------------------ + +#define AFIO_BASE_ADDRESS 0x40010000 + +union EVCR { + struct __attribute__((packed)) { + uint32_t PIN:4; + uint32_t PORT:3; + uint32_t EVOE:1; + uint32_t reserved1:24; + }; + uint32_t word; +}; + +union MAPR { + struct __attribute__((packed)) { + 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 __attribute__((packed)) { + 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 __attribute__((packed)) { + 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 __attribute__((packed)) { + 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 __attribute__((packed)) { + 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 __attribute__((packed)) { + 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 __attribute__((packed)) 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_ +