mirror of https://github.com/commaai/panda.git
parent
124a83c0bf
commit
f89207328b
|
@ -90,7 +90,7 @@ void UART5_IRQ_Handler(void) { uart_interrupt_handler(&uart_ring_lin1); }
|
|||
#define __USART_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4) | (__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
|
||||
|
||||
void uart_set_baud(USART_TypeDef *u, unsigned int baud) {
|
||||
u->BRR = __USART_BRR(APB1_FREQ, baud);
|
||||
u->BRR = __USART_BRR(APB1_FREQ*1000000U, baud);
|
||||
}
|
||||
|
||||
void uart_init(uart_ring *q, int baud) {
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
#define __DIV(_PCLK_, _BAUD_) (((_PCLK_) * 25U) / (4U * (_BAUD_)))
|
||||
#define __DIVMANT(_PCLK_, _BAUD_) (__DIV((_PCLK_), (_BAUD_)) / 100U)
|
||||
#define __DIVFRAQ(_PCLK_, _BAUD_) ((((__DIV((_PCLK_), (_BAUD_)) - (__DIVMANT((_PCLK_), (_BAUD_)) * 100U)) * 16U) + 50U) / 100U)
|
||||
#define __USART_BRR(_PCLK_, _BAUD_) ((__DIVMANT((_PCLK_), (_BAUD_)) << 4) | (__DIVFRAQ((_PCLK_), (_BAUD_)) & 0x0FU))
|
||||
|
||||
void uart_rx_ring(uart_ring *q){
|
||||
// Do not read out directly if DMA enabled
|
||||
ENTER_CRITICAL();
|
||||
|
|
Loading…
Reference in New Issue