任务栈统一1024字(heap调至20KB);CLI增加Ctrl+Z关日志/Tab补全/命令历史;提示符改为caiic->
This commit is contained in:
parent
41ff7fb52a
commit
e17648f7fe
12
AGENTS.md
12
AGENTS.md
@ -29,7 +29,7 @@ mcm-ddc-04/
|
||||
│ ├── app_tasks.c/.h # 3 个 FreeRTOS 任务 + 日志队列(生产者-消费者模型)+ 主动打印开关(默认关)
|
||||
│ ├── app_cli.c/.h # CLI 独立任务:行接收/解析/执行/应答(应答走 DMA TX),命令表驱动
|
||||
│ ├── n32wb03x_it.c/.h # NMI / HardFault 异常处理 + USART1_IRQHandler(转发到 bsp_usart_rx_isr_handler)
|
||||
│ └── FreeRTOSConfig.h # heap 8KB,SVC/PendSV/SysTick 映射给 FreeRTOS port
|
||||
│ └── FreeRTOSConfig.h # heap 20KB,SVC/PendSV/SysTick 映射给 FreeRTOS port
|
||||
├── MDK-ARM/
|
||||
│ ├── embeddedSrc.uvprojx / .uvoptx # Keil µVision5 工程文件
|
||||
│ ├── Objects/ # 编译产物(embeddedSrc.axf / .hex)
|
||||
@ -53,13 +53,13 @@ SDK 源码(固件库、CMSIS、FreeRTOS V9.0.0、启动文件)通过相对
|
||||
```
|
||||
|
||||
构建成功后自动执行 `fromelf --bin --output=.\bin\embeddedSrc.bin .\Objects\embeddedSrc.axf`。
|
||||
当前基线结果:**0 Error(s), 0 Warning(s)**,体积 `Code=14712 RO-data=944 RW-data=112 ZI-data=10696`。
|
||||
当前基线结果:**0 Error(s), 0 Warning(s)**,体积 `Code=15692 RO-data=944 RW-data=112 ZI-data=23496`。
|
||||
|
||||
烧录与运行:
|
||||
|
||||
1. Keil 打开 `MDK-ARM/embeddedSrc.uvprojx`,F7 编译
|
||||
2. NS-LINK 接 SWD(PA4/PA5),F8 下载
|
||||
3. 串口助手接 PB6(TX)/PB7(RX),115200 8N1,复位后应看到启动 banner 与 `n32> ` CLI 提示符(输入 `help` 查看命令;LED 滚动日志默认关闭,用 `log on` 打开)
|
||||
3. 串口助手接 PB6(TX)/PB7(RX),115200 8N1,复位后应看到启动 banner 与 `caiic->` CLI 提示符(输入 `help` 查看命令;LED 滚动日志默认关闭,用 `log on` 打开)
|
||||
|
||||
注意:本工程当前尚未在真实硬件上实测(见开发日志第 8、9、10 节)。
|
||||
|
||||
@ -73,12 +73,12 @@ SDK 源码(固件库、CMSIS、FreeRTOS V9.0.0、启动文件)通过相对
|
||||
## 实时架构约定
|
||||
|
||||
- 使用 FreeRTOS V9.0.0 原生 API(`xTaskCreate` / `vTaskDelay` / `xQueue`),**不使用 cmsis_os 封装**。
|
||||
- 任务模型:LedTask(LED1,500ms)、LedTask2(LED2,1000ms)为生产者,只向日志队列投递 `LogMsg_t`;PrintTask(优先级 3,栈 256 字)消费队列并 printf。**主动日志打印由 `AppTasks_SetLogEnabled()` 控制,默认关闭**(CLI 命令 `log on|off` 切换)。新增需要打印的任务时沿用此生产者-消费者模式,不要在中断或多个任务里直接 `printf`。
|
||||
- CLI 任务(优先级 3,栈 256 字,见 `app_cli.c`):从 USART1 RXDNE 中断的字节队列取输入,行结束符 `\r\n` / `\n\r` / `\r` / `\n` 均识别;解析-执行-应答一体化,应答走 `bsp_usart_write_dma`(DMA_CH1)。新命令在 `s_cmds[]` 命令表中注册。
|
||||
- 任务模型:LedTask(LED1,500ms)、LedTask2(LED2,1000ms)为生产者,只向日志队列投递 `LogMsg_t`;PrintTask(优先级 3,栈 1024 字)消费队列并 printf。**主动日志打印由 `AppTasks_SetLogEnabled()` 控制,默认关闭**(CLI 命令 `log on|off` 切换)。新增需要打印的任务时沿用此生产者-消费者模式,不要在中断或多个任务里直接 `printf`。
|
||||
- CLI 任务(优先级 3,栈 1024 字,见 `app_cli.c`):从 USART1 RXDNE 中断的字节队列取输入,行结束符 `\r\n` / `\n\r` / `\r` / `\n` 均识别;解析-执行-应答一体化,应答走 `bsp_usart_write_dma`(DMA_CH1)。新命令在 `s_cmds[]` 命令表中注册。支持 Tab 命令补全、上下方向键历史回翻(8 条环形缓冲)、Ctrl+Z 关闭主动打印。
|
||||
- 串口输出并发:PrintTask 的整条 printf 与 CLI 的整段应答分别持有 `bsp_usart_tx_lock()` 互斥锁,避免字节级交错;调度器启动前该锁为空操作。
|
||||
- SysTick 由 FreeRTOS port 接管(`FreeRTOSConfig.h` 中 `xPortSysTickHandler → SysTick_Handler` 映射):`main` 中不要手动 `SysTick_Config`,`n32wb03x_it.c` 中不要重复定义 SVC/PendSV/SysTick_Handler。
|
||||
- USART1_IRQn 中断优先级为 3(最低),因 ISR 内调用 FreeRTOS FromISR API,必须 ≥ `configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY`(=3)。
|
||||
- `configTOTAL_HEAP_SIZE = 8*1024`,使用 heap_4。
|
||||
- `configTOTAL_HEAP_SIZE = 20*1024`(4 个任务栈各 1024 字 = 16KB,另加队列/TCB/空闲任务开销),使用 heap_4。
|
||||
|
||||
## 代码风格
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -26,15 +26,28 @@ Project File Date: 09/01/2026
|
||||
|
||||
<h2>Output:</h2>
|
||||
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin'
|
||||
Build target 'N32WB03X'
|
||||
compiling n32wb03x_it.c...
|
||||
compiling main.c...
|
||||
compiling app_tasks.c...
|
||||
compiling app_cli.c...
|
||||
Rebuild target 'N32WB03X'
|
||||
assembling startup_n32wb03x.s...
|
||||
compiling queue.c...
|
||||
compiling list.c...
|
||||
compiling timers.c...
|
||||
compiling misc.c...
|
||||
compiling tasks.c...
|
||||
compiling heap_4.c...
|
||||
compiling n32wb03x_dma.c...
|
||||
compiling port.c...
|
||||
compiling n32wb03x_usart.c...
|
||||
compiling system_n32wb03x.c...
|
||||
compiling n32wb03x_gpio.c...
|
||||
compiling n32wb03x_rcc.c...
|
||||
compiling main.c...
|
||||
compiling bsp_led.c...
|
||||
compiling bsp_usart.c...
|
||||
compiling app_tasks.c...
|
||||
compiling n32wb03x_it.c...
|
||||
compiling app_cli.c...
|
||||
linking...
|
||||
Program Size: Code=14712 RO-data=944 RW-data=112 ZI-data=10696
|
||||
Program Size: Code=15692 RO-data=944 RW-data=112 ZI-data=23496
|
||||
FromELF: creating hex file...
|
||||
After Build - User command #1: fromelf --bin --output=.\bin\embeddedSrc.bin .\Objects\embeddedSrc.axf
|
||||
".\Objects\embeddedSrc.axf" - 0 Error(s), 0 Warning(s).
|
||||
@ -50,7 +63,7 @@ Package Vendor: Nationstech
|
||||
D:\Keil_v5\Arm\Packs\Nationstech\N32WB03X_DFP\1.4.0\firmware\CMSIS\device
|
||||
|
||||
<h2>Collection of Component Files used:</h2>
|
||||
Build Time Elapsed: 00:00:03
|
||||
Build Time Elapsed: 00:00:02
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -175,7 +175,7 @@ I (D:\Keil_v5\ARM\ARMCC\include\stdlib.h)(0x5EC775FC)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h)(0x60DC5C77)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stddef.h)(0x5EC775FC)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdint.h)(0x5EC775FC)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96BAF9)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96C5B9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\portable.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h)(0x60DC5C77)
|
||||
@ -188,7 +188,7 @@ I (D:\Keil_v5\ARM\ARMCC\include\string.h)(0x5EC77604)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h)(0x60DC5C77)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stddef.h)(0x5EC775FC)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdint.h)(0x5EC775FC)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96BAF9)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96C5B9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\portable.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h)(0x60DC5C77)
|
||||
@ -203,7 +203,7 @@ I (D:\Keil_v5\ARM\ARMCC\include\string.h)(0x5EC77604)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h)(0x60DC5C77)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stddef.h)(0x5EC775FC)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdint.h)(0x5EC775FC)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96BAF9)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96C5B9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\portable.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h)(0x60DC5C77)
|
||||
@ -218,7 +218,7 @@ I (D:\Keil_v5\ARM\ARMCC\include\stdlib.h)(0x5EC775FC)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h)(0x60DC5C77)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stddef.h)(0x5EC775FC)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdint.h)(0x5EC775FC)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96BAF9)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96C5B9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\portable.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h)(0x60DC5C77)
|
||||
@ -232,7 +232,7 @@ F (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h)(0x60DC5C77)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stddef.h)(0x5EC775FC)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdint.h)(0x5EC775FC)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96BAF9)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96C5B9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\portable.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h)(0x60DC5C77)
|
||||
@ -245,7 +245,7 @@ I (D:\Keil_v5\ARM\ARMCC\include\stdlib.h)(0x5EC775FC)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h)(0x60DC5C77)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stddef.h)(0x5EC775FC)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdint.h)(0x5EC775FC)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96BAF9)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96C5B9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\portable.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h)(0x60DC5C77)
|
||||
@ -284,7 +284,7 @@ I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\inc
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdio.h)(0x5EC775FC)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h)(0x60DC5C77)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stddef.h)(0x5EC775FC)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96BAF9)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96C5B9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\portable.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h)(0x60DC5C77)
|
||||
@ -328,7 +328,7 @@ I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\inc
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdio.h)(0x5EC775FC)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h)(0x60DC5C77)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stddef.h)(0x5EC775FC)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96BAF9)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96C5B9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\portable.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h)(0x60DC5C77)
|
||||
@ -367,7 +367,7 @@ I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\inc
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\inc\n32wb03x_keyscan.h)(0x68CD0B36)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\inc\n32wb03x_qflash.h)(0x68CD0B36)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\inc\misc.h)(0x68CD0B30)
|
||||
F (..\app\app_tasks.c)(0x6A96C33A)(--c99 -c --cpu Cortex-M0 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\app -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\CMSIS\core -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\CMSIS\device -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\inc -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\portable\RVDS\ARM_CM0 -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include
-ID:\Keil_v5\Arm\Packs\Nationstech\N32WB03X_DFP\1.4.0\firmware\CMSIS\device
-ID:\Keil_v5\ARM\CMSIS\Include
-D__UVISION_VERSION="531" -DN32WB03x -DUSE_STDPERIPH_DRIVER -DN32WB03X -DUSE_STDPERIPH_DRIVER
-o .\objects\app_tasks.o --omf_browse .\objects\app_tasks.crf --depend .\objects\app_tasks.d)
|
||||
F (..\app\app_tasks.c)(0x6A96C5B9)(--c99 -c --cpu Cortex-M0 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\app -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\CMSIS\core -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\CMSIS\device -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\inc -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\portable\RVDS\ARM_CM0 -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include
-ID:\Keil_v5\Arm\Packs\Nationstech\N32WB03X_DFP\1.4.0\firmware\CMSIS\device
-ID:\Keil_v5\ARM\CMSIS\Include
-D__UVISION_VERSION="531" -DN32WB03x -DUSE_STDPERIPH_DRIVER -DN32WB03X -DUSE_STDPERIPH_DRIVER
-o .\objects\app_tasks.o --omf_browse .\objects\app_tasks.crf --depend .\objects\app_tasks.d)
|
||||
I (..\app\app_tasks.h)(0x6A96C2F1)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdint.h)(0x5EC775FC)
|
||||
I (..\app\bsp_led.h)(0x6A96BAAF)
|
||||
@ -401,7 +401,7 @@ I (..\app\bsp_usart.h)(0x6A96C2A9)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdio.h)(0x5EC775FC)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h)(0x60DC5C77)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stddef.h)(0x5EC775FC)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96BAF9)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96C5B9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\portable.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h)(0x60DC5C77)
|
||||
@ -410,7 +410,7 @@ I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\task.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\list.h)(0x60DC5C77)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\queue.h)(0x60DC5C76)
|
||||
F (..\app\app_cli.c)(0x6A96C393)(--c99 -c --cpu Cortex-M0 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\app -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\CMSIS\core -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\CMSIS\device -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\inc -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\portable\RVDS\ARM_CM0 -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include
-ID:\Keil_v5\Arm\Packs\Nationstech\N32WB03X_DFP\1.4.0\firmware\CMSIS\device
-ID:\Keil_v5\ARM\CMSIS\Include
-D__UVISION_VERSION="531" -DN32WB03x -DUSE_STDPERIPH_DRIVER -DN32WB03X -DUSE_STDPERIPH_DRIVER
-o .\objects\app_cli.o --omf_browse .\objects\app_cli.crf --depend .\objects\app_cli.d)
|
||||
F (..\app\app_cli.c)(0x6A96CA08)(--c99 -c --cpu Cortex-M0 -D__MICROLIB -g -O0 --apcs=interwork --split_sections -I ..\app -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\CMSIS\core -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\CMSIS\device -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\inc -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\portable\RVDS\ARM_CM0 -I ..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include
-ID:\Keil_v5\Arm\Packs\Nationstech\N32WB03X_DFP\1.4.0\firmware\CMSIS\device
-ID:\Keil_v5\ARM\CMSIS\Include
-D__UVISION_VERSION="531" -DN32WB03x -DUSE_STDPERIPH_DRIVER -DN32WB03X -DUSE_STDPERIPH_DRIVER
-o .\objects\app_cli.o --omf_browse .\objects\app_cli.crf --depend .\objects\app_cli.d)
|
||||
I (..\app\app_cli.h)(0x6A96C353)
|
||||
I (..\app\bsp_usart.h)(0x6A96C2A9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\CMSIS\device\n32wb03x.h)(0x68CD0B30)
|
||||
@ -447,7 +447,7 @@ I (D:\Keil_v5\ARM\ARMCC\include\string.h)(0x5EC77604)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stdarg.h)(0x5EC775FC)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\FreeRTOS.h)(0x60DC5C77)
|
||||
I (D:\Keil_v5\ARM\ARMCC\include\stddef.h)(0x5EC775FC)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96BAF9)
|
||||
I (..\app\FreeRTOSConfig.h)(0x6A96C5B9)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\projdefs.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\portable.h)(0x60DC5C76)
|
||||
I (..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\include\deprecated_definitions.h)(0x60DC5C77)
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,14 +1,9 @@
|
||||
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'D:\Keil_v5\ARM\ARMCC\Bin'
|
||||
Build target 'N32WB03X'
|
||||
compiling n32wb03x_it.c...
|
||||
compiling main.c...
|
||||
compiling app_tasks.c...
|
||||
compiling app_cli.c...
|
||||
compiling n32wb03x_dma.c...
|
||||
compiling bsp_usart.c...
|
||||
linking...
|
||||
Program Size: Code=14712 RO-data=944 RW-data=112 ZI-data=10696
|
||||
Program Size: Code=15692 RO-data=944 RW-data=112 ZI-data=23496
|
||||
FromELF: creating hex file...
|
||||
After Build - User command #1: fromelf --bin --output=.\bin\embeddedSrc.bin .\Objects\embeddedSrc.axf
|
||||
".\Objects\embeddedSrc.axf" - 0 Error(s), 0 Warning(s).
|
||||
Build Time Elapsed: 00:00:03
|
||||
Build Time Elapsed: 00:00:02
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -196,7 +196,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>STARTUP</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -216,7 +216,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>CMSIS</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -236,7 +236,7 @@
|
||||
|
||||
<Group>
|
||||
<GroupName>FWLB</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
@ -288,6 +288,18 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>3</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\nations-tec\N32WB03x_SDK_V2.0.0\firmware\n32wb03x_std_periph_driver\src\n32wb03x_dma.c</PathWithFileName>
|
||||
<FilenameWithoutPath>n32wb03x_dma.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
</Group>
|
||||
|
||||
<Group>
|
||||
@ -298,7 +310,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>7</FileNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -310,7 +322,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>8</FileNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -322,7 +334,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>9</FileNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -334,7 +346,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>4</GroupNumber>
|
||||
<FileNumber>10</FileNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -354,7 +366,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>5</GroupNumber>
|
||||
<FileNumber>11</FileNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -374,9 +386,9 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>6</GroupNumber>
|
||||
<FileNumber>12</FileNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\..\nations-tec\N32WB03x_SDK_V2.0.0\middlewares\Third_Party\FreeRTOS\Source\portable\MemMang\heap_4.c</PathWithFileName>
|
||||
@ -394,7 +406,7 @@
|
||||
<RteFlg>0</RteFlg>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>13</FileNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -406,7 +418,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>14</FileNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -418,7 +430,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>15</FileNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -430,7 +442,7 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>16</FileNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
@ -442,7 +454,19 @@
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>17</FileNumber>
|
||||
<FileNumber>18</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<bDave2>0</bDave2>
|
||||
<PathWithFileName>..\app\app_cli.c</PathWithFileName>
|
||||
<FilenameWithoutPath>app_cli.c</FilenameWithoutPath>
|
||||
<RteFlg>0</RteFlg>
|
||||
<bShared>0</bShared>
|
||||
</File>
|
||||
<File>
|
||||
<GroupNumber>7</GroupNumber>
|
||||
<FileNumber>19</FileNumber>
|
||||
<FileType>1</FileType>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#define configTICK_RATE_HZ ( ( TickType_t ) 1000 )
|
||||
#define configMAX_PRIORITIES ( 7 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( uint16_t ) 128 )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 8 * 1024 ) )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 20 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configUSE_TRACE_FACILITY 1
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
|
||||
@ -19,12 +19,20 @@
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
|
||||
#define CLI_TASK_STACK 256 /* in words (printf needs more stack) */
|
||||
#define CLI_TASK_STACK 1024 /* in words (printf needs more stack) */
|
||||
#define CLI_TASK_PRIO 3
|
||||
#define CLI_LINE_BUF_SIZE 64
|
||||
#define CLI_TX_BUF_SIZE 96
|
||||
#define CLI_MAX_ARGS 8
|
||||
#define CLI_PROMPT "n32> "
|
||||
#define CLI_HISTORY_SIZE 8 /* number of remembered command lines */
|
||||
#define CLI_PROMPT "caiic->"
|
||||
|
||||
/* Key codes */
|
||||
#define CLI_KEY_TAB 0x09
|
||||
#define CLI_KEY_ESC 0x1B
|
||||
#define CLI_KEY_CTRL_Z 0x1A
|
||||
#define CLI_KEY_BACKSPACE 0x08
|
||||
#define CLI_KEY_DEL 0x7F
|
||||
|
||||
typedef void (*CliCmdHandler_t)(int argc, char* argv[]);
|
||||
|
||||
@ -180,6 +188,7 @@ static void CmdHelp(int argc, char* argv[])
|
||||
{
|
||||
cli_printf(" %-8s %s\r\n", s_cmds[i].name, s_cmds[i].help);
|
||||
}
|
||||
cli_write("keys: TAB = complete, UP/DOWN = history, Ctrl+Z = log off\r\n");
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@ -235,14 +244,180 @@ static void cli_dispatch(char* line)
|
||||
cli_printf("unknown command: %s (try 'help')\r\n", argv[0]);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Command history (ring buffer) */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
static char s_history[CLI_HISTORY_SIZE][CLI_LINE_BUF_SIZE];
|
||||
static uint8_t s_histCount = 0; /* number of valid entries */
|
||||
static uint8_t s_histHead = 0; /* next write position */
|
||||
|
||||
/**
|
||||
* @brief Store a command line in the history ring (skips empty lines and
|
||||
* repeats of the most recent entry).
|
||||
*/
|
||||
static void cli_history_add(const char* line)
|
||||
{
|
||||
if (line[0] == '\0')
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (s_histCount > 0)
|
||||
{
|
||||
uint8_t last = (s_histHead + CLI_HISTORY_SIZE - 1) % CLI_HISTORY_SIZE;
|
||||
if (strcmp(s_history[last], line) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
strcpy(s_history[s_histHead], line);
|
||||
s_histHead = (s_histHead + 1) % CLI_HISTORY_SIZE;
|
||||
if (s_histCount < CLI_HISTORY_SIZE)
|
||||
{
|
||||
s_histCount++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get a history entry; nav = 0 is the newest entry.
|
||||
*/
|
||||
static const char* cli_history_get(int nav)
|
||||
{
|
||||
int idx = ((int)s_histHead - 1 - nav + CLI_HISTORY_SIZE) % CLI_HISTORY_SIZE;
|
||||
return s_history[idx];
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* Line redraw / tab completion */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
/**
|
||||
* @brief Redraw the input line: erase `shownLen` chars, print prompt + line.
|
||||
* @return new shown length
|
||||
*/
|
||||
static uint16_t cli_redraw_line(const char* line, uint16_t shownLen)
|
||||
{
|
||||
uint16_t i;
|
||||
uint16_t len = (uint16_t)strlen(line);
|
||||
|
||||
cli_write("\r" CLI_PROMPT);
|
||||
for (i = 0; i < shownLen; i++)
|
||||
{
|
||||
cli_write(" ");
|
||||
}
|
||||
cli_write("\r" CLI_PROMPT);
|
||||
if (len > 0)
|
||||
{
|
||||
bsp_usart_write_dma((const uint8_t*)line, len);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Tab completion on the first token of the line.
|
||||
* Single match: complete it and append a space.
|
||||
* Multiple matches: extend to the common prefix, or list candidates.
|
||||
*/
|
||||
static uint16_t cli_tab_complete(char* line, uint16_t len)
|
||||
{
|
||||
char common[CLI_LINE_BUF_SIZE];
|
||||
uint16_t commonLen = 0;
|
||||
int matchCount = 0;
|
||||
uint32_t i;
|
||||
|
||||
/* Only complete the first token (no space typed yet) */
|
||||
if (memchr(line, ' ', len) != NULL)
|
||||
{
|
||||
return len;
|
||||
}
|
||||
line[len] = '\0';
|
||||
|
||||
for (i = 0; i < CLI_CMD_COUNT; i++)
|
||||
{
|
||||
if (strncmp(s_cmds[i].name, line, len) == 0)
|
||||
{
|
||||
if (matchCount == 0)
|
||||
{
|
||||
strcpy(common, s_cmds[i].name);
|
||||
commonLen = (uint16_t)strlen(common);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* shrink common to the shared prefix */
|
||||
while (commonLen > len && strncmp(common, s_cmds[i].name, commonLen) != 0)
|
||||
{
|
||||
commonLen--;
|
||||
}
|
||||
common[commonLen] = '\0';
|
||||
}
|
||||
matchCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (matchCount == 0)
|
||||
{
|
||||
return len;
|
||||
}
|
||||
|
||||
if (matchCount == 1)
|
||||
{
|
||||
/* complete the command name + one space */
|
||||
while (len < CLI_LINE_BUF_SIZE - 1 && len < commonLen)
|
||||
{
|
||||
bsp_usart_write_dma((const uint8_t*)&common[len], 1);
|
||||
line[len] = common[len];
|
||||
len++;
|
||||
}
|
||||
if (len < CLI_LINE_BUF_SIZE - 1)
|
||||
{
|
||||
line[len] = ' ';
|
||||
len++;
|
||||
cli_write(" ");
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
if (commonLen > len)
|
||||
{
|
||||
/* extend to the common prefix */
|
||||
while (len < CLI_LINE_BUF_SIZE - 1 && len < commonLen)
|
||||
{
|
||||
bsp_usart_write_dma((const uint8_t*)&common[len], 1);
|
||||
line[len] = common[len];
|
||||
len++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ambiguous: list the candidates and redraw */
|
||||
cli_write("\r\n");
|
||||
for (i = 0; i < CLI_CMD_COUNT; i++)
|
||||
{
|
||||
if (strncmp(s_cmds[i].name, line, len) == 0)
|
||||
{
|
||||
cli_write(s_cmds[i].name);
|
||||
cli_write(" ");
|
||||
}
|
||||
}
|
||||
cli_write("\r\n");
|
||||
cli_redraw_line(line, len);
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CLI task: receive bytes, edit the line, dispatch on terminator.
|
||||
* Extra keys: Ctrl+Z turns off active log printing, TAB completes
|
||||
* the command name, UP/DOWN arrows walk the command history.
|
||||
*/
|
||||
static void CliTask(void* argument)
|
||||
{
|
||||
static char line[CLI_LINE_BUF_SIZE];
|
||||
uint16_t len = 0;
|
||||
uint16_t shownLen = 0; /* chars currently displayed after the prompt */
|
||||
uint8_t swallow = 0; /* complementary terminator to swallow once */
|
||||
uint8_t escState = 0; /* 0=normal, 1=got ESC, 2=got ESC '[' */
|
||||
int histNav = -1; /* -1 = editing, 0.. = history entry (0=newest) */
|
||||
uint8_t ch;
|
||||
(void)argument;
|
||||
|
||||
@ -266,6 +441,69 @@ static void CliTask(void* argument)
|
||||
}
|
||||
}
|
||||
|
||||
/* Escape sequences (arrow keys: ESC '[' 'A'/'B') */
|
||||
if (escState == 1)
|
||||
{
|
||||
escState = (ch == '[') ? 2 : 0;
|
||||
continue;
|
||||
}
|
||||
if (escState == 2)
|
||||
{
|
||||
escState = 0;
|
||||
if (ch == 'A') /* UP: older history entry */
|
||||
{
|
||||
if (histNav + 1 < (int)s_histCount)
|
||||
{
|
||||
histNav++;
|
||||
strcpy(line, cli_history_get(histNav));
|
||||
shownLen = cli_redraw_line(line, shownLen);
|
||||
len = (uint16_t)strlen(line);
|
||||
}
|
||||
}
|
||||
else if (ch == 'B') /* DOWN: newer entry / back to empty line */
|
||||
{
|
||||
if (histNav >= 0)
|
||||
{
|
||||
histNav--;
|
||||
if (histNav >= 0)
|
||||
{
|
||||
strcpy(line, cli_history_get(histNav));
|
||||
}
|
||||
else
|
||||
{
|
||||
line[0] = '\0';
|
||||
}
|
||||
shownLen = cli_redraw_line(line, shownLen);
|
||||
len = (uint16_t)strlen(line);
|
||||
}
|
||||
}
|
||||
/* other escape sequences are ignored */
|
||||
continue;
|
||||
}
|
||||
if (ch == CLI_KEY_ESC)
|
||||
{
|
||||
escState = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == CLI_KEY_CTRL_Z)
|
||||
{
|
||||
/* Ctrl+Z: turn off active log printing */
|
||||
AppTasks_SetLogEnabled(0);
|
||||
cli_write("\r\n[log off]\r\n");
|
||||
shownLen = cli_redraw_line(line, len);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == CLI_KEY_TAB)
|
||||
{
|
||||
bsp_usart_tx_lock();
|
||||
len = cli_tab_complete(line, len);
|
||||
shownLen = len;
|
||||
bsp_usart_tx_unlock();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ch == '\r' || ch == '\n')
|
||||
{
|
||||
/* Any of "\r", "\n", "\r\n", "\n\r" terminates the line */
|
||||
@ -274,18 +512,22 @@ static void CliTask(void* argument)
|
||||
bsp_usart_tx_lock();
|
||||
cli_write("\r\n");
|
||||
line[len] = '\0';
|
||||
cli_history_add(line); /* copy before dispatch tokenizes in place */
|
||||
cli_dispatch(line);
|
||||
cli_write(CLI_PROMPT);
|
||||
bsp_usart_tx_unlock();
|
||||
|
||||
len = 0;
|
||||
shownLen = 0;
|
||||
histNav = -1;
|
||||
}
|
||||
else if (ch == '\b' || ch == 0x7F)
|
||||
else if (ch == CLI_KEY_BACKSPACE || ch == CLI_KEY_DEL)
|
||||
{
|
||||
if (len > 0)
|
||||
{
|
||||
len--;
|
||||
cli_write("\b \b");
|
||||
shownLen = len;
|
||||
}
|
||||
}
|
||||
else if (ch >= 0x20 && ch < 0x7F)
|
||||
@ -294,6 +536,7 @@ static void CliTask(void* argument)
|
||||
{
|
||||
line[len++] = (char)ch;
|
||||
bsp_usart_write_dma(&ch, 1); /* echo */
|
||||
shownLen = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -16,8 +16,8 @@
|
||||
#define LED2_PERIOD_MS 1000
|
||||
#define LOG_QUEUE_LENGTH 10
|
||||
|
||||
#define LED_TASK_STACK 128 /* in words */
|
||||
#define PRINT_TASK_STACK 256 /* printf needs more stack */
|
||||
#define LED_TASK_STACK 1024 /* in words */
|
||||
#define PRINT_TASK_STACK 1024 /* printf needs more stack */
|
||||
#define LED_TASK_PRIO 2
|
||||
#define PRINT_TASK_PRIO 3
|
||||
|
||||
|
||||
@ -157,3 +157,43 @@ LED 任务照常翻转,仅在开关打开时才向日志队列投递消息。
|
||||
- 烧录后预期:banner 之后出现 `CLI ready. Type 'help' for commands.` 与 `n32> ` 提示符;
|
||||
默认无 LED 滚动日志,`log on` 后恢复。
|
||||
- 注意:尚未上板实测,DMA 与中断路径需硬件验证。
|
||||
|
||||
---
|
||||
|
||||
日期:2026-09-01
|
||||
|
||||
## 11. 任务栈统一调整为 1024 字
|
||||
|
||||
- 上板实测 DMA/CLI/日志开关运行正常后,4 个任务栈统一调整为 1024 字(4KB/任务):
|
||||
`LED_TASK_STACK` / `PRINT_TASK_STACK`(app_tasks.c)、`CLI_TASK_STACK`(app_cli.c)。
|
||||
- 4 任务共 16KB 栈,超出原 8KB heap,故 `configTOTAL_HEAP_SIZE` 由 8KB 调至 20KB
|
||||
(含队列、TCB、空闲任务栈 128 字的开销)。
|
||||
- 编译:0 Error / 0 Warning;体积 `Code=14712 RO-data=944 RW-data=112 ZI-data=22984`,
|
||||
ZI 约占 48KB RAM 的 47%,余量充足。
|
||||
|
||||
---
|
||||
|
||||
日期:2026-09-01
|
||||
|
||||
## 12. CLI 增强:Ctrl+Z 关日志、Tab 补全、命令历史
|
||||
|
||||
均在 `app_cli.c` 的 CliTask 中实现:
|
||||
|
||||
- **Ctrl+Z(0x1A)**:立即 `AppTasks_SetLogEnabled(0)` 关闭主动打印,打印 `[log off]`
|
||||
并重绘当前输入行。用于 log 滚动刷屏时快速停止。
|
||||
- **Tab(0x09)自动补全**:仅补全行首命令名(已含空格则不动作)。唯一匹配则补全
|
||||
并追加空格;多个匹配则先扩展公共前缀,无法扩展时列出候选并重绘输入行。
|
||||
- **命令历史**:环形缓冲 8 条 × 64 字节(`s_history`),提交时去重(空行、与上一条
|
||||
相同不入队);上/下方向键(`ESC [ A` / `ESC [ B` 转义序列状态机解析)回翻历史,
|
||||
越过最新一条回到空行。回翻采用"清行重绘"(`\r` + 提示符 + 空格擦除 + 重显)。
|
||||
- `help` 输出末尾附按键说明。
|
||||
- 编译:0 Error / 0 Warning;体积 `Code=15688 RO-data=944 RW-data=112 ZI-data=23496`。
|
||||
|
||||
---
|
||||
|
||||
日期:2026-09-01
|
||||
|
||||
## 13. CLI 提示符修改
|
||||
|
||||
- 命令行提示符由 `n32> ` 改为 `caiic->`(`app_cli.c` 中 `CLI_PROMPT` 宏)。
|
||||
- 编译:0 Error / 0 Warning;体积 `Code=15692 RO-data=944 RW-data=112 ZI-data=23496`。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user