Merge #63 into xts_origin from refs/changes/63/head 64/target/1 65/target/1
author彭磊 <1624952103@qq.com>
Mon, 22 Apr 2024 03:37:42 +0000 (03:37 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Mon, 22 Apr 2024 03:37:42 +0000 (03:37 +0000)
解决佩戴模式系统不能休眠的问题

* refs/changes/63/head: (1 commits squashed)

  - 解决佩戴模式系统不能休眠的问题

Signed-off-by: aliyun6865282430 <1624952103@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/63
code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h
code/sdk/drivers/peripheral/ppg/hx3695/hx3695_check_touch.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c
code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_custom.h
code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp
code/sdk/drivers/peripheral/ppg/service/ppg_service.h

index 3facf3c..35bf669 100644 (file)
@@ -267,6 +267,17 @@ bool Efuse_judge(void)
        return true;\r
 }\r
 \r
+uint32_t hx3695_wear_mode_timers_start(void)\r
+{\r
+    tyhx_timer_start(TYHX_TIMER_5000MS);\r
+    return 0;\r
+}\r
+uint32_t hx3695_wear_mode_timers_stop(void)\r
+{\r
+    tyhx_timer_stop(TYHX_TIMER_5000MS);\r
+    return 0;\r
+}\r
+\r
 uint32_t hx3695_timers_start(void)\r
 {\r
     tyhx_timer_start(TYHX_TIMER_320MS);\r
@@ -318,6 +329,21 @@ void hx3695_40ms_timer_cfg(bool en)
     }\r
 }\r
 \r
+void hx3695_5000ms_timer_cfg(bool en)\r
+{\r
+    if(en)\r
+    {\r
+        hx3695_wear_mode_timers_start();\r
+    }\r
+    else\r
+    {\r
+      PRINT("555\r\n");\r
+        hx3695_wear_mode_timers_stop();\r
+    }\r
+\r
+}\r
+\r
+\r
 #if defined(INT_MODE)\r
 /* 如采用中断模式, 如完成中断开启和关闭接口\r
 void hx3695_ppg_Int_handle(void)\r
@@ -2546,6 +2572,16 @@ typedef struct {
     int32_t ir_data_final;\r
 } ft_test_result_t;\r
 \r
+void wear_mode_timeout_handler(void * p_context)\r
+{\r
+    if(work_mode_flag == WEAR_MODE)\r
+    {\r
+        #ifdef CHECK_TOUCH_LIB\r
+          hx3695_wear_ppg_Int_handle(); \r
+        #endif\r
+    }\r
+}\r
+\r
 \r
 void heart_rate_meas_timeout_handler(void * p_context)\r
 {\r
@@ -2571,13 +2607,6 @@ void heart_rate_meas_timeout_handler(void * p_context)
 #endif\r
         break;\r
 \r
-    case WEAR_MODE:\r
-//             PRINT("@@@@@@@@@ WEAR_MODE $$$$$$$$$\r\n");\r
-#ifdef CHECK_TOUCH_LIB\r
-        hx3695_wear_ppg_Int_handle();\r
-#endif\r
-        break;\r
-\r
     case LIVING_MODE:\r
 #ifdef CHECK_LIVING_LIB\r
         hx3695_living_Int_handle();\r
@@ -3457,7 +3486,6 @@ void hx3695_hrv_ppg_Int_handle(void)
 void hx3695_wear_ppg_Int_handle(void)\r
 {\r
 //     PRINT("hx3695_wear_ppg_Int_handle  wearstatus = %d\r\n", hrsresult.wearstatus);\r
-       \r
     uint8_t *count = &(ppg_s_data.count);\r
     int32_t *ir_buf = &(ppg_s_data.ir_data[0]);\r
     hx3695_wear_msg_code_t hx3695_wear_status;\r
@@ -3465,6 +3493,7 @@ void hx3695_wear_ppg_Int_handle(void)
     hx3695_check_touch_read(&ppg_s_data);\r
     hx3695_wear_status = hx3695_check_touch_send_data(ir_buf,*count);\r
     hrsresult.wearstatus = hx3695_wear_status;\r
+    PRINT("hx3695_wear_status : %d \r\n",hx3695_wear_status);\r
     if(wear_mode_status != hx3695_wear_status)\r
     {\r
         wear_mode_status = hx3695_wear_status;\r
index 7a7ad4d..7e14873 100644 (file)
@@ -252,6 +252,7 @@ void hx3695_ppg_off(void);
 void hx3695_ppg_on(void);  \r
 void hx3695_320ms_timer_cfg(bool en);\r
 void hx3695_40ms_timer_cfg(bool en);\r
+void hx3695_5000ms_timer_cfg(bool en);\r
 void hx3695_gpioint_cfg(bool en);\r
 bool hx3695_init(WORK_MODE_T mode);\r
 void hx3695_agc_Int_handle(void); \r
@@ -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);\r
 void agc_timeout_handler(void * p_context);\r
 void heart_rate_meas_timeout_handler(void * p_context);\r
+void wear_mode_timeout_handler(void * p_context);\r
 void Efuse_Mode_Check(void);\r
 \r
 uint8_t hx3695_get_chip_id(void);\r
index a41375f..12eb472 100644 (file)
@@ -47,7 +47,7 @@ SENSOR_ERROR_T hx3695_check_touch_enable(void)
 //             AGC_LOG("hx3695 here!\r\n");\r
                hx3695_delay_ms(100);   \r
                        \r
-    hx3695_320ms_timer_cfg(true);\r
+    hx3695_5000ms_timer_cfg(true);\r
 \r
     return SENSOR_OK;\r
 }\r
index e13ee4e..e55579d 100644 (file)
@@ -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();
     } 
index aa3fb23..60a15b9 100644 (file)
@@ -850,6 +850,7 @@ void hx3695_hrs_disable(void)
 #if defined(TIMMER_MODE)\r
     hx3695_320ms_timer_cfg(false);\r
     hx3695_40ms_timer_cfg(false);\r
+    hx3695_5000ms_timer_cfg(false);\r
 #elif defined(INT_MODE)\r
     hx3695_gpioint_cfg(false);\r
 #endif\r
index 491bf15..c6337d8 100644 (file)
@@ -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;
 }
index 3c27d4d..6d40324 100644 (file)
@@ -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);
index 3d92932..59943f0 100644 (file)
@@ -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;
index d76187e..513c2ed 100644 (file)
@@ -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