uart init interruption allowed fixes

This commit is contained in:
Kirill Kurshakow 2024-02-13 18:19:38 +03:00
parent 458b145297
commit 69e8412315

View File

@ -9,7 +9,7 @@ struct circular_buffer uartRxBuffer;
struct circular_buffer uartTxBuffer;
void UART_init(void) {
UCSR0B = (1 << RXEN0) | (1 << TXEN0) | (1 << RXCIE0) | (1 << UDRIE0); // прерывание по приему и опустошению буфера передачи
UCSR0B = (1 << RXEN0) | (1 << TXEN0) | (1 << RXCIE0) | (1<<TXCIE0) | (1 << UDRIE0); // прерывание по приему и передаче
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00);
UBRR0H = 0;
UBRR0L = 103;
@ -17,8 +17,8 @@ void UART_init(void) {
void UART_send(uint8_t* data, size_t length) {
for (size_t i = 0; i < length; i++) {
if (!buffer_full(&usartTxBuffer)) {
write_buffer(&usartTxBuffer, data[i]);
if (!buffer_full(&uartTxBuffer)) {
write_buffer(&uartTxBuffer, data[i]);
} else {
break; // если буфер передачи заполнен, то отправка прерывается
}