From: penglei <1624952103@qq.com> Date: Mon, 22 Apr 2024 02:55:30 +0000 (+0800) Subject: 解决佩戴模式系统不能休眠的问题 X-Git-Tag: release_V1.2.70_20241020_135402~1131^2~9 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=refs%2Fchanges%2F63%2Fhead;p=mirrors%2FFD230.git 解决佩戴模式系统不能休眠的问题 --- diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index 3facf3cf2..35bf6695c 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -267,6 +267,17 @@ bool Efuse_judge(void) return true; } +uint32_t hx3695_wear_mode_timers_start(void) +{ + tyhx_timer_start(TYHX_TIMER_5000MS); + return 0; +} +uint32_t hx3695_wear_mode_timers_stop(void) +{ + tyhx_timer_stop(TYHX_TIMER_5000MS); + return 0; +} + uint32_t hx3695_timers_start(void) { tyhx_timer_start(TYHX_TIMER_320MS); @@ -318,6 +329,21 @@ void hx3695_40ms_timer_cfg(bool en) } } +void hx3695_5000ms_timer_cfg(bool en) +{ + if(en) + { + hx3695_wear_mode_timers_start(); + } + else + { + PRINT("555\r\n"); + hx3695_wear_mode_timers_stop(); + } + +} + + #if defined(INT_MODE) /* 如采用中断模式, 如完成中断开启和关闭接口 void hx3695_ppg_Int_handle(void) @@ -2546,6 +2572,16 @@ typedef struct { int32_t ir_data_final; } ft_test_result_t; +void wear_mode_timeout_handler(void * p_context) +{ + if(work_mode_flag == WEAR_MODE) + { + #ifdef CHECK_TOUCH_LIB + hx3695_wear_ppg_Int_handle(); + #endif + } +} + void heart_rate_meas_timeout_handler(void * p_context) { @@ -2571,13 +2607,6 @@ void heart_rate_meas_timeout_handler(void * p_context) #endif break; - case WEAR_MODE: -// PRINT("@@@@@@@@@ WEAR_MODE $$$$$$$$$\r\n"); -#ifdef CHECK_TOUCH_LIB - hx3695_wear_ppg_Int_handle(); -#endif - break; - case LIVING_MODE: #ifdef CHECK_LIVING_LIB hx3695_living_Int_handle(); @@ -3457,7 +3486,6 @@ void hx3695_hrv_ppg_Int_handle(void) void hx3695_wear_ppg_Int_handle(void) { // PRINT("hx3695_wear_ppg_Int_handle wearstatus = %d\r\n", hrsresult.wearstatus); - uint8_t *count = &(ppg_s_data.count); int32_t *ir_buf = &(ppg_s_data.ir_data[0]); hx3695_wear_msg_code_t hx3695_wear_status; @@ -3465,6 +3493,7 @@ void hx3695_wear_ppg_Int_handle(void) hx3695_check_touch_read(&ppg_s_data); hx3695_wear_status = hx3695_check_touch_send_data(ir_buf,*count); hrsresult.wearstatus = hx3695_wear_status; + PRINT("hx3695_wear_status : %d \r\n",hx3695_wear_status); if(wear_mode_status != hx3695_wear_status) { wear_mode_status = hx3695_wear_status; diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h index 7a7ad4d9d..7e1487354 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h @@ -252,6 +252,7 @@ void hx3695_ppg_off(void); void hx3695_ppg_on(void); void hx3695_320ms_timer_cfg(bool en); void hx3695_40ms_timer_cfg(bool en); +void hx3695_5000ms_timer_cfg(bool en); void hx3695_gpioint_cfg(bool en); bool hx3695_init(WORK_MODE_T mode); void hx3695_agc_Int_handle(void); @@ -293,6 +294,7 @@ bool hx3695_living_send_data(int32_t *new_raw_data, uint8_t dat_len, int16_t *gs hx3695_living_results_t hx3695_living_get_results(void); void agc_timeout_handler(void * p_context); void heart_rate_meas_timeout_handler(void * p_context); +void wear_mode_timeout_handler(void * p_context); void Efuse_Mode_Check(void); uint8_t hx3695_get_chip_id(void); 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 a41375fc4..12eb47233 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_check_touch.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_check_touch.c @@ -47,7 +47,7 @@ SENSOR_ERROR_T hx3695_check_touch_enable(void) // AGC_LOG("hx3695 here!\r\n"); hx3695_delay_ms(100); - hx3695_320ms_timer_cfg(true); + hx3695_5000ms_timer_cfg(true); return SENSOR_OK; } diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c index e13ee4e0e..e55579dd5 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-13 17:22:50 - * @FilePath: /sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c + * @LastEditTime: 2024-04-22 10:37:39 + * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c * @Description: * * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. @@ -84,12 +84,13 @@ void ppg_send_cmd_to_driver(char* mode, uint8_t enable) { #ifdef SPO2_ALG_LIB hx3695_spo2_disable(); -#endif - }else{ -#ifdef HRS_ALG_LIB - hx3695_hrs_disable(); #endif } +// else{ +// #ifdef HRS_ALG_LIB +// hx3695_hrs_disable(); +// #endif +// } uapi_pm_control(PM_APP_WAKE_NONEED); tyhx_poweroff(); } 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 aa3fb231e..60a15b995 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c @@ -850,6 +850,7 @@ void hx3695_hrs_disable(void) #if defined(TIMMER_MODE) hx3695_320ms_timer_cfg(false); hx3695_40ms_timer_cfg(false); + hx3695_5000ms_timer_cfg(false); #elif defined(INT_MODE) hx3695_gpioint_cfg(false); #endif diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c index 491bf15b3..c6337d8a6 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c @@ -143,6 +143,7 @@ void tyhx_delay_ms(uint32_t ms) #define BUTTON_APP_TIMER_INTERVAL 20 osTimerId_t g_timer40_timer = NULL; osTimerId_t g_timer320_timer = NULL; +osTimerId_t g_timer5000_timer = NULL; static uint8_t g_hx3695_timer_installed = 0; static void timer40_func(void) @@ -156,12 +157,19 @@ static void timer320_func(void) send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_320TIMER_CALLBACK); // heart_rate_meas_timeout_handler(NULL); } + +static void timer5000_func(void) +{ + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_5000TIMER_CALLBACK); + // heart_rate_meas_timeout_handler(NULL); +} bool tyhx_timer_init(void) { if (g_hx3695_timer_installed == 1) return true; g_timer40_timer = osTimerNew((osTimerFunc_t)timer40_func, osTimerPeriodic, NULL, NULL); g_timer320_timer = osTimerNew((osTimerFunc_t)timer320_func, osTimerPeriodic, NULL, NULL); + g_timer5000_timer = osTimerNew((osTimerFunc_t)timer5000_func, osTimerPeriodic, NULL, NULL); g_hx3695_timer_installed = true; return true; } @@ -182,7 +190,12 @@ bool tyhx_timer_start(uint32_t ms) { if(osTimerIsRunning(g_timer320_timer)==0) osTimerStart(g_timer320_timer, TYHX_TIMER_320MS); + }else if (ms == TYHX_TIMER_5000MS) + { + if(osTimerIsRunning(g_timer5000_timer)==0) + osTimerStart(g_timer5000_timer, TYHX_TIMER_5000MS); } + return 1; } bool tyhx_timer_stop(uint32_t ms) @@ -196,6 +209,10 @@ bool tyhx_timer_stop(uint32_t ms) { if(osTimerIsRunning(g_timer320_timer)) osTimerStop(g_timer320_timer); + }else if (ms == TYHX_TIMER_5000MS) + { + if(osTimerIsRunning(g_timer5000_timer)) + osTimerStop(g_timer5000_timer); } return 1; } diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_custom.h b/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_custom.h index 3c27d4d48..6d40324f6 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_custom.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_custom.h @@ -1,3 +1,13 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-03-26 20:29:58 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-04-22 09:28:45 + * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_custom.h + * @Description: + * + * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. + */ #ifndef __TYHX_HRS_CUSTOM_H__ #define __TYHX_HRS_CUSTOM_H__ @@ -61,6 +71,7 @@ uint32_t tyhx_read_regs( uint8_t reg_addr,uint8_t *readbuf,uint16_t readlen); #define TYHX_TIMER_40MS 40 #define TYHX_TIMER_320MS 320 +#define TYHX_TIMER_5000MS 5000 bool tyhx_timer_start(uint32_t ms); bool tyhx_timer_stop(uint32_t ms); diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp index 3d9293210..59943f0d3 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp @@ -66,7 +66,7 @@ static unsigned long g_app_queue; static bool ppg_service_running_stat = false; static uint8_t wear_mode_state = 0; -static uint8_t keep_in_wear_det_mod = 0; //持续坚持 佩戴检测模式 +static uint8_t keep_in_wear_det_mod = 1; //持续坚持 佩戴检测模式 void set_keep_in_wear_det_mode(uint8_t mod) @@ -292,7 +292,6 @@ static void ppg_service_check_task(void *arg) if (ret != OSAL_SUCCESS) { continue; } - if((wear_mode_state == 1) && (mail > 0x10) && mail != PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST) { wear_mode_state = 0; @@ -307,6 +306,9 @@ static void ppg_service_check_task(void *arg) }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_40TIMER_CALLBACK){ agc_timeout_handler(NULL); continue; + }else if(mail == PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_5000TIMER_CALLBACK){ + wear_mode_timeout_handler(NULL); + continue; }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_TEST){ cmd = "hrs"; enable = 1; diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.h b/code/sdk/drivers/peripheral/ppg/service/ppg_service.h index d76187eeb..513c2ed38 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.h +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.h @@ -1,8 +1,8 @@ /* * @Author: penglei 1624952103@qq.com * @Date: 2024-03-27 09:07:00 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-04-21 22:49:47 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2024-04-22 10:43:36 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/service/ppg_service.h * @Description: * @@ -29,6 +29,7 @@ extern "C" { #include "stdint.h" #include "errcode.h" +#define PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_5000TIMER_CALLBACK 0x09 #define PPG_SERVICE_CMD_TYPE_DO_PPG_40TIMER_CALLBACK 0x0A #define PPG_SERVICE_CMD_TYPE_DO_PPG_320TIMER_CALLBACK 0x10 #define PPG_SERVICE_CMD_TYPE_DO_PPG_TEST 0x11