void USART1_Config(void)
{
GPIO_InitPara GPIO_InitStructure;
USART_InitPara USART_InitStructure;
/* config USART1 clock */
RCC_APB2PeriphClock_Enable(RCC_APB2PERIPH_USART1 | RCC_APB2PERIPH_GPIOA, ENABLE);
/* USART1 GPIO config */
/* Configure USART1 Tx (PA.09) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_9;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_SPEED_50MHZ;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART1 Rx (PA.10) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_PIN_10;
GPIO_InitStructure.GPIO_Mode = GPIO_MODE_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* USART1 mode config */
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(USART1, ENABLE);
}
|