more detailed comments in uart.c
This commit is contained in:
6
uart.c
6
uart.c
@@ -17,7 +17,7 @@ void uart_init()
|
|||||||
|
|
||||||
UART_CTRL_REGC |= (1<<UART_URSEL_BM)
|
UART_CTRL_REGC |= (1<<UART_URSEL_BM)
|
||||||
|(1<<UART_UCSZ0_BM)
|
|(1<<UART_UCSZ0_BM)
|
||||||
|(1<<UART_UCSZ1_BM); // 8bit data format
|
|(1<<UART_UCSZ1_BM); // 8bit data format
|
||||||
|
|
||||||
stdout = &uart_output;
|
stdout = &uart_output;
|
||||||
}
|
}
|
||||||
@@ -42,11 +42,11 @@ void read_sync(char buffer[], uint8_t buffersize, uint8_t * bufferindex){
|
|||||||
while ((UART_CTRL_REGA & (1 << UART_RXC_BM)) == 0);
|
while ((UART_CTRL_REGA & (1 << UART_RXC_BM)) == 0);
|
||||||
input = UART_DATA_REG;
|
input = UART_DATA_REG;
|
||||||
|
|
||||||
putchar(input); //echo
|
putchar(input); // echo
|
||||||
buffer[*bufferindex]=input;
|
buffer[*bufferindex]=input;
|
||||||
*bufferindex=*bufferindex+1;
|
*bufferindex=*bufferindex+1;
|
||||||
}while(!(input == '\n' || input == '\r'));
|
}while(!(input == '\n' || input == '\r'));
|
||||||
buffer[*bufferindex]=0;
|
buffer[*bufferindex]=0; // null terminate
|
||||||
putchar('\n');
|
putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user