状态灯: LED1(PB1)运行心跳 + LED2(PB2)蓝牙连接指示 (APP V1.00.42)

- LED1 改 PB1(运行心跳闪灯, 半周期=led1_blink_ms), LED2 改 PB2(蓝牙连接亮灯)
- main.c 新增 led_task 心跳 + 启动 LedInit/LedOff(LED2)
- app_ble.c connected/disconnected 控制 LED2 亮灭
- 仅 APP 改动, Boot 不动 (仍 V1.00.07)
- docs/开发日志.md: 新增 §71
This commit is contained in:
evan.liu 2026-09-13 14:18:33 +08:00
parent f34efe9070
commit ea1dbe4230
16 changed files with 6630 additions and 6529 deletions

View File

@ -1674,3 +1674,18 @@ APP2 链接的镜像发向 APP1 区。设备端 END 校验(向量表 Reset PC
- 删除 `CmdAppTest` 与 `apptest` 命令表条目;`disptest` help 更新。 - 删除 `CmdAppTest` 与 `apptest` 命令表条目;`disptest` help 更新。
- 版本:APP `V1.00.40` → `V1.00.41`(`APP_FW_VERSION_NUM` 0x00010028 → - 版本:APP `V1.00.40` → `V1.00.41`(`APP_FW_VERSION_NUM` 0x00010028 →
0x00010029)。Boot 不动(仍 V1.00.07)。 0x00010029)。Boot 不动(仍 V1.00.07)。
## 71. 状态灯:LED1(PB1) 运行心跳 + LED2(PB2) 蓝牙连接指示(2026-09-06,APP V1.00.42,仅 APP)
- 用户外接:PB1→LED1、PB2→LED2;需求:LED1 作 APP 运行状态灯、LED2 作
蓝牙连接指示。
- 修改:
- `app_gpio.h`:LED1 改 `GPIOB/PIN_1`(PB1)、LED2 改 `GPIOB/PIN_2`(PB2)
(原 PB0/PA6 已让给数码管);
- `main.c`:新增 `led_task`(优先级 1、栈 128 字)——`LedBlink(LED1)` +
以 `app_params_get()->led1_blink_ms`(默认 500ms)为半周期闪烁 + 喂狗;
启动时 `LedInit(LED1/LED2)`、`LedOff(LED2)`,并 `xTaskCreate(led_task)`;
- `app_ble.c`:`app_ble_connected()` 里 `LedOn(LED2)`、`app_ble_disconnected()`
里 `LedOff(LED2)`。
- 版本:APP `V1.00.41` → `V1.00.42`(`APP_FW_VERSION_NUM` 0x00010029 →
0x0001002A)。Boot 不动(仍 V1.00.07)。

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -63,9 +63,9 @@ extern "C" {
#include "n32wb03x.h" #include "n32wb03x.h"
#define LED1_PORT GPIOB #define LED1_PORT GPIOB
#define LED1_PIN GPIO_PIN_0 #define LED1_PIN GPIO_PIN_1 /* PB1: APP running status LED (heartbeat blink) */
#define LED2_PORT GPIOA #define LED2_PORT GPIOB
#define LED2_PIN GPIO_PIN_6 #define LED2_PIN GPIO_PIN_2 /* PB2: BLE connected indicator LED */
void LedInit(GPIO_Module* GPIOx, uint16_t Pin); void LedInit(GPIO_Module* GPIOx, uint16_t Pin);

View File

@ -9,12 +9,12 @@
#define __APP_VERSION_H__ #define __APP_VERSION_H__
#ifndef APP_FW_VERSION #ifndef APP_FW_VERSION
#define APP_FW_VERSION "V1.00.41" #define APP_FW_VERSION "V1.00.42"
#endif #endif
/* Numeric form used by the BLE info query / OTA records: 0x00MMmmpp */ /* Numeric form used by the BLE info query / OTA records: 0x00MMmmpp */
#ifndef APP_FW_VERSION_NUM #ifndef APP_FW_VERSION_NUM
#define APP_FW_VERSION_NUM 0x00010029u #define APP_FW_VERSION_NUM 0x0001002Au
#endif #endif
#endif /* __APP_VERSION_H__ */ #endif /* __APP_VERSION_H__ */

View File

@ -315,6 +315,7 @@ void app_ble_init(void)
void app_ble_connected(void) void app_ble_connected(void)
{ {
notify_en = 0; notify_en = 0;
LedOn(LED2_PORT, LED2_PIN); /* PB2: BLE connected indicator on */
if (app_ble_proto_log_get()) if (app_ble_proto_log_get())
{ {
printf("[BLE] connected\r\n"); printf("[BLE] connected\r\n");
@ -341,6 +342,7 @@ void app_ble_disconnected(void)
app_ble_proto_on_disconnect(); /* drop half RX frame + uplink buffer */ app_ble_proto_on_disconnect(); /* drop half RX frame + uplink buffer */
notify_en = 0; notify_en = 0;
LedOff(LED2_PORT, LED2_PIN); /* PB2: BLE connected indicator off */
if (app_ble_proto_log_get()) if (app_ble_proto_log_get())
{ {
printf("[BLE] disconnected, advertising restarted\r\n"); printf("[BLE] disconnected, advertising restarted\r\n");

View File

@ -107,6 +107,8 @@
#define BLE_SCHED_TASK_PRIORITY (2) #define BLE_SCHED_TASK_PRIORITY (2)
#define DISP_TASK_STACK (256) /* stack in words */ #define DISP_TASK_STACK (256) /* stack in words */
#define DISP_TASK_PRIORITY (1) #define DISP_TASK_PRIORITY (1)
#define LED_TASK_STACK (128) /* stack in words */
#define LED_TASK_PRIORITY (1)
/* Private constants ----------------------------------------------------------*/ /* Private constants ----------------------------------------------------------*/
/* Private variables ----------------------------------------------------------*/ /* Private variables ----------------------------------------------------------*/
@ -189,6 +191,21 @@ static void ble_schedule_task(void *pvParameters)
} }
} }
/**
* @brief LED1 (PB1) "running" heartbeat: blinks at the APP_DATA parameter
* led1_blink_ms half-period so a live board is visually obvious.
*/
static void led_task(void *pvParameters)
{
(void)pvParameters;
for (;;)
{
app_wdt_heartbeat();
LedBlink(LED1_PORT, LED1_PIN);
vTaskDelay(pdMS_TO_TICKS(app_params_get()->led1_blink_ms));
}
}
/** /**
* @brief main function * @brief main function
* @param * @param
@ -236,12 +253,20 @@ int main(void)
* deep sleep conflicts with the FreeRTOS tick). */ * deep sleep conflicts with the FreeRTOS tick). */
ns_sleep_lock_acquire(); ns_sleep_lock_acquire();
/* status LEDs: LED1(PB1) running heartbeat, LED2(PB2) BLE link */
LedInit(LED1_PORT, LED1_PIN);
LedInit(LED2_PORT, LED2_PIN);
LedOff(LED2_PORT, LED2_PIN);
/* BLE kernel schedule task (replaces the bare-metal while loop) */ /* BLE kernel schedule task (replaces the bare-metal while loop) */
xTaskCreate(ble_schedule_task, "BLE", BLE_SCHED_TASK_STACK, NULL, xTaskCreate(ble_schedule_task, "BLE", BLE_SCHED_TASK_STACK, NULL,
BLE_SCHED_TASK_PRIORITY, NULL); BLE_SCHED_TASK_PRIORITY, NULL);
/* YF30137 7-seg display scan task (Charlieplexing over 7 GPIOs) */ /* YF30137 7-seg display scan task (Charlieplexing over 7 GPIOs) */
xTaskCreate(display_task, "DISP", DISP_TASK_STACK, NULL, xTaskCreate(display_task, "DISP", DISP_TASK_STACK, NULL,
DISP_TASK_PRIORITY, NULL); DISP_TASK_PRIORITY, NULL);
/* LED1 running heartbeat blink task */
xTaskCreate(led_task, "LED", LED_TASK_STACK, NULL,
LED_TASK_PRIORITY, NULL);
/* CLI task (command parsing/execution/response over UART + BLE) */ /* CLI task (command parsing/execution/response over UART + BLE) */
AppCli_Init(); AppCli_Init();

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,7 +1,7 @@
{ {
"file": "mothercup_ble_prod_ota.bin", "file": "mothercup_ble_prod_ota.bin",
"target_bank": 1, "target_bank": 1,
"size": 59928, "size": 60168,
"crc32": "0xBC3F632D", "crc32": "0xAA83583C",
"version": 65577 "version": 65578
} }

View File

@ -1,7 +1,7 @@
{ {
"file": "mothercup_ble_prod_ota_app2.bin", "file": "mothercup_ble_prod_ota_app2.bin",
"target_bank": 2, "target_bank": 2,
"size": 60228, "size": 60468,
"crc32": "0x3BE600E0", "crc32": "0xABC86CA6",
"version": 65577 "version": 65578
} }