typedef struct
{
__IO uint16_t SR;
uint16_t RESERVED0;
__IO uint16_t DR;
uint16_t RESERVED1;
__IO uint16_t BRR;
uint16_t RESERVED2;
__IO uint16_t CR1;
uint16_t RESERVED3;
__IO uint16_t CR2;
uint16_t RESERVED4;
__IO uint16_t CR3;
uint16_t RESERVED5;
__IO uint16_t GTPR;
uint16_t RESERVED6;
} USART_TypeDef;
难道是因为STM32是32位单片机,为了结构体对齐,数据访问方便而定的吗?
谢谢,各位大侠解答。
c
------解决方案--------------------
这样定义是为了与实际的寄存器物理地址对应,便于指针方式访问
定义时直接
USART_TypeDef 0x00xxxxxx//初始地址
即可
------解决方案--------------------
楼主理解错了
定义保留字是和硬件有关系的 可以看芯片手册的寄存器介绍
比如
_IO uint16_t SR;
