diff --git a/avr_usart.c b/avr_usart.c index cccf6da..a934434 100644 --- a/avr_usart.c +++ b/avr_usart.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "avr_usart.h" @@ -30,14 +31,17 @@ int main() { uint8_t buf_len = 12; //unsigned char data[12] = "snd 12chars\0"; - unsigned char data[1] = "A"; - + //unsigned char data[1] = "A"; + unsigned char data = '0'; while(1) { - serial0_write(data, buf_len); - _delay_ms(1000); - serial0_read(data, buf_len); - led_blink(); + //serial0_write(data, buf_len); + tx_usart0(data); + //serial0_read(data, buf_len); + //data = rx_usart0(); + serial0_flush_rxbuf(); + serial0_read(data, 1); + //led_blink(); } return 0; @@ -66,8 +70,6 @@ void init_usart0(void) { UBRR0H |= (uint8_t) (0x33>>8); UBRR0L |= (uint8_t) 0x33; - - //Enable recv and Transmit pins, overrides other uses. //IN the usart control and status register 0B UCSR0B = (1< +#include //############################# //PIN DEFINES AND CONSTS @@ -48,9 +49,10 @@ unsigned char rx_usart0(void); void serial0_write(unsigned char* buffer, uint8_t write_length); void serial0_read(unsigned char* buffer, uint8_t buf_length); +void serial0_read_with_err_checking(unsigned char* buffer, uint8_t buf_length); void serial0_set_baud(uint8_t baud); void seiral0_enable_timeouts(uint8_t ms); - +void serial0_flush_rxbuf(void);