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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
/** STM32F1 example
|
/** STM32F1 application example
|
||||||
* @file main.c
|
* @file main.c
|
||||||
* @author King Kévin <kingkevin@cuvoodoo.info>
|
* @author King Kévin <kingkevin@cuvoodoo.info>
|
||||||
* @date 2016
|
* @date 2016-2017
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* standard libraries */
|
/* 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
|
} 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)
|
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
|
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
|
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
|
length += 2; // remember we printed 2 characters
|
||||||
newline = c; // remember on which character we sent the newline
|
newline = c; // remember on which character we sent the newline
|
||||||
} else {
|
} else {
|
||||||
|
@ -69,7 +69,7 @@ size_t putc(char c)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
usart_putchar_nonblocking(c); // send byte over USART
|
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
|
newline = 0; // clear new line
|
||||||
length++; // remember we printed 1 character
|
length++; // remember we printed 1 character
|
||||||
}
|
}
|
||||||
|
@ -93,14 +93,18 @@ static void process_command(char* str)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
// parse command
|
// parse command
|
||||||
if (0==strcmp(word,"help")) {
|
if (0==strcmp(word,"h") || 0==strcmp(word,"help") || 0==strcmp(word,"?")) {
|
||||||
printf("available commands:\n");
|
printf("available commands:\n");
|
||||||
printf("led [on|off|toggle]\n");
|
printf("led [on|off|toggle]\n");
|
||||||
printf("time [HH:MM:SS]\n");
|
} else if (0==strcmp(word,"l") || 0==strcmp(word,"led")) {
|
||||||
} else if (0==strcmp(word,"led")) {
|
|
||||||
word = strtok(NULL,delimiter);
|
word = strtok(NULL,delimiter);
|
||||||
if (!word) {
|
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")) {
|
} else if (0==strcmp(word,"on")) {
|
||||||
led_on(); // switch LED on
|
led_on(); // switch LED on
|
||||||
printf("LED switched on\n"); // notify user
|
printf("LED switched on\n"); // notify user
|
||||||
|
@ -148,7 +152,7 @@ void main(void)
|
||||||
board_setup(); // setup board
|
board_setup(); // setup board
|
||||||
usart_setup(); // setup USART (for printing)
|
usart_setup(); // setup USART (for printing)
|
||||||
cdcacm_setup(); // setup USB CDC ACM (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)
|
#if !(DEBUG)
|
||||||
// show watchdog information
|
// show watchdog information
|
||||||
|
@ -186,10 +190,10 @@ void main(void)
|
||||||
c = usart_getchar(); // store receive character
|
c = usart_getchar(); // store receive character
|
||||||
char_flag = true; // notify character has been received
|
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
|
action = true; // action has been performed
|
||||||
led_toggle(); // toggle LED
|
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
|
char_flag = true; // notify character has been received
|
||||||
}
|
}
|
||||||
while (char_flag) { // user data received
|
while (char_flag) { // user data received
|
||||||
|
|
Loading…
Reference in New Issue