GPIO配置如下
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
//#if defined(USE_STM3210B_EVAL) || defined(USE_STM32100B_EVAL)
// /* Enable the USART1 Pins Software Remapping */
// GPIO_PinRemapConfig(GPIO_Remap_USART1, ENABLE);
//#endif
/* Configure USART1 RTS and USART1 Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_RTSPin | GPIO_TxPin;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOx, &GPIO_InitStructure);
/* Configure USART1 CTS and USART1 Rx as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_CTSPin | GPIO_RxPin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOx, &GPIO_InitStructure);
}
串口配置如下:
USART_InitStructure.USART_BaudRate = 115200;
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_RTS;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
/* Enable the USART1 */
USART_Cmd(USART1, ENABLE);
用的是官方的板子(换了芯片,换成STM32F103VD)
|