uint8_t spo2_phase_num= 4;\r
uint8_t hrv_phase_num = 4;\r
extern uint8_t data_count;\r
-\r
+// extern uint8_t hr_no_living_dur;\r
+uint8_t hr_no_living_dur;\r
+// extern int tyhx_long_timer_tick; \r
//spo2 agc\r
const uint8_t hx3695_spo2_agc_red_idac = RED_AGC_OFFSET;\r
const uint8_t hx3695_spo2_agc_ir_idac = IR_AGC_OFFSET;\r
uint8_t read_fifo_first_flg = 0;\r
\r
//HRS_INFRARED_THRES\r
-const int32_t hrs_ir_unwear_thres = 20000;\r
-const int32_t hrs_ir_wear_thres = 10000;\r
+const int32_t hrs_ir_unwear_thres = 4000;\r
+const int32_t hrs_ir_wear_thres = 5000;\r
//HRV_INFRARED_THRES\r
-const int32_t hrv_ir_unwear_thres = 10000; //demo143b 25000\r
-const int32_t hrv_ir_wear_thres = 20000;\r
+const int32_t hrv_ir_unwear_thres = 4000; //demo143b 25000\r
+const int32_t hrv_ir_wear_thres = 5000;\r
//SPO2_INFRARED_THRES\r
-const int32_t spo2_ir_unwear_thres = 8000; //demo143b 25000 30000\r
-const int32_t spo2_ir_wear_thres = 10000;\r
+const int32_t spo2_ir_unwear_thres = 4000; //demo143b 25000 30000\r
+const int32_t spo2_ir_wear_thres = 5000;\r
const uint8_t spo2_ir_wear_offset = 15;\r
//CHECK_WEAR_MODE_THRES\r
const int32_t check_mode_unwear_thre = 20000;\r
}\r
#endif\r
\r
+\r
+\r
+#define RA_MEM_WRDATA_7_0 0x50\r
+#define RA_MEM_WRDATA_15_8 0x51\r
+#define RA_MEM_WRDATA_23_16 0x52\r
+#define RA_MEM_WRDATA_31_24 0x53\r
+#define RA_MEM_WRDATA_39_32 0x54\r
+#define RA_MEM_WRDATA_47_40 0x55\r
+#define RA_MEM_WRDATA_55_48 0x56\r
+#define RA_MEM_WRDATA_63_56 0x57\r
+#define RA_MEM_PWE_PULSE_CYCLE7_0 0x58\r
+#define RA_MEM_PWE_PULSE_CYCLE10_8 0x59\r
+#define RA_MEM_GLOBAL_CTRL 0x5A\r
+#define RA_MEM_MANNUAL_CTRL 0x5B\r
+#define RA_DEBUG_CFG0 0x5C\r
+#define RA_DEBUG_CFG1 0x5D\r
+\r
+uint8_t REG_50_E, REG_51_E, REG_52_E, REG_53_E;\r
+\r
+void Efuse_Mode_Check(void)\r
+{\r
+ uint8_t efuse0, efuse1, efuse2, efuse3;\r
+ \r
+ hx3695_write_reg(RA_DEBUG_CFG0, 0x8) ; //0x5c\r
+ hx3695_write_reg(RA_DEBUG_CFG1, 0x2) ; //0x5d\r
+ hx3695_delay_us(1000);\r
+ \r
+ hx3695_write_reg(RA_MEM_GLOBAL_CTRL,0x10); //0x5A\r
+// delay_us(2000);\r
+ \r
+ hx3695_write_reg(RA_MEM_MANNUAL_CTRL,0x04);\r
+ hx3695_write_reg(RA_MEM_MANNUAL_CTRL,0x00);\r
+ \r
+ hx3695_write_reg(RA_MEM_MANNUAL_CTRL,0x44);\r
+ hx3695_write_reg(RA_MEM_MANNUAL_CTRL,0x40);\r
+ \r
+ REG_50_E = hx3695_read_reg(0x50);\r
+ REG_51_E = hx3695_read_reg(0x51);\r
+ REG_52_E = hx3695_read_reg(0x52);\r
+ REG_53_E = hx3695_read_reg(0x53);\r
+\r
+// AGC_LOG("0x50=0x%x\r\n", REG_50_E);\r
+// hal_gpt_delay_ms(100);\r
+// AGC_LOG("0x51=0x%x\r\n", REG_51_E);\r
+// hal_gpt_delay_ms(100);\r
+// AGC_LOG("0x52=0x%x\r\n", REG_52_E);\r
+// hal_gpt_delay_ms(100);\r
+// AGC_LOG("0x53=0x%x\r\n", REG_53_E);\r
+// hal_gpt_delay_ms(100);\r
+ \r
+ hx3695_write_reg(RA_MEM_GLOBAL_CTRL,0x20); //0x5A\r
+ hx3695_write_reg(0x50,REG_50_E);\r
+ hx3695_write_reg(0x51,REG_51_E);\r
+ hx3695_write_reg(0x52,REG_52_E);\r
+ hx3695_write_reg(0x53,REG_53_E);\r
+\r
+ \r
+ hx3695_write_reg(RA_MEM_GLOBAL_CTRL,0x0);\r
+ \r
+ hx3695_write_reg(RA_DEBUG_CFG0, 0x0); //0x5c\r
+ hx3695_write_reg(RA_DEBUG_CFG1, 0x0); //0x5d\r
+\r
+}\r
bool hx3695_chip_check(void)\r
{\r
uint8_t i = 0;\r
uint8_t chip_id = 0;\r
- for(i=0; i<10; i++)\r
+ for(i=0; i<5; i++)\r
{\r
-// hx3695_write_reg(0x02, 0x00);\r
-// hx3695_delay_ms(5);\r
+ hx3695_write_reg(0x5c, 0x00);\r
+ hx3695_delay_ms(5);\r
chip_id = hx3695_read_reg(0x00);\r
\r
if (chip_id == 0x65)\r
{\r
- TYHX_LOG(" %x, hx3695_chip_check ok\r\n",chip_id);\r
+ TYHX_LOG("hx3695_chip_check ok chip_id: 0x%x \r\n",chip_id);\r
+ Efuse_Mode_Check();\r
return true;\r
}\r
}\r
- TYHX_LOG(" %x, hx3695_chip_check fail!\r\n",chip_id);\r
+\r
+ TYHX_LOG(" hx3695_chip_check fail! chip_id: 0x%x \r\n", chip_id);\r
+\r
return false;\r
}\r
\r
+uint8_t hx3695_get_chip_id(void)\r
+{\r
+ uint8_t i = 0;\r
+ uint8_t chip_id = 0;\r
+ for(i=0; i<5; i++)\r
+ {\r
+ hx3695_write_reg(0x5c, 0x00);\r
+ hx3695_delay_ms(5);\r
+ chip_id = hx3695_read_reg(0x00);\r
+\r
+ if (chip_id == 0x65)\r
+ {\r
+ TYHX_LOG("hx3695_chip_check ok chip_id: 0x%x \r\n",chip_id);\r
+ return chip_id;\r
+ }\r
+ }\r
+\r
+ TYHX_LOG(" hx3695_chip_check fail! chip_id: 0x%x \r\n", chip_id);\r
+\r
+ return chip_id;\r
+}\r
+\r
uint8_t hx3695_read_fifo_size(void)\r
{\r
uint8_t data_len_h,data_len_l;\r
uint8_t phase1_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
uint8_t phase1_led_drv1_cha_sel = 0; /* 1 = ldr1 NG; 2 = ldr2 GR; 4 = ldr3 IR; 8 = ldr4 RED; */\r
uint8_t phase1_led_drv2_cha_sel = 0; /*ldr5:0x20 ldr6: 0x40 red ldr8 0x80 ir */\r
- uint8_t phase1_pd_sel = 0x03; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
+ uint8_t phase1_pd_sel = 0x0F; //0x03 /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
uint8_t phase1_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase1_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase1_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase2_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/\r
uint8_t phase2_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/\r
uint8_t phase2_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
- uint8_t phase2_led_drv1_cha_sel = 0x10; //GREEN_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
+ uint8_t phase2_led_drv1_cha_sel = 0x50; //0x10 //GREEN_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase2_led_drv2_cha_sel = 0;\r
- uint8_t phase2_pd_sel = 0x03; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
+ uint8_t phase2_pd_sel = 0x0F; //0x0C //0x03 /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
uint8_t phase2_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase2_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase2_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase3_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
uint8_t phase3_led_drv1_cha_sel = 0; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase3_led_drv2_cha_sel = 0;\r
- uint8_t phase3_pd_sel = 0x03; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
+ uint8_t phase3_pd_sel = 0x0F; //0x03 /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
uint8_t phase3_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase3_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase3_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase4_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
uint8_t phase4_led_drv1_cha_sel = 0; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase4_led_drv2_cha_sel = 0;\r
- uint8_t phase4_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
+ uint8_t phase4_pd_sel = 0x0F; //0x0C /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
uint8_t phase4_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase4_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase4_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase5_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/\r
uint8_t phase5_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/\r
uint8_t phase5_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
- uint8_t phase5_led_drv1_cha_sel = 0x10; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
+ uint8_t phase5_led_drv1_cha_sel = 0x50; //0x10 /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase5_led_drv2_cha_sel = 0;\r
- uint8_t phase5_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; */\r
+ uint8_t phase5_pd_sel = 0x0F; //0x0C /* 1 = pd1; 2 = pd2; */\r
uint8_t phase5_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase5_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase5_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase6_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
uint8_t phase6_led_drv1_cha_sel = 0; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase6_led_drv2_cha_sel = 0;\r
- uint8_t phase6_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; */\r
+ uint8_t phase6_pd_sel = 0x0F; //0x0C /* 1 = pd1; 2 = pd2; */\r
uint8_t phase6_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase6_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase6_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase7_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
uint8_t phase7_led_drv1_cha_sel = 0; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase7_led_drv2_cha_sel = 0;\r
- uint8_t phase7_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; */\r
+ uint8_t phase7_pd_sel = 0x02; //0x0C /* 1 = pd1; 2 = pd2; */\r
uint8_t phase7_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase7_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase7_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase8_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/\r
uint8_t phase8_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/\r
uint8_t phase8_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
- uint8_t phase8_led_drv1_cha_sel = 0x40; //IR_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
+ uint8_t phase8_led_drv1_cha_sel = 0x20; //0x40 //IR_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase8_led_drv2_cha_sel = 0;\r
- uint8_t phase8_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; */\r
+ uint8_t phase8_pd_sel = 0x02; //0x0C /* 1 = pd1; 2 = pd2; */\r
uint8_t phase8_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase8_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase8_ldr1_cur = 32; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase1_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
uint8_t phase1_led_drv1_cha_sel = 0; /* 1 = ldr1 NG; 2 = ldr2 GR; 4 = ldr3 IR; 8 = ldr4 RED; */\r
uint8_t phase1_led_drv2_cha_sel = 0; /*ldr5:0x20 ldr6: 0x40 red ldr8 0x80 ir */\r
- uint8_t phase1_pd_sel = 0x08; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
+ uint8_t phase1_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
uint8_t phase1_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase1_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase1_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase2_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/\r
uint8_t phase2_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/\r
uint8_t phase2_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
- uint8_t phase2_led_drv1_cha_sel = 0X10; //GREEN_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
+ uint8_t phase2_led_drv1_cha_sel = 0X50; //GREEN_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase2_led_drv2_cha_sel = 0x00;\r
- uint8_t phase2_pd_sel = 0x08; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
+ uint8_t phase2_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
uint8_t phase2_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase2_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase2_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase3_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
uint8_t phase3_led_drv1_cha_sel = 0; //RED_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase3_led_drv2_cha_sel = 0;\r
- uint8_t phase3_pd_sel = 0x08; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
+ uint8_t phase3_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
uint8_t phase3_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase3_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase3_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase4_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/\r
uint8_t phase4_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/\r
uint8_t phase4_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
- uint8_t phase4_led_drv1_cha_sel = 0x20; //IR_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
+ uint8_t phase4_led_drv1_cha_sel = 0x80; //0x20 //IR_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase4_led_drv2_cha_sel = 0;\r
- uint8_t phase4_pd_sel = 0x08; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
+ uint8_t phase4_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
uint8_t phase4_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase4_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase4_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase5_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
uint8_t phase5_led_drv1_cha_sel = 0x00; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase5_led_drv2_cha_sel = 0;\r
- uint8_t phase5_pd_sel = 0x08; /* 1 = pd1; 2 = pd2; */\r
+ uint8_t phase5_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; */\r
uint8_t phase5_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase5_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase5_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase6_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/\r
uint8_t phase6_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/\r
uint8_t phase6_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
- uint8_t phase6_led_drv1_cha_sel = 0x40; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
+ uint8_t phase6_led_drv1_cha_sel = 0x20; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase6_led_drv2_cha_sel = 0;\r
- uint8_t phase6_pd_sel = 0x08; /* 1 = pd1; 2 = pd2; */\r
+ uint8_t phase6_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; */\r
uint8_t phase6_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase6_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase6_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase7_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
uint8_t phase7_led_drv1_cha_sel = 0; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase7_led_drv2_cha_sel = 0;\r
- uint8_t phase7_pd_sel = 0x08; /* 1 = pd1; 2 = pd2; */\r
+ uint8_t phase7_pd_sel = 0x02; /* 1 = pd1; 2 = pd2; */\r
uint8_t phase7_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase7_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase7_ldr1_cur = 0; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase8_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/\r
uint8_t phase8_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/\r
uint8_t phase8_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
- uint8_t phase8_led_drv1_cha_sel = 0x40; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
+ uint8_t phase8_led_drv1_cha_sel = 0x20; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase8_led_drv2_cha_sel = 0;\r
- uint8_t phase8_pd_sel = 0x08; /* 1 = pd1; 2 = pd2; */\r
+ uint8_t phase8_pd_sel = 0x02; /* 1 = pd1; 2 = pd2; */\r
uint8_t phase8_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase8_led_offset_idac = 0; /* 0~255 = 0 ~ 64ua , step = 0.25ua */\r
uint8_t phase8_ldr1_cur = 20; /* 0~255 = 0 ~ 200ma, step = 0.8ma */\r
uint8_t phase3_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/\r
uint8_t phase3_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/\r
uint8_t phase3_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
- uint8_t phase3_led_drv1_cha_sel = 0x40; //RED_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
+ uint8_t phase3_led_drv1_cha_sel = 0x08; //0x40 //RED_LED_SLE; /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase3_led_drv2_cha_sel = 0;\r
uint8_t phase3_pd_sel = 0x0a; /* 1 = pd1; 2 = pd2; 4 = pd3*/\r
uint8_t phase3_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
uint8_t phase8_inner_avg = 0; /* phase1 adc avg num 0=1, 1=2, 2=4, 3=8 , 4=16*/\r
uint8_t phase8_tia_res = 0; /* 0= 10K; 1= 20k; 2= 50k; 3= 100k; 4= 150k; 5= 200k; 6= 500k; 7= 1M*/\r
uint8_t phase8_tia_cap = 4; /* 0= ; 1= ; 2= ; 3= ; 4= ; 5= ; 6= ; 7= */\r
- uint8_t phase8_led_drv1_cha_sel = 0x40; //IR_LED_SLE /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
+ uint8_t phase8_led_drv1_cha_sel = 0x20;//0x40; //IR_LED_SLE /* 1 = ldr1; 2 = ldr2; 4 = ldr3; 8 = ldr4 ; */\r
uint8_t phase8_led_drv2_cha_sel = 0;\r
uint8_t phase8_pd_sel = 0x0c; /* 1 = pd1; 2 = pd2; */\r
uint8_t phase8_als_offset_idac = 0; /* 0~255 = 0 ~ 128ua , step = 0.5ua */\r
// 初始化调用入口函数\r
bool hx3695_init(WORK_MODE_T mode)\r
{\r
+ TYHX_LOG(" hx3695_init mode : %d \n", mode);\r
+ \r
work_mode_flag = mode;\r
hx3695_data_reset();\r
hx3695_vin_check(3800);\r
switch (work_mode_flag)\r
{\r
case HRS_MODE:\r
+ TYHX_LOG(" hx3695_init mode : HRS_MODE \n");\r
#ifdef HRS_ALG_LIB\r
- tyhx_hrs_set_living(1, 15, 30);\r
+ tyhx_hrs_set_alg_para(NORMAL_MODE, 150, 1);\r
+\r
+ tyhx_hrs_set_living(1, 15, 30);\r
if(hx3695_hrs_enable()== SENSOR_OP_FAILED)\r
{\r
return false;\r
#endif\r
}\r
\r
+\r
+void hx3695_factory_test_process(uint8_t data[], uint8_t mode, uint8_t* ppg_src)\r
+{\r
+ extern bool factory_test_flag;\r
+ extern bool factory_test_aging;\r
+ extern bool factory_test_sensor_on;\r
+ if(factory_test_flag == false || factory_test_aging != false) return;\r
+ if(factory_test_sensor_on == true ) return;\r
+ \r
+ static uint8_t ppg_data[15] = {0};\r
+\r
+ if(ppg_src == NULL)\r
+ {\r
+ memcpy(ppg_data, data, 3);\r
+ return;\r
+ }\r
+ \r
+ // switch(mode)\r
+ // {\r
+ // case APP_FACTORY_TEST_HR_START:\r
+ // memcpy((void *)&ppg_data[3], ppg_src, 4);\r
+ // factory_test_send_data(ppg_data, 7);\r
+ // break;\r
+ // case APP_FACTORY_TEST_SPO2_START:\r
+ // memcpy((void *)&ppg_data[3], ppg_src, 4);\r
+ // factory_test_send_data(ppg_data, 7);\r
+ // break;\r
+ // case APP_FACTORY_TEST_LEAKING_START:\r
+ // memcpy((void *)&ppg_data[3], ppg_src, 12);\r
+ // factory_test_send_data(ppg_data, 15);\r
+ // break;\r
+ // case APP_FACTORY_TEST_GRAY_CARD:\r
+ // memcpy((void *)&ppg_data[3], ppg_src, 12);\r
+ // factory_test_send_data(ppg_data, 15);\r
+ // break;\r
+ // default:\r
+ // break;\r
+ // }\r
+}\r
+\r
void heart_rate_meas_timeout_handler(void * p_context)\r
{\r
switch(work_mode_flag)\r
hx3695_hrspo2_ppg_Int_handle();\r
#endif\r
\r
+ case FT_LEAK_LIGHT_MODE:\r
+ hx3695_factroy_test(LEAK_LIGHT_TEST);\r
+ break;\r
+ \r
+ case FT_GRAY_CARD_MODE:\r
+ {\r
+ FT_RESULTS_t ft_result = hx3695_factroy_test(GRAY_CARD_TEST);\r
+ uint8_t data[12] = {0};\r
+ memcpy(data, (void *)&ft_result.gr_data_final, 12);\r
+ // hx3695_factory_test_process(NULL, APP_FACTORY_TEST_GRAY_CARD, data);\r
+ }\r
+ break;\r
+\r
default:\r
break;\r
}\r
#else\r
if(hx3695_hrs_read(&hrs_s_dat) == 0)\r
{\r
+ AGC_LOG("hx3695_hrs_read(&hrs_s_dat) == 0\r\n");\r
return;\r
}\r
\r
}\r
\r
hrs_wear_status = hx3695_hrs_get_wear_status();\r
+ AGC_LOG("hrs_wear_status: %d !!\r\n", hrs_wear_status);\r
if(hrs_wear_status == MSG_HRS_WEAR)\r
{\r
tyhx_hrs_alg_send_data(PPG_buf, *count, gsen_fifo_x_send, gsen_fifo_y_send, gsen_fifo_z_send, cal.Group1_Ledidac);\r
hrsresult.hr_living_qu = alg_results.hr_result_qual;\r
hrsresult.hr_living_std = alg_results.hr_result_std;\r
\r
- \r
- \r
-\r
- DEBUG_PRINTF("data_cnt: %d, hr_result:%d \r\n",alg_results.data_cnt, alg_results.hr_result);\r
+ AGC_LOG("hx3695 data_cnt: %d, hr_living: %d, hr_living_qu: %d, hr_living_std: %d, hr_result:%d \r\n",\r
+ alg_results.data_cnt, hrsresult.hr_living, hrsresult.hr_living_qu, hrsresult.hr_living_std, hrsresult.lastesthrs);\r
+ if(hrs_wear_status == MSG_HRS_WEAR && hrsresult.hr_living == MSG_LIVING_TRUE)\r
+ {\r
+// app_hr_reset_stop_timer();\r
+ if(alg_results.hr_result)\r
+ {\r
+ \r
+ // app_hr_cal_hr_values(alg_results.hr_result);\r
+ // AGC_LOG("app_hr_cal_hr_values tick:%d hr:%d", xTaskGetTickCount(), alg_results.hr_result);\r
+ AGC_LOG("app_hr_cal_hr_values hr:%d", alg_results.hr_result);\r
+ //hr_sensor_notify_factory_test();\r
+ }\r
+ hr_no_living_dur = 0;\r
+ }\r
+ else if(hrs_wear_status == MSG_HRS_WEAR && hrsresult.hr_living != MSG_LIVING_TRUE)\r
+ {\r
+ // if (++hr_no_living_dur > 12 * 1000 / tyhx_long_timer_tick)\r
+ {\r
+ // hr_stop_detect();\r
+ // AGC_LOG("tyhx_hrs_module_start(WEAR_MODE) wear:%d liv:%d", hrs_wear_status, hrsresult.hr_living);\r
+ // hr_no_living_dur = 0;\r
+ }\r
+ }\r
+ else if(hrs_wear_status == MSG_HRS_NO_WEAR || hrsresult.hr_living == MSG_LIVING_FAIL)\r
+ {\r
+ // hr_stop_detect();\r
+ AGC_LOG("tyhx_hrs_module_start(WEAR_MODE) wear:%d liv:%d", hrs_wear_status, hrsresult.hr_living);\r
+ hr_no_living_dur = 0;\r
+ }\r
#ifdef BP_CUSTDOWN_ALG_LIB\r
bp_results_t bp_alg_results;\r
bp_alg_results = tyhx_alg_get_bp_results();\r
gsen_fifo_y_send[ii] = gsen_fifo_y[32-*count+ii];\r
gsen_fifo_z_send[ii] = gsen_fifo_z[32-*count+ii];\r
//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]);\r
+ // hx3695_factory_test_process(NULL, APP_FACTORY_TEST_SPO2_START, (uint8_t *)&red_buf[ii]);\r
\r
}\r
- //DEBUG_PRINTF("%d %d %d %d %d %d\r\n", cal.R_LED, cal.IR_LED, cal.G_LED, cal.R_LEDDAC, cal.IR_LEDDAC, cal.G_LEDDAC);\r
+ 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);\r
spo2_wear_status = hx3695_spo2_get_wear_status();\r
if(spo2_wear_status == MSG_SPO2_WEAR)\r
{\r
//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);\r
\r
hrsresult.lastestspo2 = spo2_alg_results.spo2_result;\r
+// if(hrsresult.lastestspo2)\r
+ {\r
+ // store_latest_spo2(hrsresult.lastestspo2);\r
+ // app_hr_cal_hr_values(hrsresult.lastesthrs);\r
+// gui_send_message_by_data(MSG_SPO2_DATA, &hrsresult.lastestspo2, 1);\r
+// hr_sensor_notify_factory_test();\r
+ }\r
+ \r
\r
\r
/////////////////////////////////////////BLE+DISPLAY//////////////////////////////////////////\r
hx3695_check_touch_read(&ppg_s_data);\r
hx3695_wear_status = hx3695_check_touch_send_data(ir_buf,*count);\r
hrsresult.wearstatus = hx3695_wear_status;\r
+ extern uint8_t notouch_cnt;\r
+ extern uint8_t touch_cnt;\r
+\r
+ if (hrsresult.wearstatus)\r
+ {\r
+ cwm_gsensor_enable();\r
+ }\r
+ else\r
+ {\r
+ cwm_gsensor_disable();\r
+ }\r
+// AGC_LOG("===> touch_cnt: %d, notouch_cnt: %d, wear status: %d, \r\n", touch_cnt, notouch_cnt, hx3695_wear_status);\r
+\r
+// AGC_LOG("hx3695_wear_ppg_Int_handle wearstatus = %d\r\n", hrsresult.wearstatus);\r
+ \r
// for(int i=0;i<*count;i++)\r
// {\r
// DEBUG_PRINTF("%d,%d,%d,%d,%d,%d\r\n",1+i,*count,ir_buf[i],ppg_s_data.s_buf[i*2],ppg_s_data.s_buf[i*2+1],hx3695_wear_status);\r