使用USART1,看固件库里面配置tx和rx引脚都是推挽输出,搞不明白,为什么这没配置,rx不是应该配置为输入模式么?
/* Enable GPIOA clock */
RCC_AHBPeriphClock_Enable( RCC_AHBPERIPH_GPIOA , ENABLE );
/* Enable USART1 APB clock */
RCC_APB2PeriphClock_Enable( RCC_APB2PERIPH_USART1 , ENABLE );
/* USART1 Pins configuration **************************************************/
GPIO_DeInit( GPIOA );
{
/* Configure the GPIO ports */
GPIO_InitPara GPIO_InitStructure;
/* Connect pin to Periph */
GPIO_PinAFConfig( GPIOA , GPIO_PINSOURCE9, GPIO_AF_1 );
GPIO_PinAFConfig( GPIOA , GPIO_PINSOURCE10, GPIO_AF_1 );
/* Configure pins as AF pushpull */
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_9 | GPIO_PIN_10;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_AF;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_50MHZ;
GPIO_InitStructure.GPIO_OType = GPIO_OTYPE_PP;
GPIO_InitStructure.GPIO_PuPd = GPIO_PUPD_NOPULL;
GPIO_Init( GPIOA , &GPIO_InitStructure);
}
{
USART_InitPara USART_InitStructure;
USART_DeInit( USART1 );
USART_InitStructure.USART_BRR = 115200;
USART_InitStructure.USART_WL = USART_WL_8B;
USART_InitStructure.USART_STBits = USART_STBITS_1;
USART_InitStructure.USART_Parity = USART_PARITY_RESET;
USART_InitStructure.USART_HardwareFlowControl = USART_HARDWAREFLOWCONTROL_NONE;
USART_InitStructure.USART_RxorTx = USART_RXORTX_RX | USART_RXORTX_TX;
USART_Init(USART1, &USART_InitStructure);
}
/* USART enable */
USART_Enable(USART1, ENABLE); |