位操作:打开位,关闭位,移位运算符
移位运算符
左移
右移
掩码
打开位
掩码按照需要设置的位设置
关闭位
检查位的值
点击查看代码
/*CONFIGURE PA8为Alternate Function*/
#define GPIOBBASE 0X40010C00ul
#define GPIOABASE 0x40010800UL
#define RCCBASE 0X40021000ul
/*HSION, open bit 0*/
*(volatile uint32_t*)(RCCBASE + 0X0) |=(0x1ul) << 0u;
while((*(volatile uint32_t*)RCCBASE) & 0x1ul != 0x1ul );
/*配置PA8,CNF8,alternate pp模式, close bit [3.2]*/
*(volatile uint32_t*)(GPIOABASE + 0X00) |= (~0x2ul) << 2u;
/*配置PB3,MODE3,50Mhz*/
*(volatile uint32_t*)(GPIOABASE + 0X00) |= (0x3ul) << 0u;
*(volatile uint32_t*)(RCCBASE + 0X18) |= (0x1UL);/*RCC_APB2ENR, AFIO开启*/
//*(volatile uint32_t*)(RCCBASE + 0X04) |=(0x101ul) << 24u; /*选择那个时钟输出*/
*(volatile uint32_t*)(RCCBASE + 0X04) |=(0x5ul) << 24u; /*选择那个时钟输出*/