? ?如何使用 pd8,pd9 的重映射作為 usart3 使用呢
? { GPIO_InitTypeDef? GPIO_InitStructure = {0};
? ? USART_InitTypeDef USART_InitStructure = {0};
? ? NVIC_InitTypeDef? NVIC_InitStructure = {0};
? ? RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
? ? RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD| RCC_APB2Periph_AFIO, ENABLE);
? ? GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE);
? ? /* USART3 TX-->D.8? RX-->D.9 */
? ? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
? ? GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
? ? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
? ? GPIO_Init(GPIOD, &GPIO_InitStructure);
? ? GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
? ? GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
? ? ? ? ? ? //GPIO_Mode_IN_FLOATING;
? ? GPIO_Init(GPIOD, &GPIO_InitStructure);
? ? USART_InitStructure.USART_BaudRate = 9600;
? ? USART_InitStructure.USART_WordLength = USART_WordLength_8b;
? ? USART_InitStructure.USART_StopBits = USART_StopBits_1;
? ? USART_InitStructure.USART_Parity = USART_Parity_No;
? ? USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
? ? USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
? ? USART_Init(USART3, &USART_InitStructure);
? ? //USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);//開(kāi)啟串口空閑中斷
? ? //USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
? ? //USART_ClearFlag(USART3, USART_FLAG_TC|USART_FLAG_IDLE);
? ? USART_Cmd(USART3, ENABLE); //使能串口
}