diff --git a/avr_usart.c b/avr_usart.c index 2dbcd84..52706a1 100644 --- a/avr_usart.c +++ b/avr_usart.c @@ -7,7 +7,6 @@ #include #include #include -#include #include #include "avr_usart.h" @@ -22,28 +21,30 @@ int main() { led_blink(); led_blink(); _delay_ms(1000); - _delay_ms(1000); init_usart0(); //enable interrupts sei(); - - uint8_t buf_len = 12; - //unsigned char data[12] = "snd 12chars\0"; - //unsigned char data[1] = "A"; - unsigned char data[1] = "B"; + unsigned char linefeed = 0x0a; + unsigned char carrigereturn = 0x0d; + //unsigned char data[11] = "snd 11chars"; + unsigned char data[8] = "AT+BAUD3"; + unsigned char data_cmd[2] = "AT"; + uint8_t data_len = 8; + uint8_t data_cmd_len = 2; while(1) { - //serial0_write(data, buf_len); - if(data[0] == 0) { - data[0] = '!'; - } - tx_usart0(data[0]); - //serial0_read(data, buf_len); - //data = rx_usart0(); - serial0_flush_rxbuf(); - serial0_read_with_err_checking(data, 1); + led_blink(); + + serial0_write(data, data_len); + tx_usart0(carrigereturn); + tx_usart0(linefeed); + + + //_delay_ms(1000); + _delay_ms(500); + } return 0; @@ -61,26 +62,30 @@ int main() { * Description: init usart0 hardware in async mode */ void init_usart0(void) { - //DDRB |= (1<>8); - //UBRR0L |= (uint8_t) BT_UBRR; - UBRR0H |= (uint8_t) (0x33>>8); - UBRR0L |= (uint8_t) 0x33; + UBRR0H |= (uint8_t) (BT_UBRR>>8); + UBRR0L |= (uint8_t) BT_UBRR; //Enable recv and Transmit pins, overrides other uses. //IN the usart control and status register 0B UCSR0B = (1<