From 5cd5005ae367565a054d9b207cdc10d8faf8f39f Mon Sep 17 00:00:00 2001 From: true Date: Wed, 6 Nov 2024 22:19:03 -0800 Subject: [PATCH] add further boilerplate, missing functions for usb console --- gat_stand_fw/user/console/commands/about.h | 5 +---- gat_stand_fw/user/console/commands/cls.h | 5 +---- gat_stand_fw/user/console/commands/help.h | 7 ++----- gat_stand_fw/user/main.c | 7 ++++++- gat_stand_fw/user/periph/usb/cdc.c | 11 +++++++++++ 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/gat_stand_fw/user/console/commands/about.h b/gat_stand_fw/user/console/commands/about.h index 1d6b14c..b593ba8 100644 --- a/gat_stand_fw/user/console/commands/about.h +++ b/gat_stand_fw/user/console/commands/about.h @@ -1,8 +1,5 @@ /* - * cons_about.h - * - * Created on: Nov 6, 2024 - * Author: true + * about.h */ #ifndef USER_SHELL_COMMANDS_ABOUT_H_ diff --git a/gat_stand_fw/user/console/commands/cls.h b/gat_stand_fw/user/console/commands/cls.h index 35b4150..e21f4b7 100644 --- a/gat_stand_fw/user/console/commands/cls.h +++ b/gat_stand_fw/user/console/commands/cls.h @@ -1,8 +1,5 @@ /* - * cons_cls.h - * - * Created on: Nov 6, 2024 - * Author: true + * cls.h */ #ifndef USER_SHELL_COMMANDS_CLS_H_ diff --git a/gat_stand_fw/user/console/commands/help.h b/gat_stand_fw/user/console/commands/help.h index 0c68432..67b5e37 100644 --- a/gat_stand_fw/user/console/commands/help.h +++ b/gat_stand_fw/user/console/commands/help.h @@ -1,8 +1,5 @@ /* - * cons_help.h - * - * Created on: Nov 6, 2024 - * Author: true + * help.h */ #ifndef USER_SHELL_COMMANDS_HELP_H_ @@ -48,7 +45,7 @@ void cons_help_real(int argc, char **argv, command_table_t *p) } // looks like the command wasn't found - strcpy( console_line, "* no help found for command called '"); + strcpy( console_line, "* no help found for '"); strncat(console_line, argv[1], 60); strncat(console_line, "'\r\n", 62); CONS_PRINT(console_line); diff --git a/gat_stand_fw/user/main.c b/gat_stand_fw/user/main.c index 52b8a95..9f877cb 100644 --- a/gat_stand_fw/user/main.c +++ b/gat_stand_fw/user/main.c @@ -35,6 +35,8 @@ #include "usb_lib.h" #include "console/console.h" +#include "../usblib/config/usb_pwr.h" + void btn_top_push_cb(uint8_t idx) @@ -195,12 +197,15 @@ int main(void) USB_Init(); usb_intr_init(); + // then initialize shell + console_set_gets(0); + console_set_puts(0); console_init(); // let's do this while (1) { // todo: add check to see if USB is connected - if (1) { + if (bDeviceState == CONFIGURED) { console_process(); } else { console_stop(); diff --git a/gat_stand_fw/user/periph/usb/cdc.c b/gat_stand_fw/user/periph/usb/cdc.c index 4e07a40..718bfa8 100644 --- a/gat_stand_fw/user/periph/usb/cdc.c +++ b/gat_stand_fw/user/periph/usb/cdc.c @@ -345,3 +345,14 @@ void CDC_DataRx_Process( void ) } } } + +__attribute__((interrupt("WCH-Interrupt-fast"))) +void TIM4_IRQHandler(void) +{ + // uart timeout counts + Cdc.Rx_TimeOut++; + Cdc.USB_Up_TimeOut++; + + // clear status + TIM4->INTFR = (uint16_t)~TIM_IT_Update; +}