心率死机bug处理
authorp15692025051 <846603105@qq.com>
Wed, 10 May 2023 07:35:31 +0000 (15:35 +0800)
committerp15692025051 <846603105@qq.com>
Wed, 10 May 2023 07:35:31 +0000 (15:35 +0800)
2.sdk/Helios_SDK/components/GH301x/gh3011_example_config.h
2.sdk/Helios_SDK/components/GH301x/gh3011_example_port.c
2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor_GH3018.c

index 72c6805..de13880 100644 (file)
@@ -70,7 +70,7 @@
 #define __HB_ADT_CONFIRM_THR_CNT__          (20)
 
 /* hb and spo2 */
-#define __HR_SPO2_DET_SUPPORT__             (1)
+#define __HR_SPO2_DET_SUPPORT__             (0)
 /// hr spo2 fifo thr cnt config
 #define __HR_SPO2_FIFO_THR_CNT_CONFIG__     (100)
 
index 44b325e..b37db66 100644 (file)
@@ -139,15 +139,17 @@ void hal_gh30x_spi_cs_set_high(void)
 /* delay */
 
 /// delay us
+#include "helios_os.h"
 void hal_gh30x_delay_us(uint16_t us_cnt)
 {
-       int cnt = 26;
-       volatile int i = 0;
-       while (us_cnt--) {
-               i = cnt;
-               while (i--);
-       }
-       // code implement by user
+       // int cnt = 26;
+       // volatile int i = 0;
+       // while (us_cnt--) {
+       //      i = cnt;
+       //      while (i--);
+       // }
+       Helios_msleep(us_cnt/1000);
+       //code implement by user
 }
 
 /* gsensor driver */
index 2f696f6..36bad18 100644 (file)
@@ -72,6 +72,7 @@ int SC7A20_init(void);
 extern signed char SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void);
 extern unsigned char Gsensor_init_flag ;
 extern void hal_gh30x_int_handler(void);
+char GH3018_irq_lock = 0;
 // int test_count1 = 0;
 // int test_count2 = 0;
 
@@ -171,7 +172,9 @@ void sensor_thread_entry(void * argv)
                {
                        if(GH3018_irq_flag)
                        {
+                               GH3018_irq_lock = 1;
                                hal_gh30x_int_handler();
+                               GH3018_irq_lock = 0;
                                //GH3018_LOG("hal_gh30x_int_handler:test_count1:%d test_count2:%d\r\n",test_count1,test_count2);
                                GH3018_irq_flag = 0;
                        }
@@ -293,6 +296,10 @@ mp_obj_t mp_GH3018_init(mp_obj_t self_in)
 STATIC mp_obj_t mp_GH3018_deinit(mp_obj_t self_in)
 {
     GH3018_obj_t *self = MP_OBJ_TO_PTR(self_in);
+       while(GH3018_irq_lock)
+       {
+               Helios_msleep(1);
+       }
        gh30x_module_stop();
        Helios_GPIO_Deinit((Helios_GPIONum)self->irq);
        Helios_ExtInt_Deinit(self->irq);
@@ -323,7 +330,7 @@ void GH3018_test(mp_obj_t self_in,uint32_t mode)
        GH3018_LOG("mp_GH3018_open_heart gh30x_module_init:ret:%d\r\n",ret);
        if(ret == 1)
        {
-               gh30x_module_stop();
+               //gh30x_module_stop();
                Helios_msleep(10);
                gh30x_module_start_without_adt(mode);
                //gh30x_module_start(gh3018_run_mode);
@@ -361,6 +368,11 @@ STATIC mp_obj_t mp_GH3018_close(mp_obj_t self_in)
     GH3018_obj_t *self = MP_OBJ_TO_PTR(self_in);
        if(is_open_gh3018 == 1)
        {
+
+               while(GH3018_irq_lock)
+               {
+                       Helios_msleep(1);
+               }
                gh30x_module_stop();
                if(sensor_timer != 0)
                {
@@ -368,6 +380,11 @@ STATIC mp_obj_t mp_GH3018_close(mp_obj_t self_in)
                }
        }
        is_open_gh3018 = 0;
+       Helios_GPIO_SetLevel(self->power, HELIOS_LVL_LOW);
+       Helios_msleep(5);
+       Helios_GPIO_SetLevel(self->power, HELIOS_LVL_HIGH);
+       Helios_msleep(20);
+       gh30x_module_init();
        //Helios_GPIO_SetLevel(self->power, HELIOS_LVL_LOW);
     return mp_obj_new_int(1);
 }