From: SnickerSun Date: Fri, 29 Dec 2023 11:27:51 +0000 (+0800) Subject: 添加hx3695驱动编译通过,移植未完成 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=0b295be56112c9d98d84b430ba883c663079e687;p=mirrors%2FFD230.git 添加hx3695驱动编译通过,移植未完成 --- diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index 1adbac580..32dd3712f 100755 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -116,6 +116,7 @@ target = { 'CONFIG_LOW_POWER_TEST', 'ENABLE_ECC', 'FT_SINGLE_UART', + 'PPG_HX3695', #'CONFIG_ADC_SUPPORT_AUTO_SCAN','CONFIG_ADC_SUPPORT_LONG_SAMPLE', 'MIPI_ULPS_SUPPORT', 'TPTYPE_FT6X46'], 'ram_component': ["algorithm", "dfx_port_brandy", "dfx_update", 'dfx_nv', "osal", "arch_port", "-:testsuite", @@ -124,7 +125,9 @@ target = { 'ulp_aon', 'hal_l2ram', 'x_dpal', 'x_vfs', 'x_disk', 'x_fat', 'drv_mmc', 'fs_yaffs2', 'x_vfs_private', 'pm_service', 'pm_brandy', 'cmn_header', 'at_cmd', 'graphic_at_service', 'app_at_service', 'ohosfwk_at_service', - "audio_proc", "audio_dump", "audio_probe", "power_manager", "gpu_proc","batterry_service"], + "audio_proc", "audio_dump", "audio_probe", "power_manager", "gpu_proc", + "ppg_sensor", + "batterry_service"], 'ram_component_set': ['bgh', 'media', 'gpu', 'graphic_uikit', 'bgh_audio', 'dfx_set', 'ohos_set', 'wearable_set', 'alipay_set'], 'dsp_version': 'max', 'packet': True, diff --git a/code/sdk/drivers/peripheral/ppg/CMakeLists.txt b/code/sdk/drivers/peripheral/ppg/CMakeLists.txt index f0d885026..8d59792ff 100644 --- a/code/sdk/drivers/peripheral/ppg/CMakeLists.txt +++ b/code/sdk/drivers/peripheral/ppg/CMakeLists.txt @@ -4,13 +4,29 @@ #=============================================================================== set(COMPONENT_NAME "ppg_sensor") -set(SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/button.c +if("PPG_HX3695" IN_LIST DEFINES) +set(SOURCES ${SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/hx3695/hx3695.c + ${CMAKE_CURRENT_SOURCE_DIR}/hx3695/hx3695_check_touch.c + ${CMAKE_CURRENT_SOURCE_DIR}/hx3695/hx3695_factory_test.c + ${CMAKE_CURRENT_SOURCE_DIR}/hx3695/hx3695_hrs_agc.c + ${CMAKE_CURRENT_SOURCE_DIR}/hx3695/hx3695_hrv_agc.c + ${CMAKE_CURRENT_SOURCE_DIR}/hx3695/hx3695_spo2_agc.c + ${CMAKE_CURRENT_SOURCE_DIR}/hx3695/hx3695_hrs_custom.c +) +set(PUBLIC_HEADER + ${CMAKE_CURRENT_SOURCE_DIR}/hx3695 ) +else() +set(SOURCES ${SOURCES} + # ${CMAKE_CURRENT_SOURCE_DIR}/ztw523_touch/ztw523_ctrl.c +) set(PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR} ) +endif() + set(PRIVATE_HEADER ) @@ -37,3 +53,6 @@ set(MAIN_COMPONENT ) build_component() + +find_library(LIB_PATH_HX3695 hx3695/libhx3695.a ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(${TARGET_NAME} PRIVATE -Wl,--whole-archive ${LIB_PATH_HX3695} PRIVATE -Wl,--whole-archive) \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index 75b6706a2..38aabca31 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" @@ -26,7 +26,11 @@ #endif #include "hx3695_factory_test.h" +FT_CUSTOM_RESULTS_t hrsresult ={0}; +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" @@ -133,7 +137,9 @@ static int32_t ir_jump_delta = 0; static int32_t cali_data_cnt = 0; #endif -// us ÑÓʱº¯Êý£¬ ¿Í»§ÐèÌîд + + +// us 延时函数, 客户需填写 void hx3695_delay_us(uint32_t us) { tyhx_delay_us(us); @@ -145,7 +151,7 @@ void hx3695_delay_ms(uint32_t ms) tyhx_delay_ms(ms); } -// i2c дº¯Êý£¬ ¿Í»§ÐèÌîд, µØÖ·0x44(7bit) +// i2c 写函数, 客户需填写, 地址0x44(7bit) bool hx3695_write_reg(uint8_t addr, uint8_t data) { @@ -153,7 +159,7 @@ bool hx3695_write_reg(uint8_t addr, uint8_t data) return true; } -// i2c ¶Áº¯Êý£¬ ¿Í»§ÐèÌîд +// i2c 读函数, 客户需填写 uint8_t hx3695_read_reg(uint8_t addr) { uint8_t data_buf = 0; @@ -162,7 +168,7 @@ uint8_t hx3695_read_reg(uint8_t addr) return data_buf; } -// i2c Á¬¶Áº¯Êý£¬ ¿Í»§ÐèÌîд +// i2c 连读函数, 客户需填写 bool hx3695_brust_read_reg(uint8_t addr, uint8_t *buf, uint8_t length) { //TYHX_LOG("brust read\r\n"); @@ -195,7 +201,7 @@ uint32_t gsen_read_timers_stop(void) } -/* Íê³É¶ÁÈ¡PPGÊý¾Ý¶¨Ê±Æ÷½Ó¿Ú£¬ Ñ­»·µ÷Ó㬠ĬÈÏ320ms +/* 完成读取PPG数据定时器接口, 循环调用, 默认320ms void heart_rate_meas_timeout_handler(void * p_context) */ void hx3695_320ms_timer_cfg(bool en) @@ -224,7 +230,7 @@ void hx3695_40ms_timer_cfg(bool en) } #if defined(INT_MODE) -/* Èç²ÉÓÃÖжÏģʽ£¬ ÈçÍê³ÉÖжϿªÆôºÍ¹Ø±Õ½Ó¿Ú +/* 如采用中断模式, 如完成中断开启和关闭接口 void hx3695_ppg_Int_handle(void) */ void hx3695_gpioint_cfg(bool en) @@ -400,7 +406,7 @@ void hx3695_data_reset(void) } #ifdef HRS_ALG_LIB -// ÐÄÂÊģʽÏÂppg ³õʼ»¯ÅäÖà +// 心率模式下ppg 初始化配置 void hx3695_hrs_ppg_init(void) // ppg fs=25hz, phase conversion ready interupt en { uint16_t sample_rate = 25; /*config the data rate of chip alps2_fm ,uint is Hz*/ @@ -635,9 +641,9 @@ void hx3695_hrs_ppg_init(void) // ppg fs=25hz, phase conversion ready interupt e hx3695_write_reg(0X31, (led_on_time<<4| 0x00)); - hx3695_write_reg(0X33, 0x83);// Öжϼ«ÐÔ¼°¿í¶ÈÅäÖã» - hx3695_write_reg(0X34, 0x00);// ÖжÏÌØÊâÅäÖã» - hx3695_write_reg(0X36, 0x00);// phase data ready ±êÖ¾ÉèÖã» + hx3695_write_reg(0X33, 0x83);// 中断极性及宽度配置; + hx3695_write_reg(0X34, 0x00);// 中断特殊配置; + hx3695_write_reg(0X36, 0x00);// phase data ready 标志设置; hx3695_write_reg(0X38, 0x00); hx3695_write_reg(0X3a, (phase1_inner_avg | (phase2_inner_avg<<4))); @@ -808,9 +814,9 @@ void hx3695_hrs_ppg_init(void) // ppg fs=25hz, phase conversion ready interupt e 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); // 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(0X38, 0x01); // int sel,00=close almost full int,04=enable almost full int #endif @@ -830,7 +836,7 @@ void hx3695_hrs_ppg_init(void) // ppg fs=25hz, phase conversion ready interupt e #endif #ifdef SPO2_ALG_LIB -// ѪÑõģʽÏ ³õʼ»¯ÅäÖà +// 血氧模式下 初始化配置 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*/ @@ -1067,9 +1073,9 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion hx3695_write_reg(0X31, (led_on_time<<4| 0x00)); - hx3695_write_reg(0X33, 0x83);// Öжϼ«ÐÔ¼°¿í¶ÈÅäÖã» - hx3695_write_reg(0X34, 0x00);// ÖжÏÌØÊâÅäÖã» - hx3695_write_reg(0X36, 0x00);// phase data ready ±êÖ¾ÉèÖã» + hx3695_write_reg(0X33, 0x83);// 中断极性及宽度配置; + hx3695_write_reg(0X34, 0x00);// 中断特殊配置; + hx3695_write_reg(0X36, 0x00);// phase data ready 标志设置; hx3695_write_reg(0X38, 0x00); hx3695_write_reg(0X3a, (phase1_inner_avg | (phase2_inner_avg<<4))); @@ -1236,9 +1242,9 @@ 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);// 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 @@ -1263,7 +1269,7 @@ void hx3695_spo2_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion #endif #ifdef HRV_ALG_LIB -// HRVģʽÏ ³õʼ»¯ÅäÖà +// HRV模式下 初始化配置 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*/ @@ -1498,9 +1504,9 @@ void hx3695_hrv_ppg_init(void) //20200615 ericy ppg fs=25hz, phase3 conversion r hx3695_write_reg(0X31, (led_on_time<<4| 0x00)); - hx3695_write_reg(0X33, 0x83);// Öжϼ«ÐÔ¼°¿í¶ÈÅäÖã» - hx3695_write_reg(0X34, 0x00);// ÖжÏÌØÊâÅäÖã» - hx3695_write_reg(0X36, 0x00);// phase data ready ±êÖ¾ÉèÖã» + hx3695_write_reg(0X33, 0x83);// 中断极性及宽度配置; + hx3695_write_reg(0X34, 0x00);// 中断特殊配置; + hx3695_write_reg(0X36, 0x00);// phase data ready 标志设置; hx3695_write_reg(0X38, 0x00); hx3695_write_reg(0X3a, (phase1_inner_avg | (phase2_inner_avg<<4))); @@ -1667,9 +1673,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 @@ -1929,9 +1935,9 @@ void hx3695_check_touch_init(void) // hx3695_write_reg(0X31, (led_on_time<<4| 0x00)); - hx3695_write_reg(0X33, 0x83);// Öжϼ«ÐÔ¼°¿í¶ÈÅäÖã» - hx3695_write_reg(0X34, 0x00);// ÖжÏÌØÊâÅäÖã» - hx3695_write_reg(0X36, 0x00);// phase data ready ±êÖ¾ÉèÖã» + hx3695_write_reg(0X33, 0x83);// 中断极性及宽度配置; + hx3695_write_reg(0X34, 0x00);// 中断特殊配置; + hx3695_write_reg(0X36, 0x00);// phase data ready 标志设置; hx3695_write_reg(0X38, 0x00); hx3695_write_reg(0X3a, (phase1_inner_avg | (phase2_inner_avg<<4))); @@ -2098,9 +2104,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(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(0X38, 0x00); // int sel,00=close almost full int,01= prf int 04=enable almost full int @@ -2123,7 +2129,7 @@ void hx3695_check_touch_init(void) // } #endif -// ³õʼ»¯µ÷ÓÃÈë¿Úº¯Êý +// 初始化调用入口函数 bool hx3695_init(WORK_MODE_T mode) { work_mode_flag = mode; @@ -2389,14 +2395,24 @@ void hx3695_ppg_Int_handle(void) #ifdef HRS_ALG_LIB -/*TYHX ÐÄÂÊģʽÏ ¶ÁÈ¡PPG£¬ ĬÈÏ320ms*/ +/*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; - hrs_results_t alg_results = {MSG_HRS_ALG_NOT_OPEN,0,0,0,0}; + hrs_results_t alg_results = {MSG_HRS_ALG_NOT_OPEN,0,0,0,0,0,0}; hrs_wear_msg_code_t hrs_wear_status = MSG_HRS_NO_WEAR; int32_t *PPG_buf = &(hrs_s_dat.green_data[0]); int32_t *ir_buf = &(hrs_s_dat.ir_data[0]); @@ -2406,8 +2422,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++) @@ -2689,11 +2705,33 @@ int32_t hx3695_ir_data_cali(int32_t ir_new_raw_data) //#ifdef SPO2_ALG_LIB spo2_sensor_data_t spo2_s_dat; -/*TYHX ѪÑõģʽÏ ¶ÁÈ¡PPG£¬ ĬÈÏ320ms*/ +/**** + * +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) { uint8_t ii=0; - spo2_results_t spo2_alg_results = {MSG_SPO2_ALG_NOT_OPEN,0,0,0,0,0,0,1,0,0}; + spo2_results_t spo2_alg_results = {MSG_SPO2_ALG_NOT_OPEN,0,0,0,0,0,0,1,0,0,0,0,0}; spo2_wear_msg_code_t spo2_wear_status = MSG_SPO2_NO_WEAR; SPO2_CAL_SET_T cal = get_spo2_agc_status(); int32_t *red_buf = &(spo2_s_dat.red_data[0]); @@ -2797,8 +2835,8 @@ spo2_sensor_data_t hrspo2_s_data; void hx3695_hrspo2_ppg_Int_handle(void) { uint8_t ii=0; - spo2_results_t spo2_alg_results = {MSG_SPO2_ALG_NOT_OPEN,0,0,0,0,0,0}; - hrs_results_t alg_results = {MSG_HRS_ALG_NOT_OPEN,0,0,0,0}; + spo2_results_t spo2_alg_results = {MSG_SPO2_ALG_NOT_OPEN,0,0,0,0,0,0,0,0,0,0,0,0}; + hrs_results_t alg_results = {MSG_HRS_ALG_NOT_OPEN,0,0,0,0,0,0}; spo2_wear_msg_code_t spo2_wear_status = MSG_SPO2_NO_WEAR; SPO2_CAL_SET_T cal = get_spo2_agc_status(); int32_t *red_buf = &(hrspo2_s_data.red_data[0]); @@ -2812,7 +2850,7 @@ void hx3695_hrspo2_ppg_Int_handle(void) int32_t red_data_cali, ir_data_cali; #endif - if(hx3695_spo2_read(&hrspo2_s_data) == NULL) + if(hx3695_spo2_read(&hrspo2_s_data) == 0) { return; } diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h index a2ac8ceb6..1a5b561e4 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.h @@ -4,23 +4,23 @@ #include /********************* alg_swi ********************* -HRS_ALG_LIB ÐÄÂʹ¦ÄÜ -SPO2_ALG_LIB ѪÑõ¹¦ÄÜ -HRV_ALG_LIB HRV¹¦ÄÜ -CHECK_TOUCH_LIB ´¿Åå´÷¹¦ÄÜ£¨·ÇÐÄÂÊѪÑõģʽ£© -CHECK_LIVING_LIB ´¿ÎïÌåʶ±ð¹¦ÄÜ£¨·ÇÐÄÂÊѪÑõģʽ£© -BP_CUSTDOWN_ALG_LIB Ѫѹ¹¦ÄÜ - -TIMMER_MODE ¶¨Ê±Æ÷ģʽ£¬ ¶ÁPPGÊý¾Ý£¬ ĬÈϲÉÓö¨Ê±Æ÷ģʽ -INT_MODE ÖжÏģʽ£¬¶ÁPPGÊý¾Ý - -DEMO_MI demoÏà¹ØÅäÖ㬠¿Í»§¹Ø±Õ£¬ ÔÚÏÂÃæelseÀï½øÐÐÅäÖà -HRS_BLE_APP DEMOÀ¶ÑÀ¿ØÖƺ꣬ ¿Í»§¹Ø±Õ -SPO2_DATA_CALI ѪÑõDC²¹³¥Ä£Ê½£¬ ¿Í»§¹Ø±Õ -HRS_DEBUG µ÷ÊԺ꣬ ¸ù¾Ýƽ̨¶¨Òå´òÓ¡º¯Êý -AGC_DEBUG µ÷ÊԺ꣬ ¸ù¾Ýƽ̨¶¨Òå´òÓ¡º¯Êý -GSEN_40MS_TIMMER DEMOµ÷ÊÔʹÓ㬠¿Í»§¹Ø±Õ -NEW_GSEN_SCHME DEMOµ÷ÊÔʹÓ㬠¿Í»§¹Ø±Õ +HRS_ALG_LIB 心率功能 +SPO2_ALG_LIB 血氧功能 +HRV_ALG_LIB HRV功能 +CHECK_TOUCH_LIB 纯佩戴功能(非心率血氧模式) +CHECK_LIVING_LIB 纯物体识别功能(非心率血氧模式) +BP_CUSTDOWN_ALG_LIB 血压功能 + +TIMMER_MODE 定时器模式, 读PPG数据, 默认采用定时器模式 +INT_MODE 中断模式,读PPG数据 + +DEMO_MI demo相关配置, 客户关闭, 在下面else里进行配置 +HRS_BLE_APP DEMO蓝牙控制宏, 客户关闭 +SPO2_DATA_CALI 血氧DC补偿模式, 客户关闭 +HRS_DEBUG 调试宏, 根据平台定义打印函数 +AGC_DEBUG 调试宏, 根据平台定义打印函数 +GSEN_40MS_TIMMER DEMO调试使用, 客户关闭 +NEW_GSEN_SCHME DEMO调试使用, 客户关闭 */ #define HRS_ALG_LIB #define SPO2_ALG_LIB diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.c index 4ab6f2f99..9b2b56f84 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_factory_test.c @@ -242,9 +242,9 @@ void hx3695_factory_wear_mode_config(void) hx3695_write_reg(0X31, (led_on_time<<4| 0x00)); - hx3695_write_reg(0X33, 0x83);// Öжϼ«ÐÔ¼°¿í¶ÈÅäÖã» - hx3695_write_reg(0X34, 0x00);// ÖжÏÌØÊâÅäÖã» - hx3695_write_reg(0X36, 0x00);// phase data ready ±êÖ¾ÉèÖã» + hx3695_write_reg(0X33, 0x83);// 中断极性及宽度配置; + hx3695_write_reg(0X34, 0x00);// 中断特殊配置; + hx3695_write_reg(0X36, 0x00);// phase data ready 标志设置; hx3695_write_reg(0X38, 0x00); hx3695_write_reg(0X3a, (phase1_inner_avg | (phase2_inner_avg<<4))); @@ -415,9 +415,9 @@ void hx3695_factory_wear_mode_config(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(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(0X38, 0x01); // int sel,00=close almost full int,04=enable almost full int #endif @@ -438,7 +438,7 @@ void hx3695_factory_wear_mode_config(void) } -void hx3695_factory_ft_card_test_config(void)//»Ò¿¨15mm¸ß¶È²âÊÔÅäÖà +void hx3695_factory_ft_card_test_config(void)//灰卡15mm高度测试配置 { 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 */ @@ -674,9 +674,9 @@ void hx3695_factory_ft_card_test_config(void)// hx3695_write_reg(0X31, (led_on_time<<4| 0x00)); - hx3695_write_reg(0X33, 0x83);// Öжϼ«ÐÔ¼°¿í¶ÈÅäÖã» - hx3695_write_reg(0X34, 0x00);// ÖжÏÌØÊâÅäÖã» - hx3695_write_reg(0X36, 0x00);// phase data ready ±êÖ¾ÉèÖã» + hx3695_write_reg(0X33, 0x83);// 中断极性及宽度配置; + hx3695_write_reg(0X34, 0x00);// 中断特殊配置; + hx3695_write_reg(0X36, 0x00);// phase data ready 标志设置; hx3695_write_reg(0X38, 0x00); hx3695_write_reg(0X3a, (phase1_inner_avg | (phase2_inner_avg<<4))); @@ -843,9 +843,9 @@ void hx3695_factory_ft_card_test_config(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(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(0X38, 0x00); // int sel,00=close almost full int,01= prf int 04=enable almost full int @@ -865,7 +865,7 @@ void hx3695_factory_ft_card_test_config(void)// return ; } -void hx3695_factory_ft_single_check_config(void)//»Ò¿¨10mm¸ß¶È²âÊÔÅäÖà +void hx3695_factory_ft_single_check_config(void)//灰卡10mm高度测试配置 { uint16_t sample_rate = 200; /*config the data rate of chip alps2_fm ,uint is Hz*/ @@ -1099,9 +1099,9 @@ void hx3695_factory_ft_single_check_config(void)// hx3695_write_reg(0X31, (led_on_time<<4| 0x00)); - hx3695_write_reg(0X33, 0x83);// Öжϼ«ÐÔ¼°¿í¶ÈÅäÖã» - hx3695_write_reg(0X34, 0x00);// ÖжÏÌØÊâÅäÖã» - hx3695_write_reg(0X36, 0x00);// phase data ready ±êÖ¾ÉèÖã» + hx3695_write_reg(0X33, 0x83);// 中断极性及宽度配置; + hx3695_write_reg(0X34, 0x00);// 中断特殊配置; + hx3695_write_reg(0X36, 0x00);// phase data ready 标志设置; hx3695_write_reg(0X38, 0x00); hx3695_write_reg(0X3a, (phase1_inner_avg | (phase2_inner_avg<<4))); @@ -1272,9 +1272,9 @@ void hx3695_factory_ft_single_check_config(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(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(0X38, 0x01); // int sel,00=close almost full int,04=enable almost full int #endif @@ -1292,7 +1292,7 @@ void hx3695_factory_ft_single_check_config(void)// return ; } -void hx3695_factory_ft_leak_light_test_config(void)//©¹â²âÊÔÅäÖà +void hx3695_factory_ft_leak_light_test_config(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 */ @@ -1528,9 +1528,9 @@ void hx3695_factory_ft_leak_light_test_config(void)//© hx3695_write_reg(0X31, (led_on_time<<4| 0x00)); - hx3695_write_reg(0X33, 0x83);// Öжϼ«ÐÔ¼°¿í¶ÈÅäÖã» - hx3695_write_reg(0X34, 0x00);// ÖжÏÌØÊâÅäÖã» - hx3695_write_reg(0X36, 0x00);// phase data ready ±êÖ¾ÉèÖã» + hx3695_write_reg(0X33, 0x83);// 中断极性及宽度配置; + hx3695_write_reg(0X34, 0x00);// 中断特殊配置; + hx3695_write_reg(0X36, 0x00);// phase data ready 标志设置; hx3695_write_reg(0X38, 0x00); hx3695_write_reg(0X3a, (phase1_inner_avg | (phase2_inner_avg<<4))); @@ -1697,9 +1697,9 @@ void hx3695_factory_ft_leak_light_test_config(void)//© 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); //intrupt hx3695_write_reg(0X38, 0x00); // int sel,00=close almost full int,01= prf int 04=enable almost full int @@ -1952,9 +1952,9 @@ void hx3695_factory_led_off_config(void) hx3695_write_reg(0X31, (led_on_time<<4| 0x00)); - hx3695_write_reg(0X33, 0x83);// Öжϼ«ÐÔ¼°¿í¶ÈÅäÖã» - hx3695_write_reg(0X34, 0x00);// ÖжÏÌØÊâÅäÖã» - hx3695_write_reg(0X36, 0x00);// phase data ready ±êÖ¾ÉèÖã» + hx3695_write_reg(0X33, 0x83);// 中断极性及宽度配置; + hx3695_write_reg(0X34, 0x00);// 中断特殊配置; + hx3695_write_reg(0X36, 0x00);// phase data ready 标志设置; hx3695_write_reg(0X38, 0x00); hx3695_write_reg(0X3a, (phase1_inner_avg | (phase2_inner_avg<<4))); @@ -2125,9 +2125,9 @@ void hx3695_factory_led_off_config(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(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(0X38, 0x01); // int sel,00=close almost full int,04=enable almost full int #endif @@ -2145,7 +2145,7 @@ void hx3695_factory_led_off_config(void) return ; } -void hx3695_factory_ft_int_test_config(void)//ÖжϲâÊÔÅäÖà +void hx3695_factory_ft_int_test_config(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 */ @@ -2378,9 +2378,9 @@ void hx3695_factory_ft_int_test_config(void)// hx3695_write_reg(0X31, (led_on_time<<4| 0x00)); - hx3695_write_reg(0X33, 0x83);// Öжϼ«ÐÔ¼°¿í¶ÈÅäÖã» - hx3695_write_reg(0X34, 0x00);// ÖжÏÌØÊâÅäÖã» - hx3695_write_reg(0X36, 0x00);// phase data ready ±êÖ¾ÉèÖã» + hx3695_write_reg(0X33, 0x83);// 中断极性及宽度配置; + hx3695_write_reg(0X34, 0x00);// 中断特殊配置; + hx3695_write_reg(0X36, 0x00);// phase data ready 标志设置; hx3695_write_reg(0X38, 0x00); hx3695_write_reg(0X3a, (phase1_inner_avg | (phase2_inner_avg<<4))); @@ -2534,16 +2534,16 @@ void hx3695_factory_ft_int_test_config(void)// /////////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 + 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(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;\ - 0011=p4;0100=p5;0101=p6;0110=p7;\ - bits<7> fifo enble + 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(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 @@ -2551,9 +2551,9 @@ void hx3695_factory_ft_int_test_config(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(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(0X38, 0x01); // int sel,00=close almost full int,04=enable almost full int #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 cc4b817a2..65da39f93 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.c @@ -114,8 +114,8 @@ hrs_wear_msg_code_t hx3695_hrs_wear_mode_check(WORK_MODE_T mode, int32_t infrare hrs_wear_status = MSG_HRS_NO_WEAR; } } -// SEGGER_RTT_printf(0,"hrs ir_data: %d, hrs_wear_status_pre=%d, hrs_wear_status=%d\r\n",\ - infrared_data,hrs_wear_status_pre,hrs_wear_status); +// SEGGER_RTT_printf(0,"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; @@ -378,7 +378,7 @@ void PPG_hrs_Calibration_Routine(HRS_CAL_SET_T *calR, int32_t g1_led,int32_t g2_ } -HRS_CAL_SET_T PPG_hrs_agc( ) +HRS_CAL_SET_T PPG_hrs_agc(void) { int32_t g1_led_val, g2_led_val, g1_amb_val, g2_amb_val; @@ -933,8 +933,8 @@ uint8_t hx3695_hrs_read(hrs_sensor_data_t * s_dat) // SEGGER_RTT_printf(0,"PPG_data: %d , PPG_src_data2: %d\r\n", PPG_src_data,PPG_src_data2); hx3695_hrs_wear_mode_check(HRS_MODE,Ir_src_data); // SEGGER_RTT_printf(0,"hx3690_hrs_wear_mode_check:::%d %d %d\r\n", hx3695_read_reg(0X2a),hx3695_read_reg(0X2b),hx3695_read_reg(0X2c)); -// SEGGER_RTT_printf(0,"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); + // SEGGER_RTT_printf(0,"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); // SEGGER_RTT_printf(0,"ps_green_data: %d PS8: %d, PS7: %d\r\n", ps_green_data,ps_data[7],ps_data[6]); 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 3d776898e..0a7004975 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_agc.h @@ -86,7 +86,7 @@ typedef struct { uint8_t Group3_max_cur; } HRS_CAL_SET_T; -HRS_CAL_SET_T PPG_hrs_agc( ); +HRS_CAL_SET_T PPG_hrs_agc(void); void Init_hrs_PPG_Calibration_Routine(HRS_CAL_SET_T *calR); void Restart_hrs_PPG_Calibration_Routine(HRS_CAL_SET_T *calR); //void PPG_hrs_Calibration_Routine(HRS_CAL_SET_T *calR, int32_t g1_led,int32_t g2_led,int32_t g3_led, int32_t g1_amb, int32_t g2_amb,int32_t g3_amb); diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c new file mode 100644 index 000000000..70d70776e --- /dev/null +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrs_custom.c @@ -0,0 +1,40 @@ +#include +#include +#include +#include +#include + +#include "tyhx_hrs_custom.h" + + + +// us 延时函数, 客户需填写 +void tyhx_delay_us(uint32_t us) +{ + +} +void tyhx_delay_ms(uint32_t ms) +{ + +} + +// i2c 写函数, 客户需填写, 地址0x44(7bit) +bool tyhx_write_reg(uint8_t i2c_addr,uint8_t reg_addr, uint8_t data) +{ + return 1; +} + +// i2c 读函数, 客户需填写 +uint8_t tyhx_read_regs(uint8_t i2c_addr,uint8_t reg_addr,uint8_t *readbuf,uint8_t readlen) +{ + return 0; +} + +bool tyhx_timer_start(uint32_t ms) +{ + return 1; +} +bool tyhx_timer_stop(uint32_t ms) +{ + return 1; +} \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrv_agc.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrv_agc.c index 2147396b8..1bf291643 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrv_agc.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hrv_agc.c @@ -433,9 +433,9 @@ void hx3695_hrv_low_power(void) // hx3695_write_reg(0X21, 0x00); // fifo int sel,00=FIFO INT config clear hx3695_write_reg(0X38, 0x081); // 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 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 70776a545..74b0be626 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_spo2_agc.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_spo2_agc.c @@ -1047,7 +1047,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 NULL; + return 0; } data_count = hx3695_read_fifo_data(s_buf,spo2_phase_num,1); @@ -1082,25 +1082,25 @@ uint8_t hx3695_spo2_read(spo2_sensor_data_t * s_dat) ir_buf2[i] = Ir_src_data2; //SEGGER_RTT_printf(0,"G_LEDDAC: %d,R_LEDDAC: %d\r\n", calReg_SPO2.R_LEDDAC,cal.R_LEDDAC); - //DEBUG_PRINTF(0,"%d/%d %d %d %d %d %d %d %d %d\r\n" ,1+i,data_count,\ - green_buf[i],red_buf[i],ir_buf[i],s_buf[i*4],s_buf[i*4+1],s_buf[i*4+2],s_buf[i*4+3],spo2_wear_status); + //DEBUG_PRINTF(0,"%d/%d %d %d %d %d %d %d %d %d\r\n" ,1+i,data_count, + // green_buf[i],red_buf[i],ir_buf[i],s_buf[i*4],s_buf[i*4+1],s_buf[i*4+2],s_buf[i*4+3],spo2_wear_status); -// SEGGER_RTT_printf(0,"fifo_data: %d/%d %d %d %d %d\r\n", i+1,data_count,s_buf[i*4],\ -// s_buf[i*4+1],s_buf[i*4+2],s_buf[i*4+3]); +// SEGGER_RTT_printf(0,"fifo_data: %d/%d %d %d %d %d\r\n", i+1,data_count,s_buf[i*4], + // s_buf[i*4+1],s_buf[i*4+2],s_buf[i*4+3]); if(spo2_wear_status==MSG_SPO2_WEAR) { if(hx3695_spo2_check_unwear(Ir_wear_value)) //Ir_src_data2 { - return NULL; + return 0; } } else { if(hx3695_spo2_check_wear(Ir_wear_value)) { - return NULL; + return 0; } } } diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/libhx3695.a b/code/sdk/drivers/peripheral/ppg/hx3695/libhx3695.a new file mode 100644 index 000000000..4ef4b515d Binary files /dev/null and b/code/sdk/drivers/peripheral/ppg/hx3695/libhx3695.a differ diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_alg.h b/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_alg.h index a29318192..b693581dd 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_alg.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_alg.h @@ -3,7 +3,7 @@ #define _TYHX_HRS_ALG_H_ #include - +#if 0 /* portable 8-bit unsigned integer */ typedef unsigned char uint8_t; /* portable 8-bit signed integer */ @@ -16,7 +16,7 @@ typedef signed short int int16_t; typedef unsigned int uint32_t; /* portable 32-bit signed integer */ typedef signed int int32_t; - +#endif #ifndef bool #define bool unsigned char #endif diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_custom.h b/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_custom.h new file mode 100644 index 000000000..133cd2543 --- /dev/null +++ b/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrs_custom.h @@ -0,0 +1,63 @@ +#ifndef __TYHX_HRS_CUSTOM_H__ +#define __TYHX_HRS_CUSTOM_H__ + +#include "debug_print.h" +typedef struct { + int32_t leak_green; + int32_t leak_red; + int32_t leak_ir; + int32_t card_green; + int32_t card_red; + int32_t card_ir; + int32_t hr_living; + int32_t hr_living_qu; + int32_t hr_living_std; + int32_t lastesthrs; + int32_t lastestspo2; + int32_t lastesthrv; + int32_t wearstatus; +} FT_CUSTOM_RESULTS_t; + +extern FT_CUSTOM_RESULTS_t hrsresult; +#define TYHX_DEBUG + +#ifdef TYHX_DEBUG +#define TYHX_LOG(fmt, ...) \ + do { \ + PRINT(fmt"\r\n", ##__VA_ARGS__); \ + } while (0) +#else +#define TYHX_LOG(ftm, ...) +#endif + + +#define CHIP_HX3695 +#define HRS_ALG_LIB +#define SPO2_ALG_LIB +#define HRV_ALG_LIB +#define CHECK_TOUCH_LIB +// #define HRS_BLE_APP +// #define INT_MODE + +#define I2C_DEV_8ADDR 0X44 + +// us 延时函数, 客户需填写 +void tyhx_delay_us(uint32_t us); +void tyhx_delay_ms(uint32_t ms); + +// i2c 写函数, 客户需填写, 地址0x44(7bit) +bool tyhx_write_reg(uint8_t i2c_addr,uint8_t reg_addr, uint8_t data); + +// i2c 读函数, 客户需填写 +uint8_t tyhx_read_regs(uint8_t i2c_addr,uint8_t reg_addr,uint8_t *readbuf,uint8_t readlen); + +typedef enum{ + TYHX_TIMER_40MS, + TYHX_TIMER_320MS, +} TYHX_TIMER_TYPE; + +bool tyhx_timer_start(uint32_t ms); +bool tyhx_timer_stop(uint32_t ms); + + +#endif //__TYHX_HRS_CUSTOM_H__ \ No newline at end of file diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrv_alg.h b/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrv_alg.h index 4d5cd36bf..116e27889 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrv_alg.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_hrv_alg.h @@ -3,7 +3,7 @@ #endif #include - +#if 0 /* portable 8-bit unsigned integer */ typedef unsigned char uint8_t; /* portable 8-bit signed integer */ @@ -16,7 +16,7 @@ typedef signed short int int16_t; typedef unsigned int uint32_t; /* portable 32-bit signed integer */ typedef signed int int32_t; - +#endif #ifndef bool #define bool unsigned char #endif diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_spo2_alg.h b/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_spo2_alg.h index c6a83eea9..e330cc6f0 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_spo2_alg.h +++ b/code/sdk/drivers/peripheral/ppg/hx3695/tyhx_spo2_alg.h @@ -7,7 +7,7 @@ //#include "tyhx_spo2_alg_para.h" - +#if 0 /* portable 8-bit unsigned integer */ typedef unsigned char uint8_t; /* portable 8-bit signed integer */ @@ -20,6 +20,7 @@ typedef signed short int int16_t; typedef unsigned int uint32_t; /* portable 32-bit signed integer */ typedef signed int int32_t; +#endif #ifndef bool #define bool unsigned char