每个外设的寄存器都通过结构体包裹,结构体的实体被分配到该组寄存器的基地址,这样所有组内的寄存器就都有了定位,使用起来十分方便。你可以不用那些库函数,但至少可以使用这些定义好的结构体,方便你的编程。 下面是定时器(TIM)的寄存器结构体的定义: typedef struct { vu16 CR1; TIM.CR1 u16 RESERVED0; vu16 CR2; TIM.CR2 u16 RESERVED1; vu16 SMCR; TIM.SMCR u16 RESERVED2; vu16 DIER; u16 RESERVED3; vu16 SR; u16 RESERVED4; vu16 EGR; u16 RESERVED5; vu16 CCMR1; u16 RESERVED6; vu16 CCMR2; u16 RESERVED7; vu16 CCER; u16 RESERVED8; vu16 CNT; u16 RESERVED9; vu16 PSC; u16 RESERVED10; vu16 ARR; u16 RESERVED11[3]; vu16 CCR1; u16 RESERVED12; vu16 CCR2; u16 RESERVED13; vu16 CCR3; u16 RESERVED14; vu16 CCR4; u16 RESERVED15[3]; vu16 DCR; u16 RESERVED16; vu16 DMAR; u16 RESERVED17; } TIM_TypeDef;
你可以在ST的网站上下载这个固件库研究一下: 使用手册 程序包 |