Created:2018-01-19 Last modified:2018-01-19
In AVR microcontroller, the register is defined as a macro.
#define DDRB 0x20;
In STM32, registers are organized with struct
// all structs are defined in stm32f103xb.h typedef struct{ __IO uint32_t CR; __IO uint32_t CFGR; __IO uint32_t CIR; __IO uint32_t APB2RSTR; __IO uint32_t APB1RSTR; __IO uint32_t AHBENR; __IO uint32_t APB2ENR; __IO uint32_t APB1ENR; __IO uint32_t BDCR; __IO uint32_t CSR; }RCC_TypeDef; // all address are defined in stm32f103xb.h #define PERIPH_BASE 0x40000000U #define AHBPERIPH_BASE (PERIPH_BASE + 0x00020000U) #define RCC_BASE (AHBPHERIPH_BASE + 0x00001000U) // all conversions are defined in stm32f103xb.h #define RCC ((RCC_TypeDef *)RCC_BASE) //defined in stm32f1xx.h #define SET_BIT(REG, BIT) ((REG) |= BIT) //The individual bits are defined in stm32f1xx_hal_rcc.h #define RCC_HSE_ON //usage SET_BIT(RCC->CR, RCC_HSE_ON);