From ac3d08d34c03c9eea8513810130353e81e9b8008 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E9=AA=A2?= <2592509183@qq.com> Date: Thu, 1 Feb 2024 18:17:19 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E5=8F=98=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/device/led_rgb/dev_led_rgb.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/device/led_rgb/dev_led_rgb.cpp b/src/device/led_rgb/dev_led_rgb.cpp index 65e0081e..af2f4889 100644 --- a/src/device/led_rgb/dev_led_rgb.cpp +++ b/src/device/led_rgb/dev_led_rgb.cpp @@ -36,6 +36,9 @@ RGB::RGB(bool auto_start) { led->Set(BLUE, 1); led_fsm = 0; break; + default: + led_fsm = 0; + break; } led->thread_.SleepUntil(250, last_online_time); @@ -51,25 +54,20 @@ RGB::RGB(bool auto_start) { bool RGB::Set(RGB::Channel ch, float duty_cycle) { clampf(&duty_cycle, 0.0f, 1.0f); - bsp_pwm_channel_t pwm_ch = BSP_PWM_NUMBER; - switch (ch) { case RED: bsp_pwm_set_comp(BSP_PWM_LED_RED, duty_cycle); - pwm_ch = BSP_PWM_LED_RED; break; case GREEN: bsp_pwm_set_comp(BSP_PWM_LED_GRN, duty_cycle); - pwm_ch = BSP_PWM_LED_GRN; break; case BLUE: bsp_pwm_set_comp(BSP_PWM_LED_BLU, duty_cycle); - pwm_ch = BSP_PWM_LED_BLU; break; default: - pwm_ch = BSP_PWM_LED_RED; + break; } return true; -- Gitee From 50655bea4aa8eadbcec20c958fa40b481fdd47bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B7=8B?= Date: Sun, 25 Feb 2024 21:45:56 +0800 Subject: [PATCH 2/4] =?UTF-8?q?DB3-2=20#comment=20=E4=BF=AE=E6=94=B9TinyUS?= =?UTF-8?q?B=E4=BB=BB=E5=8A=A1=E4=B8=BA=E5=8F=AF=E9=80=89=E9=A1=B9=20#time?= =?UTF-8?q?=205m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/system/FreeRTOS/Kconfig | 10 +++++++++- src/system/FreeRTOS/term.cpp | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/system/FreeRTOS/Kconfig b/src/system/FreeRTOS/Kconfig index 9dfe3577..863615b8 100644 --- a/src/system/FreeRTOS/Kconfig +++ b/src/system/FreeRTOS/Kconfig @@ -10,14 +10,22 @@ config FREERTOS_TIMER_TASK_STACK_DEPTH range 128 4096 default 256 +config ENABLE_TINYUSB_TASK + bool "是否开启TinyUSB任务" + default y + +if ENABLE_TINYUSB_TASK + config FREERTOS_USB_TASK_STACK_DEPTH int "USB任务堆栈大小" range 128 4096 default 256 +endif + config FREERTOS_TERM_TASK_STACK_DEPTH int "终端任务堆栈大小" range 128 4096 default 512 -endmenu +endmenu \ No newline at end of file diff --git a/src/system/FreeRTOS/term.cpp b/src/system/FreeRTOS/term.cpp index 0b6536a8..b635949c 100644 --- a/src/system/FreeRTOS/term.cpp +++ b/src/system/FreeRTOS/term.cpp @@ -123,7 +123,7 @@ Term::Term() { ms_cmd_add(&date); #endif - +#if defined(ENABLE_TINYUSB_TASK) && (ENABLE_TINYUSB_TASK != 0) auto usb_thread_fn = [](void *arg) { XB_UNUSED(arg); while (1) { @@ -134,7 +134,7 @@ Term::Term() { usb_thread.Create(usb_thread_fn, static_cast(0), "usb_thread", FREERTOS_USB_TASK_STACK_DEPTH, System::Thread::HIGH); - +#endif auto term_thread_fn = [](void *arg) { XB_UNUSED(arg); while (1) { -- Gitee From 67ceda19a58ae846221308dc98630a31f479ce7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B7=8B?= Date: Sun, 25 Feb 2024 21:54:31 +0800 Subject: [PATCH 3/4] DB3-2 #comment Add OpenOCD Support for RM-C #time 5m --- hw/bsp/rm-c/debug/stm32f407xx.cfg | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 hw/bsp/rm-c/debug/stm32f407xx.cfg diff --git a/hw/bsp/rm-c/debug/stm32f407xx.cfg b/hw/bsp/rm-c/debug/stm32f407xx.cfg new file mode 100644 index 00000000..b8a35a69 --- /dev/null +++ b/hw/bsp/rm-c/debug/stm32f407xx.cfg @@ -0,0 +1,8 @@ +source [find interface/jlink.cfg] + +transport select swd + +set WORKAREASIZE 0x2000 +source [find target/stm32f4x.cfg] + +reset_config none \ No newline at end of file -- Gitee From a9f6a648b1cab3818be3d830245092c4e70ca6b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B7=8B?= Date: Wed, 28 Feb 2024 13:12:09 +0800 Subject: [PATCH 4/4] =?UTF-8?q?DB3-2=20#comment=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E4=BA=86=E4=BF=A1=E5=8F=B7=E9=87=8F=E5=A3=B0=E6=98=8E=EF=BC=9B?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BA=86FREERTOS=E5=8F=AF=E9=80=89=E7=BB=84?= =?UTF-8?q?=E4=BB=B6=20#time=205m?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/system/FreeRTOS/Kconfig | 20 ++++++-- src/system/FreeRTOS/semaphore.hpp | 76 ++++++++++++++++--------------- src/system/FreeRTOS/system.hpp | 9 ++++ src/system/FreeRTOS/term.cpp | 7 ++- 4 files changed, 70 insertions(+), 42 deletions(-) diff --git a/src/system/FreeRTOS/Kconfig b/src/system/FreeRTOS/Kconfig index 863615b8..0faa8736 100644 --- a/src/system/FreeRTOS/Kconfig +++ b/src/system/FreeRTOS/Kconfig @@ -10,6 +10,21 @@ config FREERTOS_TIMER_TASK_STACK_DEPTH range 128 4096 default 256 +config ENABLE_DATABASE + bool "是否开启Flash数据库" + default y + +config ENABLE_MINISHELL + bool "是否开启MiniShell" + default y + +if ENABLE_MINISHELL + +config FREERTOS_TERM_TASK_STACK_DEPTH + int "终端任务堆栈大小" + range 128 4096 + default 512 + config ENABLE_TINYUSB_TASK bool "是否开启TinyUSB任务" default y @@ -22,10 +37,7 @@ config FREERTOS_USB_TASK_STACK_DEPTH default 256 endif +endif -config FREERTOS_TERM_TASK_STACK_DEPTH - int "终端任务堆栈大小" - range 128 4096 - default 512 endmenu \ No newline at end of file diff --git a/src/system/FreeRTOS/semaphore.hpp b/src/system/FreeRTOS/semaphore.hpp index a264cc9e..7a308046 100644 --- a/src/system/FreeRTOS/semaphore.hpp +++ b/src/system/FreeRTOS/semaphore.hpp @@ -7,44 +7,48 @@ #include "semphr.h" namespace System { -class Semaphore { - public: - Semaphore(uint32_t init_count) - : handle_(xSemaphoreCreateCounting(UINT32_MAX, init_count)) {} - - ~Semaphore() { vSemaphoreDelete(handle_); } - - void Post() { - if (bsp_sys_in_isr()) { - BaseType_t px_higher_priority_task_woken = 0; - xSemaphoreGiveFromISR(this->handle_, &px_higher_priority_task_woken); - if (px_higher_priority_task_woken != pdFALSE) { - portYIELD(); - } - } else { - xSemaphoreGive(this->handle_); +class Semaphore +{ + SemaphoreHandle_t handle_; +public: + Semaphore(uint32_t init_count) + : handle_(xSemaphoreCreateCounting(UINT32_MAX, init_count)) + { } - } - - bool Wait(uint32_t timeout = UINT32_MAX) { - if (!bsp_sys_in_isr()) { - return xSemaphoreTake(this->handle_, timeout) == pdTRUE; - } else { - BaseType_t px_higher_priority_task_woken = 0; - BaseType_t ans = - xSemaphoreTakeFromISR(this->handle_, - &px_higher_priority_task_woken) == pdTRUE; - if (px_higher_priority_task_woken != pdFALSE) { - portYIELD(); - } - return ans == pdPASS; + ~Semaphore() { vSemaphoreDelete(handle_); } + bool Wait(uint32_t timeout = UINT32_MAX) { + if (!bsp_sys_in_isr()) { + return xSemaphoreTake(this->handle_, timeout) == pdTRUE; + } else { + BaseType_t px_higher_priority_task_woken = 0; + BaseType_t ans = + xSemaphoreTakeFromISR(this->handle_, + &px_higher_priority_task_woken) == pdTRUE; + + if (px_higher_priority_task_woken != pdFALSE) { + portYIELD(); + } + return ans == pdPASS; + } + } + void Post() + { + if (bsp_sys_in_isr()) + { + BaseType_t px_higher_priority_task_woken = 0; + xSemaphoreGiveFromISR(this->handle_, &px_higher_priority_task_woken); + if (px_higher_priority_task_woken != pdFALSE) + { + portYIELD(); + } + } + else + { + xSemaphoreGive(this->handle_); + } } - } - - uint32_t Value() { return uxSemaphoreGetCount(&handle_); } - private: - SemaphoreHandle_t handle_; + uint32_t Value() { return uxSemaphoreGetCount(this->handle_); } }; -} // namespace System +} \ No newline at end of file diff --git a/src/system/FreeRTOS/system.hpp b/src/system/FreeRTOS/system.hpp index 91469d21..2f4cb09b 100644 --- a/src/system/FreeRTOS/system.hpp +++ b/src/system/FreeRTOS/system.hpp @@ -1,9 +1,13 @@ +#if defined(ENABLE_DATABASE) && (ENABLE_DATABASE != 0) #include +#endif #include #include #include #include +#if defined(ENABLE_MINISHELL) && (ENABLE_MINISHELL != 0) #include +#endif #include #include @@ -15,10 +19,15 @@ void Start(RobotParam... param) { auto init_fun = [](RobotParam... param) { Message* msg = static_cast(pvPortMalloc(sizeof(Message))); new (msg) Message(); +#if defined(ENABLE_MINISHELL) && (ENABLE_MINISHELL != 0) Term* term = static_cast(pvPortMalloc(sizeof(Term))); new (term) Term(); +#endif + +#if defined(ENABLE_DATABASE) && (ENABLE_DATABASE != 0) Database* database = static_cast(pvPortMalloc(sizeof(Database))); new (database) Database(); +#endif Timer* timer = static_cast(pvPortMalloc(sizeof(Timer))); new (timer) Timer(); diff --git a/src/system/FreeRTOS/term.cpp b/src/system/FreeRTOS/term.cpp index b635949c..438ae68a 100644 --- a/src/system/FreeRTOS/term.cpp +++ b/src/system/FreeRTOS/term.cpp @@ -1,7 +1,9 @@ #include #include +#if defined(ENABLE_MINISHELL) && (ENABLE_MINISHELL != 0) #include +#endif #include #include "bsp_sys.h" @@ -55,7 +57,7 @@ int printf(const char *format, ...) { return 0; } - +#if defined(ENABLE_MINISHELL) && (ENABLE_MINISHELL != 0) Term::Term() { bsp_usb_init(); @@ -155,7 +157,8 @@ Term::Term() { } } }; - term_thread.Create(term_thread_fn, static_cast(0), "term_thread", FREERTOS_TERM_TASK_STACK_DEPTH, System::Thread::REALTIME); } +#endif + -- Gitee