From: penglei <1624952103@qq.com> Date: Fri, 22 Mar 2024 11:21:33 +0000 (+0800) Subject: 血氧心率驱动修改 X-Git-Tag: release_V1.2.70_20241020_135402~1274^2~1 X-Git-Url: http://git.snicker.com.cn/Users/apple/Desktop/static/gitweb.css?a=commitdiff_plain;h=e43959c9829957567f2717449f598f357fc7c7d4;p=mirrors%2FFD230.git 血氧心率驱动修改 --- diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index 2a67dee49..4db8ed6a7 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -5,7 +5,7 @@ #include #include "tyhx_hrs_custom.h" -// #include "tyhx_mems.h" +//#include "tyhx_mems.h" #ifdef CHIP_HX3695 #include "hx3695.h" @@ -25,6 +25,12 @@ #include "hx3695_check_touch.h" #endif #include "hx3695_factory_test.h" +//#include "app_ble_factory_test.h" + +// #include "ui.h" +// #include "app_heart_rate.h" +// #include "lv_dev.h" +// #include "app_task.h" FT_CUSTOM_RESULTS_t hrsresult ={0}; @@ -32,6 +38,7 @@ int16_t gsen_fifo_x[64]={0}; int16_t gsen_fifo_y[64]={0}; int16_t gsen_fifo_z[64]={0}; + #ifdef SPO2_VECTOR #include "spo2_vec.h" uint32_t spo2_send_cnt = 0; @@ -50,7 +57,8 @@ int32_t PPG_buf_vec[8]; #ifdef HRV_TESTVEC #include "hrv_testvec.h" #endif - +// #include "sys_init.h" +// #include "cwm_api.h" int32_t s_buf[256]; uint32_t cnt_num = 0; uint32_t phase3_rdy_num = 0; @@ -59,9 +67,10 @@ uint8_t hrs_phase_num= 3; uint8_t spo2_phase_num= 4; uint8_t hrv_phase_num = 4; extern uint8_t data_count; -// extern uint8_t hr_no_living_dur; -uint8_t hr_no_living_dur; -// extern int tyhx_long_timer_tick; +extern uint8_t hr_no_living_dur; +extern uint8_t spo2_no_living_dur; + +extern int tyhx_long_timer_tick; //spo2 agc const uint8_t hx3695_spo2_agc_red_idac = RED_AGC_OFFSET; const uint8_t hx3695_spo2_agc_ir_idac = IR_AGC_OFFSET; @@ -87,18 +96,19 @@ const uint8_t gsen_lv_val = 0; uint8_t read_fifo_first_flg = 0; //HRS_INFRARED_THRES -const int32_t hrs_ir_unwear_thres = 4000; -const int32_t hrs_ir_wear_thres = 5000; +const int32_t hrs_ir_unwear_thres = 8000; +const int32_t hrs_ir_wear_thres = 10000; //HRV_INFRARED_THRES -const int32_t hrv_ir_unwear_thres = 4000; //demo143b 25000 -const int32_t hrv_ir_wear_thres = 5000; +const int32_t hrv_ir_unwear_thres = 8000; //demo143b 25000 +const int32_t hrv_ir_wear_thres = 10000; //SPO2_INFRARED_THRES -const int32_t spo2_ir_unwear_thres = 4000; //demo143b 25000 30000 -const int32_t spo2_ir_wear_thres = 5000; +const int32_t spo2_ir_unwear_thres = 8000; //demo143b 25000 30000 +const int32_t spo2_ir_wear_thres = 10000; const uint8_t spo2_ir_wear_offset = 15; //CHECK_WEAR_MODE_THRES -const int32_t check_mode_unwear_thre = 20000; -const int32_t check_mode_wear_thre = 30000; +const int32_t check_mode_unwear_thre = 8000; +const int32_t check_mode_wear_thre = 10000; + uint8_t alg_ram[11 * 1024] __attribute__((aligned(4))); //uint8_t alg_ram[10] = {0}; @@ -114,7 +124,7 @@ const uint8_t QUICK_RESULT = 1; //come out the spo2 result qui const uint16_t MEAN_NUM = 32; //the length of smooth-average ;the value of MEAN_NUM can be given only 256 and 512 const uint8_t G_SENSOR = 0; //if =1, open the gsensor mode const uint8_t SPO2_GSEN_POW_THRE = 150; //gsen pow judge move, range:0-200; -const uint32_t SPO2_BASE_LINE_INIT = 135500; //spo2 baseline init, = 103000 + ratio(a variable quantity,depends on different cases)*SPO2_SLOPE +const uint32_t SPO2_BASE_LINE_INIT = 138000; //spo2 baseline init, = 103000 + ratio(a variable quantity,depends on different cases)*SPO2_SLOPE const int32_t SOP2_DEGLITCH_THRE = 100000; //remove signal glitch over this threshold const int32_t SPO2_REMOVE_JUMP_THRE = 50000; //remove signal jump over this threshold const uint32_t SPO2_SLOPE = 50000; //increase this slope, spo2 reduce more @@ -139,8 +149,6 @@ static int32_t ir_jump_delta = 0; static int32_t cali_data_cnt = 0; #endif - - // us 延时函数, 客户需填写 void hx3695_delay_us(uint32_t us) { @@ -171,14 +179,80 @@ uint8_t hx3695_read_reg(uint8_t addr) } // i2c 连读函数, 客户需填写 -bool hx3695_brust_read_reg(uint8_t addr, uint8_t *buf, uint8_t length) +bool hx3695_brust_read_reg(uint8_t addr, uint8_t *buf, uint16_t length) { //TYHX_LOG("brust read\r\n"); tyhx_read_regs(addr,buf,length); return true; } - +void Efuse_Mode_Check(void) +{ +#if 1//def TEST_RELEASE_USE + PRINT("@@@@@@@@@ Efuse_Mode_Check\r\n"); + uint8_t REG_50_E, REG_51_E, REG_52_E, REG_53_E; + + hx3695_write_reg(0x5c, 0x08) ; //0x5c + hx3695_write_reg(0x5d, 0x02) ; //0x5d + hx3695_delay_us(10); + + hx3695_write_reg(0x5a,0x10); //0x5A + + hx3695_write_reg(0x5b,0x04); + hx3695_write_reg(0x5b,0x00); + hx3695_delay_us(10); + hx3695_write_reg(0x5b,0x44); + hx3695_write_reg(0x5b,0x40); + + REG_50_E = hx3695_read_reg(0x50); + REG_51_E = hx3695_read_reg(0x51); + REG_52_E = hx3695_read_reg(0x52); + REG_53_E = hx3695_read_reg(0x53); + + hx3695_write_reg(0x5a,0x20); //0x5A + hx3695_write_reg(0x50,REG_50_E); + hx3695_write_reg(0x51,REG_51_E); + hx3695_write_reg(0x52,REG_52_E); + hx3695_write_reg(0x53,REG_53_E); + + TYHX_LOG("EFUSE MC2: 0x50=0x%2x 0x51= 0x%2x 0x52= 0x%2x 0x53= 0x%2x \r\n",REG_50_E,REG_51_E,REG_52_E,REG_53_E); + + hx3695_write_reg(0x5a,0x00); + hx3695_write_reg(0x5c,0x00); //0x5c + hx3695_write_reg(0x5d,0x00); //0x5d +#endif +} +bool Efuse_judge(void) +{ + uint8_t REG_50, REG_51, REG_52, REG_53,REG_50_A; + + REG_50 = hx3695_read_reg(0x50); //32k + REG_51 = hx3695_read_reg(0x51); + REG_52 = hx3695_read_reg(0x52); + REG_53 = hx3695_read_reg(0x53); //bit<7> efuse trim flg ==1 + +// hx3695_write_reg(0x5d,0x00); +// hx3695_write_reg(0x5a,0x20); +// REG_50_A=REG_50+1; +// hx3695_write_reg(0x50,REG_50_A); // REG_50+1 +// TYHX_LOG("EFUSE 0x50=%x \r\n",REG_50_A); +// hx3695_write_reg(0x50,REG_51); +// hx3695_write_reg(0x50,REG_52); +// hx3695_write_reg(0x50,REG_53); + + TYHX_LOG("EFUSE MC1 :0x50=0x%2x 0x51= 0x%2x 0x52= 0x%2x 0x53= 0x%2x \r\n",REG_50,REG_51,REG_52,REG_53); + if ((REG_50 == 0x40) && (REG_51 ==0x50) && (REG_52 ==0x10) && (REG_53 ==0x22)) + { + Efuse_Mode_Check(); + TYHX_LOG("this chip is before MC \r\n"); + } + else + { + TYHX_LOG("EFUSE MC3 :0x50=0x%2x 0x51= 0x%2x 0x52= 0x%2x 0x53= 0x%2x \r\n",REG_50,REG_51,REG_52,REG_53); + TYHX_LOG("this chip is after MC \r\n"); + } + return true; +} uint32_t hx3695_timers_start(void) { @@ -248,88 +322,25 @@ void hx3695_gpioint_cfg(bool en) } #endif - - -#define RA_MEM_WRDATA_7_0 0x50 -#define RA_MEM_WRDATA_15_8 0x51 -#define RA_MEM_WRDATA_23_16 0x52 -#define RA_MEM_WRDATA_31_24 0x53 -#define RA_MEM_WRDATA_39_32 0x54 -#define RA_MEM_WRDATA_47_40 0x55 -#define RA_MEM_WRDATA_55_48 0x56 -#define RA_MEM_WRDATA_63_56 0x57 -#define RA_MEM_PWE_PULSE_CYCLE7_0 0x58 -#define RA_MEM_PWE_PULSE_CYCLE10_8 0x59 -#define RA_MEM_GLOBAL_CTRL 0x5A -#define RA_MEM_MANNUAL_CTRL 0x5B -#define RA_DEBUG_CFG0 0x5C -#define RA_DEBUG_CFG1 0x5D - -uint8_t REG_50_E, REG_51_E, REG_52_E, REG_53_E; - -void Efuse_Mode_Check(void) -{ - uint8_t efuse0, efuse1, efuse2, efuse3; - - hx3695_write_reg(RA_DEBUG_CFG0, 0x8) ; //0x5c - hx3695_write_reg(RA_DEBUG_CFG1, 0x2) ; //0x5d - hx3695_delay_us(1000); - - hx3695_write_reg(RA_MEM_GLOBAL_CTRL,0x10); //0x5A -// delay_us(2000); - - hx3695_write_reg(RA_MEM_MANNUAL_CTRL,0x04); - hx3695_write_reg(RA_MEM_MANNUAL_CTRL,0x00); - - hx3695_write_reg(RA_MEM_MANNUAL_CTRL,0x44); - hx3695_write_reg(RA_MEM_MANNUAL_CTRL,0x40); - - REG_50_E = hx3695_read_reg(0x50); - REG_51_E = hx3695_read_reg(0x51); - REG_52_E = hx3695_read_reg(0x52); - REG_53_E = hx3695_read_reg(0x53); - -// AGC_LOG("0x50=0x%x\r\n", REG_50_E); -// hal_gpt_delay_ms(100); -// AGC_LOG("0x51=0x%x\r\n", REG_51_E); -// hal_gpt_delay_ms(100); -// AGC_LOG("0x52=0x%x\r\n", REG_52_E); -// hal_gpt_delay_ms(100); -// AGC_LOG("0x53=0x%x\r\n", REG_53_E); -// hal_gpt_delay_ms(100); - - hx3695_write_reg(RA_MEM_GLOBAL_CTRL,0x20); //0x5A - hx3695_write_reg(0x50,REG_50_E); - hx3695_write_reg(0x51,REG_51_E); - hx3695_write_reg(0x52,REG_52_E); - hx3695_write_reg(0x53,REG_53_E); - - - hx3695_write_reg(RA_MEM_GLOBAL_CTRL,0x0); - - hx3695_write_reg(RA_DEBUG_CFG0, 0x0); //0x5c - hx3695_write_reg(RA_DEBUG_CFG1, 0x0); //0x5d - -} bool hx3695_chip_check(void) { uint8_t i = 0; uint8_t chip_id = 0; for(i=0; i<5; i++) { - hx3695_write_reg(0x5c, 0x00); + hx3695_ppg_on(); hx3695_delay_ms(5); chip_id = hx3695_read_reg(0x00); if (chip_id == 0x65) { - TYHX_LOG("hx3695_chip_check ok chip_id: 0x%x \r\n",chip_id); - Efuse_Mode_Check(); + printf("hx3695_chip_check ok chip_id: 0x%x \r\n",chip_id); + //Efuse_Mode_Check(); return true; } } - TYHX_LOG(" hx3695_chip_check fail! chip_id: 0x%x \r\n", chip_id); + printf(" hx3695_chip_check fail! chip_id: 0x%x \r\n", chip_id); return false; } @@ -340,18 +351,17 @@ uint8_t hx3695_get_chip_id(void) uint8_t chip_id = 0; for(i=0; i<5; i++) { - hx3695_write_reg(0x5c, 0x00); - hx3695_delay_ms(5); + hx3695_ppg_on(); chip_id = hx3695_read_reg(0x00); if (chip_id == 0x65) { - TYHX_LOG("hx3695_chip_check ok chip_id: 0x%x \r\n",chip_id); + printf("hx3695_chip_check ok chip_id: 0x%x \r\n",chip_id); return chip_id; } } - TYHX_LOG(" hx3695_chip_check fail! chip_id: 0x%x \r\n", chip_id); + printf(" hx3695_chip_check fail! chip_id: 0x%x \r\n", chip_id); return chip_id; } @@ -370,11 +380,11 @@ uint8_t hx3695_read_fifo_size(void) uint16_t hx3695_read_fifo_data(int32_t *buf, uint8_t phase_num, uint8_t sig) { - uint8_t data_flg_start = 0; - uint8_t data_flg_end = 0; + uint8_t data_flg_start = 0; + uint8_t data_flg_end = 0; // int32_t data; - uint8_t databuf[3]; - uint32_t ii=0; + uint8_t databuf[3]; + uint32_t ii=0; uint16_t data_len_h = 0; uint16_t data_len_l = 0; uint16_t fifo_data_length = 0; @@ -386,13 +396,13 @@ uint16_t hx3695_read_fifo_data(int32_t *buf, uint8_t phase_num, uint8_t sig) data_len_h = hx3695_read_reg(0x21); data_len_l = hx3695_read_reg(0x20); fifo_data_length = (((data_len_h&0x01)<<8)|data_len_l); -// AGC_LOG("fifo_data_length = %d\r\n", fifo_data_length); +// SEGGER_RTT_printf(0,"fifo_data_length = %d\r\n", fifo_data_length); if(fifo_data_length<2*phase_num) { return 0; } fifo_read_length = ((fifo_data_length-phase_num)/phase_num)*phase_num; -// AGC_LOG("fifo_data_length_change = %d\r\n", fifo_read_length); +// SEGGER_RTT_printf(0,"fifo_data_length_change = %d\r\n", fifo_read_length); fifo_read_bytes = fifo_read_length*3; if(read_fifo_first_flg == 1) { @@ -402,7 +412,7 @@ uint16_t hx3695_read_fifo_data(int32_t *buf, uint8_t phase_num, uint8_t sig) hx3695_brust_read_reg(0x22, fifo_data_buf, fifo_read_bytes); // for(ii=0; ii>5); + SEGGER_RTT_printf(0,"fifo_length = %d/%d, %d %d\r\n", ii+1,fifo_read_length,buf[ii],fifo_data_buf[ii*3+2]>>5); } data_flg_start = fifo_data_buf[2]>>5; data_flg_end = fifo_data_buf[fifo_read_bytes-1]>>5; @@ -446,7 +456,7 @@ uint16_t hx3695_read_fifo_data(int32_t *buf, uint8_t phase_num, uint8_t sig) } for(ii=0; ii fifo data sel, 0000 = p1;0001= p2;0010=p3;\ - 0011=p4;0100=p5;0101=p6;0110=p7;\ - bits<7> fifo enble + 0011=p4;0100=p5;0101=p6;0110=p7;\ bits<7> fifo enble hx3695_write_reg(0X33, 0x83); // int width - hx3695_write_reg(0X21, 0x00); // fifo int sel,00=FIFO INT config clear hx3695_write_reg(0X38, 0x01); // int sel,00=close almost full int,04=enable almost full int #elif defined(INT_MODE) //FIFO_ALL_MOST_FULL) hx3695_write_reg(0X1b, 0x92);// bits<3:0> fifo data sel, 0000 = p1;0001= p2;0010=p3;\ @@ -900,13 +896,11 @@ void hx3695_hrs_ppg_init(void) // ppg fs=25hz, phase conversion ready interupt e hx3695_write_reg(0X1c, (fifo_watermark&0xff)); //fifo_watermark hx3695_write_reg(0X1d, fifo_watermark<<8); //bit<0>=fifo_watermark[8] hx3695_write_reg(0X33, 0x83); // int width - hx3695_write_reg(0X21, 0x00); // fifo int sel,00=FIFO INT config clear hx3695_write_reg(0X38, 0x04); // int sel,00=close almost full int,04=enable almost full int #else - hx3695_write_reg(0X1b, 0x92); // bits<3:0> fifo data sel, 0000 = p1;0001= p2;0010=p3; - // 0011=p4;0100=p5;0101=p6;0110=p7; - // bits<7> fifo enble + hx3695_write_reg(0X1b, 0x92); + hx3695_write_reg(0X38, 0x01); // int sel,00=close almost full int,04=enable almost full int #endif @@ -930,9 +924,9 @@ void hx3695_hrs_ppg_init(void) // ppg fs=25hz, phase conversion ready interupt e void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion ready interupt en { uint16_t sample_rate = 25; /*config the data rate of chip alps2_fm ,uint is Hz*/ - uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */ + uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */ -// uint16_t fifo_watermark= 250 ; + uint16_t fifo_watermark= 250 ; uint8_t adc_rst_post_num=0; /* 00=16,01=32,10=64,11=128*/ uint8_t samp_delay_leden_num = 0; /* 00=8,01=16,10=32,11=64*/ uint8_t samp_copy_avg = 0; /* 0=1, 1=2, 2=4 ,3=8, 4=16*/ @@ -974,7 +968,7 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion uint8_t phase1_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase1_led_drv1_cha_sel = 0; /* 1 = ldr1 NG; 2 = ldr2 GR; 4 = ldr3 IR; 8 = ldr4 RED; */ uint8_t phase1_led_drv2_cha_sel = 0; /*ldr5:0x20 ldr6: 0x40 red ldr8 0x80 ir */ - uint8_t phase1_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; 4 = pd3*/ + uint8_t phase1_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; 4 = pd3*/ uint8_t phase1_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase1_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase1_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -994,9 +988,9 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion uint8_t phase2_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/ uint8_t phase2_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/ uint8_t phase2_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ - uint8_t phase2_led_drv1_cha_sel = 0X50; //GREEN_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ + uint8_t phase2_led_drv1_cha_sel = GREEN_LED_SLE; //GREEN_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase2_led_drv2_cha_sel = 0x00; - uint8_t phase2_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; 4 = pd3*/ + uint8_t phase2_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; 4 = pd3*/ uint8_t phase2_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase2_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase2_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1017,7 +1011,7 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion uint8_t phase3_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase3_led_drv1_cha_sel = 0; //RED_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase3_led_drv2_cha_sel = 0; - uint8_t phase3_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; 4 = pd3*/ + uint8_t phase3_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; 4 = pd3*/ uint8_t phase3_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase3_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase3_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1036,9 +1030,9 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion uint8_t phase4_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/ uint8_t phase4_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/ uint8_t phase4_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ - uint8_t phase4_led_drv1_cha_sel = 0x80; //0x20 //IR_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ + uint8_t phase4_led_drv1_cha_sel = RED_LED_SLE; //0x20 //IR_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase4_led_drv2_cha_sel = 0; - uint8_t phase4_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; 4 = pd3*/ + uint8_t phase4_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; 4 = pd3*/ uint8_t phase4_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase4_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase4_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1058,7 +1052,7 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion uint8_t phase5_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase5_led_drv1_cha_sel = 0x00; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase5_led_drv2_cha_sel = 0; - uint8_t phase5_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; */ + uint8_t phase5_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; */ uint8_t phase5_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase5_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase5_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1076,9 +1070,9 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion uint8_t phase6_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/ uint8_t phase6_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/ uint8_t phase6_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ - uint8_t phase6_led_drv1_cha_sel = 0x20; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ + uint8_t phase6_led_drv1_cha_sel = IR_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase6_led_drv2_cha_sel = 0; - uint8_t phase6_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; */ + uint8_t phase6_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; */ uint8_t phase6_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase6_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase6_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1098,7 +1092,7 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion uint8_t phase7_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase7_led_drv1_cha_sel = 0; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase7_led_drv2_cha_sel = 0; - uint8_t phase7_pd_sel = 0x02; /* 1 = pd1; 2 = pd2; */ + uint8_t phase7_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; */ uint8_t phase7_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase7_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase7_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1116,12 +1110,12 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion uint8_t phase8_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/ uint8_t phase8_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/ uint8_t phase8_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ - uint8_t phase8_led_drv1_cha_sel = 0x20; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ + uint8_t phase8_led_drv1_cha_sel = IR_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase8_led_drv2_cha_sel = 0; - uint8_t phase8_pd_sel = 0x02; /* 1 = pd1; 2 = pd2; */ + uint8_t phase8_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; */ uint8_t phase8_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase8_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ - uint8_t phase8_ldr1_cur = 20; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ + uint8_t phase8_ldr1_cur = 32; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ uint8_t phase8_ldr2_cur = 0; // uint8_t phase8_of_idac1_cur = 0; // uint8_t phase8_of_idac2_cur = 0; @@ -1312,15 +1306,13 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion hx3695_write_reg(0X6c, 0X00); hx3695_write_reg(0X6d, 0X37); hx3695_write_reg(0X6e, 0X82); - hx3695_write_reg(0X6f, 0X08); + hx3695_write_reg(0X6f, 0X00); /////////FIFO and adc conversion ready config//////// /////////FIFO and adc conversion ready config//////// #if defined(PPG_INT_MODE) hx3695_write_reg(0X1b, 0x92);// bits<3:0> fifo data sel, 0000 = p1;0001= p2;0010=p3;\ - 0011=p4;0100=p5;0101=p6;0110=p7;\ - bits<7> fifo enble + 0011=p4;0100=p5;0101=p6;0110=p7;\ bits<7> fifo enble hx3695_write_reg(0X33, 0x83); // int width - hx3695_write_reg(0X21, 0x00); // fifo int sel,00=FIFO INT config clear hx3695_write_reg(0X38, 0x08); // int sel,00=close almost full int,04=enable almost full int #elif defined(INT_MODE) //(FIFO_ALL_MOST_FULL) hx3695_write_reg(0X1b, 0x92);// bits<3:0> fifo data sel, 0000 = p1;0001= p2;0010=p3;\ @@ -1332,9 +1324,7 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion hx3695_write_reg(0X38, 0x04); // int sel,00=close almost full int,04=enable almost full int #else - hx3695_write_reg(0X1b, 0x91);// bits<3:0> fifo data sel, 0000 = p1;0001= p2;0010=p3; - // 0011=p4;0100=p5;0101=p6;0110=p7; - // bits<7> fifo enble + hx3695_write_reg(0X1b, 0x91); hx3695_write_reg(0X36, 0x00); hx3695_write_reg(0X38, 0x00); // int sel,00=close almost full int,01= prf int 04=enable almost full int @@ -1363,15 +1353,15 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion void hx3695_hrv_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion ready interupt en { uint16_t sample_rate = 125; /*config the data rate of chip alps2_fm ,uint is Hz*/ - uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */ + uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */ -; uint8_t adc_rst_post_num=0; /* 00=16,01=32,10=64,11=128*/ uint8_t samp_delay_leden_num = 0; /* 00=8,01=16,10=32,11=64*/ uint8_t samp_copy_avg = 0; /* 0=1, 1=2, 2=4 ,3=8, 4=16*/ uint8_t data_avg_num = 0; /* 0 = 1 ; 1 = 2; 2 =4 ; 3 =8 ; 4 =16 ;*/ uint8_t phase7_8_internal = 0; /* phase7 and phase8 prf internal cfg */ + uint16_t fifo_watermark= 164 ; uint8_t phase1_enable = 1; /*phase1_enable , 1 mean enable ; 0 mean disable */ uint8_t phase2_enable = 1; /*phase2_enable , 1 mean enable ; 0 mean disable */ uint8_t phase3_enable = 1; /*phase3_enable , 1 mean enable ; 0 mean disable */ @@ -1743,7 +1733,7 @@ void hx3695_hrv_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion r hx3695_write_reg(0X6c, 0X00); hx3695_write_reg(0X6d, 0X37); hx3695_write_reg(0X6e, 0X82); - hx3695_write_reg(0X6f, 0X08); + hx3695_write_reg(0X6f, 0X00); /////////FIFO and adc conversion ready config//////// /////////FIFO and adc conversion ready config//////// #if defined(PPG_INT_MODE) @@ -1751,7 +1741,6 @@ void hx3695_hrv_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion r 0011=p4;0100=p5;0101=p6;0110=p7;\ bits<7> fifo enble hx3695_write_reg(0X33, 0x83); // int width - hx3695_write_reg(0X21, 0x00); // fifo int sel,00=FIFO INT config clear hx3695_write_reg(0X38, 0x08); // int sel,00=close almost full int,04=enable almost full int #elif defined(INT_MODE) //(FIFO_ALL_MOST_FULL) hx3695_write_reg(0X1b, 0x90);// bits<3:0> fifo data sel, 0000 = p1;0001= p2;0010=p3;\ @@ -1763,9 +1752,9 @@ void hx3695_hrv_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion r hx3695_write_reg(0X38, 0x04); // int sel,00=close almost full int,04=enable almost full int #else - hx3695_write_reg(0X1b, 0x90);// bits<3:0> fifo data sel, 0000 = p1;0001= p2;0010=p3; - // 0011=p4;0100=p5;0101=p6;0110=p7; - // bits<7> fifo enble + hx3695_write_reg(0X1b, 0x90);// bits<3:0> fifo data sel, 0000 = p1;0001= p2;0010=p3;\ + 0011=p4;0100=p5;0101=p6;0110=p7;\ + bits<7> fifo enble hx3695_write_reg(0X36, 0x00); hx3695_write_reg(0X38, 0x00); // int sel,00=close almost full int,01= prf int 04=enable almost full int @@ -1791,10 +1780,10 @@ void hx3695_hrv_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion r #ifdef CHECK_TOUCH_LIB void hx3695_check_touch_init(void) // { - uint16_t sample_rate = 25; /*config the data rate of chip alps2_fm ,uint is Hz*/ - uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */ + uint16_t sample_rate = 5; /*config the data rate of chip alps2_fm ,uint is Hz*/ + uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */ -// uint16_t fifo_watermark= 250 ; + uint16_t fifo_watermark= 250 ; uint8_t adc_rst_post_num= 0; /* 00=16,01=32,10=64,11=128*/ uint8_t samp_delay_leden_num = 0; /* 00=8,01=16,10=32,11=64*/ uint8_t samp_copy_avg = 0; /* 0=1, 1=2, 2=4 ,3=8, 4=16*/ @@ -1836,7 +1825,7 @@ void hx3695_check_touch_init(void) // uint8_t phase1_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase1_led_drv1_cha_sel = 0; /* 1 = ldr1 NG; 2 = ldr2 GR; 4 = ldr3 IR; 8 = ldr4 RED; */ uint8_t phase1_led_drv2_cha_sel = 0; /*ldr5:0x20 ldr6: 0x40 red ldr8 0x80 ir */ - uint8_t phase1_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; 4 = pd3*/ + uint8_t phase1_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; 4 = pd3*/ uint8_t phase1_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase1_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase1_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1858,7 +1847,7 @@ void hx3695_check_touch_init(void) // uint8_t phase2_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase2_led_drv1_cha_sel = 0; //GREEN_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase2_led_drv2_cha_sel = 0; - uint8_t phase2_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; 4 = pd3*/ + uint8_t phase2_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; 4 = pd3*/ uint8_t phase2_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase2_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase2_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1879,7 +1868,7 @@ void hx3695_check_touch_init(void) // uint8_t phase3_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase3_led_drv1_cha_sel = 0; //RED_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase3_led_drv2_cha_sel = 0; - uint8_t phase3_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; 4 = pd3*/ + uint8_t phase3_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; 4 = pd3*/ uint8_t phase3_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase3_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase3_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1900,7 +1889,7 @@ void hx3695_check_touch_init(void) // uint8_t phase4_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase4_led_drv1_cha_sel = 0; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase4_led_drv2_cha_sel = 0; - uint8_t phase4_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; 4 = pd3*/ + uint8_t phase4_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; 4 = pd3*/ uint8_t phase4_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase4_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase4_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1920,7 +1909,7 @@ void hx3695_check_touch_init(void) // uint8_t phase5_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase5_led_drv1_cha_sel = 0; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase5_led_drv2_cha_sel = 0; - uint8_t phase5_pd_sel = 4; /* 1 = pd1; 2 = pd2; */ + uint8_t phase5_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; */ uint8_t phase5_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase5_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase5_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1937,7 +1926,7 @@ void hx3695_check_touch_init(void) // uint8_t phase6_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/ uint8_t phase6_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/ - uint8_t phase6_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ + uint8_t phase6_tia_cap = SPO2_PD; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase6_led_drv1_cha_sel = 0; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase6_led_drv2_cha_sel = 0; uint8_t phase6_pd_sel = 4; /* 1 = pd1; 2 = pd2; */ @@ -1960,7 +1949,7 @@ void hx3695_check_touch_init(void) // uint8_t phase7_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ uint8_t phase7_led_drv1_cha_sel = 0; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase7_led_drv2_cha_sel = 0; - uint8_t phase7_pd_sel = 0x00; /* 1 = pd1; 2 = pd2; */ + uint8_t phase7_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; */ uint8_t phase7_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase7_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ uint8_t phase7_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ @@ -1978,12 +1967,12 @@ void hx3695_check_touch_init(void) // uint8_t phase8_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/ uint8_t phase8_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/ uint8_t phase8_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */ - uint8_t phase8_led_drv1_cha_sel = 0x20;//0x40; //IR_LED_SLE /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ + uint8_t phase8_led_drv1_cha_sel = IR_LED_SLE;//0x40; //IR_LED_SLE /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */ uint8_t phase8_led_drv2_cha_sel = 0; - uint8_t phase8_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; */ + uint8_t phase8_pd_sel = SPO2_PD; /* 1 = pd1; 2 = pd2; */ uint8_t phase8_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */ uint8_t phase8_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */ - uint8_t phase8_ldr1_cur = 20; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ + uint8_t phase8_ldr1_cur = 32; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ uint8_t phase8_ldr2_cur = 0; // uint8_t phase8_of_idac1_cur = 0; // uint8_t phase8_of_idac2_cur = 0; @@ -2174,7 +2163,7 @@ void hx3695_check_touch_init(void) // hx3695_write_reg(0X6c, 0X00); hx3695_write_reg(0X6d, 0X37); hx3695_write_reg(0X6e, 0X82); - hx3695_write_reg(0X6f, 0X08); + hx3695_write_reg(0X6f, 0X00); /////////FIFO and adc conversion ready config//////// /////////FIFO and adc conversion ready config//////// #if defined(PPG_INT_MODE) @@ -2182,8 +2171,7 @@ void hx3695_check_touch_init(void) // 0011=p4;0100=p5;0101=p6;0110=p7;\ bits<7> fifo enble hx3695_write_reg(0X33, 0x83); // int width - hx3695_write_reg(0X21, 0x00); // fifo int sel,00=FIFO INT config clear - hx3695_write_reg(0X38, 0x08); // int sel,00=close almost full int,04=enable almost full int + hx3695_write_reg(0X38, 0x01); // int sel,00=close almost full int,04=enable almost full int #elif defined(INT_MODE) //(FIFO_ALL_MOST_FULL) hx3695_write_reg(0X1b, 0x92);// bits<3:0> fifo data sel, 0000 = p1;0001= p2;0010=p3;\ 0011=p4;0100=p5;0101=p6;0110=p7;\ @@ -2194,10 +2182,9 @@ void hx3695_check_touch_init(void) // hx3695_write_reg(0X38, 0x04); // int sel,00=close almost full int,04=enable almost full int #else - hx3695_write_reg(0X1b, 0x92);// bits<3:0> fifo data sel, 0000 = p1;0001= p2;0010=p3; - // 0011=p4;0100=p5;0101=p6;0110=p7; - // bits<7> fifo enble - hx3695_write_reg(0X36, 0x00); //intrupt + hx3695_write_reg(0X1b, 0x92); + + hx3695_write_reg(0X36, 0x00); hx3695_write_reg(0X38, 0x00); // int sel,00=close almost full int,01= prf int 04=enable almost full int @@ -2223,8 +2210,13 @@ void hx3695_check_touch_init(void) // bool hx3695_init(WORK_MODE_T mode) { hx3695_msg_callback_t func; - TYHX_LOG(" hx3695_init mode : %d \n", mode); + + TYHX_LOG("this chip hx3695_init mode: %d !! \r\n", mode); + hx3695_ppg_on(); + + Efuse_judge(); //MC前后芯片判断 + // Efuse_Mode_Check(); work_mode_flag = mode; hx3695_data_reset(); hx3695_vin_check(3800); @@ -2233,9 +2225,7 @@ bool hx3695_init(WORK_MODE_T mode) case HRS_MODE: TYHX_LOG(" hx3695_init mode : HRS_MODE \n"); #ifdef HRS_ALG_LIB - tyhx_hrs_set_alg_para(NORMAL_MODE, 150, 1); - - tyhx_hrs_set_living(1, 15, 30); + tyhx_hrs_set_living(1, 10, 30); if(hx3695_hrs_enable()== SENSOR_OP_FAILED) { return false; @@ -2262,7 +2252,7 @@ bool hx3695_init(WORK_MODE_T mode) tyhx_spo2_para_barelychange(MEAN_NUM,SOP2_DEGLITCH_THRE,SPO2_REMOVE_JUMP_THRE, \ SPO2_LOW_CLIP_END_TIME,SPO2_LOW_CLIP_DN,SPO2_NORMAL_CLIP_DN, \ IR_AC_TOUCH_THRE,IR_FFT_POW_THRE,SPO2_CALI,SLOPE_PARA_MAX,SLOPE_PARA_MIN); - tyhx_spo2_set_living(1, 15, 30); + tyhx_spo2_set_living(1, 7, 20); if(hx3695_spo2_enable()== SENSOR_OP_FAILED) { return false; @@ -2315,9 +2305,6 @@ bool hx3695_init(WORK_MODE_T mode) func(HX3695_MSG_TYPE_LEAKLIGHT_UPDATE,&hrsresult,sizeof(FT_CUSTOM_RESULTS_t)); } break; - return true; - - break; case FT_GRAY_CARD_MODE: if (!hx3695_chip_check()) @@ -2340,17 +2327,24 @@ bool hx3695_init(WORK_MODE_T mode) break; case FT_SINGLE_CHECK_MODE: + if (!hx3695_chip_check()) + { + AGC_LOG("hx3695 check id failed!\r\n"); + return false; + } hx3695_factroy_test(SINGLE_CHECK_TEST); break; case FT_LED_OFF_MODE: hx3695_factroy_test(LED_OFF_TEST); break; - + case FT_WEAR_MODE: hx3695_factroy_test(WEAR_MODE_TEST); break; - + // case NEW_PPG_TEST_MODE: + // hx3695_factroy_test(NEW_PPG_TEST); + // break; case LAB_TEST_MODE: #ifdef LAB_TEST if(hx3695_lab_test_enable()== SENSOR_OP_FAILED) @@ -2368,6 +2362,7 @@ bool hx3695_init(WORK_MODE_T mode) void hx3695_agc_Int_handle(void) { + TYHX_LOG(" hx3695_init mode : HRS_MODE \n"); switch (work_mode_flag) { case HRS_MODE: @@ -2418,48 +2413,130 @@ void agc_timeout_handler(void * p_context) #endif } +static uint32_t ft_ppg_green = 0; +static uint32_t ft_ppg_iir = 0; void hx3695_factory_test_process(uint8_t data[], uint8_t mode, uint8_t* ppg_src) { extern bool factory_test_flag; - extern bool factory_test_aging; extern bool factory_test_sensor_on; - if(factory_test_flag == false || factory_test_aging != false) return; + extern bool factory_test_aging; + + if(factory_test_flag == false) return; if(factory_test_sensor_on == true ) return; static uint8_t ppg_data[15] = {0}; + uint32_t test = 0; +// uint32_t green = 0; +// uint32_t red = 0; +// uint32_t iir = 0; - if(ppg_src == NULL) + if(data != NULL && ppg_src == NULL) { memcpy(ppg_data, data, 3); return; } - - // switch(mode) - // { - // case APP_FACTORY_TEST_HR_START: - // memcpy((void *)&ppg_data[3], ppg_src, 4); - // factory_test_send_data(ppg_data, 7); - // break; - // case APP_FACTORY_TEST_SPO2_START: - // memcpy((void *)&ppg_data[3], ppg_src, 4); - // factory_test_send_data(ppg_data, 7); - // break; - // case APP_FACTORY_TEST_LEAKING_START: - // memcpy((void *)&ppg_data[3], ppg_src, 12); - // factory_test_send_data(ppg_data, 15); - // break; - // case APP_FACTORY_TEST_GRAY_CARD: - // memcpy((void *)&ppg_data[3], ppg_src, 12); - // factory_test_send_data(ppg_data, 15); - // break; - // default: - // break; - // } +// switch(mode) +// { +// case APP_FACTORY_TEST_HR_START: +// ppg_data[3] = *(ppg_src + 3); +// ppg_data[4] = *(ppg_src + 2); +// ppg_data[5] = *(ppg_src + 1); +// ppg_data[6] = *(ppg_src + 0); + +// ppg_data[7] = *(ppg_src + 7); +// ppg_data[8] = *(ppg_src + 6); +// ppg_data[9] = *(ppg_src + 5); +// ppg_data[10] = *(ppg_src + 4); + +// ppg_data[11] = *(ppg_src + 11); +// ppg_data[12] = *(ppg_src + 10); +// ppg_data[13] = *(ppg_src + 9); +// ppg_data[14] = *(ppg_src + 8); + +// factory_test_send_data(ppg_data, 15); +// break; +// case APP_FACTORY_TEST_SPO2_START: +// ppg_data[3] = *(ppg_src + 3); +// ppg_data[4] = *(ppg_src + 2); +// ppg_data[5] = *(ppg_src + 1); +// ppg_data[6] = *(ppg_src + 0); + +// ppg_data[7] = *(ppg_src + 7); +// ppg_data[8] = *(ppg_src + 6); +// ppg_data[9] = *(ppg_src + 5); +// ppg_data[10] = *(ppg_src + 4); + +// ppg_data[11] = *(ppg_src + 11); +// ppg_data[12] = *(ppg_src + 10); +// ppg_data[13] = *(ppg_src + 9); +// ppg_data[14] = *(ppg_src + 8); + +// factory_test_send_data(ppg_data, 15); +// break; +// case APP_FACTORY_TEST_LEAKING_START: +// // memcpy((void *)&ppg_data[3], ppg_src, 12); + +// ppg_data[3] = *(ppg_src + 3); +// ppg_data[4] = *(ppg_src + 2); +// ppg_data[5] = *(ppg_src + 1); +// ppg_data[6] = *(ppg_src + 0); + +// ppg_data[7] = *(ppg_src + 7); +// ppg_data[8] = *(ppg_src + 6); +// ppg_data[9] = *(ppg_src + 5); +// ppg_data[10] = *(ppg_src + 4); + +// ppg_data[11] = *(ppg_src + 11); +// ppg_data[12] = *(ppg_src + 10); +// ppg_data[13] = *(ppg_src + 9); +// ppg_data[14] = *(ppg_src + 8); + + +// gui_send_message_by_data(MSG_FACTORY_TEST_UPDATE_HR, ppg_src, 12); +// if(factory_test_aging) break; +// factory_test_send_data(ppg_data, 15); +// break; +// case APP_FACTORY_TEST_GRAY_CARD: +// { +// // memcpy((void *)&ppg_data[3], ppg_src, 12); +// ppg_data[3] = *(ppg_src + 3); +// ppg_data[4] = *(ppg_src + 2); +// ppg_data[5] = *(ppg_src + 1); +// ppg_data[6] = *(ppg_src + 0); + +// ppg_data[7] = *(ppg_src + 7); +// ppg_data[8] = *(ppg_src + 6); +// ppg_data[9] = *(ppg_src + 5); +// ppg_data[10] = *(ppg_src + 4); + +// ppg_data[11] = *(ppg_src + 11); +// ppg_data[12] = *(ppg_src + 10); +// ppg_data[13] = *(ppg_src + 9); +// ppg_data[14] = *(ppg_src + 8); + +// gui_send_message_by_data(MSG_FACTORY_TEST_UPDATE_HR, ppg_src, 12); +// if(factory_test_aging) break; +// factory_test_send_data(ppg_data, 15); +// } +// break; +// default: +// break; +// } } + +typedef struct { + int32_t gr_data_final; + int32_t red_data_final; + int32_t ir_data_final; +} ft_test_result_t; + + void heart_rate_meas_timeout_handler(void * p_context) { + TYHX_LOG(" heart_rate_meas_timeout_handler mode: %d \n", work_mode_flag); + switch(work_mode_flag) { case HRS_MODE: @@ -2481,6 +2558,7 @@ void heart_rate_meas_timeout_handler(void * p_context) break; case WEAR_MODE: +// PRINT("@@@@@@@@@ WEAR_MODE $$$$$$$$$\r\n"); #ifdef CHECK_TOUCH_LIB hx3695_wear_ppg_Int_handle(); #endif @@ -2498,8 +2576,11 @@ void heart_rate_meas_timeout_handler(void * p_context) #endif case FT_LEAK_LIGHT_MODE: + { hx3695_factroy_test(LEAK_LIGHT_TEST); break; + } + break; case FT_GRAY_CARD_MODE: { @@ -2563,17 +2644,7 @@ void hx3695_ppg_Int_handle(void) /*TYHX 心率模式下 读取PPG, 默认320ms*/ hrs_sensor_data_t hrs_s_dat; //hx3695_results_t alg_results_pre; -/*** - * typedef struct { - hrs_alg_msg_code_t hrs_alg_status; - living_msg_code_t living_status; - uint32_t data_cnt; - uint8_t hr_result; - uint16_t cal_result; - uint8_t hr_result_qual; - uint32_t hr_result_std; -} hrs_results_t; -*/ + void hx3695_hrs_ppg_Int_handle(void) { uint8_t ii=0; @@ -2587,8 +2658,8 @@ void hx3695_hrs_ppg_Int_handle(void) int16_t gsen_fifo_y_send[32]= {0}; int16_t gsen_fifo_z_send[32]= {0}; - HRS_CAL_SET_T cal; - cal = get_hrs_agc_status(); + HRS_CAL_SET_T cal; + cal = get_hrs_agc_status(); #ifdef HR_VECTOR for(ii=0; ii<8; ii++) @@ -2603,75 +2674,134 @@ void hx3695_hrs_ppg_Int_handle(void) tyhx_hrs_alg_send_data(PPG_buf_vec,*count, gsen_fifo_x_send, gsen_fifo_y_send, gsen_fifo_z_send); #else + if(hx3695_hrs_read(&hrs_s_dat) == 0) { - AGC_LOG("hx3695_hrs_read(&hrs_s_dat) == 0\r\n"); return; } #ifndef GSEN_40MS_TIMMER - readFifoByHrsModule(); + //readFifoByHrsModule(); #endif // DEBUG_PRINTF("\r\nsend jlink cnt=%d\r\n",*count); - - for(ii=0; ii<*count; ii++) - { - gsen_fifo_x_send[ii] = gsen_fifo_x[32-*count+ii]; - gsen_fifo_y_send[ii] = gsen_fifo_y[32-*count+ii]; - gsen_fifo_z_send[ii] = gsen_fifo_z[32-*count+ii]; - -// DEBUG_PRINTF("gr,ir,gsen:%d/%d %d %d %d %d %d %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x[ii],gsen_fifo_y[ii],gsen_fifo_z[ii],ppg_s_data.green_cur); - } +/* gsensor 屏蔽 */ +// for(ii=0; ii<*count; ii++) +// { +// #if 0 +// gsen_fifo_x_send[ii] = gsen_fifo_x[32-*count+ii]; +// gsen_fifo_y_send[ii] = gsen_fifo_y[32-*count+ii]; +// gsen_fifo_z_send[ii] = gsen_fifo_z[32-*count+ii]; + +// PRINT("hx3695 gr,ir,gsen:%d/%d %d %d %d %d %d %d\r\n" , +// 1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x[ii],gsen_fifo_y[ii],gsen_fifo_z[ii],cal.Group1_Cur); +// #else +// accel_data_struct_t accel_raw_data = {0}; +// queue_output(&accel_raw_data); +// gsen_fifo_x_send[ii] = accel_raw_data.x; +// gsen_fifo_y_send[ii] = accel_raw_data.y; +// gsen_fifo_z_send[ii] = accel_raw_data.z; +// // PRINT("hx3695 gr,ir,gsen:%d/%d %d %d %d %d %d %d\r\n" , +// // 1+ii,*count,PPG_buf[ii], ir_buf[0], gsen_fifo_x_send[ii], gsen_fifo_y_send[ii], gsen_fifo_z_send[ii], cal.Group1_Cur); +// printf("FFF==> hr PPG_buf : %d, %d, PPG_buf: %d, ir_buf: %d \n", 1+ii, *count, PPG_buf[ii], ir_buf[0]); + +// #endif +// } +// ft_ppg_green = hrs_s_dat.green_data[0]; + // ft_test_result_t result = {0}; + // result.gr_data_final = hrs_s_dat.green_data[0]; + // result.ir_data_final = hrs_s_dat.ir_data[0]; + // hx3695_factory_test_process(NULL, APP_FACTORY_TEST_HR_START, &result); hrs_wear_status = hx3695_hrs_get_wear_status(); - AGC_LOG("hrs_wear_status: %d !!\r\n", hrs_wear_status); + PRINT("hrs_wear_status: %d !!\r\n", hrs_wear_status); + if(hrs_wear_status == MSG_HRS_WEAR) { - tyhx_hrs_alg_send_data(PPG_buf, *count, gsen_fifo_x_send, gsen_fifo_y_send, gsen_fifo_z_send, cal.Group1_Ledidac); + tyhx_hrs_alg_send_data(PPG_buf, *count, gsen_fifo_x_send, gsen_fifo_y_send, + gsen_fifo_z_send, cal.Group1_Ledidac); } #endif - alg_results = tyhx_hrs_alg_get_results(); - hrsresult.lastesthrs = alg_results.hr_result; - hrsresult.hr_living = alg_results.living_status; - hrsresult.hr_living_qu = alg_results.hr_result_qual; - hrsresult.hr_living_std = alg_results.hr_result_std; + +/*屏蔽*/ +// for(ii=0; ii<*count; ii++) +// { +// #if 0 +// gsen_fifo_x_send[ii] = gsen_fifo_x[32-*count+ii]; +// gsen_fifo_y_send[ii] = gsen_fifo_y[32-*count+ii]; +// gsen_fifo_z_send[ii] = gsen_fifo_z[32-*count+ii]; + +// PRINT("hx3695 gr,ir,gsen:%d/%d %d %d %d %d %d %d\r\n" , +// 1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x[ii],gsen_fifo_y[ii],gsen_fifo_z[ii],cal.Group1_Cur); +// #else +// // accel_data_struct_t accel_raw_data = {0}; +// // queue_output(&accel_raw_data); +// // gsen_fifo_x_send[ii] = accel_raw_data.x; +// // gsen_fifo_y_send[ii] = accel_raw_data.y; +// // gsen_fifo_z_send[ii] = accel_raw_data.z; +// // PRINT("hx3695 gr,ir,gsen:%d/%d %d %d %d %d %d %d hr==%d\r\n" , +// // 1+ii,*count,PPG_buf[ii], ir_buf[0], gsen_fifo_x_send[ii], gsen_fifo_y_send[ii], gsen_fifo_z_send[ii], cal.Group1_Cur,alg_results.hr_result); +// #endif +// } + + uint8_t curr_wear = 1; + //uint8_t last_wear = cwm_get_wear_status(); + + alg_results = tyhx_hrs_alg_get_results(); + hrsresult.lastesthrs = alg_results.hr_result; + hrsresult.hr_living = alg_results.living_status; + hrsresult.hr_living_qu = alg_results.hr_result_qual; + hrsresult.hr_living_std = alg_results.hr_result_std; - AGC_LOG("hx3695 data_cnt: %d, hr_living: %d, hr_living_qu: %d, hr_living_std: %d, hr_result:%d \r\n", - alg_results.data_cnt, hrsresult.hr_living, hrsresult.hr_living_qu, hrsresult.hr_living_std, hrsresult.lastesthrs); + PRINT("hx3695 data_cnt: %d, hr_living: %d, hr_living_qu: %d, hr_living_std: %d, hr_result:%d \r\n", + alg_results.data_cnt, hrsresult.hr_living, hrsresult.hr_living_qu, hrsresult.hr_living_std, hrsresult.lastesthrs); if(hrs_wear_status == MSG_HRS_WEAR && hrsresult.hr_living == MSG_LIVING_TRUE) { // app_hr_reset_stop_timer(); if(alg_results.hr_result) { - // app_hr_cal_hr_values(alg_results.hr_result); - // AGC_LOG("app_hr_cal_hr_values tick:%d hr:%d", xTaskGetTickCount(), alg_results.hr_result); - AGC_LOG("app_hr_cal_hr_values hr:%d", alg_results.hr_result); + //app_hr_cal_hr_values(alg_results.hr_result); + //PRINT("app_hr_cal_hr_values tick:%d hr:%d", xTaskGetTickCount(), alg_results.hr_result); + //cwm_hr_input(alg_results.hr_result); //hr_sensor_notify_factory_test(); } hr_no_living_dur = 0; + curr_wear = 1; } else if(hrs_wear_status == MSG_HRS_WEAR && hrsresult.hr_living != MSG_LIVING_TRUE) { - // if (++hr_no_living_dur > 12 * 1000 / tyhx_long_timer_tick) + if (++hr_no_living_dur > 12 * 1000 / tyhx_long_timer_tick) { - // hr_stop_detect(); - // AGC_LOG("tyhx_hrs_module_start(WEAR_MODE) wear:%d liv:%d", hrs_wear_status, hrsresult.hr_living); - // hr_no_living_dur = 0; + //hr_stop_detect(); + PRINT("MSG_HRS_WEAR:%d liv:%d", hrs_wear_status, hrsresult.hr_living); + hr_no_living_dur = 0; + curr_wear = 0; } } else if(hrs_wear_status == MSG_HRS_NO_WEAR || hrsresult.hr_living == MSG_LIVING_FAIL) { - // hr_stop_detect(); - AGC_LOG("tyhx_hrs_module_start(WEAR_MODE) wear:%d liv:%d", hrs_wear_status, hrsresult.hr_living); + //hr_stop_detect(); + PRINT("MSG_HRS_NO_WEAR:%d liv:%d", hrs_wear_status, hrsresult.hr_living); hr_no_living_dur = 0; + curr_wear = 0; + } + + //cwm_off_body_detect(curr_wear); + + #if defined(GSENSOR_LOG_NOTIFY) && GSENSOR_LOG_NOTIFY == 1 || defined(HRS_BLE_APP) + + if (last_wear!=curr_wear) + { + gui_send_message_by_data(MSG_HR_WEAR_STATUS_UPDATE, &curr_wear, 1); } + #endif + #ifdef BP_CUSTDOWN_ALG_LIB bp_results_t bp_alg_results; bp_alg_results = tyhx_alg_get_bp_results(); #endif - + ////////////////////////////////////////BLE+DISPLAY///////////////////////////////// @@ -2690,7 +2820,7 @@ void hx3695_hrs_ppg_Int_handle(void) rawdata.gsensor_z = gsen_fifo_z_send[ii]; rawdata.red_cur = cal.Group1_Cur; rawdata.ir_cur = cal.Group1_Ledidac; - +// PRINT("@@@@@@@@@ HRS_BLE_APP gsen:%d %d %d\r\n", rawdata.gsensor_x, rawdata.gsensor_y, rawdata.gsensor_z); ble_rawdata_vector_push(rawdata); } } @@ -2728,7 +2858,7 @@ void hx3695_living_Int_handle(void) } #ifndef GSEN_40MS_TIMMER - readFifoByHrsModule(); +// readFifoByHrsModule(); #endif DEBUG_PRINTF("\r\nsend jlink cnt=%d\r\n",*count); @@ -2904,28 +3034,6 @@ int32_t hx3695_ir_data_cali(int32_t ir_new_raw_data) //#ifdef SPO2_ALG_LIB spo2_sensor_data_t spo2_s_dat; -/**** - * -typedef struct { - spo2_alg_msg_code_t spo2_alg_status; - spo2_living_code_t spo2_living_status; - uint32_t data_cnt; - uint8_t spo2_result; - uint8_t hr_result; - uint8_t block_cnt; - uint8_t ir_quality; - uint16_t reliable_score_result; - - uint8_t screen_up; - uint8_t motion; - uint8_t poor_signal; - - uint8_t signal_snr; - uint32_t signal_std; - -} spo2_results_t; - -*/ /*TYHX 血氧模式下 读取PPG, 默认320ms*/ void hx3695_spo2_ppg_Int_handle(void) { @@ -2963,28 +3071,85 @@ void hx3695_spo2_ppg_Int_handle(void) #ifndef GSEN_40MS_TIMMER - readFifoByHrsModule(); +// readFifoByHrsModule(); #endif DEBUG_PRINTF("\r\n send1 jlink cnt=%d\r\n",*count); + + /*屏蔽*/ +// for(ii=0; ii<*count; ii++) +// { +// gsen_fifo_x_send[ii] = gsen_fifo_x[32-*count+ii]; +// gsen_fifo_y_send[ii] = gsen_fifo_y[32-*count+ii]; +// gsen_fifo_z_send[ii] = gsen_fifo_z[32-*count+ii]; +// // PRINT("hx3695 data: %d/%d %d %d %d %d %d %d\r\n" , +// // 1+ii,*count,red_buf[ii],ir_buf[ii],green_buf[ii],gsen_fifo_x[ii],gsen_fifo_y[ii],gsen_fifo_z[ii]); +// // printf("FFF==>spo2 red_buf : %d, %d, %d, %d \n", 1+ii, *count, red_buf[ii], ir_buf[0]); - for(ii=0; ii<*count; ii++) - { - gsen_fifo_x_send[ii] = gsen_fifo_x[32-*count+ii]; - gsen_fifo_y_send[ii] = gsen_fifo_y[32-*count+ii]; - gsen_fifo_z_send[ii] = gsen_fifo_z[32-*count+ii]; - //DEBUG_PRINTF("%d/%d %d %d %d %d %d %d\r\n" ,1+ii,*count,red_buf[ii],ir_buf[ii],green_buf[ii],gsen_fifo_x[ii],gsen_fifo_y[ii],gsen_fifo_z[ii]); - // hx3695_factory_test_process(NULL, APP_FACTORY_TEST_SPO2_START, (uint8_t *)&red_buf[ii]); - } - AGC_LOG("hx3695 current value: %d %d %d %d %d %d\r\n", cal.R_LED, cal.IR_LED1, cal.G_LED, cal.R_LEDDAC, cal.IR_LEDDAC1, cal.G_LEDDAC); +// } + +// ft_ppg_iir = spo2_s_dat.red_data[0]; +// hx3695_factory_test_process(NULL, APP_FACTORY_TEST_SPO2_START, &ft_ppg_iir); + + ft_test_result_t result = {0}; + result.gr_data_final = spo2_s_dat.green_data[0]; + result.red_data_final = spo2_s_dat.red_data[0]; + result.ir_data_final = spo2_s_dat.ir_data1[0]; + //hx3695_factory_test_process(NULL, APP_FACTORY_TEST_SPO2_START, &result); + + + PRINT("hx3695 current value: %d %d %d %d %d %d\r\n", cal.R_LED, cal.IR_LED1, cal.G_LED, cal.R_LEDDAC, cal.IR_LEDDAC1, cal.G_LEDDAC); spo2_wear_status = hx3695_spo2_get_wear_status(); + PRINT("spo2_wear_status : %d\r\n",spo2_wear_status); if(spo2_wear_status == MSG_SPO2_WEAR) { - tyhx_spo2_alg_send_data(red_buf, ir_buf, green_buf, cal.R_LEDDAC, cal.IR_LEDDAC1, cal.G_LEDDAC, gsen_fifo_x_send, gsen_fifo_y_send, gsen_fifo_z_send, *count); + tyhx_spo2_alg_send_data(red_buf, ir_buf, green_buf, cal.R_LEDDAC, cal.IR_LEDDAC1, cal.G_LEDDAC, + gsen_fifo_x_send, gsen_fifo_y_send, gsen_fifo_z_send, *count); } #endif spo2_alg_results = tyhx_spo2_alg_get_results(); +//------------------------adjust------------------- +// DEBUG_PRINTF("block_cnt: %d, data_cnt:%d, hr_result:%d,ir_quality:%d,motion:%d,poor_signal:%d,reliable_score_result:%d,screen_up:%d,spo2_result:%d\r\n",spo2_alg_results.block_cnt,spo2_alg_results.data_cnt,spo2_alg_results.hr_result,spo2_alg_results.ir_quality,spo2_alg_results.motion,spo2_alg_results.poor_signal,spo2_alg_results.reliable_score_result,spo2_alg_results.screen_up,spo2_alg_results.spo2_result); + + hrsresult.lastestspo2 = spo2_alg_results.spo2_result; + hrsresult.lastesthrs = spo2_alg_results.hr_result; + uint8_t curr_wear = 1; + //uint8_t last_wear = cwm_get_wear_status(); + if(spo2_wear_status == MSG_SPO2_WEAR && spo2_alg_results.spo2_living_status == MSG_SPO2_LIVING_TRUE) + { + //store_latest_spo2(hrsresult.lastestspo2); + //app_hr_cal_hr_values(hrsresult.lastesthrs); + //cwm_hr_input(hrsresult.lastesthrs); + spo2_no_living_dur = 0; + curr_wear = 1; + } + else if(spo2_wear_status == MSG_SPO2_WEAR && spo2_alg_results.spo2_living_status != MSG_SPO2_LIVING_TRUE) + { + if (++spo2_no_living_dur > 12 * 1000 / tyhx_long_timer_tick) + { + //gui_send_msg_by_evt(MSG_SPO2_MEASURE_CANCEL); + PRINT("MSG_SPO2_WEAR:%d liv:%d", spo2_wear_status, spo2_alg_results.spo2_living_status); + spo2_no_living_dur = 0; + curr_wear = 0; + } + } + else if(spo2_wear_status == MSG_SPO2_NO_WEAR || spo2_alg_results.spo2_living_status == MSG_SPO2_LIVING_FAIL) + { + //gui_send_msg_by_evt(MSG_SPO2_MEASURE_CANCEL); + PRINT("MSG_SPO2_NO_WEAR:%d liv:%d", spo2_wear_status, spo2_alg_results.spo2_living_status); + spo2_no_living_dur = 0; + curr_wear = 0; + } + //cwm_off_body_detect(curr_wear); + #if defined(GSENSOR_LOG_NOTIFY) && GSENSOR_LOG_NOTIFY == 1 || defined(HRS_BLE_APP) + if (last_wear!=curr_wear) + { + gui_send_message_by_data(MSG_HR_WEAR_STATUS_UPDATE, &curr_wear, 1); + } + #endif +/////////////////////////////////////////BLE+DISPLAY////////////////////////////////////////// + spo2_alg_results = tyhx_spo2_alg_get_results(); //------------------------adjust------------------- DEBUG_PRINTF("block_cnt: %d, data_cnt:%d, hr_result:%d,ir_quality:%d,motion:%d,poor_signal:%d,reliable_score_result:%d,screen_up:%d,spo2_result:%d\r\n",spo2_alg_results.block_cnt,spo2_alg_results.data_cnt,spo2_alg_results.hr_result,spo2_alg_results.ir_quality,spo2_alg_results.motion,spo2_alg_results.poor_signal,spo2_alg_results.reliable_score_result,spo2_alg_results.screen_up,spo2_alg_results.spo2_result); @@ -3005,7 +3170,6 @@ void hx3695_spo2_ppg_Int_handle(void) } -/////////////////////////////////////////BLE+DISPLAY////////////////////////////////////////// #ifdef HRS_BLE_APP @@ -3024,7 +3188,7 @@ void hx3695_spo2_ppg_Int_handle(void) rawdata.ir_raw_data = ir_buf[ii]; #endif rawdata.vector_flag = SPO2_VECTOR_FLAG; - rawdata.data_cnt = cal.G_LEDDAC; + rawdata.data_cnt = cal.G_LED; rawdata.hr_result = spo2_alg_results.spo2_result; rawdata.gsensor_x = (int16_t)(green_buf[ii]>>5); rawdata.gsensor_y = cal.R_LEDDAC; @@ -3070,18 +3234,18 @@ void hx3695_hrspo2_ppg_Int_handle(void) } #ifndef GSEN_40MS_TIMMER - readFifoByHrsModule(); +//readFifoByHrsModule(); #endif DEBUG_PRINTF("\r\nsend jlink cnt=%d\r\n",*count); - for(ii=0; ii<*count; ii++) - { - gsen_fifo_x_send[ii] = gsen_fifo_x[32-*count+ii]; - gsen_fifo_y_send[ii] = gsen_fifo_y[32-*count+ii]; - gsen_fifo_z_send[ii] = gsen_fifo_z[32-*count+ii]; + // for(ii=0; ii<*count; ii++) + // { + // gsen_fifo_x_send[ii] = gsen_fifo_x[32-*count+ii]; + // gsen_fifo_y_send[ii] = gsen_fifo_y[32-*count+ii]; + // gsen_fifo_z_send[ii] = gsen_fifo_z[32-*count+ii]; - } + // } spo2_wear_status = hx3695_spo2_get_wear_status(); if(spo2_wear_status == MSG_SPO2_WEAR) { @@ -3158,7 +3322,7 @@ void hx3695_hrv_ppg_Int_handle(void) } #ifndef GSEN_40MS_TIMMER - readFifoByHrsModule(); +// readFifoByHrsModule(); #endif DEBUG_PRINTF("\r\nsend jlink cnt=%d\r\n",*count); @@ -3216,27 +3380,23 @@ void hx3695_hrv_ppg_Int_handle(void) #ifdef CHECK_TOUCH_LIB void hx3695_wear_ppg_Int_handle(void) { +// PRINT("hx3695_wear_ppg_Int_handle wearstatus = %d\r\n", hrsresult.wearstatus); + uint8_t *count = &(ppg_s_data.count); int32_t *ir_buf = &(ppg_s_data.ir_data[0]); hx3695_wear_msg_code_t hx3695_wear_status; hx3695_check_touch_read(&ppg_s_data); + hx3695_wear_status = hx3695_check_touch_send_data(ir_buf,*count); hrsresult.wearstatus = hx3695_wear_status; + extern uint8_t notouch_cnt; extern uint8_t touch_cnt; + +// PRINT("===> touch_cnt: %d, notouch_cnt: %d, wear status: %d, \r\n", touch_cnt, notouch_cnt, hx3695_wear_status); - if (hrsresult.wearstatus) - { - cwm_gsensor_enable(); - } - else - { - cwm_gsensor_disable(); - } -// AGC_LOG("===> touch_cnt: %d, notouch_cnt: %d, wear status: %d, \r\n", touch_cnt, notouch_cnt, hx3695_wear_status); - -// AGC_LOG("hx3695_wear_ppg_Int_handle wearstatus = %d\r\n", hrsresult.wearstatus); +// PRINT("hx3695_wear_ppg_Int_handle wearstatus = %d\r\n", hrsresult.wearstatus); // for(int i=0;i<*count;i++) // { diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h index 7e911092b..b35d7a256 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h @@ -24,17 +24,17 @@ NEW_GSEN_SCHME DEMO调试使用, 客户关闭 */ #define HRS_ALG_LIB #define SPO2_ALG_LIB -// #define HRV_ALG_LIB -// #define CHECK_TOUCH_LIB +//#define HRV_ALG_LIB +#define CHECK_TOUCH_LIB //#define CHECK_LIVING_LIB -#define BP_CUSTDOWN_ALG_LIB +//#define BP_CUSTDOWN_ALG_LIB //**************** read_data_mode ******************// #define TIMMER_MODE //timmer read fifo //#define INT_MODE //fifo_all_most_full //****************** gsen_cgf *********************// -// #define GSEN_40MS_TIMMER +//#define GSEN_40MS_TIMMER //#define NEW_GSEN_SCHME //****************** other_cgf ********************// @@ -53,27 +53,23 @@ NEW_GSEN_SCHME DEMO调试使用, 客户关闭 //****************** print_swi ********************// #define HRS_DEBUG -#define AGC_DEBUG +//#define AGC_DEBUG //**************************************************// -#include "debug_print.h" +#define PREFIX_PRINTF(_message,...) //printf(_message,##__VA_ARGS__) + +#define SEGGER_RTT_printf(_message, ...) //printf(_message,##__VA_ARGS__) #ifdef AGC_DEBUG -#define AGC_LOG(fmt, ...) \ - do { \ - PRINT(fmt" ", ##__VA_ARGS__); \ - } while (0) +#define AGC_LOG(...) SEGGER_RTT_printf(0,__VA_ARGS__) #else -#define AGC_LOG(...) +#define AGC_LOG(...) PREFIX_PRINTF("hx3695 agc=>"__VA_ARGS__) #endif #ifdef HRS_DEBUG -#define DEBUG_PRINTF(fmt, ...) \ - do { \ - PRINT(fmt" ", ##__VA_ARGS__); \ - } while (0) +#define DEBUG_PRINTF(...) SEGGER_RTT_printf(0,__VA_ARGS__) #else -#define DEBUG_PRINTF(...) +#define DEBUG_PRINTF(...) PREFIX_PRINTF("hx3695 debug=>"__VA_ARGS__) #endif @@ -83,18 +79,18 @@ NEW_GSEN_SCHME DEMO调试使用, 客户关闭 #define LIS3DH_IIC_CLK 18 #define LIS3DH_IIC_SDA 16 #define EXT_INT_PIN 1 - #define GREEN_LED_SLE 0x10 - #define RED_LED_SLE 0x20 - #define IR_LED_SLE 0x40 + #define GREEN_LED_SLE 0x50 //demo 0x10 evb 2 + #define RED_LED_SLE 0x80 //demo 0x20 evb 4 + #define IR_LED_SLE 0x20 //demo 0x40 evb 1 #define RED_AGC_OFFSET 64 //32 #define IR_AGC_OFFSET 64 //32 - #define GREEN_AGC_OFFSET 4 //10 - #define HR_GREEN_AGC_OFFSET 20 - #define HR_GREEN1_AGC_OFFSET 24 - #define HR_GREEN2_AGC_OFFSET 24 - #define HR_GREEN3_AGC_OFFSET 24 - - + #define GREEN_AGC_OFFSET 20 //10 + #define HR_GREEN_AGC_OFFSET 48 + #define HR_GREEN1_AGC_OFFSET 48 + #define HR_GREEN2_AGC_OFFSET 48 + #define HR_GREEN3_AGC_OFFSET 48 + #define HRS_PD 0x0F // PD1:1 PD2:2 PD3:4 PD4:8 + #define SPO2_PD 0x02 // PD1:1 PD2:2 PD3:4 PD4:8 #define BIG_SCREEN @@ -173,20 +169,21 @@ typedef enum { } SENSOR_TYPE_T; typedef enum { - HRS_MODE, - SPO2_MODE, - HRSPO2_MODE, - WEAR_MODE, - HRV_MODE, - LIVING_MODE, - LAB_TEST_MODE, - FT_LEAK_LIGHT_MODE, - FT_GRAY_CARD_MODE, - FT_INT_TEST_MODE, + HRS_MODE, // 0 + SPO2_MODE, // 1 + HRSPO2_MODE, // 2 + WEAR_MODE, //3 + HRV_MODE, // 4 + LIVING_MODE, // 5 + LAB_TEST_MODE, // 6 + FT_LEAK_LIGHT_MODE, // 7 + FT_GRAY_CARD_MODE, // 8 + FT_INT_TEST_MODE, // 9 FT_SINGLE_CHECK_MODE, - FT_LED_OFF_MODE, - FT_WEAR_MODE, - NULL_MODE, + FT_LED_OFF_MODE, + FT_WEAR_MODE, + NEW_PPG_TEST_MODE, + NULL_MODE, } WORK_MODE_T; @@ -247,7 +244,7 @@ void hx3695_delay_us(uint32_t us); void hx3695_delay_ms(uint32_t ms); bool hx3695_write_reg(uint8_t addr, uint8_t data); uint8_t hx3695_read_reg(uint8_t addr); -bool hx3695_brust_read_reg(uint8_t addr , uint8_t *buf, uint8_t length); +bool hx3695_brust_read_reg(uint8_t addr , uint8_t *buf, uint16_t length); bool hx3695_chip_check(void); uint8_t hx3695_read_fifo_size(void); uint16_t hx3695_read_fifo_data(int32_t *s_buf, uint8_t size, uint8_t phase_num); @@ -271,6 +268,7 @@ void hx3695_hrv_ppg_Int_handle(void); void hx3695_living_Int_handle(void); void hx3695_hrspo2_ppg_Int_handle(void); + void hx3695_ppg_Int_handle(void); uint32_t hx3695_timers_start(void); uint32_t hx3695_timers_stop(void); @@ -280,9 +278,9 @@ uint32_t hx3695_gpioint_enable(void); uint32_t hx3695_gpioint_disable(void); uint32_t gsen_read_timers_start(void); uint32_t gsen_read_timers_stop(void); - +bool Efuse_judge(void); void hx3695_vin_check(uint16_t led_vin); - +void nrf_gpioint_handle(void); #ifdef LAB_TEST void hx3695_lab_test_init(void); void hx3695_test_alg_cfg(void); @@ -295,7 +293,9 @@ bool hx3695_living_send_data(int32_t *new_raw_data, uint8_t dat_len, int16_t *gs hx3695_living_results_t hx3695_living_get_results(void); void agc_timeout_handler(void * p_context); void heart_rate_meas_timeout_handler(void * p_context); +void Efuse_Mode_Check(void); #include "hx3695_hal.h" + #endif diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c index 5fa347d14..98b7a7a84 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c @@ -10,6 +10,8 @@ #include "hx3695.h" #include "hx3695_hrs_agc.h" #include "tyhx_hrs_alg.h" +//#include "lv_dev.h" + #ifdef HRS_ALG_LIB extern const uint8_t hx3695_hrs_agc_idac; @@ -113,8 +115,7 @@ hrs_wear_msg_code_t hx3695_hrs_wear_mode_check(WORK_MODE_T mode, int32_t infrare hrs_wear_status = MSG_HRS_NO_WEAR; } } -// AGC_LOG("hrs ir_data: %d, hrs_wear_status_pre=%d, hrs_wear_status=%d\r\n", - // infrared_data,hrs_wear_status_pre,hrs_wear_status); + if(mode == WEAR_MODE) { return hrs_wear_status; @@ -240,8 +241,8 @@ void PPG_hrs_Calibration_Routine(HRS_CAL_SET_T *calR, int32_t g1_led,int32_t g2_ // } // } - calR->Group1_RF = 5; - calR->Group2_RF = 5; + calR->Group1_RF = 3; + calR->Group2_RF = 3; // calR->Group3_RF = 6; calR->flag = CAL_FLG_LED_DR|CAL_FLG_LED_DAC|CAL_FLG_AMB_DAC|CAL_FLG_RF; @@ -438,7 +439,7 @@ HRS_CAL_SET_T PPG_hrs_agc(void) void hx3695_hrs_cal_init(void) { uint16_t sample_rate = 200; //200 /*config the data rate of chip alps2_fm ,uint is Hz*/ - uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */ + uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */ uint8_t data_avg_num = 0; hx3695_write_reg(0X2a, (uint8_t)prf_clk_num); // prf bit<7:0> hx3695_write_reg(0X2b, (uint8_t)(prf_clk_num>>8)); // prf bit<15:8> @@ -465,7 +466,7 @@ void hx3695_hrs_cal_init(void) void hx3695_hrs_cal_off(void) { uint16_t sample_rate = 25; /*config the data rate of chip alps2_fm ,uint is Hz*/ - uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */ + uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */ uint8_t data_avg_num = 0; hx3695_write_reg(0X2a, (uint8_t)prf_clk_num); // prf bit<7:0> hx3695_write_reg(0X2b, (uint8_t)(prf_clk_num>>8)); // prf bit<15:8> @@ -489,7 +490,7 @@ void hx3695_hrs_cal_off(void) hx3695_write_reg(0x5c,0x08); //Chip state machine work normal hx3695_delay_ms(5); read_fifo_first_flg = 1; -// AGC_LOG("caloff_fifo: %d\r\n", (fifo_data_temp[0]|(fifo_data_temp[1]<<8)|(fifo_data_temp[2]<<16))); +// SEGGER_RTT_printf(0,"caloff_fifo: %d\r\n", (fifo_data_temp[0]|(fifo_data_temp[1]<<8)|(fifo_data_temp[2]<<16))); } void read_hrs_data_packet(int32_t *s_buf) @@ -514,7 +515,7 @@ void read_hrs_data_packet(int32_t *s_buf) s_buf[6] = ((databuf4[0])|(databuf4[1]<<8)|(databuf4[2]<<16)); s_buf[7] = ((databuf4[3])|(databuf4[4]<<8)|(databuf4[5]<<16)); -// AGC_LOG("phase7_data: %d, phase8_data: %d\r\n", s_buf[6],s_buf[7]); +// SEGGER_RTT_printf(0,"phase7_data: %d, phase8_data: %d\r\n", s_buf[6],s_buf[7]); } @@ -551,15 +552,15 @@ void hx3695_hrs_read_data_packet(int32_t *buf) // TYHX_LOG("tyhx_here ! \r\n"); -// AGC_LOG("P1~P4: %x, %x %x, %x \r\n", P1,P2,P3,P4); +// SEGGER_RTT_printf(0,"P1~P4: %x, %x %x, %x \r\n", P1,P2,P3,P4); } void hx3695_hrs_low_power(void) { - uint16_t sample_rate = 25; /*config the data rate of chip alps2_fm ,uint is Hz*/ + uint16_t sample_rate = 5; /*config the data rate of chip alps2_fm ,uint is Hz*/ uint8_t data_avg_num = 0; /* 0 = 1 ; 1 = 2; 2 =4 ; 3 =8 ; 4 =16 ;*/ - uint32_t prf_clk_num = 32000/sample_rate; /*period in clk num, num = Fclk/fs */ + uint32_t prf_clk_num = 32000/sample_rate*24/25; /*period in clk num, num = Fclk/fs */ uint8_t phase2_offset_idac = 0; /* 0~127 = 0 ~ 32ua , step = 0.25ua */ uint8_t phase5_offset_idac = 0; /* 0~127 = 0 ~ 32ua , step = 0.25ua */ @@ -592,7 +593,7 @@ void hx3695_hrs_low_power(void) uint8_t phase7_mux_sel = 6; uint8_t phase8_mux_sel = 7; - uint8_t phase8_ldr_cur = 25; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ + uint8_t phase8_ldr_cur = 32; /* 0~255 = 0 ~ 200ma, step = 0.8ma */ uint8_t led_on_time = 1; /* 0 = 32clk=8us ; 1 = 64clk=16us; 2=128clk=32us ; 3 = 256clk=64us ; 4 = 512clk=128us ; 5 = 1024clk=256us; 6= 2048clk=512us; 7 = 4096clk=1024us */ @@ -914,8 +915,8 @@ uint8_t hx3695_hrs_read(hrs_sensor_data_t * s_dat) } // TYHX_LOG("ppg_state: %d ,hrs_cal_state: %d\r\n",s_ppg_state,hrs_cal_state); data_count = hx3695_read_fifo_data(s_buf,hrs_phase_num,1); - //AGC_LOG("ppg data size: %d %d\r\n", data_count,hrs_phase_num); -// AGC_LOG("af_hx3695_read_fifo_data:::%d %d %d\r\n", hx3695_read_reg(0X2a),hx3695_read_reg(0X2b),hx3695_read_reg(0X2c)); + //SEGGER_RTT_printf(0,"ppg data size: %d %d\r\n", data_count,hrs_phase_num); +// SEGGER_RTT_printf(0,"af_hx3695_read_fifo_data:::%d %d %d\r\n", hx3695_read_reg(0X2a),hx3695_read_reg(0X2b),hx3695_read_reg(0X2c)); s_dat->count = data_count; read_hrs_data_packet(ps_data); @@ -928,15 +929,14 @@ uint8_t hx3695_hrs_read(hrs_sensor_data_t * s_dat) // Ir_src_data = s_buf[i*4+3]; PPG_buf[i] = PPG_src_data * 2; - ir_buf[i] = PPG_src_data2 * 2; //Ir_src_data; -// AGC_LOG("PPG_data: %d , PPG_src_data2: %d\r\n", PPG_src_data,PPG_src_data2); + ir_buf[i] = Ir_src_data; //Ir_src_data; +// SEGGER_RTT_printf(0,"PPG_data: %d , PPG_src_data2: %d\r\n", PPG_src_data,PPG_src_data2); + //my_printf("hx3695 Ir_src_data %d \r\n", Ir_src_data); hx3695_hrs_wear_mode_check(HRS_MODE,Ir_src_data); -// AGC_LOG("hx3690_hrs_wear_mode_check:::%d %d %d\r\n", hx3695_read_reg(0X2a),hx3695_read_reg(0X2b),hx3695_read_reg(0X2c)); - // AGC_LOG("fifo:%d/%d %d %d, fifo_data: %d %d %d %d\r\n" ,1+i,data_count, - // PPG_buf[i],ir_buf[i],s_buf[i*3],s_buf[i*3+1],s_buf[i*3+2],calReg_Hrs.LED); + } ps_green_data = ps_data[1]; // - ((ps_data[2]+ps_data[0])>>1); -// AGC_LOG("ps_green_data: %d PS8: %d, PS7: %d\r\n", ps_green_data,ps_data[7],ps_data[6]); +// SEGGER_RTT_printf(0,"ps_green_data: %d PS8: %d, PS7: %d\r\n", ps_green_data,ps_data[7],ps_data[6]); if (ps_green_data<300000 || ps_green_data>800000) { recal = true; diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.h b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.h index 46bff12d1..8f6374469 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.h @@ -22,7 +22,7 @@ typedef struct { uint8_t count; int32_t green_data[64]; int32_t ir_data[64]; - int32_t s_buf[64]; + int32_t s_buf[192]; uint32_t als; uint32_t agc_green; } hrs_sensor_data_t; @@ -50,7 +50,7 @@ typedef struct { typedef enum { hrsCalStart, - hrsCalStart1, + hrsCalStart1, hrsCalLed, hrsCalLed2, hrsCalLed3, @@ -65,18 +65,18 @@ typedef struct { uint8_t int_cnt; uint8_t cur255_cnt; uint8_t Group1_Ledidac; //led_idac - uint8_t Group2_Ledidac; - uint8_t Group3_Ledidac; + uint8_t Group2_Ledidac; + uint8_t Group3_Ledidac; uint16_t Group1_Cur; //LED; uint16_t Group2_Cur; //LED; uint16_t Group3_Cur; //LED; // uint8_t LEDDAC; uint8_t Group1_AMBDAC; - uint8_t Group2_AMBDAC; - uint8_t Group3_AMBDAC; + uint8_t Group2_AMBDAC; + uint8_t Group3_AMBDAC; uint8_t Group1_RF; - uint8_t Group2_RF; - uint8_t Group3_RF; + uint8_t Group2_RF; + uint8_t Group3_RF; uint32_t Group1_step; uint32_t Group2_step; uint32_t Group3_step; diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c index 37e867d66..cdb44e6bc 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c @@ -17,6 +17,15 @@ #include "soc_osal.h" #include "tcxo.h" +// bool b_hrs_work = false; //心率模块是否已经开始工作 +// WORK_MODE_T currmode = NULL_MODE;//心率模块的工作模式; +// tyhx_hrsresult_t hrsresult;//心率的测试结果 + +uint8_t hr_no_living_dur = 0; //used to increase no living dur, when no living status detected +uint8_t spo2_no_living_dur = 0; //used to increase no living dur, when no living status detected +int tyhx_long_timer_tick = 400; + + typedef struct { i2c_bus_t i2c_id; uint32_t i2c_speed; diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_spo2_agc.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_spo2_agc.c index fa030eeea..9a230be3f 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_spo2_agc.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_spo2_agc.c @@ -11,6 +11,7 @@ #include "tyhx_hrs_custom.h" +//#include "lv_dev.h" @@ -1047,7 +1048,7 @@ uint8_t hx3695_spo2_read(spo2_sensor_data_t * s_dat) //AGC_LOG("s_ppg_state: %d,s_cal_state: %d\r\n",s_ppg_state,s_cal_state); if (!s_ppg_state || s_cal_state) { - return 0; + return NULL; } data_count = hx3695_read_fifo_data(s_buf,spo2_phase_num,1); @@ -1055,7 +1056,7 @@ uint8_t hx3695_spo2_read(spo2_sensor_data_t * s_dat) hx3695_spo2_read_data( agc_buf ); Ir_wear_value = agc_buf[7]- agc_buf[6]; - TYHX_LOG("Ir_wear_value: %d \r\n",Ir_wear_value); + //my_printf("hx3695 Ir_wear_value: %d \r\n",Ir_wear_value); for (i=0; i