2022-03-26 04:58 AM
void SA_USART_config(void)
{
USART_InitTypeDef USART_InitStructure;
// USART_DeInit(USART2);
/*************RCC_configuration*******************/
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
RCC->CFGR3 |= RCC_CFGR3_USART2SW_0;
USART_InitStructure.USART_BaudRate = USART_BAUD_RATE; //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_Mode = USART_CR1_TE |USART_CR1_RE;
USART_InitStructure.USART_HardwareFlowControl =USART_HardwareFlowControl_None;
USART_Init( USART2, &USART_InitStructure);
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
NVIC->ISER[1] = 0x00000040;
USART_Cmd(USART2, ENABLE);
}