From 0395a811f704d9a2272fe42e808364790e94b9bb Mon Sep 17 00:00:00 2001 From: Steven Dan Date: Tue, 9 Jun 2026 18:10:05 +0800 Subject: [PATCH] enable key verify --- .../src/extensions/audiohw.xc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sw_usb_audio/app_usb_aud_fosi_c1/src/extensions/audiohw.xc b/sw_usb_audio/app_usb_aud_fosi_c1/src/extensions/audiohw.xc index 941f414..73e2da6 100644 --- a/sw_usb_audio/app_usb_aud_fosi_c1/src/extensions/audiohw.xc +++ b/sw_usb_audio/app_usb_aud_fosi_c1/src/extensions/audiohw.xc @@ -144,6 +144,8 @@ timer tm; #define C1_JACK_DEBOUNCE_SAMPLES 3u extern void device_reboot(void); +extern unsigned char key_validate(unsigned char offset); +extern void flash_opt_unlock(void); // 改动原因:判断 Flash 读出字节是否为合法 NAU88C22 DAC 音量码:0x00 表示按键规则下的 mute,0x4B~0xCF 为正常衰减范围。 static unsigned c1_saved_dac_vol_is_valid(unsigned char v) @@ -394,7 +396,7 @@ static inline i2c_regop_res_t NAU88C22_REGWRITE(unsigned reg, unsigned val, clie } else { - // debug_printf("write reg [0x%02X] [0x%02X]\n", reg, val); + debug_printf("write reg [0x%02X] [0x%02X]\n", reg, val); } return result; @@ -586,6 +588,17 @@ void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, cli eq_mode_time += EQ_MODE_DELAY; eq_sync_timer :> eq_sync_time; eq_sync_time += EQ_SYNC_DELAY; + unsigned key_verified = 0; + + delay_milliseconds(10); + + if (key_validate(1) == 1) + { + key_verified = 1; + } + + flash_opt_unlock(); + unsigned c1_mode = load_value(C1_MODE_INFO_PATH); #if HID_DFU_EN @@ -1552,8 +1565,7 @@ void AudioHwRemote2(streaming chanend c, client interface i2c_master_if i2c, cli if ((se_count % 90) == 0) { - unsigned key = GetKeyFlag(); - if (key != 0x20241224) + if (key_verified == 0) { debug_printf("se reboot\n"); device_reboot();