From 1229352c64ce277ac515ac1d42979902d8f8100b Mon Sep 17 00:00:00 2001 From: Alexey Zholtikov Date: Sun, 10 Aug 2025 20:42:19 +0300 Subject: [PATCH] wip: --- .gitignore | 4 ++++ src/main.c | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 .gitignore create mode 100644 src/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..df66652 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.pio +.vscode +.DS_Store +platformio.ini \ No newline at end of file diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..745c555 --- /dev/null +++ b/src/main.c @@ -0,0 +1,25 @@ +#include "avr/io.h" +#include "stdio.h" + +#define BAUD_RATE 9600 +#define BAUD_PRESCALE (F_CPU / 16 / BAUD_RATE - 1) + +int usart(char byte, FILE *stream) +{ + while ((UCSR0A & (1 << UDRE0)) == 0) + { + } + UDR0 = byte; + return 0; +} +FILE uart = FDEV_SETUP_STREAM(usart, NULL, _FDEV_SETUP_WRITE); + +int main(void) +{ + UBRR0H = (BAUD_PRESCALE >> 8); + UBRR0L = BAUD_PRESCALE; + UCSR0B = (1 << RXEN0) | (1 << TXEN0); + UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); + stdout = &uart; + return 0; +} \ No newline at end of file