Files
ch32v203-eth-node/include/uart.h
2024-11-10 14:59:30 +06:00

23 lines
458 B
C

#ifndef UART_H
#define UART_H
#include <stdint.h>
#define UART1_BAUD_RATE 9600
// Macro definitions
#define APB1_CLOCK (FUNCONF_SYSTEM_CORE_CLOCK / 2) // APB1 is divided by 2
// USART2
#define UART_BRR_APB1 (((APB1_CLOCK) + (UART_BAUD_RATE / 2)) / (UART_BAUD_RATE))
// USART1
#define UART_BRR_APB2 \
(((FUNCONF_SYSTEM_CORE_CLOCK) + (UART1_BAUD_RATE / 2)) / (UART1_BAUD_RATE))
// Function prototypes
void init_uart(int uart_brr);
#endif // UART_H