/* * uart.c * * Created: 13.04.2023 15:32:02 * Author: mrnek */ #include <avr/io.h> #include "uart.h" void USART_Init(unsigned int ubrr) { /*Set baud rate */ UBRR0H = (unsigned char)(ubrr>>8); UBRR0L = (unsigned char)ubrr; UBRR0H = 0; UBRR0L = 8; /* Set frame format: 8data, 2stop bit */ UCSR0C = (1<<USBS0)|(3<<UCSZ00); /* Enable receiver and transmitter */ UCSR0B = (1<<RXEN0)|(1<<TXEN0); } void USART_Transmit(unsigned char data) { /* Wait for empty transmit buffer */ while (!(UCSR0A & (1<<UDREn))) ; /* Put data into buffer, sends the data */ UDR0 = data; }