re-add USART1 as print/debug output
This commit is contained in:
parent
5ca1bbef4b
commit
23975a9dd6
16
main.c
16
main.c
|
@ -42,7 +42,7 @@
|
|||
|
||||
/* own libraries */
|
||||
#include "global.h" // board definitions
|
||||
//#include "usart.h" // USART utilities
|
||||
#include "usart.h" // USART utilities
|
||||
#include "usb_cdcacm.h" // USB CDC ACM utilities
|
||||
#include "sensor_sdm120.h" // SDM120 electricity meter utilities
|
||||
#include "radio_esp8266.h" // ESP8266 WiFi SoC utilities
|
||||
|
@ -96,8 +96,8 @@ int _write(int file, char *ptr, int len)
|
|||
for (i = 0; i < len; i++) {
|
||||
if (ptr[i] == '\r' || ptr[i] == '\n') { // send CR+LF newline for most carriage return and line feed combination
|
||||
if (newline==0 || (newline==ptr[i])) { // newline has already been detected
|
||||
//usart_putchar_nonblocking('\r'); // send newline over USART
|
||||
//usart_putchar_nonblocking('\n'); // send newline over USART
|
||||
usart_putchar_nonblocking('\r'); // send newline over USART
|
||||
usart_putchar_nonblocking('\n'); // send newline over USART
|
||||
cdcacm_putchar('\r'); // send newline over USB
|
||||
cdcacm_putchar('\n'); // send newline over USB
|
||||
newline = ptr[i]; // remember the newline
|
||||
|
@ -106,7 +106,7 @@ int _write(int file, char *ptr, int len)
|
|||
newline = 0; // clear new line
|
||||
}
|
||||
} else { // non-newline character
|
||||
//usart_putchar_nonblocking(ptr[i]); // send byte over USART
|
||||
usart_putchar_nonblocking(ptr[i]); // send byte over USART
|
||||
cdcacm_putchar(ptr[i]); // send byte over USB
|
||||
newline = 0; // clear new line
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ void main(void)
|
|||
led_on();
|
||||
|
||||
// setup USART and USB for user communication
|
||||
//usart_setup(); // setup USART (for printing)
|
||||
usart_setup(); // setup USART (for printing)
|
||||
cdcacm_setup(); // setup USB CDC ACM (for printing)
|
||||
setbuf(stdout, NULL); // set standard out buffer to NULL to immediately print
|
||||
setbuf(stderr, NULL); // set standard error buffer to NULL to immediately print
|
||||
|
@ -377,6 +377,12 @@ void main(void)
|
|||
|
||||
while (true) { // infinite loop
|
||||
iwdg_reset(); // kick the dog
|
||||
while (usart_received) { // data received over UART
|
||||
action = true; // action has been performed
|
||||
led_toggle(); // toggle LED
|
||||
c = usart_getchar(); // store receive character
|
||||
char_flag = true; // notify character has been received
|
||||
}
|
||||
while (cdcacm_received) { // data received over USB
|
||||
action = true; // action has been performed
|
||||
c = cdcacm_getchar(); // store receive character
|
||||
|
|
Loading…
Reference in New Issue