chore: housekeeping
This commit is contained in:
@@ -3,20 +3,29 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// RS485 baud rate
|
||||
#define UART1_BAUD_RATE 9600
|
||||
#define UART2_BAUD_RATE 115200
|
||||
|
||||
// Macro definitions
|
||||
#define APB1_CLOCK (FUNCONF_SYSTEM_CORE_CLOCK / 2) // APB1 is divided by 2
|
||||
// APB1 bus clock is half the system core clock
|
||||
#define APB1_CLOCK (FUNCONF_SYSTEM_CORE_CLOCK / 2)
|
||||
|
||||
// USART2
|
||||
#define UART_BRR_APB1 (((APB1_CLOCK) + (UART_BAUD_RATE / 2)) / (UART_BAUD_RATE))
|
||||
|
||||
// USART1
|
||||
// Calculate baud rate divisors
|
||||
// Adds BAUD_RATE/2 for rounding to nearest integer
|
||||
#define UART_BRR_APB1 \
|
||||
(((APB1_CLOCK) + (UART2_BAUD_RATE / 2)) / (UART2_BAUD_RATE))
|
||||
#define UART_BRR_APB2 \
|
||||
(((FUNCONF_SYSTEM_CORE_CLOCK) + (UART1_BAUD_RATE / 2)) / (UART1_BAUD_RATE))
|
||||
|
||||
// Function prototypes
|
||||
|
||||
void init_uart(int uart_brr);
|
||||
// UART2
|
||||
void uart2_init(int uart_brr);
|
||||
|
||||
// RS485 functions
|
||||
void rs485_init(int uart_brr);
|
||||
void rs485_send(uint8_t *buf, uint16_t len);
|
||||
uint8_t rs485_available(void);
|
||||
uint8_t rs485_read(void);
|
||||
|
||||
#endif // UART_H
|
||||
|
||||
Reference in New Issue
Block a user