From 3ade6ed9167b6f063271e521f37f38fc7a301d79 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Wed, 12 Jun 2024 20:43:29 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96=E8=93=9D=E7=89=99=E4=BA=A7?= =?utf8?q?=E6=B5=8B=EF=BC=8C=E4=BD=BF=E8=83=BD=E6=8C=89=E9=94=AE=E5=8F=8C?= =?utf8?q?=E5=87=BB=E6=A3=80=E6=B5=8B=EF=BC=8C=E6=B7=BB=E5=8A=A0efuse?= =?utf8?q?=E8=AF=BB=E5=86=99=E6=B5=8B=E8=AF=95=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../factorytest_protocol.c | 133 +++++++++++++++++- .../product/product_evb4_standard.h | 2 +- .../cywee/src/custom_factory_core.c | 4 +- .../drivers/peripheral/utils/custom_utils.c | 13 ++ .../drivers/peripheral/utils/custom_utils.h | 1 + .../peripheral/utils/custom_utils_at_cmd.c | 12 +- 6 files changed, 160 insertions(+), 5 deletions(-) diff --git a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c index fafe602d6..0beb7e92e 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -59,6 +59,7 @@ typedef struct #pragma pack() +static int factorytest_mode_flag = 0; ble_aging_t aging_t; @@ -122,6 +123,68 @@ errcode_t factorytest_protocol_replymsg(uint8_t mode, uint8_t submode,uint8_t te return ret; } +static void pwr_button_callback_press(void) +{ + uint8_t send_data = 1; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x02, + &send_data, + 1); +} +static void pwr_button_callback_click_2(void) +{ + uint8_t send_data = 3; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x02, + &send_data, + 1); +} +static void pwr_button_callback_long_press_2s(void) +{ + uint8_t send_data = 2; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x02, + &send_data, + 1); +} + +static void func_button_callback_press(void) +{ + uint8_t send_data = 1; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x03, + &send_data, + 1); +} +static void func_button_callback_click_2(void) +{ + uint8_t send_data = 3; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x03, + &send_data, + 1); +} +static void func_button_callback_long_press_2s(void) +{ + uint8_t send_data = 2; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x03, + &send_data, + 1); +} + void ble_vibrator_check_timer_callback(void) { uapi_vibrationModeSet(3); @@ -390,6 +453,33 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t printf("submode 0x%02X testitem 0x%02X\r\n",submode,testitem); switch(submode) { + case BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE: + if (testitem == 0x01) + { + + uint8_t send_data=0; + + factorytest_mode_flag = 1; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_COMMON, + BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE, + 0x01, + send_data, + 1); + } else if (testitem == 0x02) + { + + uint8_t send_data=0; + + factorytest_mode_flag = 0; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_COMMON, + BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE, + 0x02, + send_data, + 1); + } + break; case BLE_TEST_CMD_COMMON_SUB_MODE_SYSTEM_VERSION: if (testitem == 0x01) { @@ -670,7 +760,46 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint break; case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY: - //按键测试(未完成) + //清除按键测试结果 + if(testitem == 0x01) + { + uint8_t send_data = 0; + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x01, + &send_data, + 1); + } else if(testitem == 0x02) + { + //查询电源键测试结果 + uint8_t send_data = 0; + + uapi_button_register_event_cb(pwr_button_callback_press, 1); + uapi_button_register_event_cb(pwr_button_callback_click_2, 3); + uapi_button_register_event_cb(pwr_button_callback_long_press_2s, 5); + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x02, + &send_data, + 1); + } else if(testitem == 0x03) + { + //查询功能键测试结果 + uint8_t send_data = 0; + + uapi_button_register_event_cb(func_button_callback_press, 24); + uapi_button_register_event_cb(func_button_callback_click_2, 26); + uapi_button_register_event_cb(func_button_callback_long_press_2s, 28); + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, + 0x03, + &send_data, + 1); + } + break; case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_RTC: @@ -1516,6 +1645,8 @@ errcode_t factorytest_protocol_decode(uint8_t *buf, uint16_t event_size) //if( crc16 == crc16_2) //校验通过,开始正式解析 { + if(factorytest_mode_flag == 0 && header.submod != BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE) + return ERRCODE_FAIL; printf("mode %d\n",header.mode); switch(header.mode) { diff --git a/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h b/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h index 39fe7824e..24d6e2bc3 100755 --- a/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h +++ b/code/sdk/drivers/boards/brandy_evb/product/product_evb4_standard.h @@ -193,7 +193,7 @@ #define CONFIG_PM_SLEEP_INT_EN NO // Double-click the key -#define CONFIG_SUPPORT_BUTTON_DOUBLE_CLICK NO +#define CONFIG_SUPPORT_BUTTON_DOUBLE_CLICK YES // LCD VCI_EN #define VCI_LCD_GPIO S_AGPIO_L24 diff --git a/code/sdk/drivers/peripheral/cywee/src/custom_factory_core.c b/code/sdk/drivers/peripheral/cywee/src/custom_factory_core.c index 915139a0d..d24dab306 100644 --- a/code/sdk/drivers/peripheral/cywee/src/custom_factory_core.c +++ b/code/sdk/drivers/peripheral/cywee/src/custom_factory_core.c @@ -45,7 +45,7 @@ void reburn_log_printf(const char* fmt, ...) { static int is_sec_empty(uint8_t* buf, uint32_t len) { for (int i = 0 ; i < len ; i++) { if (buf[i] != m_var.sec_empty_value) { - reburn_log_printf("is_sec_empty(): block %d not empty(0x%02x)\n", i, buf[i]); + printf("is_sec_empty(): block %d not empty(0x%02x)\n", i, buf[i]); return 0; } } @@ -60,7 +60,7 @@ static void dump_sec(uint8_t* buf, uint32_t len) { return; while (remainBytes >= 16) { - reburn_log_printf("%08x | %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", offset, + printf("%08x | %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n", offset, *(buf + (offset) + 0 ), *(buf + (offset) + 1 ), *(buf + (offset) + 2 ), *(buf + (offset) + 3 ), *(buf + (offset) + 4 ), *(buf + (offset) + 5 ), *(buf + (offset) + 6 ), *(buf + (offset) + 7 ), *(buf + (offset) + 8 ), *(buf + (offset) + 9 ), *(buf + (offset) + 10), *(buf + (offset) + 11), diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 630eea7ed..25a108edf 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -2184,4 +2184,17 @@ void uapi_check_spk(bool isopen) #ifdef FD230 check_spk(isopen); #endif +} + +void uapi_efuse_test(void) +{ + uint8_t writedata[8] = {1,2,3,4,5,6,7,8}; + uint8_t readdata[8] = {0}; + + uapi_efuse_write_buffer(0x170, writedata, 8); + + uapi_efuse_read_buffer(readdata, 0x170, 8); + for(int i = 0; i < 8; i++) + PRINT("readdata[%d] : %d \r\n",i,readdata[i]); + } \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 574d8dbfa..1b654cba9 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -200,6 +200,7 @@ void uapi_ppg_get_id(uint8_t *chip_id); void uapi_microhone_switch(bool isopen); void uapi_check_spk(bool isopen); +void uapi_efuse_test(void); #include "custom_utilscpp.h" diff --git a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c index 851b4b1a1..f1c49636e 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils_at_cmd.c @@ -592,6 +592,16 @@ static uint32_t custom_test_sntp(uint8_t *para, uint32_t paraLen, char *strCommo return ERRCODE_SUCC; } +static uint32_t custom_uapi_efuse_test(uint8_t *para, uint32_t paraLen, char *strCommonCmd) +{ + + UNUSED(strCommonCmd); + + uapi_efuse_test(); + + return ERRCODE_SUCC; +} + static const at_cmd_table_t g_custom_utils_cmd[] = { { (char *)"AT^CUSTOM_SN", custom_utils_setsn, (char *)"123456789ABCDEF2345678" }, { (char *)"AT^CUSTOM_SN_REQ", custom_utils_getsn, (char *)" " }, @@ -638,7 +648,7 @@ static const at_cmd_table_t g_custom_utils_cmd[] = { { (char *)"AT^TIMESYNC", custom_test_time_synct, (char *)" " }, { (char *)"AT^24HOUR", custom_test_time_showtype, (char *)" " }, - + { (char *)"AT^EFUSETEST", custom_uapi_efuse_test, (char *)" " }, }; -- 2.17.1