wip:
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.pio
|
||||||
|
.vscode
|
||||||
|
.DS_Store
|
||||||
|
platformio.ini
|
25
src/main.c
Normal file
25
src/main.c
Normal file
@@ -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;
|
||||||
|
}
|
Reference in New Issue
Block a user