1、添加acnt117体温驱动
authorp15692025051 <846603105@qq.com>
Tue, 30 May 2023 01:30:39 +0000 (09:30 +0800)
committerp15692025051 <846603105@qq.com>
Tue, 30 May 2023 01:30:39 +0000 (09:30 +0800)
2.sdk/gui/lv_drivers/CMakeLists.txt
2.sdk/gui/lv_drivers/indev/ACNT117.c [new file with mode: 0644]
2.sdk/gui/lv_drivers/indev/ACNT117.h [new file with mode: 0644]
2.sdk/gui/lv_drivers/indev/bl6xx3_fw_update.h
2.sdk/gui/lv_drivers/indev/gh3018.c
2.sdk/gui/lv_watch/app_adaptor/app_adaptor_sensor_interface.c
2.sdk/gui/lv_watch/app_adaptor/app_sensor_task.h
2.sdk/product/craneg_modem/config/watch/lv_drv_conf.h
2.sdk/product/craneg_modem/lv_gui_main.c
2.sdk/sdk说明.txt

index 2fe8fbc..7f13748 100644 (file)
@@ -78,6 +78,7 @@ set(lv_drivers_sources
   indev/gh3018_source/HRNet_knWeightsSmall.c
   indev/gh3018_source/pv_v2.0.1_sm_spo2wrnet_for_GH3018_masimo_0f423c.c
   indev/ACNT180.c
+  indev/ACNT117.c  
   jpeg/crane_jpuc_common.c
   jpeg/crane_jpuc_dma.c
   jpeg/crane_jpuc_decoder.c
diff --git a/2.sdk/gui/lv_drivers/indev/ACNT117.c b/2.sdk/gui/lv_drivers/indev/ACNT117.c
new file mode 100644 (file)
index 0000000..c80507b
--- /dev/null
@@ -0,0 +1,159 @@
+#include "ACNT117.h"
+#if USE_ACNT117
+#include "../../../product/craneg_modem/framework/inc/gpio_api.h"
+#include "lvgl/hal/hal.h"
+#include "../../lv_watch/app_adaptor/app_sensor_task.h"
+#include "../common/i2c.h"
+static  uint32_t acnt117_mfp_cfgs[] = {
+    MFP_REG(GPIO_16) | MFP_AF0 | MFP_DRIVE_MEDIUM | MFP_PULL_NONE | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,//电源
+    // MFP_REG(GPIO_16) | MFP_AF0 | MFP_DRIVE_MEDIUM | MFP_PULL_NONE | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,//电源
+    // MFP_REG(CLK_REQ) | MFP_AF1 | MFP_DRIVE_MEDIUM | MFP_PULL_NONE | MFP_SLEEP_DIR | MFP_LPM_EDGE_NONE,//数据
+    MFP_EOC
+};
+static void acnt117_gpio_init(void)
+{
+    gpio_set_direction(GPIO16, GPIO_OUT);
+    gpio_set_value(GPIO16, GPIO_LOW);
+}
+static cant117_irq_count = 0;
+static void * acnt117_timer = NULL;
+static float temp = 0.00;
+//static void acnt117_IRQ_callback(void);
+static  void*      acnt117_hisr_ref;
+static void acnt117_timer_callback(uint32_t val)
+{
+    sensor_task_send_message(ACNT117_ID,SENSOR_MSG_PROCESS_DATA);//发送测试命令
+}
+static void acnt117_start(void)
+{
+    //gpio_set_value(GPIO16, GPIO_HIGH);
+    gpio_set_value(GPIO16, GPIO_LOW);
+    //sensor_task_send_message(ACNT117_ID,SENSOR_MSG_PROCESS_DATA);//发送测试命令
+    uos_timer_start(acnt117_timer, MS_TO_TICKS(1000), MS_TO_TICKS(1000), acnt117_timer_callback, NULL);//开启1秒一次定时器
+    
+}
+
+static void acnt117_stop(void)
+{
+    //gpio_set_value(GPIO16, GPIO_LOW);
+    gpio_set_value(GPIO16, GPIO_HIGH);
+    uos_timer_stop(acnt117_timer);
+}
+
+static void acnt117_delay_ms(UINT32 ms)
+{
+       INT32 cnt = 0x29F9;  //uart_log cal as: 1ms
+       volatile INT32 i = 0;
+       
+       for(;ms != 0; ms--){
+               i = cnt;
+               for(;i != 0; i--);
+       }
+}
+#define ACNT117_ADDR 0x49
+static void acnt117_hisr_callback(void)
+{
+    unsigned int gpio_count = 0;
+    int s_data_bit = 0,tmp_data_bit = 0;
+    float temp1 = 0.00;
+    cant117_irq_count = 0; 
+    
+    char write_buffer[2] = {0};
+    write_buffer[0] = 0xA0 ;
+    write_buffer[1] = 0x61;
+    //唤醒
+    if(-1 == i2c_write_regs(I2C_MASTER_CI2C1, ACNT117_ADDR, 0x01,(void *)write_buffer, 2,0))
+    {
+        cplog_printf("acnt117_hisr_callback:write:i2c transmit failed! \r\n");
+    }
+    char read_buffer[2] = {0};
+    // //读数据
+    if(-1 == i2c_read_regs(I2C_MASTER_CI2C1, ACNT117_ADDR, 0x00,(void *)read_buffer, 2,0))
+    {
+        printf("acnt117_hisr_callback:read data:i2c receive failed! \r\n");
+        
+    }
+    //printf("acnt117_hisr_callback:read_buffer:0x%x  0x%x",read_buffer[0],read_buffer[1]);
+    int temp_s = ((read_buffer[0]<<8) | (read_buffer[1]));
+    //printf("acnt117_hisr_callback:temp_s:%d",temp_s);
+    float tmp = 0.00;
+    tmp = temp_s;
+    temp  = (tmp) /256;
+    //printf("acnt117_hisr_callback:temp:%d",(int)(temp*100));
+    //休眠
+    write_buffer[0] = 0xA0 ;
+    write_buffer[1] = 0x60;
+    if(-1 == i2c_write_regs(I2C_MASTER_CI2C1, ACNT117_ADDR, 0x01,(void *)write_buffer, 2,0))
+    {
+        cplog_printf("acnt117_hisr_callback:write:i2c transmit failed! \r\n");
+    }
+
+    // char addr = 0x00;
+    // printf("acnt117_hisr_callback:1");
+    // if(-1 == i2c_write_bytes(I2C_MASTER_CI2C1, ACNT117_ADDR, (void *)&addr, (size_t)(1),0))
+    // {
+    //     printf("read-------->>>i2c transmit failed! \r\n");
+    //     //return ;
+    // }
+    // char read_buffer[2] = {0};
+    // if(-1 == i2c_read_bytes(I2C_MASTER_CI2C1, ACNT117_ADDR, (void *)read_buffer, (size_t)2,0))
+    // {
+    //     printf("read-------->>>i2c receive failed! \r\n");
+    //     //return ;
+    // }
+    // printf("acnt117_hisr_callback:read_buffer:0x%x  0x%x",read_buffer[0],read_buffer[1]);
+}
+
+//测试数据
+
+void hal_acnt117_process_data(uint32_t *process_data)
+{
+    
+    OS_Activate_HISR(&acnt117_hisr_ref);
+
+}
+void acnt117_measure_start(void)
+{
+    sys_pm_wakeup_no_lcd();
+
+    sensor_task_send_message(ACNT117_ID,SENSOR_MSG_START);
+}
+void acnt117_measure_stop(void)
+{
+    watch_set_sleep_lcd_only(false);
+    asl_hr_bp_bo_measure_finish_flag_set();
+    sensor_task_send_message(ACNT117_ID,SENSOR_MSG_STOP);
+}
+float acnt117_get_body_temperature(void)
+{
+       printf("[@CHENG_DEBUG][%s][%d]: %f\n", __FUNCTION__, __LINE__, temp);
+       
+    return  temp;
+}
+// static void acnt117_IRQ_callback(void)
+// {
+//     cant117_irq_count++;
+// }
+/// ACNT117 int pin init, should config as rise edge trigger
+void hal_acnt117_init(void)
+{
+       // code implement by user
+    // must register func hal_gh30x_int_handler as callback
+    mfp_config(acnt117_mfp_cfgs);
+    acnt117_gpio_init();
+
+    sensor_drv_t sensor_drv;
+    sensor_drv.sensor_name = "acnt117";
+    sensor_drv.sensor_start = acnt117_start;
+    sensor_drv.sensor_stop = acnt117_stop;
+    sensor_drv.sensor_process_data = hal_acnt117_process_data;
+    sensor_drv_register(ACNT117_ID,&sensor_drv);
+    uos_timer_create(&acnt117_timer);//创建定时器
+    OS_Create_HISR(&acnt117_hisr_ref,"temp_hisr", acnt117_hisr_callback, HISR_PRIORITY_0);//创建线程
+    // gpio_set_direction(GPIO16, GPIO_OUT);
+    // gpio_set_direction(GPIO123, GPIO_OUT);
+    // gpio_set_value(GPIO16, GPIO_LOW);
+    // gpio_set_value(GPIO123, GPIO_LOW);
+}
+
+#endif
diff --git a/2.sdk/gui/lv_drivers/indev/ACNT117.h b/2.sdk/gui/lv_drivers/indev/ACNT117.h
new file mode 100644 (file)
index 0000000..466fb79
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef _ACNT117_H
+#define _ACNT117_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "lv_drv_conf.h"
+
+#include <stdbool.h>
+
+#if USE_ACNT117
+
+void hal_acnt117_process_data(uint32_t *process_data);
+void hal_acnt117_init(void);
+void acnt117_measure_start(void);
+void acnt117_measure_stop(void);
+float acnt117_get_body_temperature(void);
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif /* USE_ACNT117 */
+
+#endif /* _ACNT117_H */
\ No newline at end of file
index 68e133d..26e3ca1 100644 (file)
@@ -14,6 +14,8 @@
 #include "bl6xx3_fw_h81_st_update.h"
 #elif H81_TP == 3
 #include "bl6xx3_fw_h81_st_JL_update.h"
+#elif H81_TP == 4
+#include "bl6xx3_fw_h81_st_K7_update.h"
 #endif
 #else
 #if 1
index da05618..6fe96a0 100644 (file)
@@ -60,7 +60,7 @@ static void gh3018_en_gpio_enable(bool param)
     } else {
         gpio_set_value(GPIO18, GPIO_LOW);
         gpio_set_value(GPIO81, GPIO_LOW);
-        gpio_set_value(GPIO84, GPIO_LOW);
+        // gpio_set_value(GPIO84, GPIO_LOW);
     }
 }
 
@@ -270,7 +270,7 @@ uint8_t hal_gh30x_i2c_read(uint8_t device_id, const uint8_t write_buffer[], uint
         cplog_printf("read-------->>>i2c receive failed! \r\n");
         return GH30X_EXAMPLE_ERR_VAL;
     }
-
+    printf("hal_gh30x_i2c_read1");
        return ret;
 }
 
index decaef2..eafdeba 100644 (file)
@@ -20,6 +20,8 @@
 #endif
 #if USE_ACNT180
 #include "../../lv_drivers/indev/ACNT180.h"
+#elif USE_ACNT117
+#include "../../lv_drivers/indev/ACNT117.h"
 #endif
 /*********************
  *      DEFINES
@@ -502,6 +504,8 @@ float asl_body_temperature_get(void)
     return ct1711_get_body_temperature();
 #elif USE_ACNT180
     return acnt180_get_body_temperature();
+#elif USE_ACNT117
+    return acnt117_get_body_temperature();
 #else
     return 0;
 #endif
@@ -515,6 +519,8 @@ void asl_temperature_measure_start(void)
        ct1711_measure_start();
 #elif USE_ACNT180
     acnt180_measure_start();
+#elif USE_ACNT117
+    acnt117_measure_start();    
 #endif
 }
 
@@ -526,6 +532,8 @@ void asl_temperature_measure_stop(void)
     ct1711_measure_stop();
 #elif USE_ACNT180
     acnt180_measure_stop();
+#elif USE_ACNT117
+    acnt117_measure_stop();
 #endif
 }
 
index 7c4005a..a20200b 100644 (file)
@@ -37,7 +37,12 @@ enum {
     BD1662_ID,
     VCHR02_ID,
     GH3018_ID,
-    ACNT180_ID
+#if USE_ACNT180
+    ACNT180_ID,
+#endif
+#if USE_ACNT117
+    ACNT117_ID
+#endif
 };
 enum {
     SENSOR_MSG_START = 0,
index 93d816f..0bc247d 100644 (file)
 
 /****************temperature***********/
 #ifndef USE_ACNT180
-#define USE_ACNT180               1
+#define USE_ACNT180               0
 #endif
+#ifndef USE_ACNT117
+#define USE_ACNT117               1
+#endif
+
 /****************temperature***********/
 /* GPS driver */
 #ifndef USE_GPS
index 0cd2fb9..32af309 100644 (file)
@@ -39,6 +39,8 @@
 #endif
 #if USE_ACNT180
 #include "lv_drivers/indev/ACNT180.h"
+#elif USE_ACNT117
+#include "lv_drivers/indev/ACNT117.h"
 #endif
 #if USE_SOS_KEY
 #include "lv_drivers/indev/sos_key.h"
@@ -1265,6 +1267,8 @@ static void gui_main(void *param)
 #endif
 #if USE_ACNT180
     hal_acnt180_init();
+#elif USE_ACNT117
+    hal_acnt117_init();
 #endif
     is_phase1 = 0;
     while(1) {
index f2a0a4b..e85d64a 100644 (file)
@@ -1,7 +1,7 @@
 编译指令
 打开 mingw64.exe,输入SDK路径
 export PS_MODE=LWG
-make craneg_modem_sdk PS_MODE=LWG
+make craneg_modem_sdk PS_MODE=LWG -j8
 make craneg_modem_watch PS_MODE=LWG
 图片资源位置
 E:\共享文件夹\1.asr\3.Z5\2.sdk\gui\lv_watch\resource
@@ -10,6 +10,8 @@ E:\共享文件夹\1.asr\3.Z5\2.sdk\gui\lv_watch\resource\png\primary_function
 主菜单添加APP
 static watch_app_info_t app[]
 
+TP选择:H81_TP
+
 心率UI入口
 lv_obj_t * heart_rate_create(lv_obj_t * activity_obj)
 //心率单独测试