解决 ppg timer和 cywee timer 冲突造成 ppg总是失灵问题。
authorSnickerSun <snickersun@163.com>
Tue, 26 Mar 2024 14:47:21 +0000 (22:47 +0800)
committerSnickerSun <snickersun@163.com>
Tue, 26 Mar 2024 14:47:21 +0000 (22:47 +0800)
code/sdk/drivers/peripheral/cywee/service/cywee_service.c
code/sdk/drivers/peripheral/cywee/src/main_dml.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c
code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp
code/sdk/drivers/peripheral/ppg/service/ppg_service.h

index 1f61fae..724308e 100644 (file)
@@ -39,7 +39,7 @@ typedef struct
  * 其他cmd在Header里定义,对外开放
 */
 
-#define CYWEE_CHECK_MS 40
+#define CYWEE_CHECK_MS 20
 
 osTimerId_t g_cywee_service_timer = NULL;
 static bool g_batter_service_initialled = false;
index 5922f39..16f1b36 100644 (file)
@@ -281,7 +281,7 @@ int cywee_main_dml(void) {
     memset(&scl, 0, sizeof(scl));
     scl.iData[0] = 1;
     scl.iData[3] = 2;
-    scl.iData[4] = 1; //anytime
+    scl.iData[4] = 2; //1 anytime 2 fifo
     scl.iData[6] = 5; //先設定5
     scl.iData[7] = 5;
     scl.iData[8] = 25; // for st sensor(52Hz)
index bdb035e..5e1d005 100644 (file)
@@ -138,7 +138,7 @@ void tyhx_delay_ms(uint32_t ms)
 
 
 
-
+#include "ppg_service.h"
 #include "cmsis_os2.h"
 #define BUTTON_APP_TIMER_INTERVAL 20
 osTimerId_t g_timer40_timer = NULL;
@@ -147,12 +147,14 @@ static uint8_t g_hx3695_timer_installed = 0;
 
 static void timer40_func(void)
 {
-    agc_timeout_handler(NULL);
+    send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_40TIMER_CALLBACK);
+    // agc_timeout_handler(NULL);
 }
 
 static void timer320_func(void)
 {
-    heart_rate_meas_timeout_handler(NULL);
+    send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_320TIMER_CALLBACK);
+    // heart_rate_meas_timeout_handler(NULL);
 }
 bool tyhx_timer_init(void)
 {
index 3ed64b3..3a388bd 100644 (file)
@@ -179,7 +179,7 @@ errcode_t update_wearstatus_event_sendmsg_toUI(int32_t wearstatus)
 }
 
 #include "hx3695_hal.h"
-
+#include "hx3695.h"
 void hx3695_msg_callback(uint8_t msg_type, uint8_t *msg_data, int32_t msg_datalen)
 {
     WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "hx3695_msg_callback");
@@ -279,10 +279,16 @@ static void ppg_service_check_task(void  *arg)
         if (ret != OSAL_SUCCESS) {
             continue;
         }
-
+        
         char* cmd = "hrs";
         int enable = 1;
-        if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_TEST){
+        if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_320TIMER_CALLBACK){
+            heart_rate_meas_timeout_handler(NULL);
+            continue;
+        }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_40TIMER_CALLBACK){
+            agc_timeout_handler(NULL);
+            continue;
+        }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_TEST){
             cmd = "hrs";
             enable = 1;
         }else if (mail == PPG_SERVICE_CMD_TYPE_DO_HRV_TEST){
index 7869655..9837670 100644 (file)
@@ -19,7 +19,8 @@ extern "C" {
 #include "stdint.h"
 #include "errcode.h"
 
-
+#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
 #define PPG_SERVICE_CMD_TYPE_DO_HRV_TEST 0x12
 #define PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST 0x13