From: penglei <1624952103@qq.com> Date: Mon, 21 Jul 2025 01:41:22 +0000 (+0800) Subject: 兼容n9 230蓝牙产测 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=9567cf5b7447ac79b3aefd14f4b106cf13489a97;p=mirrors%2FFD230.git 兼容n9 230蓝牙产测 --- 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 a70915396..a81a95686 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-17 14:31:08 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-01 16:30:09 + * @LastEditTime: 2025-07-16 17:17:45 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -65,9 +65,7 @@ #ifdef ENABLE_HP4570 #include "hp4570.h" #endif -#ifdef PPG_VC9202 -#include "vc9202_user.h" -#endif + #ifdef SUPPORT_GNSS #include "gnss_ctl.h" #include "NMEA0183.h" @@ -83,6 +81,8 @@ static gps_data_t send_gps_data = {0}; #include "gyro_hal.h" #endif +#include "touch_screen_drv.h" +#include "rotary_encoder_drv.h" #pragma pack(1) typedef struct factorytest_cmd_header_t @@ -296,10 +296,8 @@ void aging_task(void) // /*********************TP 老化测试*****************************/ //读TP ID uint16_t tp_id; -#ifdef TPTYPE_FT6X46 - touch_getid(&tp_id); -#endif - if(tp_id != 0x6456) + touch_get_chip_id(&tp_id); + if(tp_id != TP_CHIP_ID) { aging_t.tp_error++; aging_t.fail_num++; @@ -308,11 +306,9 @@ void aging_task(void) /*********************表冠 老化测试*****************************/ //读crown ID - uint8_t crown_id = 0; -#ifdef ROTARYENCODER_HX3507 - crown_read_id(&crown_id); -#endif - if(crown_id != 0x30) + uint16_t crown_id = 0; + rotary_get_chip_id(&crown_id); + if(crown_id != ROTARY_CHIP_ID) { aging_t.crown_error++; aging_t.fail_num++; @@ -405,7 +401,7 @@ void aging_task(void) #ifdef SUPPORT_PPG_SERVICE send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST); - LOS_Msleep(1000); + LOS_Msleep(2000); ppg_get_leaklight_data(&green,&red,&ir); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); #endif @@ -626,11 +622,11 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t mmc5603_getid(&mmc_id); if(mmc_id != 0x10) send_data[1] |= 2 << 4; -#ifdef TPTYPE_FT6X46 - touch_getid(&tp_id); -#endif + + touch_get_chip_id(&tp_id); + PRINT("touch_getid : %2X \r\n",tp_id); - if(tp_id != 0x6456) + if(tp_id != TP_CHIP_ID) send_data[1] |= 1 << 4; #ifdef SUPPORT_PPG_SERVICE id = ppg_get_chip_id(); @@ -1273,9 +1269,9 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //获取TP_ID uint16_t id = 0; uint8_t tp_id[3]; -#ifdef TPTYPE_FT6X46 - touch_getid(&id); -#endif + + touch_get_chip_id(&id); + tp_id[0] = 0; tp_id[1] = id >> 8; tp_id[2] = id; @@ -1445,20 +1441,21 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 1); } else if(testitem == 0x03) { - //打开心率检测 + //获取绿灯数据 + uint8_t databuf[4] = {0}; +#ifdef BOARD_FD230 #ifdef PPG_HX3695 send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SINGLE_CHECK_MODE_TEST); - LOS_Msleep(500); + LOS_Msleep(2000); FT_RESULTS_t ft_result = hx3695_factroy_test(SINGLE_CHECK_TEST); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); - uint8_t databuf[4] = {0}; databuf[0] = (uint8_t)((ft_result.gr_data_final & 0xFF000000) >> 24); databuf[1] = (uint8_t)((ft_result.gr_data_final & 0x00FF0000) >> 16); databuf[2] = (uint8_t)((ft_result.gr_data_final & 0x0000FF00) >> 8); databuf[3] = (uint8_t)((ft_result.gr_data_final & 0x000000FF) >> 0); - PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); + PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, @@ -1466,21 +1463,63 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint databuf, 4); #endif +#elif defined BOARD_N9 + int32_t data = 0; +#ifdef SUPPORT_PPG_SERVICE + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_TEST); + LOS_Msleep(2000); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); + data = ppg_get_factory_data(); +#endif + PRINT("%d\r\n",data); + + + databuf[0] = (uint8_t)((data & 0xFF000000) >> 24); + databuf[1] = (uint8_t)((data & 0x00FF0000) >> 16); + databuf[2] = (uint8_t)((data & 0x0000FF00) >> 8); + databuf[3] = (uint8_t)((data & 0x000000FF) >> 0); +#endif + + PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, + 0x03, + databuf, + 4); + } else if(testitem == 0x04) { - //打开血氧检测 + uint8_t databuf[4] = {0}; +#ifdef BOARD_FD230 #ifdef PPG_HX3695 send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SINGLE_CHECK_MODE_TEST); LOS_Msleep(500); FT_RESULTS_t ft_result = hx3695_factroy_test(SINGLE_CHECK_TEST); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); - uint8_t databuf[4] = {0}; databuf[0] = (uint8_t)((ft_result.red_data_final & 0xFF000000) >> 24); databuf[1] = (uint8_t)((ft_result.red_data_final & 0x00FF0000) >> 16); databuf[2] = (uint8_t)((ft_result.red_data_final & 0x0000FF00) >> 8); databuf[3] = (uint8_t)((ft_result.red_data_final & 0x000000FF) >> 0); +#endif +#elif defined BOARD_N9 + //获取红灯数据 + int32_t data = 0; +#ifdef SUPPORT_PPG_SERVICE + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST); + LOS_Msleep(2000); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); + data = ppg_get_factory_data(); +#endif + PRINT("%d\r\n",data); + + databuf[0] = (uint8_t)((data & 0xFF000000) >> 24); + databuf[1] = (uint8_t)((data & 0x00FF0000) >> 16); + databuf[2] = (uint8_t)((data & 0x0000FF00) >> 8); + databuf[3] = (uint8_t)((data & 0x000000FF) >> 0); +#endif PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, @@ -1488,13 +1527,13 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 0x04, databuf, 4); -#endif + } else if(testitem == 0x05) { #ifdef PPG_HX3695 //灰卡测试 send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST); - LOS_Msleep(1000); + LOS_Msleep(2000); uint8_t databuf[12] = {0}; FT_RESULTS_t ft_result = hx3695_factroy_test(GRAY_CARD_TEST); databuf[0] = (uint8_t)((ft_result.gr_data_final & 0xFF000000) >> 24); @@ -1537,7 +1576,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint #ifdef SUPPORT_PPG_SERVICE send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST); - LOS_Msleep(1000); + LOS_Msleep(2000); ppg_get_leaklight_data(&green,&red,&ir); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); #endif @@ -1591,10 +1630,11 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint float fAzimuth,fPitch,fRoll; do_mag_service_check_msg(MAG_SERVICE_CMD_START_CHECK); - LOS_Msleep(500); + LOS_Msleep(1000); mmc5603_getdata(&fAzimuth,&fPitch,&fRoll); do_mag_service_check_msg(MAG_SERVICE_CMD_STOP_CHECK); - +#ifdef BOARD_FD230 + uint8_t databuf[6] = {0}; databuf[0] = (uint8_t)(((uint32_t)fAzimuth & 0xFF00) >> 8); @@ -1613,6 +1653,21 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 0x02, databuf, 6); + +#elif defined BOARD_N9 + uint8_t databuf[2] = {0}; + + databuf[0] = (uint8_t)(((uint32_t)fAzimuth & 0xFF00) >> 8); + databuf[1] = (uint8_t)((uint32_t)fAzimuth & 0x00FF); + + PRINT("%2X %2X\r\n",databuf[0],databuf[1]); + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_COMPASS, + 0x02, + databuf, + 2); +#endif } break; @@ -2079,7 +2134,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint gnss_start(); LOS_Msleep(100); do{ - gps_data_t *gps_data = getGPSGlobaldata(); + gps_data_t *gps_data = getPGPSGlobaldata(); if(gps_data == NULL) { PRINT("gps_data == NULL \n"); diff --git a/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.c b/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.c index 5f24a5bc7..1f04ab703 100644 --- a/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.c +++ b/code/sdk/drivers/peripheral/bp/service/bp_tcp_server.c @@ -50,6 +50,7 @@ // #define MAX_CNT 16 * 5 * 60 #define MAX_CNT 16 * 5 * 50 +static char *rx_buffer = NULL; static unsigned long g_app_queue= 0xFFFFFFFF; @@ -331,7 +332,6 @@ int bp_tcp_socket_init(void) memcpy(&server_addr.sin_addr.s_addr, &ip_sem.ip.u_addr.ip4, 4); // 创建套接字 - listen_socket = lwip_socket(AF_INET, SOCK_STREAM, 0); if(listen_socket < 0) { @@ -1945,8 +1945,8 @@ void do_bp_tcp_server_send_data(int cmd,int *data,uint32_t len) PRINT("Error bp Check MSG 0x send failed! err=0x%x! \r\n", ret); } - if(send_data.data != NULL) - free(send_data.data); + // if(send_data.data != NULL) + // free(send_data.data); } // unsigned char buf[14100] = {0}; // 算法库计算过程中所需要的缓存 @@ -1986,6 +1986,12 @@ static void bp_tcp_deinit(void) lwip_close(g_listen_sock); g_listen_sock = -1; } + if (rx_buffer != NULL) + { + free(rx_buffer); + rx_buffer = NULL; + } + } int bp_tcp_init(void) @@ -2094,6 +2100,10 @@ static void bp_tcp_server_send_task(void const *arg) if(mail.cmd == BP_TCP_SERVICE_CMD_SEND_DATA) { tcp_data_handler((int *)mail.data,mail.len); + if(mail.data != NULL) + { + free(mail.data); + } } else if(mail.cmd == BP_TCP_SERVICE_CMD_SERVER_INIT) { @@ -2114,13 +2124,6 @@ static void bp_tcp_server_send_task(void const *arg) void bp_tcp_server_recv_task(void *pvParameters) { - char *rx_buffer = (char *)malloc(2048); - if(rx_buffer == NULL) - { - printf("rx_buffer malloc failed\n"); - return; - } - while (1) { if(!uapi_dev_runtime_get_bp_status_flag()) @@ -2165,6 +2168,19 @@ void bp_tcp_server_recv_task(void *pvParameters) // printf("tcp_sign_up\n"); + if(rx_buffer == NULL) + { + char *rx_buffer = (char *)malloc(2048); + if(rx_buffer == NULL) + { + printf("rx_buffer malloc failed\n"); + do_bp_tcp_server_send_data(BP_TCP_SERVICE_CMD_SERVER_DEINIT,NULL,0); + return; + } + + } + + // 接收数据 memset(rx_buffer, 0, 2048); int len = recv(g_listen_sock, rx_buffer, 2048 - 1, 0); diff --git a/code/sdk/drivers/peripheral/ppg/hal/ppg_hal.c b/code/sdk/drivers/peripheral/ppg/hal/ppg_hal.c index 9f4ef78d6..aa7e24ccb 100644 --- a/code/sdk/drivers/peripheral/ppg/hal/ppg_hal.c +++ b/code/sdk/drivers/peripheral/ppg/hal/ppg_hal.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-03-13 15:08:38 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-15 12:13:23 + * @LastEditTime: 2025-07-16 15:34:10 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c * @Description: * @@ -162,7 +162,7 @@ void ppg_send_cmd_to_driver(char* mode, uint8_t enable) void ppg_get_leaklight_data(uint32_t *ch0,uint32_t *ch1,uint32_t *ch2) { #ifdef PPG_HX3695 - hx3695_get_factory_data(ch0,ch1,ch2); + hx3695_get_leaklight_data(ch0,ch1,ch2); #elif defined PPG_VC9202 vc9202_get_leaklight_data(ch0,ch1,ch2); #elif defined PPG_PAH8009 @@ -170,13 +170,13 @@ void ppg_get_leaklight_data(uint32_t *ch0,uint32_t *ch1,uint32_t *ch2) #endif } -uint32_t ppg_get_factory_data(void) +int32_t ppg_get_factory_data(void) { - uint32_t data = 0; + int32_t data = 0; #ifdef PPG_PAH8009 data = pah8009_get_factory_data(); #elif defined PPG_HX3695 - + data = hx3695_get_factory_data(); #endif return data; } diff --git a/code/sdk/drivers/peripheral/ppg/hal/ppg_hal.h b/code/sdk/drivers/peripheral/ppg/hal/ppg_hal.h index e2b9ebc31..a1623dee7 100644 --- a/code/sdk/drivers/peripheral/ppg/hal/ppg_hal.h +++ b/code/sdk/drivers/peripheral/ppg/hal/ppg_hal.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-07 11:18:26 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-09 16:12:34 + * @LastEditTime: 2025-07-16 15:35:58 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/ppg/ppg_hal.h * @Description: * @@ -58,7 +58,7 @@ void ppg_power_on(void); void ppg_power_off(void); void ppg_int_handler(void); void ppg_get_leaklight_data(uint32_t *ch0,uint32_t *ch1,uint32_t *ch2); -uint32_t ppg_get_factory_data(void); +int32_t ppg_get_factory_data(void); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index 8494713bb..98dfabdda 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -174,6 +174,8 @@ static int32_t ir_jump_delta = 0; static int32_t cali_data_cnt = 0; #endif +static int32_t factory_data = 0; + // us 延时函数, 客户需填写 void hx3695_delay_us(uint32_t us) { @@ -2864,7 +2866,7 @@ void hx3695_hrs_ppg_Int_handle(void) gsen_fifo_y_send[ii] = gsensordata[ii].y * 4096 / 10; gsen_fifo_z_send[ii] = gsensordata[ii].z * 4096 / 10; } - + factory_data = PPG_buf[ii]; // gsensor_get_n_data(8,gsensordata); // for(ii=0; ii<*count; ii++) // { @@ -3416,11 +3418,14 @@ void hx3695_spo2_ppg_Int_handle(void) // gsen_fifo_y_send[ii] = gsensordata[ii].y * 2048; // gsen_fifo_z_send[ii] = gsensordata[ii].z * 2048; // } - //("hxdata:%d/%d %d %d %d %d %d %d\r\n", - //1+ii,*count,red_buf[ii],ir_buf[ii],green_buf[ii],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii]); - //printf("FFF==>spo2 red_buf : %d, %d, %d, %d \n", 1+ii, *count, red_buf[ii], ir_buf[0]); + // printf("hxdata:%d/%d %d %d %d %d %d %d\r\n",1+ii,*count,red_buf[ii],ir_buf[ii],green_buf[ii],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii]); + // printf("FFF==>spo2 red_buf : %d, %d, %d, %d \n", 1+ii, *count, red_buf[ii], ir_buf[0]); + + factory_data = red_buf[ii]; } + + // ft_ppg_iir = spo2_s_dat.red_data[0]; // hx3695_factory_test_process(NULL, APP_FACTORY_TEST_SPO2_START, &ft_ppg_iir); @@ -3859,4 +3864,11 @@ void hx3695_control(char *mode,uint8_t enable) } } +int32_t hx3695_get_factory_data(void) +{ + int32_t data = factory_data; + factory_data = 0; + return data; +} + #endif //CHIP_HX3695 \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h index e259aaef6..b938d20ed 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h @@ -301,6 +301,7 @@ void hx3695_wearstatus_update(void); void hx3695_unwearstatus_update(void); void hx3695_set_hrs_ble_swtich(uint8_t cmd); uint8_t hx3695_get_hrs_ble_swtich(void); +int32_t hx3695_get_factory_data(void); #include "hx3695_hal.h" #endif diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.c index 37992c20f..9a94ffa7e 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.c @@ -2919,7 +2919,7 @@ FT_RESULTS_t hx3695_factroy_test(TEST_MODE_t test_mode) return ft_result; } -void hx3695_get_factory_data(uint32_t *green,uint32_t *red,uint32_t *ir) +void hx3695_get_leaklight_data(uint32_t *green,uint32_t *red,uint32_t *ir) { *green = factory_green; *red = factory_red; diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.h b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.h index 93c62bf1b..f770ebfba 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.h @@ -46,7 +46,7 @@ FT_RESULTS_t hx3695_factroy_test(TEST_MODE_t test_mode); void hx3695_lab_test(uint32_t test_mode); void hx3695_lab_test_read(void); -void hx3695_get_factory_data(uint32_t *green,uint32_t *red,uint32_t *ir); +void hx3695_get_leaklight_data(uint32_t *green,uint32_t *red,uint32_t *ir); #endif // _HX3695_FACTORY_TEST_H_ diff --git a/code/sdk/drivers/peripheral/ppg/pah8009/sensor/pah800x_main.c b/code/sdk/drivers/peripheral/ppg/pah8009/sensor/pah800x_main.c index c650f00b1..485396e41 100644 --- a/code/sdk/drivers/peripheral/ppg/pah8009/sensor/pah800x_main.c +++ b/code/sdk/drivers/peripheral/ppg/pah8009/sensor/pah800x_main.c @@ -79,7 +79,7 @@ static uint8_t AnomalyFlag = 0; uint8_t Stress_ReadyFlag = 0; uint8_t Weak_Flag = 0; -static uint32_t factory_data = 0; +static int32_t factory_data = 0; static uint8_t work_mode = 0; @@ -1659,9 +1659,9 @@ uint16_t pah8009_get_chip_id(void) return product_id; } -uint32_t pah8009_get_factory_data(void) +int32_t pah8009_get_factory_data(void) { - uint32_t data = factory_data; + int32_t data = factory_data; factory_data = 0; return data; } diff --git a/code/sdk/drivers/peripheral/ppg/pah8009/sensor/pah800x_main.h b/code/sdk/drivers/peripheral/ppg/pah8009/sensor/pah800x_main.h index 8445abe1a..70a8b0518 100644 --- a/code/sdk/drivers/peripheral/ppg/pah8009/sensor/pah800x_main.h +++ b/code/sdk/drivers/peripheral/ppg/pah8009/sensor/pah800x_main.h @@ -158,7 +158,7 @@ void stress_alg_task(int grade); uint16_t pah8009_get_chip_id(void); void pah8009_control(char *mode,uint8_t enable); -uint32_t pah8009_get_factory_data(void); +int32_t pah8009_get_factory_data(void); void pah8009_int_handler(void); /** diff --git a/code/sdk/drivers/peripheral/rotary_encoder/hx3507/hx3507.c b/code/sdk/drivers/peripheral/rotary_encoder/hx3507/hx3507.c index 3c4250b47..f7ea3707a 100644 --- a/code/sdk/drivers/peripheral/rotary_encoder/hx3507/hx3507.c +++ b/code/sdk/drivers/peripheral/rotary_encoder/hx3507/hx3507.c @@ -602,7 +602,7 @@ int16_t get_crown_result(void) return resulttemp; } -void crown_read_id(uint8_t *id) +void crown_read_id(uint16_t *id) { uapi_gpio_set_dir(PIN_TYHX_SDIO,GPIO_DIRECTION_OUTPUT); // uapi_pin_set_pull(PIN_TYHX_SDIO, (pin_pull_t)HAL_PIO_PULL_UP); diff --git a/code/sdk/drivers/peripheral/rotary_encoder/hx3507/hx3507.h b/code/sdk/drivers/peripheral/rotary_encoder/hx3507/hx3507.h index 27581abb4..cb0b10f53 100644 --- a/code/sdk/drivers/peripheral/rotary_encoder/hx3507/hx3507.h +++ b/code/sdk/drivers/peripheral/rotary_encoder/hx3507/hx3507.h @@ -1,3 +1,11 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2025-01-08 18:26:42 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-16 16:07:38 + * @FilePath: /FD230/code/sdk/drivers/peripheral/rotary_encoder/hx3507/hx3507.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ /** * Copyright (c) 2014 - 2023, 南京天易合芯电子有限公司 * @@ -91,6 +99,6 @@ void report_zero_data_for_start_stop_flag(void); //把角度结果上报的函数 int16_t get_crown_result(void); -void crown_read_id(uint8_t *id); +void crown_read_id(uint16_t *id); #endif //_TYHX_CROWN_CUSTOM_H_ diff --git a/code/sdk/drivers/peripheral/rotary_encoder/mixo/mixo_ots_driver.c b/code/sdk/drivers/peripheral/rotary_encoder/mixo/mixo_ots_driver.c index 844e511eb..34c2068dd 100644 --- a/code/sdk/drivers/peripheral/rotary_encoder/mixo/mixo_ots_driver.c +++ b/code/sdk/drivers/peripheral/rotary_encoder/mixo/mixo_ots_driver.c @@ -364,3 +364,13 @@ uint8_t mixo_get_check_mode(void) { return int_mode; } + + +void mixo_get_chip_id(uint16_t *id) +{ + mixo_ots_enter_suspend_mode(0); + uint8_t chip_id[2] = {0}; + mixo_ots_reg_read(0x00, &chip_id[0]); // Read chip-id high byte + mixo_ots_reg_read(0x01, &chip_id[1]); // Read chip-id low byte + *id = (chip_id[0] & 0XFF) << 8 | (chip_id[1] & 0XFF); +} \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/rotary_encoder/mixo/mixo_ots_driver.h b/code/sdk/drivers/peripheral/rotary_encoder/mixo/mixo_ots_driver.h index a991947ec..9852bf96b 100644 --- a/code/sdk/drivers/peripheral/rotary_encoder/mixo/mixo_ots_driver.h +++ b/code/sdk/drivers/peripheral/rotary_encoder/mixo/mixo_ots_driver.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2025-01-04 10:53:54 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-05-14 17:13:14 + * @LastEditTime: 2025-07-16 16:07:09 * @FilePath: /sdk615/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -42,5 +42,6 @@ int16_t mixo_get_crown_result(void); void mixo_ots_timer_callback(void); void mixo_clean_result(void); uint8_t mixo_get_check_mode(void); +void mixo_get_chip_id(uint16_t *id); #endif //_MXS_DRIVER_H_ diff --git a/code/sdk/drivers/peripheral/rotary_encoder/rotary_encoder_drv.c b/code/sdk/drivers/peripheral/rotary_encoder/rotary_encoder_drv.c index 8fe65452c..d729f2895 100644 --- a/code/sdk/drivers/peripheral/rotary_encoder/rotary_encoder_drv.c +++ b/code/sdk/drivers/peripheral/rotary_encoder/rotary_encoder_drv.c @@ -506,4 +506,13 @@ void rotary_encoder_restart(void) // uapi_i2c_master_init(TOUCH_I2C_BUS, 400000, I2C_SPEED_MODE_FS); /* 400000: 400KHz */ re_err("rotary_encoder_restart ----------succ!!!\n"); +} + +void rotary_get_chip_id(uint16_t *id) +{ +#ifdef ROTARYENCODER_HX3507 + crown_read_id(id); +#elif defined ROTARYENCODER_MIXO + mixo_get_chip_id(id); +#endif } \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/rotary_encoder/rotary_encoder_drv.h b/code/sdk/drivers/peripheral/rotary_encoder/rotary_encoder_drv.h index 3a37a05fd..ba50d8c61 100644 --- a/code/sdk/drivers/peripheral/rotary_encoder/rotary_encoder_drv.h +++ b/code/sdk/drivers/peripheral/rotary_encoder/rotary_encoder_drv.h @@ -11,6 +11,14 @@ #include "soc_osal.h" #include "rotary_encoder_queue1.h" +#ifdef ROTARYENCODER_HX3507 +#define ROTARY_CHIP_ID 0x30 +#elif defined ROTARYENCODER_MIXO +#define ROTARY_CHIP_ID 0x585b +#else +#define ROTARY_CHIP_ID 0 +#endif + struct re_driver_data { osal_task *task_handle; osal_event event; @@ -29,5 +37,6 @@ struct re_ops { ext_errno rotary_encoder_module_init(void); ext_errno rotary_encoder_module_deinit(void); ext_errno encoder_info_process(void); +void rotary_get_chip_id(uint16_t *id); #endif \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/touch/cst86xx_touch/cst86xx_touch1.c b/code/sdk/drivers/peripheral/touch/cst86xx_touch/cst86xx_touch1.c index e1aaa3ea5..9ec2a375d 100644 --- a/code/sdk/drivers/peripheral/touch/cst86xx_touch/cst86xx_touch1.c +++ b/code/sdk/drivers/peripheral/touch/cst86xx_touch/cst86xx_touch1.c @@ -406,7 +406,10 @@ ext_errno cst86xx_deinit(void) void cst86xx_get_chip_id(uint16_t *chip_id) { - *chip_id = g_cst86xx_drv.chip_id; + cst86xx_resume(); + cst86xx_tp_i2c_data_read(CST86XX_HW_ID, chip_id, 1); + // cst86xx_set_sleep_mode(); + cst86xx_suspend(); } #ifdef __cplusplus diff --git a/code/sdk/drivers/peripheral/touch/ft6x46_touch/ft6x46_touch1.c b/code/sdk/drivers/peripheral/touch/ft6x46_touch/ft6x46_touch1.c index aa6f91c5d..bb7ca4b56 100644 --- a/code/sdk/drivers/peripheral/touch/ft6x46_touch/ft6x46_touch1.c +++ b/code/sdk/drivers/peripheral/touch/ft6x46_touch/ft6x46_touch1.c @@ -392,15 +392,15 @@ static ext_errno ft6x46_power_sequence(void) /*get chip id*/ ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID, &chip_id[0], 1); if (ret != EXT_ERR_SUCCESS) { - tp_err("222222222get ic information, error1"); + tp_err("get ic information, error1"); return EXT_ERR_TP_ZTW523_POWERUP_READ_CHIPID; } ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID2, &chip_id[1], 1); if (ret != EXT_ERR_SUCCESS) { - tp_err("3333333get ic information, error2"); + tp_err("get ic information, error2"); return EXT_ERR_TP_ZTW523_POWERUP_READ_CHIPID; } - // tp_print("11111111111111get ic information, chip id = 0x%02x%02x", chip_id[0], chip_id[1]); + // tp_print("get ic information, chip id = 0x%02x%02x", chip_id[0], chip_id[1]); if ((FTS_CHIP_IDH == chip_id[0]) && (FTS_CHIP_IDL == chip_id[1])) { tp_warning("get ic information, chip id = 0x%02x%02x", chip_id[0], chip_id[1]); return EXT_ERR_SUCCESS; @@ -973,6 +973,33 @@ ext_errno ft6x46_deinit(void) return EXT_ERR_SUCCESS; } + + + +void ft6x46_get_chip_id(uint16_t *id) +{ + ft6x46_resume(); + + ext_errno ret; + uint8_t chip_id[2] = { 0 }; + /*get chip id*/ + ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID, &chip_id[0], 1); + if (ret != EXT_ERR_SUCCESS) { + PRINT("get ic information error1"); + } else { + ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID2, &chip_id[1], 1); + if (ret != EXT_ERR_SUCCESS) { + PRINT("get ic information error2"); + } else + { + // PRINT("TOUCH CHIP ID = 0x%02x%02x \r\n", chip_id[0], chip_id[1]); + *id = (chip_id[0] & 0XFF) << 8 | (chip_id[1] & 0XFF); + //sprintf(id,"0x%02x%02x", chip_id[0], chip_id[1]); + } + } + ft6x46_suspend(); +} + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/touch/ft6x46_touch/ft6x46_touch1.h b/code/sdk/drivers/peripheral/touch/ft6x46_touch/ft6x46_touch1.h index b0e57762f..452df03bc 100644 --- a/code/sdk/drivers/peripheral/touch/ft6x46_touch/ft6x46_touch1.h +++ b/code/sdk/drivers/peripheral/touch/ft6x46_touch/ft6x46_touch1.h @@ -412,6 +412,7 @@ ext_errno ft6x46_resume(void); ext_errno ft6x46_suspend(void); ext_errno ft6x46_irq_callback(uint8_t *data_buf, uint8_t data_len); ext_errno ft6x46_host_init_sample(void); +void ft6x46_get_chip_id(uint16_t *id); #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/drivers/peripheral/touch/touch_screen_drv.c b/code/sdk/drivers/peripheral/touch/touch_screen_drv.c index f12dd7c5d..38c1dd47e 100644 --- a/code/sdk/drivers/peripheral/touch/touch_screen_drv.c +++ b/code/sdk/drivers/peripheral/touch/touch_screen_drv.c @@ -510,4 +510,14 @@ void touch_screen_restart(void) ztw523_resume(); #endif uapi_gpio_enable_interrupt(TOUCH_INT_GPIO); // open tp_int gpio interrupt +} + +void touch_get_chip_id(uint16_t *id) +{ +#ifdef TPTYPE_CST86XX + cst86xx_get_chip_id(id); +#elif defined TPTYPE_FT6X46 + ft6x46_get_chip_id(id); +#endif + } \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/touch/touch_screen_drv.h b/code/sdk/drivers/peripheral/touch/touch_screen_drv.h index 4ec2d0ce0..e28919da4 100644 --- a/code/sdk/drivers/peripheral/touch/touch_screen_drv.h +++ b/code/sdk/drivers/peripheral/touch/touch_screen_drv.h @@ -1,3 +1,11 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-12-07 15:32:08 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-16 12:24:50 + * @FilePath: /FD230/code/sdk/drivers/peripheral/touch/touch_screen_drv.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ /* * Copyright (c) @CompanyNameMagicTag 2021-2022. All rights reserved. * Description: header of touch screen driver. @@ -26,8 +34,17 @@ struct ts_ops { uint32_t (*priv_operator)(struct ts_driver_data *udd); }; +#ifdef TPTYPE_FT6X46 +#define TP_CHIP_ID 0x6456 +#elif defined TPTYPE_CST86XX +#define TP_CHIP_ID 0xb7 +#else +#define TP_CHIP_ID 0 +#endif + ext_errno touch_screen_module_init(void); ext_errno touch_screen_module_deinit(void); ext_errno touch_info_process(void); +void touch_get_chip_id(uint16_t *id); #endif \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index f31e2125b..726710c5d 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -1959,27 +1959,6 @@ void get_tp_info(int16_t *x,int16_t *y) } -void touch_getid(uint16_t *id) -{ - ext_errno ret; - uint8_t chip_id[2] = { 0 }; - /*get chip id*/ - ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID, &chip_id[0], 1); - if (ret != EXT_ERR_SUCCESS) { - PRINT("get ic information error1"); - } else { - ret = tp_ft6x46_i2c_data_read(FTS_REG_CHIP_ID2, &chip_id[1], 1); - if (ret != EXT_ERR_SUCCESS) { - PRINT("get ic information error2"); - } else - { - PRINT("TOUCH CHIP ID = 0x%02x%02x \r\n", chip_id[0], chip_id[1]); - *id = (chip_id[0] & 0XFF) << 8 | (chip_id[1] & 0XFF); - //sprintf(id,"0x%02x%02x", chip_id[0], chip_id[1]); - } - } -} - void touch_getstate(void) { int32_t state; @@ -3167,10 +3146,10 @@ void uapi_vibrator_test(uint32_t test_time) } //创建指定路径文件夹 -void uapi_create_folder(char *dir_path) +int uapi_create_folder(char *dir_path) { if(dir_path == NULL) - return; + return -1; char *path_copy = strdup(dir_path); char *token; @@ -3180,7 +3159,7 @@ void uapi_create_folder(char *dir_path) if (token == NULL) { free(path_copy); - return; + return -1; } char current_path[256] = ""; @@ -3194,7 +3173,7 @@ void uapi_create_folder(char *dir_path) { PRINT("mkdir %s failed\n", current_path); free(path_copy); - return; + return -1; } } @@ -3208,13 +3187,14 @@ void uapi_create_folder(char *dir_path) { PRINT("mkdir %s failed\n", current_path); free(path_copy); - return; + return -1; } } } free(path_copy); PRINT("mkdir %s succed\n", dir_path); + return 0; } //获取小睡数据长度(协议用) diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 288ce8364..0d26b3137 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -174,8 +174,6 @@ void uapi_take_to_wake(int cmd); //获取lcd id void lcd_getid(uint32_t *id); -//获取TP ID -void touch_getid(uint16_t *id); void get_tp_info(int16_t *x,int16_t *y); //获取触摸屏状态 @@ -374,7 +372,7 @@ errcode_t uapi_stop_audio_test(void); void uapi_save_sleep_flag(uint8_t *data,uint16_t len); void start_save_file_thread(void); -void uapi_create_folder(char *dir_path); +int uapi_create_folder(char *dir_path); uint32_t uapi_get_file_size(char *filepath); /** * 资源文件校验码保存在文件 /user/fileschecksum.txt 中