/* USART1 configuration ------------------------------------------------------*/
/* USART1 configured as follow:
- BaudRate = 38400 baud
- Word Length = 8 Bits
- One Stop Bit
- Odd parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
*/
USART_StructInit(&USART_InitStructure);//2008-12-02添加
//原因是每次复位后CPOL中的值为0x3xxx的随机值
//导致停止位配置不对,比如初始化时配置成1位停止位,
//若没有此句,则会变成1.5位
USART_InitStructure.USART_BaudRate = 38400;
USART_InitStructure.USART_WordLength = USART_WordLength_9b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_Odd;
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
/* Configure the USART1 */
USART_Init(USART1, &USART_InitStructure);
/* Enable the USART Transmoit compeleted interrupt: this interrupt is generated when the
USART transmit data register was transmited */
USART_ClearITPendingBit(USART1, USART_IT_TC);
USART_ITConfig(USART1, USART_IT_TC, ENABLE);
/* Enable the USART Receive interrupt: this interrupt is generated when the
USART receive data register is not empty */
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);
USART_ClearITPendingBit(USART1, USART_IT_RXNE);
/* Enable USART */
USART_Cmd(USART1, ENABLE);
}