新增gsensor与hsensor的编译宏开关
authorp15692025051 <846603105@qq.com>
Mon, 24 Jul 2023 06:59:35 +0000 (14:59 +0800)
committerp15692025051 <846603105@qq.com>
Mon, 24 Jul 2023 06:59:35 +0000 (14:59 +0800)
2.sdk/Helios_SDK/components/GH301x/gh3011_example_port.c
2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modGsensor.c
2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modGsensor_SC7A20.c
2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor.c
2.sdk/Helios_SDK/services/microPython/ports/quectel/core/source/modHsensor_GH3018.c
2.sdk/project/K5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_ALIPAY/images/DBG.7z

index 1111214..10a7361 100644 (file)
@@ -203,12 +203,19 @@ void gsensor_drv_enter_motion_det_mode(void)
        */
        gsensor_drv_motion_det_mode = true;
 }
+#include "autoconf.h"
+#if CONFIG_SC7A20
 extern unsigned int get_Gsensor_buf(ST_GS_DATA_TYPE *buf);
+#endif
 /// gsensor get fifo data
 void gsensor_drv_get_fifo_data(ST_GS_DATA_TYPE gsensor_buffer[], uint16_t *gsensor_buffer_index, uint16_t gsensor_max_len)
 {
        unsigned int buffer_len = 0,i;
+       #if CONFIG_SC7A20
        buffer_len = get_Gsensor_buf(gsensor_buffer);
+       #else
+       buffer_len = 0;
+       #endif
        GH301x_LOG("gsensor_drv_get_fifo_data:buffer_len:%d gsensor_max_len:%d",buffer_len,gsensor_max_len);
        if(buffer_len > gsensor_max_len)
                buffer_len = gsensor_max_len;
index 407cd61..c2cd76b 100644 (file)
@@ -46,9 +46,9 @@ extern const mp_obj_type_t Gsensor_SC7A20_type;
 STATIC const mp_rom_map_elem_t Gsensor_module_globals_table[] = {
        { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_Gsensor) },
 
-//#if MICROPY_QPY_SC7A20
+#if CONFIG_SC7A20
        { MP_ROM_QSTR(MP_QSTR_SC7A20), MP_ROM_PTR(&Gsensor_SC7A20_type) },
-//#endif
+#endif
        //TODO add other deriver
 };
 
index e805121..9659342 100644 (file)
 #include "runtime.h"
 #include <stdlib.h>
 #include <math.h>
+#include "autoconf.h"
 #include "mphalport.h"
 #include "compile.h"
 #include "repl.h"
 #include "mperrno.h"
 #include "binary.h"
+
+#if CONFIG_GH301x
 #include "hbd_ctrl.h"
+#endif
 
 #include <string.h>
-
-#if 1//MICROPY_QPY_Gsensor_SC7A20
+#if CONFIG_SC7A20
 
 #include "helios_gpio.h"
 #include "helios_iic.h"
 #include "helios_fs.h"
 #include "helios_pin.h"
 
-#ifdef CONFIG_LVGL
-#include "lvgl.h"
+// #ifdef CONFIG_LVGL
+// #include "lvgl.h"
 
-#endif
+// #endif
 
 
 #include "helios_debug.h"
@@ -269,12 +272,14 @@ uint8_t gsensor_sc7a20_fall_detect(acc_g_data_t * acc)
 
     return 0;
 }
-
+#if CONFIG_GH301x
 static ST_GS_DATA_TYPE s_sc7a20_read_data[32] = {0};
-signed short SC7A20_XYZ_Buf_tmp[3][32];
-unsigned int SC7A20_XYZ_Buf_tmp_len =0;
 static unsigned int s_sc7a20_read_data_len = 0;
 static unsigned char s_sc7a20_read_data_counter = 0;
+#endif
+signed short SC7A20_XYZ_Buf_tmp[3][32];
+unsigned int SC7A20_XYZ_Buf_tmp_len =0;
+
 unsigned char Gsensor_init_flag = 0;
 float x,y,z;
 unsigned int  SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void)
@@ -404,7 +409,7 @@ unsigned int  SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void)
        
        SC7A20_XYZ_Buf_tmp_len += SC7A20_FIFO_NUM;
        //dump2
-
+       #if CONFIG_GH301x
        // s_sc7a20_read_data_counter++;  
        if(SC7A20_XYZ_Buf_tmp_len >= 25)
        {
@@ -430,6 +435,7 @@ unsigned int  SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void)
                SC7A20_XYZ_Buf_tmp_len = 0;
                //SC7A20_LOG("SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO:s_sc7a20_read_data_len:%d\r\n",s_sc7a20_read_data_len);
        }
+       #endif
        //SC7A20_LOG("SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO:SC7A20_FIFO_NUM:%d\r\n",SC7A20_FIFO_NUM);
        
        x = s_acc.x;
@@ -459,6 +465,7 @@ unsigned int  SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void)
        }
     return SL_STEP;
 }
+#if CONFIG_GH301x
 //获取Gsensor数据,填充到buf,返回长度,data长度需要32*3个short大小
 unsigned int get_Gsensor_buf(ST_GS_DATA_TYPE *buf)
 {
@@ -470,6 +477,7 @@ void clean_Gsensor_buf(void)
        memset(s_sc7a20_read_data,0,sizeof(s_sc7a20_read_data));
        s_sc7a20_read_data_len = 0;
 }
+#endif
 /**
  * 设置算法库灵敏度
  * Please modify the following parameters according to the actual situation**/
index 68ecf79..21ec318 100644 (file)
@@ -46,9 +46,9 @@ extern const mp_obj_type_t Hsensor_GH3018_type;
 STATIC const mp_rom_map_elem_t Hsensor_module_globals_table[] = {
        { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_Hsensor) },
 
-//#if MICROPY_QPY_GH3018
+#if CONFIG_GH301x
        { MP_ROM_QSTR(MP_QSTR_GH3018), MP_ROM_PTR(&Hsensor_GH3018_type) },
-//#endif
+#endif
        //TODO add other deriver
 };
 
index 342c06f..08e1903 100644 (file)
 #include "binary.h"
 
 #include <string.h>
-
-#if 1//MICROPY_QPY_Hsensor_GH3018
+Helios_Thread_t sensor_thread_id = 0;
+void sensor_thread_entry(void * argv);
+Helios_ThreadAttr ThreadAttr = {
+        .name = "HealthSensor",
+        .stack_size = 1024*20,
+        .priority = 100,
+        .entry = sensor_thread_entry,
+        .argv = NULL
+    };
+#if CONFIG_GH301x
 
 #include "helios_gpio.h"
 #include "helios_iic.h"
@@ -33,6 +41,7 @@
 
 #include "helios_debug.h"
 #include "gh3011_example.h"
+#include "autoconf.h"
 #define GH3018_LOG(msg, ...)      custom_log("GH3018", msg, ##__VA_ARGS__)
 //////////////////////////////////////////////////////////////////////////////
 typedef struct _GH3018_obj_t
@@ -58,10 +67,11 @@ static unsigned char s_gh3018_wear_status = 0;//佩戴状态
 #define HEART_RATE_BUFF_LEN 10
 unsigned char s_gh3018_heart_rate_buff[HEART_RATE_BUFF_LEN]={0};
 unsigned short s_gh3018_heart_rate_buff_count = 0;
-void sensor_thread_entry(void * argv);
+
+Helios_ThreadAttr ThreadAttr;
 char GH3018_sleep_flag =  0;
 #include "helios_extint.h"
-Helios_Thread_t sensor_thread_id = 0;
+
 int sensor_timer = 0;
 #define TIMER_TIME_MS  100 //10ms
 #define IS_CYCLICAL 1
@@ -69,22 +79,20 @@ uint8_t GH3018_irq_flag = 0;
 uint32_t gh3018_run_mode =RUN_MODE_INVALID;
 #define RUN_MODE_CLOSE 0xffff
 static uint32_t timer_Gsensor_count = 0;
-int SC7A20_init(void);
+#if CONFIG_SC7A20
+extern int SC7A20_init(void);
 extern signed char SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO(void);
 extern unsigned char Gsensor_init_flag ;
+
+#endif
 extern void hal_gh30x_int_handler(void);
+
 char GH3018_irq_lock = 0;
 // int test_count1 = 0;
 // int test_count2 = 0;
 
 void sensor_timerout_cb(void);
-Helios_ThreadAttr ThreadAttr = {
-        .name = "GH3018",
-        .stack_size = 1024*20,
-        .priority = 100,
-        .entry = sensor_thread_entry,
-        .argv = NULL
-    };
+
 void GH3018_result_set_heart_rate(unsigned char heart_rate)
 {
 //    s_gh3018_heart_rate_buff[HEART_RATE_BUFF_LEN]={0};
@@ -162,61 +170,7 @@ STATIC mp_obj_t mp_GH3018_deinit(mp_obj_t self_in);
 
 void GH3018_test(uint32_t mode);
 void gh3018_close(void);
-void sensor_thread_entry(void * argv)
-{
-       //GH3018_LOG("sensor_thread_entry: 11111111!!!!!!!!\r\n");
-       
-       
-       while(1)
-       {
-               
-               if(gh3018_run_mode == RUN_MODE_CLOSE)
-               {
-                       gh3018_close();
-                       //GH3018_LOG("GH3018_irq_cb: 1111111111111!!!!!!!!\r\n");
-                       gh3018_run_mode = RUN_MODE_INVALID;
-                       GH3018_irq_flag = 0;
-                       continue;
-               }
-               if(gh3018_run_mode != RUN_MODE_INVALID )
-               {
-                       GH3018_test(gh3018_run_mode);
-                       
-                       gh3018_run_mode = RUN_MODE_INVALID;
-               }
-               if(is_gh3018 == 1 && is_open_gh3018 == 1)//处理Hsensor中断数据
-               {
-                       if(GH3018_irq_flag)
-                       {
-                               GH3018_irq_lock = 1;
-                               hal_gh30x_int_handler();
-                               
-                               GH3018_irq_lock = 0;
-                               //GH3018_LOG("GH3018_irq_cb: 1111111111111!!!!!!!!\r\n");
-                               //GH3018_LOG("hal_gh30x_int_handler:test_count1:%d test_count2:%d\r\n",test_count1,test_count2);
-                               GH3018_irq_flag = 0;
-                       }
-                       if(timer_Gsensor_count>(1000/TIMER_TIME_MS))//1秒定时,轮询更新Gsensor数据
-                       {
-                               timer_Gsensor_count = 0;
-                               //Helios_msleep(5);
-                               SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO();
 
-                       }
-               }
-               else
-               {
-                       SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO();
-                       Helios_msleep(1000);
-                       if(GH3018_sleep_flag == 1)
-                       {
-                               GH3018_sleep_flag = 0;
-                               Helios_msleep(3000);
-                       }
-               }
-               Helios_msleep(5);
-       }
-}
 
 void sensor_timerout_cb(void)
 {
@@ -311,8 +265,10 @@ mp_obj_t mp_GH3018_init(mp_obj_t self_in)
                is_gh3018 = 1;
                Helios_ExtInt_Init(self->irq,  &extint_struct1);//初始化中断
                Helios_ExtInt_Enable(self->irq);//打开中断
+               #if CONFIG_SC7A20
                if(Gsensor_init_flag == 0)//初始化Gsensor
                        SC7A20_init();
+               #endif
        }
        
     return mp_obj_new_int(ret);
@@ -502,11 +458,75 @@ const mp_obj_type_t Hsensor_GH3018_type = {
     .locals_dict = (mp_obj_dict_t*)&GH3018_locals_dict,
 };
 
+#endif 
 
+void sensor_thread_entry(void * argv)
+{
+       //GH3018_LOG("sensor_thread_entry: 11111111!!!!!!!!\r\n");
+       
+       #if CONFIG_GH301x
+       while(1)
+       {
+               
+               if(gh3018_run_mode == RUN_MODE_CLOSE)
+               {
+                       gh3018_close();
+                       //GH3018_LOG("GH3018_irq_cb: 1111111111111!!!!!!!!\r\n");
+                       gh3018_run_mode = RUN_MODE_INVALID;
+                       GH3018_irq_flag = 0;
+                       continue;
+               }
+               if(gh3018_run_mode != RUN_MODE_INVALID )
+               {
+                       GH3018_test(gh3018_run_mode);
+                       
+                       gh3018_run_mode = RUN_MODE_INVALID;
+               }
+               if(is_gh3018 == 1 && is_open_gh3018 == 1)//处理Hsensor中断数据
+               {
+                       if(GH3018_irq_flag)
+                       {
+                               GH3018_irq_lock = 1;
+                               hal_gh30x_int_handler();
+                               
+                               GH3018_irq_lock = 0;
+                               //GH3018_LOG("GH3018_irq_cb: 1111111111111!!!!!!!!\r\n");
+                               //GH3018_LOG("hal_gh30x_int_handler:test_count1:%d test_count2:%d\r\n",test_count1,test_count2);
+                               GH3018_irq_flag = 0;
+                       }
+                       if(timer_Gsensor_count>(1000/TIMER_TIME_MS))//1秒定时,轮询更新Gsensor数据
+                       {
+                               timer_Gsensor_count = 0;
+                               //Helios_msleep(5);
+                               #if CONFIG_SC7A20
+                               SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO();
+                               #endif
 
-
-
-
-
-
-#endif /* MICROPY_QPY_ */
\ No newline at end of file
+                       }
+               }
+               else
+               {
+                       #if CONFIG_SC7A20
+                       SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO();
+                       #endif
+                       Helios_msleep(1000);
+                       if(GH3018_sleep_flag == 1)
+                       {
+                               GH3018_sleep_flag = 0;
+                               Helios_msleep(3000);
+                       }
+               }
+               Helios_msleep(5);
+       }
+       #else
+       while(1)
+       {
+               #if CONFIG_SC7A20
+               SL_SC7A20_PEDO_KCAL_WRIST_SLEEP_SWAY_L_ALGO();
+               #endif
+               Helios_msleep(1000);
+               
+       }
+       #endif
+       
+}
index 07d345b..5f669ea 100644 (file)
Binary files a/2.sdk/project/K5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_ALIPAY/images/DBG.7z and b/2.sdk/project/K5/sdk/system/platform/ASR_1606/boards/EG810MCN_GA_ALIPAY/images/DBG.7z differ