你的浏览器版本过低,可能导致网站不能正常访问!为了你能正常使用网站功能,请使用这些浏览器。
举报
STM32隐藏
5.18活动板子会不会是STM32L4呢
STM32 CUBE软件中找不到STM32L4系列单片机
Your UAT Feedback is needed within today.
应用
AAA
测试测试12345
群
tiwen
BBBB
Struct <unnamed> has no field :AFRL",GPIOx_AFRL和GPIOx_AFRH,GPIOX_MODER等都是寄存器,定义GPIOB->MODER = 0X55551655;则OK.
该怎么解决?Thanks
直接看官方库函数和数据手册的值。具体的寄存器,通过代入常量计算获取。
//-------------------------------------------------------------
#define SetAF_TIM3_CH1 {GPIO_PinAFConfig(GPIOB, GPIO_PinSource4, GPIO_AF_1);}
//-------------------------------------------------------------
void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
{
uint32_t temp = 0x00;
uint32_t temp_2 = 0x00;
/* Check the parameters */
assert_param(IS_GPIO_ALL_PERIPH(GPIOx));
assert_param(IS_GPIO_PIN_SOURCE(GPIO_PinSource));
assert_param(IS_GPIO_AF(GPIO_AF));
temp = ((uint32_t)(GPIO_AF) << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
GPIOx->AFR[GPIO_PinSource >> 0x03] &= ~((uint32_t)0xF << ((uint32_t)((uint32_t)GPIO_PinSource & (uint32_t)0x07) * 4));
temp_2 = GPIOx->AFR[GPIO_PinSource >> 0x03] | temp;
GPIOx->AFR[GPIO_PinSource >> 0x03] = temp_2;
}