From: penglei <1624952103@qq.com> Date: Mon, 15 Apr 2024 08:01:20 +0000 (+0800) Subject: 修改心率驱动,解决佩戴模式不能获得佩戴状态的问题, X-Git-Tag: release_V1.2.70_20241020_135402~1190 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=refs%2Fchanges%2F9%2F1;p=mirrors%2FFD230.git 修改心率驱动,解决佩戴模式不能获得佩戴状态的问题, --- diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h index 3caaf8223..31a214bc8 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h @@ -530,6 +530,7 @@ void cywee_int_handler(void); void watch_hand_updown(int fdata); void cyw_inactivity_mode_change(int mode); void cyw_activity_mode_change(int mode); +void set_user_info(int age,int gender,double weight,int height,int wearing_method); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 3134adc71..41ad59a4e 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -36,28 +36,71 @@ SettingControl_t scl; cywee_activity_result_t c_activity_result_t; cywee_inactivity_result_t c_inactivity_result_t; -static int cywee_installized = 0 ; -static int free_training_installized = 0 ; +static uint8_t cywee_installized = 0 ; static osTimerId_t g_cywee_hrs_timer; -// static osTimerId_t g_cywee_wearstatus_timer; +static osTimerId_t g_cywee_wearstatus_timer; static osTimerId_t g_cywee_oncharging_timer; CustomSensorData csd; + + static uint8_t hrs = 0; static uint8_t wearstatus = 0; +static uint8_t wearstatus_tmp = 0; +static uint8_t oncharging_tmp = 0; + + +static unsigned long g_cywee_mode_init_queue; + +static uint8_t hrs_mode_state = 0; +static uint8_t wear_mode_state = 0; + +static uint8_t mail = 0; + +void watch_hand_updown(int fdata) +{ + #if defined(SUPPORT_POWER_MANAGER) + const power_display_svr_api_t *display_api = power_display_svr_get_api(); + #endif + if (fdata == 2) + { + #if defined(SUPPORT_POWER_MANAGER) + display_api->set_screen_set_keepon_timeout(0); + CWM_OS_dbgPrintf("[cwyee] turn_off_screen"); + #endif + }else if (fdata == 1) + { + #if defined(SUPPORT_POWER_MANAGER) + if (display_api->get_screen_state() != SCREEN_ON) { + CWM_OS_dbgPrintf("[cwyee] turn_on_screen"); + display_api->turn_on_screen(); + } + display_api->set_screen_set_keepon_timeout(5000); + #endif + } +} + +void get_sleep_data(void) +{ + memset(&scl, 0, sizeof(scl)); + scl.iData[0] = 1; + scl.iData[1] = 0; + CWM_SettingControl(SCL_REQ_SLEEPING_DATA, &scl); +} + void set_user_info(int age,int gender,double weight,int height,int wearing_method) { memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; scl.iData[1] = age; - scl.iData[2] = weight; + scl.iData[2] = gender; scl.iData[3] = (int)weight; - scl.iData[4] = weight; + scl.iData[4] = height; scl.iData[5] = wearing_method; CWM_SettingControl(SCL_USER_INFO, &scl); } @@ -69,7 +112,7 @@ void time_sync(void) time(&rawtime); timeinfo = localtime(&rawtime); PRINT("year[%d], mon[%d], day[%d], hour[%d], min[%d], msc[%d] \r\n", - timeinfo->tm_year,timeinfo->tm_mon,timeinfo->tm_mday, + timeinfo->tm_year+1900,timeinfo->tm_mon+1,timeinfo->tm_mday, timeinfo->tm_hour,timeinfo->tm_min,timeinfo->tm_sec); memset(&scl, 0, sizeof(scl)); @@ -86,86 +129,109 @@ void time_sync(void) void cywee_hrs_check_timer_callback(void) { get_hrs_wearstatus(&hrs,&wearstatus); - CWM_OS_dbgPrintf("hrs : %d,wearstatus : %d \r\n",hrs,wearstatus); + CWM_OS_dbgPrintf("hrs : %d\r\n",hrs); memset(&csd, 0, sizeof(CUSTOM_HEARTRATE)); csd.sensorType = CUSTOM_HEARTRATE; csd.fData[0] = hrs + 15; CWM_CustomSensorInput(&csd); - memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT)); - csd.sensorType = CUSTOM_OFFBODY_DETECT; - csd.fData[0] = wearstatus; - CWM_CustomSensorInput(&csd); + if(wearstatus_tmp != wearstatus) + { + wearstatus_tmp = wearstatus; + CWM_OS_dbgPrintf("222wearstatus : %d\r\n",wearstatus); + //CWM_OS_dbgPrintf("tmp : %d \r\n",tmp); + memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT)); + csd.sensorType = CUSTOM_OFFBODY_DETECT; + csd.fData[0] = wearstatus; + CWM_CustomSensorInput(&csd); + } } void cywee_oncharging_check_timer_callback(void) { - bool oncharging_status; - oncharging_status = uapi_get_charger_plug_status(); - //CWM_OS_dbgPrintf("charging_status : %d\r\n",oncharging_status); - memset(&csd, 0, sizeof(CUSTOM_ON_CHARGING)); - csd.sensorType = CUSTOM_ON_CHARGING; - csd.fData[0] = oncharging_status; - CWM_CustomSensorInput(&csd); + bool oncharging_status = uapi_get_charger_plug_status(); + if(oncharging_tmp != oncharging_status) + { + oncharging_tmp = oncharging_status; + CWM_OS_dbgPrintf("oncharging_status : %d\r\n",oncharging_status); + memset(&csd, 0, sizeof(CUSTOM_ON_CHARGING)); + csd.sensorType = CUSTOM_ON_CHARGING; + csd.fData[0] = oncharging_status; + CWM_CustomSensorInput(&csd); + } } +void cywee_wearstatus_check_timer_callback(void) +{ + get_wearstatus(&wearstatus); + //CWM_OS_dbgPrintf("tmp : %d \r\n",tmp); + if(wearstatus_tmp != wearstatus) + { + wearstatus_tmp = wearstatus; + CWM_OS_dbgPrintf("111wearstatus : %d\r\n",wearstatus); + //CWM_OS_dbgPrintf("tmp : %d \r\n",tmp); + memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT)); + csd.sensorType = CUSTOM_OFFBODY_DETECT; + csd.fData[0] = wearstatus; + CWM_CustomSensorInput(&csd); + } +} -void free_training_task(void) +void activity_mode_task(void) { - ppg_send_cmd_to_driver("hrs",1); + if(hrs_mode_state == 1) + { + ppg_send_cmd_to_driver("hrs",0); + //osTimerStop(g_cywee_hrs_timer); + hrs_mode_state = 0; + } + if(wear_mode_state == 1) + { + ppg_send_cmd_to_driver("wear",0); + osTimerStop(g_cywee_wearstatus_timer); + wear_mode_state = 0; + } + if(mail == 1 && hrs_mode_state == 0) + { + ppg_send_cmd_to_driver("hrs",1); + hrs_mode_state = 1; + } + else if(mail == 2 && wear_mode_state == 0) + { + ppg_send_cmd_to_driver("wear",1); + osTimerStart(g_cywee_wearstatus_timer,400); + wear_mode_state = 1; + } } -errcode_t free_training_init(void) +void activity_mode_exit() +{ + ppg_send_cmd_to_driver("wear",0); + osTimerStop(g_cywee_wearstatus_timer); + wear_mode_state = 0; +} + + +errcode_t activity_mode_init(void) { - if(free_training_installized == 1) - return ERRCODE_FAIL; - free_training_installized = 1; app_task_definition_t taskcfg={0}; taskcfg.create_queue_handle = NULL; - taskcfg.attr.name="free_training_service"; + taskcfg.attr.name="activity_mode_service"; taskcfg.attr.priority = TASK_PRIORITY_CMD; taskcfg.attr.stack_size = 1024*8; - taskcfg.func = free_training_task; + taskcfg.func = activity_mode_task; taskcfg.use_mem = USE_EXTEND_MEM; errcode_t ret=uapi_create_osThread_custom(&taskcfg); if(ret != ERRCODE_SUCC) { - PRINT("create free_training_task failed %d!\r\n",ret); + CWM_OS_dbgPrintf("create activity_mode_task failed %d!\r\n",ret); return ERRCODE_FAIL; } - - g_cywee_hrs_timer = osTimerNew((osTimerFunc_t)cywee_hrs_check_timer_callback, osTimerPeriodic, NULL, NULL); - //g_cywee_wearstatus_timer = osTimerNew((osTimerFunc_t)cywee_wearstatus_check_timer_callback, osTimerPeriodic, NULL, NULL); - g_cywee_oncharging_timer = osTimerNew((osTimerFunc_t)cywee_oncharging_check_timer_callback, osTimerPeriodic, NULL, NULL); - return ERRCODE_SUCC; } -void watch_hand_updown(int fdata) -{ - #if defined(SUPPORT_POWER_MANAGER) - const power_display_svr_api_t *display_api = power_display_svr_get_api(); - #endif - if (fdata == 2) - { - #if defined(SUPPORT_POWER_MANAGER) - display_api->set_screen_set_keepon_timeout(0); - CWM_OS_dbgPrintf("[cwyee] turn_off_screen"); - #endif - }else if (fdata == 1) - { - #if defined(SUPPORT_POWER_MANAGER) - if (display_api->get_screen_state() != SCREEN_ON) { - CWM_OS_dbgPrintf("[cwyee] turn_on_screen"); - display_api->turn_on_screen(); - } - display_api->set_screen_set_keepon_timeout(5000); - #endif - } -} - //0:resume , 1:pause -void activity_setstatus(int cmd) +void activity_mode_setstatus(int cmd) { memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; @@ -173,29 +239,9 @@ void activity_setstatus(int cmd) CWM_SettingControl(SCL_ACTIVITY_PAUSE, &scl); } - -void activity_exit(void) -{ - memset(&scl, 0, sizeof(scl)); - scl.iData[0] = 1; - CWM_SettingControl(SCL_REQ_ACTIVITY_EXIT, &scl); - - // if(cywee_installized == 1) - // cywee_installized = 0; - if(free_training_installized == 1) - { - free_training_installized = 0; - //osTimerStop(g_cywee_wearstatus_timer); - osTimerStop(g_cywee_oncharging_timer); - osTimerStop(g_cywee_hrs_timer); - osTimerDelete(g_cywee_oncharging_timer); - osTimerDelete(g_cywee_hrs_timer); - ppg_send_cmd_to_driver("hrs",0); - } -} - void cyw_inactivity_mode_change(int mode) { + time_sync(); switch (mode) { //無作用 @@ -208,7 +254,7 @@ void cyw_inactivity_mode_change(int mode) //久坐和有效站立 case INACTIVITY_MODE_SEDENTARY: - PRINT("INACTIVITY_MODE_SEDENTARY\r\n"); + CWM_OS_dbgPrintf("INACTIVITY_MODE_SEDENTARY\r\n"); //training_mode_init(); //配置久坐相关参数 memset(&scl, 0, sizeof(scl)); @@ -264,6 +310,7 @@ void cyw_inactivity_mode_change(int mode) void cyw_activity_mode_change(int mode) { + activity_mode_init(); switch (mode) { //一般模式(生活模式) @@ -272,9 +319,6 @@ void cyw_activity_mode_change(int mode) scl.iData[0] = 1; scl.iData[1] = SPORT_ACTIVE_MODE_NORMAL; CWM_SettingControl(SCL_SET_ACTIVITY_MODE, &scl); - // CWM_SettingControl(SCL_SET_INACTIVITY_MODE, &scl); - //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); - break; //跑步机 @@ -283,7 +327,6 @@ void cyw_activity_mode_change(int mode) scl.iData[0] = 1; scl.iData[1] = SPORT_ACTIVE_MODE_TREADMILL; CWM_SettingControl(SCL_SET_ACTIVITY_MODE, &scl); - break; //户外跑步 @@ -312,7 +355,6 @@ void cyw_activity_mode_change(int mode) //自由运动 case SPORT_ACTIVE_MODE_FREE_TRAINING: - free_training_init(); memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; scl.iData[1] = SPORT_ACTIVE_MODE_FREE_TRAINING; @@ -439,20 +481,43 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { if((int)sensorEVT->fData[1] == CUSTOM_OFFBODY_DETECT) { CWM_OS_dbgPrintf("CUSTOM_OFFBODY_DETECT !!! \r\n"); - // if(free_training_installized == 1) - // osTimerStart(g_cywee_wearstatus_timer,20); + if((int)sensorEVT->fData[2] == 1) + { + memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT)); + csd.sensorType = CUSTOM_OFFBODY_DETECT; + csd.fData[0] = 0; + CWM_CustomSensorInput(&csd); + //if(mail == 2) + //osTimerStart(g_cywee_wearstatus_timer,20); + // else + // osTimerStop(g_cywee_wearstatus_timer); + } + // else if((int)sensorEVT->fData[2] == 0) + // osTimerStop(g_cywee_wearstatus_timer); + } if((int)sensorEVT->fData[1] == CUSTOM_ON_CHARGING) { CWM_OS_dbgPrintf("CUSTOM_ON_CHARGING !!! \r\n"); - //if(free_training_installized == 1) - osTimerStart(g_cywee_oncharging_timer,20); + if((int)sensorEVT->fData[2] == 1) + { + memset(&csd, 0, sizeof(CUSTOM_ON_CHARGING)); + csd.sensorType = CUSTOM_ON_CHARGING; + csd.fData[0] = 0; + CWM_CustomSensorInput(&csd); + osTimerStart(g_cywee_oncharging_timer,400); + } + else + osTimerStop(g_cywee_oncharging_timer); + } if((int)sensorEVT->fData[1] == CUSTOM_HEARTRATE) { CWM_OS_dbgPrintf("CUSTOM_HEARTRATE !!! \r\n"); - if(free_training_installized == 1) - osTimerStart(g_cywee_hrs_timer,20); + if((int)sensorEVT->fData[2] == 1) + osTimerStart(g_cywee_hrs_timer,400); + else + osTimerStop(g_cywee_hrs_timer); } break; case IDX_ALGO_SHAKE: @@ -577,7 +642,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { c_activity_result_t.MHR_zone = (int)sensorEVT->fData[6]; c_activity_result_t.hrs = hrs; cywee_func(CYWEE_MSG_TYPE_ACTIVITY_UPDATE,&c_activity_result_t,sizeof(cywee_activity_result_t)); - + }else if((int)sensorEVT->fData[0] == 102) { CWM_OS_dbgPrintf("ar alert type : %d\n",(int)sensorEVT->fData[1]); @@ -672,6 +737,10 @@ void CWM_AP_dmlSensorDataOutput_listen(const dml_sensorData_t * pSdo) { int cywee_main_dml(int cmd) { + if(cmd == SPORT_ACTIVE_MODE_NORMAL) + mail = 2; + else + mail = 1; if (cywee_installized==0) { @@ -860,14 +929,18 @@ int cywee_main_dml(int cmd) memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; scl.iData[2] = 1; - // int[2] = 3,代表開啟acc和gyro感測器 1代表开启acc scl.iData[3] = 1; scl.iData[4] = 3; scl.iData[5] = 1; CWM_SettingControl(SCL_SEDENTARY, &scl); + // CWM_SettingControl(SCL_LOG, &scl); + + g_cywee_hrs_timer = osTimerNew((osTimerFunc_t)cywee_hrs_check_timer_callback, osTimerPeriodic, NULL, NULL); + g_cywee_wearstatus_timer = osTimerNew((osTimerFunc_t)cywee_wearstatus_check_timer_callback, osTimerPeriodic, NULL, NULL); + g_cywee_oncharging_timer = osTimerNew((osTimerFunc_t)cywee_oncharging_check_timer_callback, osTimerPeriodic, NULL, NULL); - //呼叫任一個CWM_Sensor_Enable 前呼叫此指令 设置手动或自动模式 + //呼叫任一個CWM_Sensor_Enable 前呼叫此指令 设置手动或自动模式 memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; scl.iData[1] = 1; @@ -879,12 +952,10 @@ int cywee_main_dml(int cmd) memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; scl.iData[3] = 3; - scl.iData[4] = 5; - // CWM_SettingControl(SCL_LOG, &scl); - + scl.iData[4] = 5; + CWM_Sensor_Enable(IDX_REQUEST_SENSOR); // //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); - CWM_Sensor_Enable(IDX_ALGO_INACTIVITY_OUTPUT); CWM_Sensor_Enable(IDX_ALGO_ACTIVITY_OUTPUT); @@ -897,12 +968,13 @@ int cywee_main_dml(int cmd) CWM_Sensor_Enable(IDX_ALGO_ABSOLUTE_STATIC); //CWM_OS_dbgPrintf("[DBG] %s %d\n", __func__,__LINE__); CWM_Sensor_Enable(IDX_ALGO_WATCH_HANDUP); - CWM_OS_dbgPrintf("cywee_installized skip install\n"); } - cyw_activity_mode_change(cmd); if(cmd == SPORT_ACTIVE_MODE_NORMAL) - cyw_activity_mode_change(INACTIVITY_MODE_NOTHING); + { + cyw_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY); + CWM_Sensor_Enable(IDX_ALGO_INACTIVITY_OUTPUT); + } // memset(&scl, 0, sizeof(scl)); // scl.iData[0] = 1; // scl.iData[1] = SPORT_ACTIVE_MODE_NORMAL; //ACTIVITY_MODE_NORMAL 1001 diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index 2a48240a0..aa4a45da0 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -120,6 +120,8 @@ ppg_sensor_data_t ppg_s_data; uint8_t free_trainning_hrs = 0; uint8_t free_trainning_wearstatus = 0; +uint8_t wear_mode_status = 0; + //////// spo2 para and switches const uint8_t COUNT_BLOCK_NUM = 25; //delay the block of some single good signal after a series of bad signal const uint8_t SPO2_LOW_XCORR_THRE = 30; //(64*xcorr)'s square below this threshold, means error signal @@ -166,6 +168,10 @@ void get_hrs_wearstatus(uint8_t *hrs,uint8_t *wearstatus) *wearstatus = free_trainning_wearstatus; } +void get_wearstatus(uint8_t *wearstatus) +{ + *wearstatus = wear_mode_status; +} // us 延时函数, 客户需填写 void hx3695_delay_us(uint32_t us) @@ -427,12 +433,11 @@ uint16_t hx3695_read_fifo_data(int32_t *buf, uint8_t phase_num, uint8_t sig) hx3695_brust_read_reg(0x22, databuf, 3); read_fifo_first_flg = 0; } - hx3695_brust_read_reg(0x22, fifo_data_buf, fifo_read_bytes); - PRINT("hx3695_brust_read_reg !!! \r\n"); - for(ii=0; iispo2 red_buf : %d, %d, %d, %d \n", 1+ii, *count, red_buf[ii], ir_buf[0]); + // for(ii=0; ii<*count; ii++) + // { + // gsen_fifo_x_send[ii] = gsen_fifo_x[32-*count+ii]; + // gsen_fifo_y_send[ii] = gsen_fifo_y[32-*count+ii]; + // gsen_fifo_z_send[ii] = gsen_fifo_z[32-*count+ii]; + // PRINT("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[ii],gsen_fifo_y[ii],gsen_fifo_z[ii]); + // //printf("FFF==>spo2 red_buf : %d, %d, %d, %d \n", 1+ii, *count, red_buf[ii], ir_buf[0]); -// } + // } // ft_ppg_iir = spo2_s_dat.red_data[0]; // hx3695_factory_test_process(NULL, APP_FACTORY_TEST_SPO2_START, &ft_ppg_iir); @@ -3456,21 +3461,21 @@ void hx3695_wear_ppg_Int_handle(void) hx3695_wear_msg_code_t hx3695_wear_status; hx3695_check_touch_read(&ppg_s_data); - hx3695_wear_status = hx3695_check_touch_send_data(ir_buf,*count); hrsresult.wearstatus = hx3695_wear_status; - + wear_mode_status = hx3695_wear_status; + //PRINT("wear_mode_status : %d \r\n",wear_mode_status); extern uint8_t notouch_cnt; extern uint8_t touch_cnt; // PRINT("===> touch_cnt: %d, notouch_cnt: %d, wear status: %d, \r\n", touch_cnt, notouch_cnt, hx3695_wear_status); - PRINT("hx3695_wear_ppg_Int_handle wearstatus = %d\r\n", hrsresult.wearstatus); - PRINT("count : %d \r\n",*count); - for(int i=0;i<*count;i++) - { - PRINT("%d,%d,%d,%d,%d,%d\r\n",1+i,*count,ir_buf[i],ppg_s_data.s_buf[i*2],ppg_s_data.s_buf[i*2+1],hx3695_wear_status); - } + // PRINT("hx3695_wear_ppg_Int_handle wearstatus = %d\r\n", hrsresult.wearstatus); + // PRINT("count : %d \r\n",*count); + // for(int i=0;i<*count;i++) + // { + // PRINT("%d,%d,%d,%d,%d,%d\r\n",1+i,*count,ir_buf[i],ppg_s_data.s_buf[i*2],ppg_s_data.s_buf[i*2+1],hx3695_wear_status); + // } } #endif diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_check_touch.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_check_touch.c index c4b2e4d50..a41375fc4 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_check_touch.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_check_touch.c @@ -8,7 +8,7 @@ #include "tyhx_hrs_custom.h" #include "hx3695.h" #include "hx3695_check_touch.h" - +#include "hx3695_hrs_agc.h" hx3695_wear_msg_code_t hx3695_wear_status = MSG_NO_WEAR; @@ -137,7 +137,7 @@ uint8_t hx3695_check_touch_read(ppg_sensor_data_t *s_dat) int32_t *green_data = &(s_dat->green_data[0]); int32_t *ir_buf = &(s_dat->ir_data[0]); int32_t *s_buf = &(s_dat->s_buf[0]); - + int32_t IR_data[8] = {0}; // size = hx3695_read_fifo_size(); // // if(size<2) @@ -148,13 +148,14 @@ uint8_t hx3695_check_touch_read(ppg_sensor_data_t *s_dat) // if (size && size <= 256) // { fifo_out_size = hx3695_read_fifo_data(s_buf,hrs_phase_num,2); - PRINT("fifo_out_size : %d\r\n",fifo_out_size); + //PRINT("fifo_out_size : %d\r\n",fifo_out_size); s_dat->count = fifo_out_size; + read_hrs_data_packet(IR_data); for (i=0; icheck_mode_wear_thre) { notouch_cnt = 0; diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c index 944aa79a7..e13ee4e0e 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c @@ -2,8 +2,8 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-03-13 15:08:38 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-04-12 20:23:58 - * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c + * @LastEditTime: 2024-04-13 17:22:50 + * @FilePath: /sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c * @Description: * * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. @@ -70,7 +70,7 @@ void ppg_send_cmd_to_driver(char* mode, uint8_t enable) } else { // ppg_service_running_stat = false; - if(md == HRS_MODE|| md == FT_LEAK_LIGHT_MODE || md == FT_GRAY_CARD_MODE || md == FT_GRAY_CARD_MODE) + if(md == HRS_MODE|| md == FT_LEAK_LIGHT_MODE || md == FT_GRAY_CARD_MODE || md == WEAR_MODE) { #ifdef HRS_ALG_LIB hx3695_hrs_disable(); diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c index 98b7a7a84..aa3fb231e 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c @@ -44,6 +44,8 @@ static hrs_wear_msg_code_t hrs_wear_status_pre = MSG_HRS_NO_WEAR; static uint8_t no_touch_cnt = 0; +int32_t Ir_data = 0; + void Init_hrs_PPG_Calibration_Routine(HRS_CAL_SET_T *calR) { calR->flag = CAL_FLG_LED_DR|CAL_FLG_LED_DAC|CAL_FLG_AMB_DAC|CAL_FLG_RF; @@ -515,8 +517,8 @@ void read_hrs_data_packet(int32_t *s_buf) s_buf[6] = ((databuf4[0])|(databuf4[1]<<8)|(databuf4[2]<<16)); s_buf[7] = ((databuf4[3])|(databuf4[4]<<8)|(databuf4[5]<<16)); -// SEGGER_RTT_printf(0,"phase7_data: %d, phase8_data: %d\r\n", s_buf[6],s_buf[7]); - + //PRINT("phase7_data: %d, phase8_data: %d %d\r\n", s_buf[6],s_buf[7],s_buf[7] - s_buf[6]); + Ir_data = s_buf[7] - s_buf[6]; } void read_hrs_ir_packet(int32_t *buf) diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.h b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.h index 8f6374469..91aea996f 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.h @@ -112,4 +112,6 @@ hrs_wear_msg_code_t hx3695_hrs_wear_mode_check(WORK_MODE_T mode, int32_t infrare HRS_CAL_SET_T get_hrs_agc_status(void); void hx3695_hrs_data_reset(void); +extern int32_t Ir_data; + #endif diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.h b/code/sdk/drivers/peripheral/ppg/service/ppg_service.h index 9f4e5e27a..9940bee8f 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.h +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.h @@ -53,7 +53,7 @@ uint32_t ppg_suspend(void); uint32_t ppg_resume(void); void get_hrs_wearstatus(uint8_t *hrs,uint8_t *wearstatus); - +void get_wearstatus(uint8_t *wearstatus); typedef enum { PPG_TEST_MODE_HRS, PPG_TEST_MODE_SPO2,