wrote echoing main test

This commit is contained in:
Jake Goodwin 2023-01-14 13:26:11 -08:00
parent 6c9a11828b
commit 49dd584185
1 changed files with 11 additions and 6 deletions

View File

@ -32,16 +32,18 @@ int main() {
uint8_t buf_len = 12;
//unsigned char data[12] = "snd 12chars\0";
//unsigned char data[1] = "A";
unsigned char data = '0';
unsigned char data[1] = "B";
while(1) {
//serial0_write(data, buf_len);
tx_usart0(data);
if(data[0] == 0) {
data[0] = '!';
}
tx_usart0(data[0]);
//serial0_read(data, buf_len);
//data = rx_usart0();
serial0_flush_rxbuf();
serial0_read(data, 1);
//led_blink();
serial0_read_with_err_checking(data, 1);
}
return 0;
@ -77,7 +79,8 @@ void init_usart0(void) {
//setting the data frame format
//We leave the 2MSB zero for async serial. And we also don't enable
//parity bits for now. We set a 2bit stop bit and 8bit char size.
UCSR0C = (1<<USBS0) | (3<<UCSZ00);
//UCSR0C = (1<<USBS0) | (3<<UCSZ00);
UCSR0C = (1<<USBS0) | (1<<UCSZ00) | (1<<UCSZ01) | (0<<UCSZ02);
}
@ -116,7 +119,9 @@ unsigned char rx_usart0(void) {
void serial0_flush_rxbuf(void) {
uint8_t none;
while( UCSR0A & (1<<RXC0)) none = UDR0;
while( UCSR0A & (1<<RXC0)) {
none = UDR0;
}
}