F4: fix wrong PCLK value (#1608)

* fix mistake

* clean
This commit is contained in:
Igor Biletskyy 2023-08-31 09:35:25 -07:00 committed by GitHub
parent 124a83c0bf
commit f89207328b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 6 deletions

View File

@ -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) {

View File

@ -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();