/* * src/uart.c * (c) 2021 Jonas Gunz * License: All rights reserved. */ #include "uart.h" struct ringbuff_s { uint8_t buffer[256]; uint8_t read; uint8_t write; } rxc_buf, txc_buf ; ISR(USART_RXC_vect) { cli(); /* Discard if buffer full */ if( rxc_buf.read - 1 == rxc_buf.write ) goto end; rxc_buf.buffer[rxc_buf.write] = UDR; rxc_buf.write++; end: sei(); } ISR(USART_UDRE_vect) { cli(); /* Prevent interrupt loops */ if( txc_buf.read == txc_buf.write ) { UCSRB &= ~(1<>8); UBRRL = (uint8_t)(UBRR); UCSRB |= (1<