From 74cc193a160429aee5719b77e89af21704a1f3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?King=20K=C3=A9vin?= Date: Wed, 19 Apr 2017 16:24:07 +0200 Subject: [PATCH] update usb_cdcacm function calls --- application.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/application.c b/application.c index 77e3449..77e2311 100644 --- a/application.c +++ b/application.c @@ -12,10 +12,10 @@ * along with this program. If not, see . * */ -/** STM32F1 example +/** STM32F1 application example * @file main.c * @author King Kévin - * @date 2016 + * @date 2016-2017 */ /* standard libraries */ @@ -59,9 +59,9 @@ size_t putc(char c) } 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 - cdcacm_putchar('\r'); // send CR over USB + usb_cdcacm_putchar('\r'); // send CR over USB usart_putchar_nonblocking('\n'); // send LF over USART - cdcacm_putchar('\n'); // send LF over USB + 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 } else { @@ -69,7 +69,7 @@ size_t putc(char c) } } else { usart_putchar_nonblocking(c); // send byte over USART - cdcacm_putchar(c); // send byte over USB + usb_cdcacm_putchar(c); // send byte over USB newline = 0; // clear new line length++; // remember we printed 1 character } @@ -93,14 +93,18 @@ static void process_command(char* str) goto error; } // parse command - if (0==strcmp(word,"help")) { + if (0==strcmp(word,"h") || 0==strcmp(word,"help") || 0==strcmp(word,"?")) { printf("available commands:\n"); printf("led [on|off|toggle]\n"); - printf("time [HH:MM:SS]\n"); - } else if (0==strcmp(word,"led")) { + } else if (0==strcmp(word,"l") || 0==strcmp(word,"led")) { word = strtok(NULL,delimiter); if (!word) { - goto error; + printf("LED is "); + if (gpio_get(GPIO(LED_PORT), GPIO(LED_PIN))) { + printf("on\n"); + } else { + printf("off\n"); + } } else if (0==strcmp(word,"on")) { led_on(); // switch LED on printf("LED switched on\n"); // notify user @@ -148,7 +152,7 @@ void main(void) board_setup(); // setup board usart_setup(); // setup USART (for printing) cdcacm_setup(); // setup USB CDC ACM (for printing) - printf("welcome to the STM32F1 CuVoodoo example code\n"); // print welcome message + printf("welcome to the CuVoodoo STM32F1 example application\n"); // print welcome message #if !(DEBUG) // show watchdog information @@ -186,10 +190,10 @@ void main(void) c = usart_getchar(); // store receive character char_flag = true; // notify character has been received } - while (cdcacm_received) { // data received over USB + while (usb_cdcacm_received) { // data received over USB action = true; // action has been performed led_toggle(); // toggle LED - c = cdcacm_getchar(); // store receive character + c = usb_cdcacm_getchar(); // store receive character char_flag = true; // notify character has been received } while (char_flag) { // user data received