--- /dev/null
+#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