application: update usart to uart
This commit is contained in:
parent
5f19504c6b
commit
1b24f5e05c
|
@ -41,7 +41,7 @@
|
|||
/* own libraries */
|
||||
#include "global.h" // board definitions
|
||||
#include "print.h" // printing utilities
|
||||
#include "usart.h" // USART utilities
|
||||
#include "uart.h" // USART utilities
|
||||
#include "usb_cdcacm.h" // USB CDC ACM utilities
|
||||
|
||||
//#include "rs485.h" // RS-485 utilities
|
||||
|
@ -102,9 +102,9 @@ size_t putc(char c)
|
|||
length = 0; // don't print string termination character
|
||||
} else if ('\r' == c || '\n' == c) { // send CR+LF newline for most carriage return and line feed combination
|
||||
if (0==newline || c==newline) { // send newline only if not already send (and only once on \r\n or \n\r)
|
||||
usart_putchar_nonblocking('\r'); // send CR over USART
|
||||
uart_putchar_nonblocking('\r'); // send CR over USART
|
||||
usb_cdcacm_putchar('\r'); // send CR over USB
|
||||
usart_putchar_nonblocking('\n'); // send LF over USART
|
||||
uart_putchar_nonblocking('\n'); // send LF over USART
|
||||
usb_cdcacm_putchar('\n'); // send LF over USB
|
||||
length += 2; // remember we printed 2 characters
|
||||
newline = c; // remember on which character we sent the newline
|
||||
|
@ -112,7 +112,7 @@ size_t putc(char c)
|
|||
length = 0; // the \r or \n of \n\r or \r\n has already been printed
|
||||
}
|
||||
} else {
|
||||
usart_putchar_nonblocking(c); // send byte over USART
|
||||
uart_putchar_nonblocking(c); // send byte over USART
|
||||
usb_cdcacm_putchar(c); // send byte over USB
|
||||
newline = 0; // clear new line
|
||||
length++; // remember we printed 1 character
|
||||
|
@ -124,12 +124,12 @@ static bool wait_space(void)
|
|||
{
|
||||
// disable watchdog when waiting for user input
|
||||
printf("press space to continue, or any other key to abort\n");
|
||||
while (!usart_received && !usb_cdcacm_received) { // wait for user input
|
||||
while (!uart_received && !usb_cdcacm_received) { // wait for user input
|
||||
__WFI(); // go to sleep
|
||||
}
|
||||
char c = 0;
|
||||
if (usart_received) {
|
||||
c = usart_getchar(); // read user input from UART
|
||||
if (uart_received) {
|
||||
c = uart_getchar(); // read user input from UART
|
||||
} else if (usb_cdcacm_received) {
|
||||
c = usb_cdcacm_getchar(); // read user input from USB
|
||||
} else {
|
||||
|
@ -756,7 +756,7 @@ void main(void)
|
|||
#endif
|
||||
|
||||
board_setup(); // setup board
|
||||
usart_setup(); // setup USART (for printing)
|
||||
uart_setup(); // setup USART (for printing)
|
||||
usb_cdcacm_setup(); // setup USB CDC ACM (for printing)
|
||||
led_blink(0, 1); // switch blue LED on to show firmware is working
|
||||
printf("\nwelcome to BusVoodoo\n"); // print welcome message
|
||||
|
@ -872,10 +872,10 @@ void main(void)
|
|||
bool char_flag = false; // a new character has been received
|
||||
while (true) { // infinite loop
|
||||
iwdg_reset(); // kick the dog
|
||||
while (usart_received) { // data received over UART
|
||||
while (uart_received) { // data received over UART
|
||||
action = true; // action has been performed
|
||||
led_toggle(); // toggle LED
|
||||
c = usart_getchar(); // store receive character
|
||||
c = uart_getchar(); // store receive character
|
||||
char_flag = true; // notify character has been received
|
||||
}
|
||||
while (usb_cdcacm_received) { // data received over USB
|
||||
|
@ -887,7 +887,8 @@ void main(void)
|
|||
while (char_flag) { // user data received
|
||||
char_flag = false; // reset flag
|
||||
action = true; // action has been performed
|
||||
printf("%c",c); // echo receive character
|
||||
//printf("%c",c); // echo receive character
|
||||
printf("%02x\n",c);
|
||||
if (c=='\r' || c=='\n') { // end of command received
|
||||
if (command_i>0) { // there is a command to process
|
||||
command[command_i] = 0; // end string
|
||||
|
|
Loading…
Reference in New Issue