debug: 增加 KEY_SOS 物理按键开机自检与运行期电平跳变串口调试打印

This commit is contained in:
2026-07-29 10:04:00 +08:00
parent 2f4dd2660d
commit 48db6523fb
2 changed files with 18 additions and 0 deletions

View File

@@ -196,6 +196,19 @@ void Event_KeyScan_Poll(void)
u8 raw_sos = !KEY_SOS; // 恢复 SOS 物理按键电平检测
key_scan_timer = 0; // 重置扫描分频计数器
// 【SOS 按键电平实时诊断】
{
static u8 last_raw_sos = 99;
if (raw_sos != last_raw_sos) {
last_raw_sos = raw_sos;
Uart_SendString("[KEY-DIAG] KEY_SOS (P2.6) logic raw: ");
Uart_SendByte(raw_sos ? '1' : '0');
Uart_SendString(", Physical GPIO Pin: ");
Uart_SendByte(KEY_SOS ? '1' : '0');
Uart_SendString("\r\n");
}
}
// 按键调试诊断:若按键 ADC 值有变化或处于高电平,串口输出真实 ADC 值
{
u16 down_val = ADC_ReadFiltered(ADC_CHANNEL_KEY_DOWN);

View File

@@ -212,6 +212,11 @@ void Self_Test(void)
Uart_SendByte((u8)('0' + (key_down_adc % 10)));
Uart_SendString(" [OK]\r\n");
// 2.2 检测 KEY_SOS (P2.6) 物理电平常态
Uart_SendString("[SELF-TEST] KEY_SOS (P2.6) Pin Level: ");
Uart_SendByte((u8)(KEY_SOS ? '1' : '0'));
Uart_SendString("\r\n");
// 3. 检查 P1.3 电池电压检测与百分比
vbat_mv = ADC_GetBatteryVoltage_mV();
percent = ADC_GetBatteryPercent();