配置PB3为Alternate Function
配置输出模式
如何确定端口和PIN地址?
GPIOBBASE = 0X40010C00;
(GPIOBBASE + 0X00) |= unint32_t(0X0) << 12; /配置CNF3,pp模式/
运算符优先级:赋值运算符最后 < 移位运算 < 一元运算符 < 后缀运算符
(GPIOBBASE + 0X00ul) |= unint32_t(0X11UL) << 12U; /配置MODE3,50Mhz/
确定alternate function 时钟是否开启?
RCCBASE = 0X40021000;
(RCCBASE + 0X18ul) |= unint32_t(0x1UL);/RCC_APB2ENR开启*/
U表示无符号型,UL无符号长整型;系统默认数值为int类型,是有符号类型;
配置选择输出的时钟
*(RCCBASE + 0X04ul) |= unint32_t(0x101ul) << 24u;
以下为LL库的内容摘抄
#define LED2_PIN LL_GPIO_PIN_8 #define LED2_GPIO_PORT GPIOB #define LED2_GPIO_CLK_ENABLE() LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOB)/*LED2_GPIO_CLK_ENABLE() 是被调用的函数*/ #define LL_APB2_GRP1_PERIPH_GPIOB RCC_APB2ENR_IOPBEN #define RCC_APB2ENR_IOPBEN_Pos (3U) #define RCC_APB2ENR_IOPBEN_Msk (0x1UL << RCC_APB2ENR_IOPBEN_Pos) /*!< 0x00000008 */ #define RCC_APB2ENR_IOPBEN RCC_APB2ENR_IOPBEN_Msk #define SET_BIT(REG, BIT) ((REG) |= (BIT)) #define RCC_BASE (AHBPERIPH_BASE + 0x00001000UL) 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; #define RCC ((RCC_TypeDef *)RCC_BASE) /**RCC被定义为RCC_TypeDef类型指针**/ SET_BIT(RCC->APB2ENR, Periphs); /**RCC->APB2ENR通过指针访问变量**/