13 while (!(uart_inst->SR & USART_SR_TC))
32 while (!(uart_inst->SR & USART_SR_RXNE))
39 void init_uart(USART_TypeDef* uart_inst,
const uint32_t baudrate,
const uint32_t sys_clk,uint8_t enable_rxne_int)
41 const float temp_float_baudrate = ((float)sys_clk)/(16.0*baudrate);
42 const uint32_t temp_baud_whole = (uint32_t)temp_float_baudrate;
43 const uint32_t temp_baud_frac = (temp_float_baudrate - ((float)temp_baud_whole))*16.0;
45 uart_inst->BRR = (temp_baud_whole<<4) | temp_baud_frac;
49 uart_inst->CR1 = USART_CR1_RE | USART_CR1_TE | USART_CR1_RXNEIE | USART_CR1_UE;
53 uart_inst->CR1 = USART_CR1_RE | USART_CR1_TE | USART_CR1_UE;