first commit

This commit is contained in:
Jérôme Delacotte
2025-03-06 11:15:32 +01:00
commit 7b30d6e298
5276 changed files with 2108927 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
#include<avr/io.h>
#define USART_BAUDRATE 9600
#define BAUD_PRESCALE (((F_CPU/(USART_BAUDRATE*16UL)))-1)
int main(void){
char recieved_byte;
UCSR0B |= (1<<RXEN0) | (1<<TXEN0);
UCSR0C |= (1<<UCSZ00) | (1<<UCSZ01);
UBRR0H = (BAUD_PRESCALE >> 8);
UBRR0L = BAUD_PRESCALE;
for(;;){
// wait until a byte is ready to read
while( ( UCSR0A & ( 1 << RXC0 ) ) == 0 ){}
// grab the byte from the serial port
recieved_byte = UDR0;
// wait until the port is ready to be written to
while( ( UCSR0A & ( 1 << UDRE0 ) ) == 0 ){}
// write the byte to the serial port
UDR0 = recieved_byte;
}
return 0; /* never reached */
}