update usb_cdcacm function calls
This commit is contained in:
parent
22e932dd95
commit
74cc193a16
|
@ -12,10 +12,10 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
/** STM32F1 example
|
||||
/** STM32F1 application example
|
||||
* @file main.c
|
||||
* @author King Kévin <kingkevin@cuvoodoo.info>
|
||||
* @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
|
||||
|
|
Loading…
Reference in New Issue