STM32 GPIO重映射(转)

标准库重映射步骤为:(把串口PA9、PA10 重映射到 PA6、PA7)

1.打开重映射时钟和USART重映射后的I/O口引脚时钟, 

           RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO,ENABLE);

2.I/O口重映射开启.

                    GPIO_PinRemapConfig(GPIO_Remap_USART1,ENABLE);

3.配制重映射引脚.

                              GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
                              GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
                              GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
                              GPIO_Init(GPIOB, &GPIO_InitStructure);


                               GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7;
                               GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
                               GPIO_Init(GPIOB, &GPIO_InitStructure);

猜你喜欢

转载自www.cnblogs.com/xingboy/p/9592745.html