From 26d04ee4de6c0306120c5ee1616c3e51f51328f6 Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Mon, 4 Aug 2025 21:17:51 +0800 Subject: Refactor UART code to separate file. --- main.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index 3af81c5..9c43e20 100644 --- a/main.c +++ b/main.c @@ -5,6 +5,7 @@ #include #include "fpm.h" +#include "uart.h" #define SERVO_PIN PB1 #define SERVO_DDR DDRB @@ -95,21 +96,12 @@ int main(void) WDTCSR |= (1 << WDCE) | (1 << WDE); WDTCSR = 0x00; - /* power on peripherals */ + uart_init(); + + /* power on the FPM and the servo */ PWR_DDR |= (1 << PWR_FPM) | (1 << PWR_SERVO); pwr_fpm_servo_on(); - /* UART for FPM */ - UBRR0H = UBRRH_VALUE; - UBRR0L = UBRRL_VALUE; -#if USE_2X - UCSR0A |= (1 << U2X0); -#else - UCSR0A &= ~(1 << U2X0); -#endif - UCSR0B = (1 << TXEN0) | (1 << RXEN0); - UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); - /* servo */ TCCR1A |= (1 << WGM11); TCCR1B |= (1 << WGM12) | (1 << WGM13); -- cgit v1.2.3