wrote echoing main test
This commit is contained in:
parent
6c9a11828b
commit
49dd584185
17
avr_usart.c
17
avr_usart.c
|
@ -32,16 +32,18 @@ int main() {
|
||||||
uint8_t buf_len = 12;
|
uint8_t buf_len = 12;
|
||||||
//unsigned char data[12] = "snd 12chars\0";
|
//unsigned char data[12] = "snd 12chars\0";
|
||||||
//unsigned char data[1] = "A";
|
//unsigned char data[1] = "A";
|
||||||
unsigned char data = '0';
|
unsigned char data[1] = "B";
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
//serial0_write(data, buf_len);
|
//serial0_write(data, buf_len);
|
||||||
tx_usart0(data);
|
if(data[0] == 0) {
|
||||||
|
data[0] = '!';
|
||||||
|
}
|
||||||
|
tx_usart0(data[0]);
|
||||||
//serial0_read(data, buf_len);
|
//serial0_read(data, buf_len);
|
||||||
//data = rx_usart0();
|
//data = rx_usart0();
|
||||||
serial0_flush_rxbuf();
|
serial0_flush_rxbuf();
|
||||||
serial0_read(data, 1);
|
serial0_read_with_err_checking(data, 1);
|
||||||
//led_blink();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -77,7 +79,8 @@ void init_usart0(void) {
|
||||||
//setting the data frame format
|
//setting the data frame format
|
||||||
//We leave the 2MSB zero for async serial. And we also don't enable
|
//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.
|
//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) {
|
void serial0_flush_rxbuf(void) {
|
||||||
uint8_t none;
|
uint8_t none;
|
||||||
while( UCSR0A & (1<<RXC0)) none = UDR0;
|
while( UCSR0A & (1<<RXC0)) {
|
||||||
|
none = UDR0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue