From: penglei <1624952103@qq.com> Date: Tue, 29 Jul 2025 01:44:33 +0000 (+0800) Subject: 移植原相心率驱动,光电编码器服务,去除VC心率驱动 X-Git-Tag: leiniao_debug_1.0.0_20250922_020716~210^2~2^2 X-Git-Url: http://git.snicker.com.cn/css/static/gitweb.css?a=commitdiff_plain;h=refs%2Fchanges%2F2015%2Fhead;p=mirrors%2FFD230.git 移植原相心率驱动,光电编码器服务,去除VC心率驱动 --- diff --git a/autobuild.sh b/autobuild.sh index bad237134..5ab4a35f1 100644 --- a/autobuild.sh +++ b/autobuild.sh @@ -121,6 +121,16 @@ RECOVERY_NAME=$APPLICATION_NAME-r SSB_NAME=$APPLICATION_NAME-ssb BUILD_NAME=_L22 fi + +if [ "$1" == "n9" ] +then +TARGET_PACK_NAME=pack_brandy_native_js_n9 +APPLICATION_NAME=brandy-native-js-n9 +RECOVERY_NAME=brandy-native-js-n9-r +SSB_NAME=brandy-native-js-n9-ssb +BUILD_NAME=_N9 +fi + if [ "$1" == "hso" ] then HSO_BUILD=hso diff --git a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c index 5c44a742d..544b35ba2 100644 --- a/code/sdk/application/brandy/brandy_standard/thread_pri_init.c +++ b/code/sdk/application/brandy/brandy_standard/thread_pri_init.c @@ -128,6 +128,10 @@ #include "bp_service.h" #endif +#ifdef ROTARYENCODER_MIXO +#include "mixo_service.h" +#endif + #define EMMC_BASE_ADDR 0x52062000 #define TASK_PRIORITY_APP (osPriority_t)(17) #define TICK_TEN_MS (10U) @@ -531,7 +535,9 @@ static void thread_main(const void *unused) // custom_i2c_init(I2C_BUS_3); // custom_i2c_init(I2C_BUS_0); custom_i2c_init(I2C_BUS_2); - +#ifdef ROTARYENCODER_MIXO + uapi_mixo_service_init(); +#endif #ifdef SUPORT_MAG_SERVICE uapi_mag_service_init(); #endif diff --git a/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-n9/libuikit_fwk.a b/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-n9/libuikit_fwk.a new file mode 100644 index 000000000..b1ab9d2d0 Binary files /dev/null and b/code/sdk/application/wearable/fd230/nativeapp/brandy-native-js-n9/libuikit_fwk.a differ diff --git a/code/sdk/application/wearable/fd230/nativeapp/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp b/code/sdk/application/wearable/fd230/nativeapp/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp index 22d65b3b7..fba8330b8 100644 --- a/code/sdk/application/wearable/fd230/nativeapp/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp +++ b/code/sdk/application/wearable/fd230/nativeapp/nativeui/alarmclocktimerconfig/src/AlarmClockTimerConfig.cpp @@ -36,7 +36,7 @@ #include "record/include/RecordingPlayerView.h" #include "custom_utils.h" #include "alarm/include/AlarmClockModel.h" -#ifdef CYWEE_SPORT +#ifdef SUPPORT_CYWEE_SERVICE #include "cywee_service.h" #endif @@ -118,9 +118,9 @@ extern "C" sedentary_switch = get_sedentary_switch_from_config_model(); sedentary_time = get_sedentary_time_from_config_model(); sedentary_interval = get_sedentary_interval_from_config_model(); - #ifdef CYWEE_SPORT +#ifdef SUPPORT_CYWEE_SERVICE do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SET_SEDENTARY_INTERVAL, &sedentary_interval); // 设置久坐提醒间隔 - #endif +#endif // sedentary_start_hour = (sedentary_time & 0XFF000000) >> 24; // sedentary_start_min = (sedentary_time & 0X00FF0000) >> 16; @@ -371,9 +371,9 @@ extern "C" if (curTime.tm_sec % 60 == 0) { - #ifdef CYWEE_SPORT +#ifdef SUPPORT_CYWEE_SERVICE do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CHECK_ACC, NULL); // 一分钟检查一次gsensor是否停止 - #endif +#endif } if (curTime.tm_min % 60 == 0 && curTime.tm_sec == 0) @@ -544,12 +544,12 @@ extern "C" // 设置状态为小睡 uapi_dev_runtime_set_nap_status(0); // 清零小睡状态 uapi_dev_runtime_set_absolute_static_status(0); // 清零绝对静止状态 - #ifdef SUPPORT_PPG_SERVICE - set_keep_in_wear_det_mode(1); // 开启小睡佩戴监测 - #endif - #ifdef CYWEE_SPORT +#ifdef SUPPORT_PPG_SERVICE + set_keep_in_wear_det_mode(1); // 开启小睡佩戴监测 +#endif +#ifdef SUPPORT_CYWEE_SERVICE do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NAP_SEDENTARY_MODE, NULL); // 算法底层切换小睡监测模式 - #endif +#endif time_sync_flag = 0; } } @@ -563,12 +563,12 @@ extern "C" // if(uapi_dev_runtime_get_nap_monitoring_status() == 1) // uapi_clean_sleep_flag(); // 清除睡眠标志文件 // OHOS::create_sleep_folder(); // 创建睡眠文件夹 - #ifdef SUPPORT_PPG_SERVICE +#ifdef SUPPORT_PPG_SERVICE set_keep_in_wear_det_mode(0); - #endif - #ifdef CYWEE_SPORT +#endif +#ifdef SUPPORT_CYWEE_SERVICE do_cywee_service_check_msg(CYWEE_SERVICE_CMD_GET_SLEEP_DATA, &cmd); // 强制获取小睡数据,结束小睡 - #endif +#endif // 睡眠弹窗 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "要睡觉啦!"); @@ -585,9 +585,9 @@ extern "C" WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "要睡觉啦!!!! 结束"); } - #ifdef CYWEE_SPORT +#ifdef SUPPORT_CYWEE_SERVICE do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SLEEPING_MODE, NULL); // 算法底层切换睡眠监测模式 - #endif +#endif time_sync_flag = 0; } } diff --git a/code/sdk/bootloader/flashboot/brandy/nandflash/nandflash_config.c b/code/sdk/bootloader/flashboot/brandy/nandflash/nandflash_config.c index 380ec0ffa..ecdf1fcee 100644 --- a/code/sdk/bootloader/flashboot/brandy/nandflash/nandflash_config.c +++ b/code/sdk/bootloader/flashboot/brandy/nandflash/nandflash_config.c @@ -15,6 +15,7 @@ #include "hal_nandflash.h" #include "nandflash_ds35x1g.h" #include "nandflash_w25n01g.h" +#include "nandflash_f35uqa001g.h" #include "nandflash_inner.h" #include "nandflash.h" #include "hal_nandflash.h" diff --git a/code/sdk/build/config/target_config/brandy/config.py b/code/sdk/build/config/target_config/brandy/config.py index a0e2ce53b..ca626bc35 100644 --- a/code/sdk/build/config/target_config/brandy/config.py +++ b/code/sdk/build/config/target_config/brandy/config.py @@ -923,7 +923,128 @@ target = { 'CFG_FLASH_SIZE=8', 'NANDFLASH_F35UQA' ] - } + }, + ################# N9 ############################ + 'brandy-native-js-n9': { + 'base_target_name': 'brandy-native-js', + 'defines': [ + 'BOARD_N9', + 'FT_SINGLE_UART', + 'CONFIG_EFUSE_READ_TO_RAM', + 'CUSTOM_UTILS', + # 'CUSTOM_HID_SERVICE', + # 'WEARABLE_LOG_DEBUG', + 'SUPPORT_RC_CALIBRATION', + 'VIB_USE_PWM', + 'CONFIG_PWM_SUPPORT', + # 'ACC_LIS2DOC', + 'ENABLE_CUSTOM_I2C', + #'ENABLE_VIBRATOR', + # 'ENABLE_SLIP', + 'ENCODER_SUPPORT', + # 'SUPPORT_SPO2_NOTIFICATION', + # 'SUPPORT_SPO2_NOTIFICATION_TEST', + 'SUPPORT_DEVICE_PAIRING_NOTIFICATION', + # 'ENABLE_FONT_VECTOR_GLOBAL', + # 'ENABLE_SHAPING', + 'SUPPORT_CHARGER_PLUG_DETECTION_NOTIFICATION', + # 'SUPPORT_AT_CUSTOMUTILS', + 'SUPPORT_BLE_SERVICE', + 'SUPPORT_PPG_SERVICE', + 'SUPPORT_CYWEE_SERVICE', + 'SUPPORT_BATTERY_SERVICE', + 'FD230', + # 'SUPPORT_AUTO_OTA_SERVER', + # 'CONFIG_DFX_SUPPORT_DIAG_UP_MACHINE=1', + #"MEM_CHECK", + #'ENABLE_WEBSOCKET', + 'CYWEE_MAC_ACTIVE', + 'SUPPORT_CAT1_SERVICE', + #'SUPPORT_TCPIP', + #'SUPPORT_HID_SERVICE', + 'SUPPORT_BAIDU_MAP', + 'CFG_FLASH_SIZE=16', + 'SINGLE_USER_PARTITION', + 'TPTYPE_CST86XX', + 'ROTARYENCODER_MIXO', + 'NANDFLASH_F35UQA', + 'BLE_INSTRUCT', + 'PPG_PAH8009', + # 'AILPAY_SUPPORT', + # 'FACTORYTEST_SERVICE', + # 'MEMORY_CORRUPTION', + + ], + #添加自定义应用 + 'ram_component': [ + 'audio_at_service', + 'media_at_service', + 'bt_manager_at_service', + "ppg_sensor_pah8009", + # "ppgBleService", + "mag_sensor_mmc5603", + "vibrator", + "vibrator_service", + "-:lwip", + "cat1Service", + "cat1Test", + "audio_manager", + "CustomUIcomponentTool", + "nativeabilityfwk", + "custom_utils", + "custom_utilscpp", + "custom_config", + "rotary_encoder", + "nativelauncher", + "ppg_service", + "cywee_service", + "batterry_service", + "bleservice", + "blemoder", + "transspecard", + "factorytest_service", + # "hid_service", + "producttest", + "ppg_hal", + "mag_hal", + "mag_service", + "cywee_dml", + #"cyweeBleService", + ], + 'image_analysis': False, + 'fs_image_path':'fd230', + # 'fs_image_path':'evb', + 'fs_image': True + }, + 'brandy-native-js-n9-r': { + 'base_target_name': 'brandy-native-js-r', + #自定义配置项,选择硬件及功能参数 + 'defines': [ + 'BOARD_N9', + 'FT_SINGLE_UART', + 'CFG_FLASH_SIZE=16', + 'FD230', + 'SINGLE_USER_PARTITION', + 'TPTYPE_CST86XX', + 'NANDFLASH_F35UQA' + ], + 'ram_component': ["at_cmd"] + }, + 'brandy-native-js-n9-ssb': { + 'base_target_name': 'brandy-ssb', + #自定义配置项,选择硬件及功能参数 + 'defines': [ + 'CFG_FLASH_SIZE=16', + 'FD230', + 'BOARD_N9', + 'FT_SINGLE_UART', + 'ENABLE_ECC', + 'CFG_DRIVERS_NANDFLASH', + 'SINGLE_USER_PARTITION', + 'GPIO_POWERON_FLASH', + 'NANDFLASH_F35UQA' + ] + }, } target_group = { @@ -940,6 +1061,7 @@ target_group = { 'pack_brandy_native_js_fd230': ['brandy-native-js-fd230-ssb', 'brandy-native-js-fd230-r', 'brandy-native-js-fd230'], 'pack_brandy_native_js_u8': ['brandy-native-js-u8-ssb', 'brandy-native-js-u8-r', 'brandy-native-js-u8'], 'pack_brandy_native_js_w9': ['brandy-native-js-w9-ssb', 'brandy-native-js-w9-r', 'brandy-native-js-w9'], + 'pack_brandy_native_js_n9': ['brandy-native-js-n9-ssb', 'brandy-native-js-n9-r', 'brandy-native-js-n9'], 'pack_brandy_native_js_lt22': ['brandy-native-js-lt22-ssb', 'brandy-native-js-lt22-r', 'brandy-native-js-lt22'], 'pack_brandy_native_js_xts': ['brandy-native-js-xts-ssb', 'brandy-native-js-xts-r', 'brandy-native-js-xts'], diff --git a/code/sdk/drivers/chips/brandy/porting/pinctrl/pinctrl_porting_brandy.c b/code/sdk/drivers/chips/brandy/porting/pinctrl/pinctrl_porting_brandy.c index 970be6daa..815e04f6d 100644 --- a/code/sdk/drivers/chips/brandy/porting/pinctrl/pinctrl_porting_brandy.c +++ b/code/sdk/drivers/chips/brandy/porting/pinctrl/pinctrl_porting_brandy.c @@ -16,7 +16,7 @@ #include "board_fd230.h" #elif defined(BOARD_U8) #include "board_u8.h" -#elif defined(BOARD_W9) +#elif defined(BOARD_W9) || defined(BOARD_N9) #include "board_w9.h" #elif defined(BOARD_L22) #include "board_lt22.h" diff --git a/code/sdk/drivers/drivers/driver/touch/cst86xx_touch/cst86xx_touch1.c b/code/sdk/drivers/drivers/driver/touch/cst86xx_touch/cst86xx_touch1.c index b5e28b1fd..ec3a96128 100644 --- a/code/sdk/drivers/drivers/driver/touch/cst86xx_touch/cst86xx_touch1.c +++ b/code/sdk/drivers/drivers/driver/touch/cst86xx_touch/cst86xx_touch1.c @@ -407,7 +407,7 @@ void cst86xx_get_chip_id(uint16_t *chip_id) ext_errno ret = cst86xx_tp_i2c_data_read(CST86XX_HW_ID, chip_id, 1); if (ret != EXT_ERR_SUCCESS) { tp_err("configuration error (read chip id) 0x%x", ret); - return EXT_ERR_FAILURE; + return; } } diff --git a/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c b/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c index c344ceae2..b0a5e6a17 100644 --- a/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c +++ b/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.c @@ -510,11 +510,11 @@ void touch_screen_restart(void) uapi_gpio_enable_interrupt(TOUCH_INT_GPIO); // open tp_int gpio interrupt } -void touch_getid(uint16_t *id) +void touch_get_chip_id(uint16_t *id) { -#ifdef TPTYPE_FT6X46 - ft6x46_get_chip_id(id); -#elif defined TPTYPE_CST86XX +#ifdef TPTYPE_CST86XX cst86xx_get_chip_id(id); +#elif defined TPTYPE_FT6X46 + ft6x46_get_chip_id(id); #endif } \ No newline at end of file diff --git a/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.h b/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.h index b6c116da3..3624e1152 100644 --- a/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.h +++ b/code/sdk/drivers/drivers/driver/touch/touch_screen_drv.h @@ -1,3 +1,11 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-12-07 15:32:08 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-28 16:18:51 + * @FilePath: /FD230/code/sdk/drivers/peripheral/touch/touch_screen_drv.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ /* * Copyright (c) @CompanyNameMagicTag 2021-2022. All rights reserved. * Description: header of touch screen driver. @@ -26,8 +34,17 @@ struct ts_ops { uint32_t (*priv_operator)(struct ts_driver_data *udd); }; +#ifdef TPTYPE_FT6X46 +#define TP_CHIP_ID 0x6456 +#elif defined TPTYPE_CST86XX +#define TP_CHIP_ID 0xb7 +#else +#define TP_CHIP_ID 0 +#endif + ext_errno touch_screen_module_init(void); ext_errno touch_screen_module_deinit(void); ext_errno touch_info_process(void); +void touch_get_chip_id(uint16_t *id); #endif \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_data.h b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.h index 9449b920b..375eb81c4 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_data.h +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_data.h @@ -1,3 +1,11 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2025-05-20 11:51:23 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-23 14:02:35 + * @FilePath: /FD230/code/sdk/zhihui/drivers/cywee/dml/cywee_data.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ /** * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n * @@ -75,6 +83,7 @@ void cywee_calories_history_save(uint32_t time); void cywee_stand_history_save(uint32_t time); void cywee_restoreData(void); void cywee_save_data(void); +int32_t cywee_get_now_hour_data(void*value, uint8_t type); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c index 3943fed24..dd1a780d9 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_dml.c @@ -77,7 +77,7 @@ static char cywee_version[20] = {0}; static SLEEP_STAT_T sleep_stat[SLEEP_STATUS_LENGTH] = {0}; static inact_ext_result_t sleep_time = {0}; -// static NAP_T nap_data = {0}; +// static SLEEP_T nap_data = {0}; static int stat_num = 0; static int current_year = 0; static uint32_t fall_asleep_timestamp = 0; @@ -274,6 +274,58 @@ static void clean_sleep_data(void) wake_up_flag = 0; } + +void cywee_read_sleep_data(void) +{ + char day[12] = {0}; + uapi_get_YYMMDD_Time(day, '\0'); + + char file_path[64] = {0}; + sprintf_s(file_path, 64, SLEEP_TIME_PATH, day); + + FILE *fp = fopen(file_path, "rb"); + if (fp == NULL) + { + CWM_OS_dbgPrintf("read_sleep_data fopen fail %s \n",file_path); + return false; + } + + // 读取睡眠类型 + uint8_t sleep_type; + fread(&sleep_type, 1, 1, fp); + + if (sleep_type == 0) + { + fclose(fp); + return false; + } + + // 入睡时间 + uint32_t fall_asleep_timestamp; + fread(&fall_asleep_timestamp, 1, 4, fp); + + // 起床时间 + uint32_t wake_up_timestamp; + fread(&wake_up_timestamp, 1, 4, fp); + + // 睡眠总时间 + uint8_t total_time_hour, total_time_minute; + fread(&total_time_hour, 1, 1, fp); + fread(&total_time_minute, 1, 1, fp); + uint16_t total_time = total_time_hour * 60 + total_time_minute; + + // 累加睡眠数据 + sleep_data.fall_asleep_timestamp = fall_asleep_timestamp; + sleep_data.wake_up_timestamp = wake_up_timestamp; + sleep_data.total_time = total_time; + + sleep_update_timestamp = wake_up_timestamp; + + fclose(fp); + + return true; +} + static void cywee_set_sleep_time_data(inact_ext_result_t *sleep_data) { memset(&sleep_time, 0, sizeof(inact_ext_result_t)); @@ -358,11 +410,11 @@ static void cywee_save_sleep_time_data(void) ephemeral_flag = 0; } - // CWM_OS_dbgPrintf("wake_up_timestamp : %d ,fall_asleep_timestamp : %d \n",wake_up_timestamp,fall_asleep_timestamp); - // CWM_OS_dbgPrintf("total_time[%d], total_deep_sleep_time[%d], total_mild_sleep_time[%d], total_rem_sleep_time[%d], total_wake_time[%d] \n", - // total_time,total_deep_sleep_time,total_mild_sleep_time,total_rem_sleep_time,total_wake_time); + CWM_OS_dbgPrintf("wake_up_timestamp : %d ,fall_asleep_timestamp : %d \n",wake_up_timestamp,fall_asleep_timestamp); + CWM_OS_dbgPrintf("total_time[%d], total_deep_sleep_time[%d], total_mild_sleep_time[%d], total_rem_sleep_time[%d], total_wake_time[%d] \n", + total_time,total_deep_sleep_time,total_mild_sleep_time,total_rem_sleep_time,total_wake_time); - update_sleep_data(fall_asleep_timestamp,wake_up_timestamp,total_time); + // update_sleep_data(fall_asleep_timestamp,wake_up_timestamp,total_time); } @@ -498,7 +550,7 @@ static void cywee_save_nap_time_data(void) uint8_t total_time_minute = (total_time % 60); fwrite(&total_time_minute, 1, 1, fp); - // CWM_OS_dbgPrintf("save_nap_sleep_data succ \n"); + CWM_OS_dbgPrintf("save_nap_sleep_data succ \n"); fclose(fp); @@ -892,7 +944,7 @@ void cywee_oncharging_update(int oncharging_status) void cywee_wearstatus_update(int wearstatus) { -#if 1 +#if 0 uapi_dev_runtime_set_wear_status(wearstatus); memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT)); csd.sensorType = CUSTOM_OFFBODY_DETECT; @@ -976,7 +1028,7 @@ void cywee_inactivity_mode_change(int mode) //久坐、有效站立和小睡 case INACTIVITY_MODE_SEDENTARY_AND_NAP: - // CWM_OS_dbgPrintf("INACTIVITY_MODE_SEDENTARY_AND_NAP\r\n"); + CWM_OS_dbgPrintf("INACTIVITY_MODE_SEDENTARY_AND_NAP\r\n"); memset(&scl, 0, sizeof(scl)); scl.iData[0] = 1; scl.iData[1] = 3; @@ -1193,7 +1245,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { if((int)sensorEVT->fData[1] == CUSTOM_OFFBODY_DETECT) { CWM_OS_dbgPrintf("CUSTOM_OFFBODY_DETECT !!! \r\n"); -#if 1 +#if 0 if((int)sensorEVT->fData[2] == 1) { #ifdef SUPPORT_PPG_SERVICE @@ -1358,6 +1410,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { }else if((int)sensorEVT->fData[0] == 22){ + CWM_OS_dbgPrintf("sensorEVT->fData[0] == 22\n"); memset(&c_inact_result_t,0,sizeof(inact_result_t)); c_inact_result_t.output_number = (int)sensorEVT->fData[0]; @@ -1380,6 +1433,8 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { uapi_get_timestampe_ss_extend(&wake_up_timestamp,current_year,c_inact_result_t.month,c_inact_result_t.day,c_inact_result_t.hour,c_inact_result_t.minute,0); nap_update_timestamp = wake_up_timestamp; } + CWM_OS_dbgPrintf("fall_asleep_timestamp : %d\n,fall_asleep_timestampn"); + CWM_OS_dbgPrintf("nap_update_timestamp : %d\n,nap_update_timestamp"); // cywee_func(CYWEE_MSG_TYPE_INACTIVITY_UPDATE,&c_inact_result_t,sizeof(inact_result_t)); }else if((int)sensorEVT->fData[0] == 32){ diff --git a/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h index 454b6620e..2072b2aa3 100644 --- a/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h +++ b/code/sdk/zhihui/drivers/cywee/dml/cywee_hal.h @@ -143,13 +143,6 @@ typedef struct } SLEEP_STAT_T; -typedef struct -{ - uint32_t fall_asleep_timestamp; // 入睡 - uint32_t wake_up_timestamp; // 出睡 - uint16_t total_time; // 总时长 -} NAP_T; - typedef struct { uint32_t fall_asleep_timestamp; // 入睡 diff --git a/code/sdk/zhihui/drivers/cywee/service/cywee_service.c b/code/sdk/zhihui/drivers/cywee/service/cywee_service.c index 3d0389997..227684ab8 100644 --- a/code/sdk/zhihui/drivers/cywee/service/cywee_service.c +++ b/code/sdk/zhihui/drivers/cywee/service/cywee_service.c @@ -326,18 +326,18 @@ static void cywee_service_check_task(void const *arg) break; case CYWEE_SERVICE_CMD_SEDENTARY_MODE: - // cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY); + cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY); break; case CYWEE_SERVICE_CMD_NAP_MODE: - // cywee_inactivity_mode_change(INACTIVITY_MODE_NAP); + cywee_inactivity_mode_change(INACTIVITY_MODE_NAP); case CYWEE_SERVICE_CMD_NAP_SEDENTARY_MODE: - // cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY_AND_NAP); + cywee_inactivity_mode_change(INACTIVITY_MODE_SEDENTARY_AND_NAP); break; case CYWEE_SERVICE_CMD_SLEEPING_MODE: - // cywee_inactivity_mode_change(INACTIVITY_MODE_SLEEPING); + cywee_inactivity_mode_change(INACTIVITY_MODE_SLEEPING); break; case CYWEE_SERVICE_CMD_OPEN_HAND_UPDOWN: @@ -369,7 +369,7 @@ static void cywee_service_check_task(void const *arg) break; case CYWEE_SERVICE_CMD_SAVE_DATA: - // cywee_save_data(); + cywee_save_data(); break; case CYWEE_SERVICE_CMD_SET_SEDENTARY_INTERVAL: diff --git a/code/sdk/zhihui/drivers/ppg/CMakeLists.txt b/code/sdk/zhihui/drivers/ppg/CMakeLists.txt index 271ddd2e8..e90ddc98c 100644 --- a/code/sdk/zhihui/drivers/ppg/CMakeLists.txt +++ b/code/sdk/zhihui/drivers/ppg/CMakeLists.txt @@ -1,7 +1,6 @@ add_subdirectory_if_exist(service) add_subdirectory_if_exist(hx3695) add_subdirectory_if_exist(ppgBleService) -add_subdirectory_if_exist(vc9202) -add_subdirectory_if_exist(vc921x) +add_subdirectory_if_exist(pah8009) add_subdirectory_if_exist(gh3x2x) add_subdirectory_if_exist(hal) \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c index f6d9d9868..ed35c71a2 100644 --- a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c +++ b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-03-13 15:08:38 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-15 12:13:56 + * @LastEditTime: 2025-07-28 17:37:22 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c * @Description: * @@ -35,6 +35,7 @@ #ifdef PPG_GH3X2X #include "gh3x2x_afe_drv.h" +// #include "gh_demo.h" #endif @@ -48,6 +49,7 @@ // S_AGPIO_R0 PRG_LED_POWER ON 心率等电源控制脚 #define GPIO_PIN_PRG_LED_ON S_AGPIO_R0 + void ppg_power_on(void) { // printf("ppg_power_on\n"); @@ -79,8 +81,11 @@ uint8_t ppg_get_hrs(void) uint8_t hrs = 0; #ifdef PPG_HX3695 hrs = hx3695_get_hrs(); - // printf("ppg_get_hrs : %d\n",hrs); +#elif defined PPG_PAH8009 + hrs = pah8009_get_hrs(); #endif + + printf("ppg_get_hrs : %d\n",hrs); return hrs; } @@ -89,6 +94,8 @@ uint8_t ppg_get_spo2(void) uint8_t spo2 = 0; #ifdef PPG_HX3695 spo2 = hx3695_get_spo2(); +#elif defined PPG_PAH8009 + spo2 = pah8009_get_spo2(); #endif return spo2; } @@ -98,14 +105,16 @@ uint8_t ppg_get_wear_status(void) uint8_t wear_status = 0; #ifdef PPG_HX3695 wear_status = hx3695_get_wear_status(); +#elif defined PPG_PAH8009 + wear_status = pah8009_get_wear_status(); #endif return wear_status; } uint16_t ppg_get_chip_id(void) { - ppg_power_on(); uint16_t chip_id = 0; + ppg_power_on(); #ifdef PPG_HX3695 chip_id = hx3695_chip_check(); #elif defined PPG_PAH8009 @@ -137,9 +146,6 @@ void ppg_int_handler(void) { #ifdef PPG_PAH8009 pah8009_int_handler(); -#elif defined PPG_PAH8009 - hal_gh3x2x_afe_int_handler_call_back(); - GH3X2X_AFE_ChipPro(); #endif } @@ -153,16 +159,18 @@ void ppg_send_cmd_to_driver(char* mode, uint8_t enable) #elif defined PPG_PAH8009 pah8009_control(mode,enable); #elif defined PPG_GH3X2X - gh3x2x_control(mode,enable); + // gh3x2x_control(mode,enable); #endif if(!enable) ppg_power_off(); + + } void ppg_get_leaklight_data(uint32_t *ch0,uint32_t *ch1,uint32_t *ch2) { #ifdef PPG_HX3695 - hx3695_get_factory_data(ch0,ch1,ch2); + hx3695_get_leaklight_data(ch0,ch1,ch2); #elif defined PPG_VC9202 vc9202_get_leaklight_data(ch0,ch1,ch2); #elif defined PPG_PAH8009 @@ -170,13 +178,21 @@ void ppg_get_leaklight_data(uint32_t *ch0,uint32_t *ch1,uint32_t *ch2) #endif } -uint32_t ppg_get_factory_data(void) +int32_t ppg_get_factory_data(void) { - uint32_t data = 0; + int32_t data = 0; #ifdef PPG_PAH8009 data = pah8009_get_factory_data(); #elif defined PPG_HX3695 - + data = hx3695_get_factory_data(); #endif return data; } + +void ppg_check_int(void) +{ +#ifdef PPG_HX3695 +#elif defined PPG_PAH8009 + pah8009_check_int(); +#endif +} diff --git a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h index ad98eb73c..aef8c3944 100644 --- a/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h +++ b/code/sdk/zhihui/drivers/ppg/hal/ppg_hal.h @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-07 11:18:26 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-09 16:12:34 + * @LastEditTime: 2025-07-28 16:41:38 * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/ppg/ppg_hal.h * @Description: * @@ -35,6 +35,17 @@ extern "C" { typedef uint32_t PPG_CMD_TYPE_T ; +typedef enum{ + PPG_MSG_TYPE_HRS_UPDATE, + PPG_MSG_TYPE_HRV_UPDATE, + PPG_MSG_TYPE_SPO2_UPDATE, + PPG_MSG_TYPE_WEARSTAT_UPDATE, + PPG_MSG_TYPE_STATIC_HRS_UPDATE, +} ppg_msg_type_t; + +typedef void (*ppg_msg_callback_t)(uint8_t msg_type, uint8_t *msg_data, int32_t msg_datalen); +uint32_t ppg_register_msg_callback(ppg_msg_callback_t func); +ppg_msg_callback_t ppg_get_send_msg_callback_func(void); void ppg_send_cmd_to_driver(char* mode, uint8_t enable); void ppg_timer_handler(uint8_t mode); @@ -47,7 +58,9 @@ void ppg_power_on(void); void ppg_power_off(void); void ppg_int_handler(void); void ppg_get_leaklight_data(uint32_t *ch0,uint32_t *ch1,uint32_t *ch2); -uint32_t ppg_get_factory_data(void); +int32_t ppg_get_factory_data(void); +void ppg_ble_send(uint8_t hr); +void ppg_check_int(void); #ifdef __cplusplus #if __cplusplus diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/CMakeLists.txt b/code/sdk/zhihui/drivers/ppg/pah8009/CMakeLists.txt new file mode 100644 index 000000000..6f44d7ee0 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/CMakeLists.txt @@ -0,0 +1,57 @@ +#=============================================================================== +# @brief cmake file +# Copyright (c) @CompanyNameMagicTag 2022-2023. All rights reserved. +#=============================================================================== +set(COMPONENT_NAME "ppg_sensor_pah8009") + +set(SOURCES ${SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/sensor/pah_800x.c + ${CMAKE_CURRENT_SOURCE_DIR}/sensor/pah800x_bsp.c + ${CMAKE_CURRENT_SOURCE_DIR}/sensor/pah800x_main.c + ${CMAKE_CURRENT_SOURCE_DIR}/factory/pah800x_factory_test.c + ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/pah_hr/V303009/test_library_HRD.c +) +set(PUBLIC_HEADER + ${CMAKE_CURRENT_SOURCE_DIR}/sensor + ${CMAKE_CURRENT_SOURCE_DIR}/factory + ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/pah_spo2/V703 + ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/pah_stress/V6033 + ${CMAKE_CURRENT_SOURCE_DIR}/algorithm/pah_hr/V303009 +) + +set(PRIVATE_HEADER +) + +set(PRIVATE_DEFINES +) + +set(PUBLIC_DEFINES + +) + +# use this when you want to add ccflags like -include xxx +set(COMPONENT_PUBLIC_CCFLAGS +) + +set(COMPONENT_CCFLAGS +) + +set(WHOLE_LINK + true +) + +set(MAIN_COMPONENT + false +) + +if("PPG_PAH8009" IN_LIST DEFINES) + +find_library(LIB_PATH_SPO2 algorithm/pah_spo2/V703/libv703_0_1.a ${CMAKE_CURRENT_SOURCE_DIR}) +find_library(LIB_PATH_HR algorithm/pah_hr/V303009/libv307009_4.a ${CMAKE_CURRENT_SOURCE_DIR}) + +target_link_libraries(${TARGET_NAME} PRIVATE -Wl,--whole-archive ${LIB_PATH_HR} ${LIB_PATH_SPO2} PRIVATE -Wl,--whole-archive) + +endif() + +build_component() + diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/MEMS_INT/Interrupt_function.c b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/MEMS_INT/Interrupt_function.c new file mode 100644 index 000000000..6c91bba23 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/MEMS_INT/Interrupt_function.c @@ -0,0 +1,12 @@ +#include "pxi_interp.h" + + +void PXI_MEMS_interp(int16_t *src_data, size_t src_data_count, int16_t *dst_data, size_t dst_data_count) +{ + pxi_interp_ex1(src_data, src_data_count ,dst_data,dst_data_count ,3); + pxi_interp_ex1(&src_data[1], src_data_count ,&dst_data[1],dst_data_count ,3); + pxi_interp_ex1(&src_data[2], src_data_count ,&dst_data[2],dst_data_count ,3); +} + + + diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/MEMS_INT/pxi_interp.c b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/MEMS_INT/pxi_interp.c new file mode 100644 index 000000000..36ed8cd8c --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/MEMS_INT/pxi_interp.c @@ -0,0 +1,42 @@ +#include "pxi_interp.h" + + +/***** +* @brief Example of Platform. In this function we initialize powerkey and register callback. +* @param None. +* @return None. +* +*****/ + +void pxi_interp_ex1(int16_t *src_data, size_t src_data_count, int16_t *dst_data, size_t dst_data_count, size_t offset) +{ + float pre_time_acc = 0.0f; + float time_acc = 0.0f; + float d_time = (float)dst_data_count / src_data_count; + size_t idx_ptr = 0; + + for (size_t i = 0; i < dst_data_count; ++i) + { + while (time_acc < (float)i) + { + pre_time_acc = time_acc; + time_acc = time_acc + d_time; + idx_ptr++; + } + + if (idx_ptr == 0) + { + dst_data[i * offset] = src_data[idx_ptr * offset]; + } + else if (idx_ptr == dst_data_count) + { + dst_data[i * offset] = src_data[(idx_ptr - 1) * offset]; + } + else + { + float time_ratio = ((float)i - pre_time_acc) / (time_acc - pre_time_acc); + dst_data[i * offset] = (int16_t)((float)src_data[(idx_ptr - 1) * offset] * (1.0f - time_ratio) + (float)src_data[idx_ptr * offset] * time_ratio + 0.5f); + } + } +} + diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/MEMS_INT/pxi_interp.h b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/MEMS_INT/pxi_interp.h new file mode 100644 index 000000000..15c4149b5 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/MEMS_INT/pxi_interp.h @@ -0,0 +1,7 @@ +//#pragma once + +#include +#include + +void pxi_interp_ex1(int16_t *src_data, size_t src_data_count, int16_t *dst_data, size_t dst_data_count, size_t offset); +void PXI_MEMS_interp(int16_t *src_data, size_t src_data_count, int16_t *dst_data, size_t dst_data_count); diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/libv307009_4.a b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/libv307009_4.a new file mode 100644 index 000000000..d0d7a954f Binary files /dev/null and b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/libv307009_4.a differ diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/pah8009_testpattern_HRD.h b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/pah8009_testpattern_HRD.h new file mode 100644 index 000000000..44b62ae41 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/pah8009_testpattern_HRD.h @@ -0,0 +1,23944 @@ +#ifndef _PAH8009_TESTPATTERN_ +#define _PAH8009_TESTPATTERN_ + +#include +#define NF_PPG_CHANNEL 3 +#define NF_PPG_PER_CHANNEL 3 +static const int32_t PAH8009_rawdata_HRD[][NF_PPG_PER_CHANNEL*NF_PPG_CHANNEL] = +{ +{0, 123629, 5910}, +{0, 118569, 5918}, +{0, 113318, 5916}, +{0, 106371, 5944}, +{0, 105522, 5928}, +{0, 96770, 5938}, +{0, 91486, 5928}, +{0, 86122, 5918}, +{0, 81476, 5906}, +{0, 80788, 5908}, +{0, 80266, 5904}, +{0, 79770, 5909}, +{0, 79298, 5908}, +{0, 78950, 5892}, +{0, 78704, 5900}, +{0, 78700, 5897}, +{0, 78620, 5897}, +{0, 78202, 5900}, +{0, 77595, 5903}, +{0, 77266, 5899}, +{0, 77183, 5888}, +{0, 77194, 5893}, +{0, 77168, 5884}, +{0, 76801, 5883}, +{0, 76396, 5875}, +{0, 75904, 5877}, +{0, 75403, 5886}, +{0, 74506, 5860}, +{0, 72984, 5866}, +{0, 71718, 5857}, +{0, 70789, 5854}, +{0, 70106, 5851}, +{0, 69559, 5845}, +{0, 69000, 5840}, +{0, 68416, 5827}, +{0, 67926, 5840}, +{0, 67615, 5840}, +{0, 67369, 5826}, +{0, 66701, 5816}, +{0, 65556, 5820}, +{0, 64648, 5827}, +{0, 63936, 5806}, +{0, 63453, 5806}, +{0, 63170, 5815}, +{0, 62967, 5818}, +{0, 62761, 5801}, +{0, 62594, 5806}, +{0, 62541, 5807}, +{0, 62525, 5799}, +{0, 62088, 5792}, +{0, 61096, 5784}, +{0, 60432, 5782}, +{0, 60066, 5777}, +{0, 59871, 5789}, +{0, 59953, 5791}, +{0, 60000, 5791}, +{0, 60065, 5788}, +{0, 60235, 5786}, +{0, 60431, 5797}, +{0, 60713, 5797}, +{0, 60770, 5797}, +{0, 60015, 5801}, +{0, 59364, 5796}, +{0, 59129, 5776}, +{0, 59016, 5790}, +{0, 59049, 5791}, +{0, 59116, 5783}, +{0, 59132, 5786}, +{0, 59220, 5786}, +{0, 59394, 5795}, +{0, 59670, 5788}, +{0, 59727, 5788}, +{0, 59063, 5796}, +{0, 58552, 5788}, +{0, 58411, 5771}, +{0, 58361, 5771}, +{0, 58441, 5776}, +{0, 58643, 5771}, +{0, 58852, 5785}, +{0, 59047, 5777}, +{0, 59266, 5774}, +{0, 59575, 5779}, +{0, 59891, 5786}, +{0, 59477, 5801}, +{0, 58938, 5776}, +{0, 58697, 5772}, +{0, 58468, 5779}, +{0, 58370, 5771}, +{0, 58427, 5764}, +{0, 58382, 5775}, +{0, 58432, 5772}, +{0, 58479, 5781}, +{0, 58621, 5769}, +{0, 58790, 5773}, +{0, 58663, 5771}, +{0, 58086, 5758}, +{0, 57739, 5760}, +{0, 57461, 5759}, +{0, 57334, 5755}, +{0, 57343, 5751}, +{0, 57375, 5758}, +{0, 57431, 5746}, +{0, 57478, 5755}, +{0, 57565, 5755}, +{0, 57716, 5756}, +{0, 57982, 5749}, +{0, 57981, 5750}, +{0, 57916, 5757}, +{0, 57709, 5734}, +{0, 57546, 5743}, +{0, 57514, 5749}, +{0, 57607, 5742}, +{0, 57762, 5745}, +{0, 57895, 5749}, +{0, 58073, 5756}, +{0, 58254, 5751}, +{0, 58467, 5754}, +{0, 58649, 5742}, +{0, 58465, 5755}, +{0, 58106, 5747}, +{0, 57839, 5753}, +{0, 57640, 5741}, +{0, 57646, 5744}, +{0, 57765, 5744}, +{0, 57903, 5733}, +{0, 58067, 5750}, +{0, 58267, 5750}, +{0, 58492, 5758}, +{0, 58740, 5746}, +{0, 58888, 5746}, +{0, 58582, 5749}, +{0, 58189, 5741}, +{0, 58011, 5749}, +{0, 58024, 5743}, +{0, 58121, 5752}, +{0, 58343, 5745}, +{0, 58442, 5751}, +{0, 58542, 5750}, +{0, 58672, 5766}, +{0, 58794, 5753}, +{0, 58959, 5753}, +{0, 58984, 5760}, +{0, 58907, 5758}, +{0, 58684, 5751}, +{0, 58478, 5740}, +{0, 58365, 5746}, +{0, 58427, 5745}, +{0, 58506, 5751}, +{0, 58578, 5744}, +{0, 58631, 5751}, +{0, 58713, 5762}, +{0, 58823, 5748}, +{0, 58954, 5749}, +{0, 59096, 5754}, +{0, 58921, 5745}, +{0, 58644, 5748}, +{0, 58535, 5737}, +{0, 58464, 5744}, +{0, 58465, 5742}, +{0, 58579, 5748}, +{0, 58640, 5750}, +{0, 58767, 5753}, +{0, 58864, 5743}, +{0, 59022, 5758}, +{0, 59158, 5755}, +{0, 59290, 5754}, +{0, 59226, 5755}, +{0, 58941, 5751}, +{0, 58717, 5758}, +{0, 58687, 5748}, +{0, 58599, 5748}, +{0, 58670, 5744}, +{0, 58694, 5744}, +{0, 58653, 5730}, +{0, 58575, 5736}, +{0, 58443, 5738}, +{0, 58226, 5737}, +{0, 57957, 5731}, +{0, 57664, 5744}, +{0, 57410, 5727}, +{0, 57131, 5731}, +{0, 57002, 5729}, +{0, 56949, 5726}, +{0, 56996, 5734}, +{0, 57041, 5736}, +{0, 57073, 5740}, +{0, 57122, 5733}, +{0, 57229, 5737}, +{0, 57328, 5738}, +{0, 57443, 5738}, +{0, 57591, 5734}, +{0, 57670, 5737}, +{0, 57489, 5742}, +{0, 57335, 5727}, +{0, 57307, 5729}, +{0, 57370, 5730}, +{0, 57454, 5725}, +{0, 57553, 5731}, +{0, 57636, 5726}, +{0, 57694, 5731}, +{0, 57782, 5723}, +{0, 57860, 5731}, +{0, 57953, 5737}, +{0, 57978, 5735}, +{0, 57758, 5737}, +{0, 57593, 5730}, +{0, 57484, 5734}, +{0, 57454, 5735}, +{0, 57447, 5717}, +{0, 57429, 5728}, +{0, 57402, 5740}, +{0, 57444, 5734}, +{0, 57493, 5727}, +{0, 57583, 5723}, +{0, 57683, 5725}, +{0, 57812, 5729}, +{0, 57658, 5716}, +{0, 57615, 5722}, +{0, 57641, 5721}, +{0, 57787, 5715}, +{0, 57986, 5733}, +{0, 58116, 5725}, +{0, 58211, 5727}, +{0, 58335, 5724}, +{0, 58464, 5724}, +{0, 58575, 5719}, +{0, 58657, 5734}, +{0, 58753, 5740}, +{0, 58533, 5730}, +{0, 58259, 5721}, +{0, 58161, 5726}, +{0, 58156, 5737}, +{0, 58106, 5727}, +{0, 58076, 5737}, +{0, 58128, 5731}, +{0, 58129, 5735}, +{0, 58213, 5727}, +{0, 58282, 5733}, +{0, 58282, 5728}, +{0, 58252, 5728}, +{0, 57998, 5721}, +{0, 57697, 5706}, +{0, 57559, 5719}, +{0, 57528, 5713}, +{0, 57520, 5723}, +{0, 57651, 5727}, +{0, 57819, 5719}, +{0, 58009, 5717}, +{0, 58287, 5733}, +{0, 58597, 5741}, +{0, 58811, 5732}, +{0, 59046, 5744}, +{0, 59025, 5726}, +{0, 58912, 5734}, +{0, 58919, 5738}, +{0, 59012, 5732}, +{0, 59143, 5748}, +{0, 59188, 5745}, +{0, 59227, 5749}, +{0, 59316, 5743}, +{0, 59358, 5740}, +{0, 59496, 5750}, +{0, 59627, 5751}, +{0, 59740, 5746}, +{0, 59647, 5735}, +{0, 59492, 5738}, +{0, 59361, 5725}, +{0, 59307, 5727}, +{0, 59357, 5728}, +{0, 59335, 5731}, +{0, 59163, 5729}, +{0, 58947, 5736}, +{0, 58960, 5747}, +{0, 59110, 5739}, +{0, 59246, 5744}, +{0, 59243, 5742}, +{0, 58958, 5732}, +{0, 58742, 5735}, +{0, 58692, 5725}, +{0, 58708, 5746}, +{0, 58787, 5744}, +{0, 59036, 5750}, +{0, 59671, 5735}, +{0, 60295, 5756}, +{0, 60927, 5763}, +{0, 61483, 5775}, +{0, 62005, 5778}, +{0, 62364, 5775}, +{0, 62685, 5780}, +{0, 63073, 5793}, +{0, 63430, 5798}, +{0, 63809, 5806}, +{0, 64149, 5810}, +{0, 64475, 5804}, +{0, 64774, 5810}, +{0, 65019, 5809}, +{0, 65321, 5807}, +{0, 65612, 5812}, +{0, 65791, 5818}, +{0, 65710, 5815}, +{0, 65624, 5802}, +{0, 65575, 5809}, +{0, 65443, 5800}, +{0, 65313, 5812}, +{0, 65198, 5812}, +{0, 65152, 5796}, +{0, 65148, 5795}, +{0, 65237, 5799}, +{0, 65317, 5799}, +{0, 65423, 5803}, +{0, 65467, 5800}, +{0, 65256, 5792}, +{0, 65124, 5790}, +{0, 65061, 5803}, +{0, 65012, 5796}, +{0, 64980, 5796}, +{0, 64932, 5792}, +{0, 64922, 5795}, +{0, 64895, 5803}, +{0, 64900, 5798}, +{0, 64872, 5798}, +{0, 64872, 5793}, +{0, 64747, 5789}, +{0, 64413, 5798}, +{0, 64165, 5794}, +{0, 63986, 5790}, +{0, 63882, 5781}, +{0, 63760, 5789}, +{0, 63792, 5780}, +{0, 63732, 5794}, +{0, 63781, 5788}, +{0, 63736, 5803}, +{0, 63854, 5791}, +{0, 63865, 5789}, +{0, 63866, 5799}, +{0, 63594, 5778}, +{0, 63433, 5777}, +{0, 63378, 5791}, +{0, 63409, 5779}, +{0, 63463, 5764}, +{0, 63486, 5775}, +{0, 63487, 5787}, +{0, 63572, 5778}, +{0, 63735, 5783}, +{0, 63803, 5773}, +{0, 63922, 5785}, +{0, 64029, 5783}, +{0, 63849, 5789}, +{0, 63604, 5785}, +{0, 63504, 5782}, +{0, 63472, 5774}, +{0, 63538, 5777}, +{0, 63570, 5775}, +{0, 63577, 5784}, +{0, 63590, 5776}, +{0, 63669, 5778}, +{0, 63772, 5782}, +{0, 63856, 5779}, +{0, 63959, 5779}, +{0, 63837, 5784}, +{0, 63557, 5776}, +{0, 63414, 5778}, +{0, 63370, 5781}, +{0, 63343, 5787}, +{0, 63346, 5781}, +{0, 63259, 5773}, +{0, 63253, 5771}, +{0, 63201, 5782}, +{0, 63234, 5782}, +{0, 63266, 5773}, +{0, 63307, 5774}, +{0, 63246, 5774}, +{0, 62919, 5769}, +{0, 62727, 5774}, +{0, 62685, 5779}, +{0, 62739, 5766}, +{0, 62789, 5759}, +{0, 62847, 5762}, +{0, 63030, 5765}, +{0, 63262, 5770}, +{0, 63561, 5784}, +{0, 63943, 5792}, +{0, 64274, 5795}, +{0, 64520, 5789}, +{0, 64439, 5796}, +{0, 64276, 5802}, +{0, 64338, 5792}, +{0, 64500, 5801}, +{0, 64753, 5805}, +{0, 65005, 5806}, +{0, 65246, 5809}, +{0, 65430, 5798}, +{0, 65691, 5809}, +{0, 65870, 5815}, +{0, 66098, 5807}, +{0, 66239, 5814}, +{0, 65989, 5813}, +{0, 65656, 5812}, +{0, 65523, 5810}, +{0, 65470, 5802}, +{0, 65429, 5798}, +{0, 65380, 5802}, +{0, 65218, 5793}, +{0, 65087, 5787}, +{0, 64942, 5787}, +{0, 64877, 5793}, +{0, 64720, 5796}, +{0, 64662, 5780}, +{0, 64332, 5772}, +{0, 63902, 5763}, +{0, 63639, 5763}, +{0, 63495, 5766}, +{0, 63367, 5760}, +{0, 63324, 5764}, +{0, 63315, 5772}, +{0, 63263, 5764}, +{0, 63258, 5755}, +{0, 63344, 5763}, +{0, 63369, 5758}, +{0, 63416, 5762}, +{0, 63060, 5755}, +{0, 62872, 5763}, +{0, 62919, 5769}, +{0, 63045, 5764}, +{0, 63173, 5786}, +{0, 63278, 5775}, +{0, 63357, 5774}, +{0, 63445, 5773}, +{0, 63543, 5781}, +{0, 63648, 5780}, +{0, 63715, 5782}, +{0, 63488, 5777}, +{0, 62867, 5780}, +{0, 62518, 5783}, +{0, 62258, 5773}, +{0, 62083, 5771}, +{0, 61984, 5770}, +{0, 61896, 5759}, +{0, 61733, 5761}, +{0, 61567, 5759}, +{0, 61535, 5768}, +{0, 61595, 5758}, +{0, 61726, 5775}, +{0, 61675, 5762}, +{0, 61330, 5759}, +{0, 61190, 5756}, +{0, 61269, 5765}, +{0, 61508, 5774}, +{0, 61756, 5778}, +{0, 62028, 5785}, +{0, 62209, 5787}, +{0, 62461, 5787}, +{0, 62716, 5793}, +{0, 63008, 5787}, +{0, 63274, 5792}, +{0, 63253, 5789}, +{0, 62966, 5791}, +{0, 62966, 5788}, +{0, 62994, 5784}, +{0, 63066, 5796}, +{0, 63155, 5789}, +{0, 63205, 5792}, +{0, 63262, 5789}, +{0, 63272, 5793}, +{0, 63273, 5791}, +{0, 63206, 5779}, +{0, 63087, 5779}, +{0, 62588, 5777}, +{0, 62075, 5771}, +{0, 61794, 5769}, +{0, 61577, 5768}, +{0, 61466, 5766}, +{0, 61429, 5764}, +{0, 61455, 5758}, +{0, 61475, 5757}, +{0, 61626, 5755}, +{0, 61776, 5768}, +{0, 61934, 5752}, +{0, 61846, 5756}, +{0, 61389, 5753}, +{0, 61208, 5746}, +{0, 61084, 5748}, +{0, 61091, 5751}, +{0, 61154, 5746}, +{0, 61209, 5748}, +{0, 61262, 5759}, +{0, 61363, 5743}, +{0, 61588, 5752}, +{0, 61931, 5766}, +{0, 62269, 5764}, +{0, 62412, 5769}, +{0, 62312, 5770}, +{0, 62235, 5771}, +{0, 62334, 5778}, +{0, 62378, 5772}, +{0, 62394, 5772}, +{0, 62360, 5760}, +{0, 62291, 5763}, +{0, 62295, 5761}, +{0, 62378, 5751}, +{0, 62481, 5762}, +{0, 62624, 5774}, +{0, 62644, 5772}, +{0, 62389, 5770}, +{0, 62120, 5764}, +{0, 61878, 5753}, +{0, 61725, 5762}, +{0, 61746, 5757}, +{0, 61881, 5766}, +{0, 62153, 5760}, +{0, 62325, 5761}, +{0, 62548, 5761}, +{0, 62669, 5754}, +{0, 62879, 5764}, +{0, 62629, 5756}, +{0, 62332, 5769}, +{0, 62140, 5761}, +{0, 62120, 5757}, +{0, 62169, 5762}, +{0, 62272, 5766}, +{0, 62331, 5762}, +{0, 62382, 5769}, +{0, 62445, 5763}, +{0, 62407, 5762}, +{0, 62353, 5774}, +{0, 62361, 5773}, +{0, 62135, 5773}, +{0, 61827, 5766}, +{0, 61601, 5750}, +{0, 61589, 5761}, +{0, 61690, 5749}, +{0, 61801, 5744}, +{0, 61820, 5740}, +{0, 61842, 5747}, +{0, 61860, 5766}, +{0, 62029, 5760}, +{0, 62251, 5762}, +{0, 62550, 5769}, +{0, 62878, 5776}, +{0, 62925, 5768}, +{0, 62918, 5763}, +{0, 63128, 5777}, +{0, 63394, 5775}, +{0, 63669, 5780}, +{0, 63835, 5778}, +{0, 64013, 5789}, +{0, 64079, 5779}, +{0, 64186, 5784}, +{0, 64308, 5778}, +{0, 64334, 5784}, +{0, 64282, 5794}, +{0, 63926, 5776}, +{0, 63585, 5769}, +{0, 63334, 5760}, +{0, 63121, 5765}, +{0, 63129, 5768}, +{0, 63284, 5767}, +{0, 63503, 5765}, +{0, 63541, 5765}, +{0, 63550, 5769}, +{0, 63622, 5780}, +{0, 63724, 5771}, +{0, 63704, 5767}, +{0, 63429, 5774}, +{0, 63210, 5761}, +{0, 63150, 5774}, +{0, 63176, 5783}, +{0, 63244, 5765}, +{0, 63444, 5773}, +{0, 63690, 5795}, +{0, 63968, 5803}, +{0, 64241, 5807}, +{0, 64575, 5809}, +{0, 65009, 5814}, +{0, 65276, 5815}, +{0, 65257, 5803}, +{0, 65316, 5824}, +{0, 65368, 5818}, +{0, 65327, 5811}, +{0, 65260, 5814}, +{0, 65179, 5804}, +{0, 65040, 5801}, +{0, 64913, 5807}, +{0, 64802, 5797}, +{0, 64718, 5799}, +{0, 64611, 5797}, +{0, 64415, 5800}, +{0, 64046, 5793}, +{0, 63772, 5780}, +{0, 63499, 5775}, +{0, 63292, 5772}, +{0, 63055, 5758}, +{0, 62893, 5769}, +{0, 62851, 5762}, +{0, 62815, 5777}, +{0, 62848, 5775}, +{0, 62991, 5762}, +{0, 63131, 5772}, +{0, 62987, 5772}, +{0, 62700, 5771}, +{0, 62261, 5772}, +{0, 61915, 5753}, +{0, 61787, 5761}, +{0, 61831, 5763}, +{0, 61778, 5762}, +{0, 61723, 5754}, +{0, 61759, 5757}, +{0, 61860, 5750}, +{0, 61924, 5764}, +{0, 61758, 5756}, +{0, 61283, 5755}, +{0, 60873, 5753}, +{0, 60417, 5741}, +{0, 60167, 5751}, +{0, 59971, 5744}, +{0, 59851, 5749}, +{0, 59669, 5757}, +{0, 59506, 5756}, +{0, 59345, 5757}, +{0, 59243, 5752}, +{0, 59105, 5761}, +{0, 58659, 5769}, +{0, 57940, 5761}, +{0, 57566, 5749}, +{0, 57450, 5748}, +{0, 57445, 5745}, +{0, 57486, 5738}, +{0, 57651, 5744}, +{0, 57905, 5750}, +{0, 58216, 5751}, +{0, 58463, 5750}, +{0, 58707, 5755}, +{0, 58813, 5761}, +{0, 58531, 5752}, +{0, 58351, 5752}, +{0, 58368, 5753}, +{0, 58483, 5749}, +{0, 58537, 5752}, +{0, 58424, 5758}, +{0, 58200, 5751}, +{0, 58067, 5754}, +{0, 58120, 5753}, +{0, 58109, 5758}, +{0, 58206, 5758}, +{0, 58438, 5759}, +{0, 58333, 5757}, +{0, 58264, 5761}, +{0, 58408, 5762}, +{0, 58653, 5771}, +{0, 58882, 5773}, +{0, 59063, 5785}, +{0, 59244, 5778}, +{0, 59428, 5782}, +{0, 59686, 5780}, +{0, 59884, 5786}, +{0, 60120, 5780}, +{0, 59927, 5770}, +{0, 59720, 5783}, +{0, 59758, 5768}, +{0, 59921, 5776}, +{0, 60162, 5772}, +{0, 60400, 5777}, +{0, 60629, 5786}, +{0, 60963, 5788}, +{0, 61245, 5785}, +{0, 61478, 5798}, +{0, 61742, 5795}, +{0, 61906, 5801}, +{0, 61764, 5779}, +{0, 61563, 5771}, +{0, 61160, 5783}, +{0, 60853, 5774}, +{0, 60623, 5767}, +{0, 60401, 5764}, +{0, 60175, 5760}, +{0, 60017, 5747}, +{0, 59984, 5741}, +{0, 60044, 5749}, +{0, 60098, 5757}, +{0, 60058, 5750}, +{0, 59791, 5745}, +{0, 59593, 5738}, +{0, 59563, 5749}, +{0, 59562, 5745}, +{0, 59708, 5750}, +{0, 59850, 5761}, +{0, 60212, 5763}, +{0, 60788, 5772}, +{0, 61619, 5794}, +{0, 62580, 5807}, +{0, 63490, 5819}, +{0, 64080, 5810}, +{0, 64358, 5800}, +{0, 64702, 5810}, +{0, 65016, 5820}, +{0, 65346, 5815}, +{0, 65728, 5818}, +{0, 66106, 5825}, +{0, 66387, 5819}, +{0, 66487, 5803}, +{0, 66536, 5816}, +{0, 66665, 5812}, +{0, 66835, 5817}, +{0, 66918, 5815}, +{0, 66891, 5813}, +{0, 67104, 5823}, +{0, 67512, 5839}, +{0, 68016, 5847}, +{0, 68617, 5847}, +{0, 69134, 5837}, +{0, 69657, 5851}, +{0, 70277, 5850}, +{0, 70854, 5863}, +{0, 71531, 5868}, +{0, 72171, 5862}, +{0, 72584, 5858}, +{0, 72533, 5855}, +{0, 72529, 5860}, +{0, 72557, 5862}, +{0, 72559, 5848}, +{0, 72536, 5844}, +{0, 72540, 5857}, +{0, 72433, 5841}, +{0, 72360, 5839}, +{0, 72366, 5852}, +{0, 72429, 5853}, +{0, 72535, 5851}, +{0, 72559, 5844}, +{0, 72224, 5850}, +{0, 71803, 5831}, +{0, 71524, 5836}, +{0, 71237, 5830}, +{0, 70999, 5843}, +{0, 70703, 5831}, +{0, 70440, 5836}, +{0, 70200, 5825}, +{0, 70089, 5816}, +{0, 70102, 5825}, +{0, 70163, 5826}, +{0, 70264, 5824}, +{0, 69955, 5808}, +{0, 69458, 5817}, +{0, 69074, 5824}, +{0, 68792, 5815}, +{0, 68544, 5812}, +{0, 68363, 5816}, +{0, 68082, 5811}, +{0, 67793, 5806}, +{0, 67555, 5821}, +{0, 67313, 5802}, +{0, 67154, 5801}, +{0, 67135, 5806}, +{0, 66807, 5797}, +{0, 66342, 5796}, +{0, 65999, 5786}, +{0, 65750, 5789}, +{0, 65594, 5800}, +{0, 65564, 5798}, +{0, 65579, 5805}, +{0, 65708, 5793}, +{0, 65976, 5812}, +{0, 66309, 5818}, +{0, 66750, 5820}, +{0, 67196, 5828}, +{0, 67576, 5835}, +{0, 67401, 5824}, +{0, 67390, 5817}, +{0, 67687, 5828}, +{0, 68049, 5825}, +{0, 68289, 5837}, +{0, 68354, 5834}, +{0, 68266, 5829}, +{0, 68110, 5824}, +{0, 68086, 5824}, +{0, 68194, 5830}, +{0, 68355, 5820}, +{0, 68271, 5830}, +{0, 67668, 5818}, +{0, 67010, 5799}, +{0, 66590, 5790}, +{0, 66325, 5801}, +{0, 66197, 5803}, +{0, 66116, 5811}, +{0, 66067, 5796}, +{0, 66104, 5801}, +{0, 66128, 5794}, +{0, 66202, 5801}, +{0, 66259, 5798}, +{0, 66405, 5796}, +{0, 66178, 5803}, +{0, 65969, 5809}, +{0, 65970, 5826}, +{0, 66127, 5832}, +{0, 66350, 5823}, +{0, 66644, 5831}, +{0, 66948, 5833}, +{0, 67228, 5830}, +{0, 67423, 5831}, +{0, 67608, 5829}, +{0, 67628, 5835}, +{0, 67624, 5834}, +{0, 67072, 5819}, +{0, 66363, 5809}, +{0, 65909, 5814}, +{0, 65618, 5802}, +{0, 65434, 5811}, +{0, 65385, 5802}, +{0, 65371, 5799}, +{0, 65307, 5803}, +{0, 65389, 5807}, +{0, 65475, 5803}, +{0, 65600, 5797}, +{0, 65817, 5791}, +{0, 65903, 5795}, +{0, 65955, 5785}, +{0, 66018, 5803}, +{0, 66068, 5803}, +{0, 66256, 5823}, +{0, 66470, 5814}, +{0, 66754, 5827}, +{0, 66957, 5815}, +{0, 67166, 5819}, +{0, 67434, 5823}, +{0, 67766, 5814}, +{0, 67944, 5823}, +{0, 67453, 5815}, +{0, 66912, 5822}, +{0, 66562, 5816}, +{0, 66312, 5808}, +{0, 66113, 5809}, +{0, 66043, 5800}, +{0, 66037, 5791}, +{0, 66111, 5790}, +{0, 66138, 5798}, +{0, 66118, 5794}, +{0, 66166, 5803}, +{0, 65942, 5807}, +{0, 65162, 5806}, +{0, 64551, 5788}, +{0, 64171, 5790}, +{0, 64015, 5781}, +{0, 63944, 5776}, +{0, 63951, 5782}, +{0, 63982, 5786}, +{0, 64003, 5775}, +{0, 64111, 5764}, +{0, 64352, 5773}, +{0, 64586, 5778}, +{0, 64494, 5786}, +{0, 63841, 5793}, +{0, 63485, 5772}, +{0, 63356, 5772}, +{0, 63387, 5781}, +{0, 63461, 5781}, +{0, 63500, 5785}, +{0, 63508, 5800}, +{0, 63672, 5794}, +{0, 63958, 5790}, +{0, 64148, 5802}, +{0, 64287, 5803}, +{0, 64042, 5794}, +{0, 63661, 5795}, +{0, 63571, 5774}, +{0, 63626, 5783}, +{0, 63707, 5791}, +{0, 63814, 5801}, +{0, 63880, 5785}, +{0, 63927, 5803}, +{0, 64073, 5797}, +{0, 64378, 5796}, +{0, 64669, 5804}, +{0, 64946, 5804}, +{0, 64931, 5813}, +{0, 64756, 5802}, +{0, 64879, 5801}, +{0, 65114, 5806}, +{0, 65326, 5811}, +{0, 65482, 5805}, +{0, 65343, 5802}, +{0, 65069, 5793}, +{0, 64859, 5782}, +{0, 64643, 5790}, +{0, 64495, 5801}, +{0, 64215, 5786}, +{0, 63659, 5771}, +{0, 63267, 5771}, +{0, 63058, 5777}, +{0, 63026, 5772}, +{0, 63035, 5765}, +{0, 63062, 5765}, +{0, 62976, 5773}, +{0, 63006, 5776}, +{0, 63091, 5769}, +{0, 63301, 5774}, +{0, 63552, 5779}, +{0, 63545, 5769}, +{0, 63334, 5769}, +{0, 63208, 5782}, +{0, 63195, 5785}, +{0, 63141, 5778}, +{0, 63223, 5777}, +{0, 63365, 5770}, +{0, 63532, 5776}, +{0, 63595, 5770}, +{0, 63604, 5771}, +{0, 63612, 5767}, +{0, 63617, 5763}, +{0, 63330, 5759}, +{0, 63173, 5761}, +{0, 63254, 5759}, +{0, 63392, 5767}, +{0, 63557, 5776}, +{0, 63637, 5778}, +{0, 63674, 5785}, +{0, 63563, 5781}, +{0, 63390, 5773}, +{0, 63113, 5785}, +{0, 62949, 5781}, +{0, 62921, 5764}, +{0, 62731, 5772}, +{0, 62536, 5787}, +{0, 62566, 5779}, +{0, 62709, 5770}, +{0, 62973, 5761}, +{0, 62930, 5760}, +{0, 62722, 5768}, +{0, 62678, 5783}, +{0, 62750, 5773}, +{0, 62701, 5787}, +{0, 62641, 5766}, +{0, 62456, 5768}, +{0, 62061, 5769}, +{0, 61566, 5766}, +{0, 61094, 5759}, +{0, 60794, 5753}, +{0, 60716, 5763}, +{0, 60749, 5765}, +{0, 60691, 5766}, +{0, 60600, 5764}, +{0, 60608, 5762}, +{0, 60806, 5777}, +{0, 60900, 5761}, +{0, 60554, 5757}, +{0, 60184, 5767}, +{0, 60018, 5775}, +{0, 60038, 5756}, +{0, 60070, 5762}, +{0, 60201, 5765}, +{0, 60224, 5762}, +{0, 60226, 5762}, +{0, 60238, 5760}, +{0, 60294, 5759}, +{0, 60325, 5760}, +{0, 59975, 5763}, +{0, 59527, 5752}, +{0, 59243, 5747}, +{0, 59081, 5761}, +{0, 58982, 5754}, +{0, 59055, 5752}, +{0, 59020, 5769}, +{0, 58892, 5757}, +{0, 58811, 5770}, +{0, 58830, 5755}, +{0, 59012, 5760}, +{0, 58978, 5756}, +{0, 58707, 5739}, +{0, 58480, 5747}, +{0, 58500, 5750}, +{0, 58540, 5749}, +{0, 58683, 5751}, +{0, 58817, 5755}, +{0, 58919, 5747}, +{0, 59049, 5758}, +{0, 59185, 5754}, +{0, 59365, 5753}, +{0, 59505, 5756}, +{0, 59120, 5746}, +{0, 58775, 5738}, +{0, 58560, 5743}, +{0, 58458, 5742}, +{0, 58326, 5742}, +{0, 58099, 5744}, +{0, 57782, 5750}, +{0, 57663, 5747}, +{0, 57583, 5751}, +{0, 57501, 5759}, +{0, 57472, 5747}, +{0, 57352, 5762}, +{0, 57101, 5763}, +{0, 57000, 5754}, +{0, 57037, 5744}, +{0, 57180, 5745}, +{0, 57364, 5750}, +{0, 57533, 5755}, +{0, 57798, 5751}, +{0, 58047, 5752}, +{0, 58303, 5758}, +{0, 58605, 5755}, +{0, 58525, 5741}, +{0, 58442, 5743}, +{0, 58462, 5742}, +{0, 58490, 5739}, +{0, 58560, 5748}, +{0, 58525, 5749}, +{0, 58540, 5750}, +{0, 58503, 5746}, +{0, 58493, 5761}, +{0, 58545, 5739}, +{0, 58611, 5745}, +{0, 58398, 5744}, +{0, 58150, 5735}, +{0, 57974, 5747}, +{0, 57910, 5753}, +{0, 57873, 5755}, +{0, 57974, 5747}, +{0, 58039, 5739}, +{0, 58109, 5743}, +{0, 58262, 5747}, +{0, 58475, 5745}, +{0, 58743, 5746}, +{0, 58708, 5744}, +{0, 58682, 5740}, +{0, 58788, 5742}, +{0, 58870, 5735}, +{0, 59011, 5753}, +{0, 59102, 5744}, +{0, 59174, 5757}, +{0, 59160, 5765}, +{0, 59160, 5750}, +{0, 59133, 5736}, +{0, 59067, 5755}, +{0, 58809, 5752}, +{0, 58558, 5738}, +{0, 58407, 5739}, +{0, 58292, 5748}, +{0, 58251, 5740}, +{0, 58202, 5753}, +{0, 58198, 5752}, +{0, 58281, 5752}, +{0, 58366, 5745}, +{0, 58480, 5749}, +{0, 58661, 5750}, +{0, 58558, 5754}, +{0, 58560, 5735}, +{0, 58650, 5732}, +{0, 58802, 5744}, +{0, 59016, 5745}, +{0, 59198, 5744}, +{0, 59345, 5745}, +{0, 59413, 5746}, +{0, 59437, 5751}, +{0, 59463, 5743}, +{0, 59468, 5751}, +{0, 59121, 5749}, +{0, 58823, 5741}, +{0, 58629, 5749}, +{0, 58602, 5750}, +{0, 58552, 5750}, +{0, 58340, 5761}, +{0, 58175, 5760}, +{0, 58375, 5764}, +{0, 58742, 5756}, +{0, 59153, 5754}, +{0, 59574, 5776}, +{0, 59689, 5764}, +{0, 59730, 5765}, +{0, 59944, 5768}, +{0, 60291, 5767}, +{0, 60651, 5779}, +{0, 60970, 5778}, +{0, 61158, 5785}, +{0, 61301, 5789}, +{0, 61367, 5782}, +{0, 61452, 5783}, +{0, 61498, 5778}, +{0, 61177, 5765}, +{0, 60974, 5768}, +{0, 60937, 5779}, +{0, 60978, 5776}, +{0, 61039, 5773}, +{0, 61187, 5773}, +{0, 61391, 5770}, +{0, 61560, 5781}, +{0, 61708, 5771}, +{0, 61897, 5788}, +{0, 62062, 5781}, +{0, 61847, 5776}, +{0, 61679, 5774}, +{0, 61729, 5767}, +{0, 61817, 5762}, +{0, 62033, 5774}, +{0, 62435, 5781}, +{0, 62691, 5789}, +{0, 62874, 5778}, +{0, 62944, 5777}, +{0, 62923, 5779}, +{0, 62701, 5777}, +{0, 62265, 5769}, +{0, 61947, 5761}, +{0, 61728, 5770}, +{0, 61531, 5762}, +{0, 61388, 5766}, +{0, 61354, 5762}, +{0, 61261, 5760}, +{0, 61357, 5755}, +{0, 61658, 5767}, +{0, 61964, 5754}, +{0, 61978, 5752}, +{0, 61821, 5752}, +{0, 62047, 5752}, +{0, 62480, 5765}, +{0, 63117, 5784}, +{0, 63920, 5797}, +{0, 64722, 5820}, +{0, 65481, 5820}, +{0, 66153, 5840}, +{0, 66805, 5832}, +{0, 67430, 5830}, +{0, 67616, 5827}, +{0, 67176, 5799}, +{0, 66784, 5793}, +{0, 66504, 5784}, +{0, 66281, 5794}, +{0, 66279, 5800}, +{0, 66315, 5789}, +{0, 66427, 5794}, +{0, 66577, 5804}, +{0, 66901, 5812}, +{0, 67291, 5803}, +{0, 67197, 5807}, +{0, 66853, 5810}, +{0, 66640, 5799}, +{0, 66557, 5807}, +{0, 66489, 5808}, +{0, 66766, 5793}, +{0, 67121, 5817}, +{0, 67509, 5830}, +{0, 67877, 5826}, +{0, 68346, 5854}, +{0, 68755, 5840}, +{0, 68684, 5826}, +{0, 68376, 5810}, +{0, 68194, 5825}, +{0, 68102, 5820}, +{0, 68062, 5832}, +{0, 68109, 5815}, +{0, 68151, 5820}, +{0, 68191, 5810}, +{0, 68216, 5814}, +{0, 68286, 5829}, +{0, 68272, 5818}, +{0, 67857, 5811}, +{0, 67430, 5811}, +{0, 67198, 5808}, +{0, 67092, 5813}, +{0, 67054, 5812}, +{0, 67066, 5813}, +{0, 67162, 5817}, +{0, 67365, 5803}, +{0, 67515, 5823}, +{0, 67768, 5809}, +{0, 67856, 5817}, +{0, 67338, 5802}, +{0, 66942, 5818}, +{0, 66703, 5805}, +{0, 66609, 5818}, +{0, 66564, 5809}, +{0, 66526, 5814}, +{0, 66527, 5801}, +{0, 66432, 5804}, +{0, 66472, 5800}, +{0, 66588, 5799}, +{0, 66481, 5805}, +{0, 66056, 5796}, +{0, 65725, 5797}, +{0, 65665, 5795}, +{0, 65769, 5788}, +{0, 66041, 5791}, +{0, 66367, 5804}, +{0, 66625, 5811}, +{0, 66977, 5813}, +{0, 67326, 5818}, +{0, 67674, 5827}, +{0, 67523, 5818}, +{0, 67166, 5816}, +{0, 67022, 5814}, +{0, 67012, 5822}, +{0, 67069, 5810}, +{0, 67155, 5814}, +{0, 67175, 5823}, +{0, 67157, 5822}, +{0, 67220, 5814}, +{0, 67291, 5816}, +{0, 67360, 5808}, +{0, 66878, 5802}, +{0, 66324, 5808}, +{0, 65974, 5804}, +{0, 65771, 5792}, +{0, 65684, 5800}, +{0, 65698, 5797}, +{0, 65929, 5791}, +{0, 66161, 5804}, +{0, 66476, 5800}, +{0, 66790, 5811}, +{0, 66773, 5811}, +{0, 66449, 5805}, +{0, 66313, 5807}, +{0, 66311, 5804}, +{0, 66367, 5808}, +{0, 66407, 5801}, +{0, 66416, 5802}, +{0, 66329, 5807}, +{0, 66250, 5804}, +{0, 66168, 5804}, +{0, 65886, 5804}, +{0, 65142, 5794}, +{0, 64512, 5789}, +{0, 64154, 5792}, +{0, 63912, 5786}, +{0, 63745, 5783}, +{0, 63634, 5792}, +{0, 63618, 5781}, +{0, 63589, 5780}, +{0, 63621, 5784}, +{0, 63667, 5788}, +{0, 63723, 5775}, +{0, 63663, 5783}, +{0, 63543, 5781}, +{0, 63339, 5782}, +{0, 63415, 5785}, +{0, 63624, 5789}, +{0, 63856, 5790}, +{0, 64020, 5794}, +{0, 64166, 5786}, +{0, 64343, 5784}, +{0, 64011, 5788}, +{0, 63315, 5786}, +{0, 62970, 5781}, +{0, 62792, 5780}, +{0, 62726, 5779}, +{0, 62643, 5787}, +{0, 62619, 5769}, +{0, 62679, 5784}, +{0, 62745, 5781}, +{0, 62700, 5791}, +{0, 62715, 5785}, +{0, 62752, 5778}, +{0, 62799, 5784}, +{0, 62886, 5779}, +{0, 63014, 5777}, +{0, 63144, 5783}, +{0, 63154, 5773}, +{0, 63229, 5780}, +{0, 63342, 5798}, +{0, 63509, 5792}, +{0, 63717, 5777}, +{0, 63398, 5785}, +{0, 63108, 5783}, +{0, 63116, 5775}, +{0, 63216, 5775}, +{0, 63266, 5778}, +{0, 63243, 5771}, +{0, 63181, 5772}, +{0, 63147, 5782}, +{0, 63098, 5775}, +{0, 63081, 5767}, +{0, 62881, 5777}, +{0, 62521, 5773}, +{0, 62174, 5766}, +{0, 61926, 5762}, +{0, 62018, 5769}, +{0, 62183, 5772}, +{0, 62361, 5782}, +{0, 62569, 5774}, +{0, 62877, 5796}, +{0, 63329, 5813}, +{0, 63713, 5811}, +{0, 63611, 5812}, +{0, 63706, 5814}, +{0, 63983, 5806}, +{0, 64201, 5814}, +{0, 64393, 5814}, +{0, 64477, 5801}, +{0, 64463, 5795}, +{0, 64578, 5821}, +{0, 64567, 5806}, +{0, 64551, 5809}, +{0, 63995, 5803}, +{0, 63444, 5792}, +{0, 63179, 5788}, +{0, 63083, 5786}, +{0, 62980, 5785}, +{0, 63076, 5790}, +{0, 63157, 5795}, +{0, 63215, 5796}, +{0, 63245, 5782}, +{0, 63377, 5789}, +{0, 63108, 5779}, +{0, 62438, 5768}, +{0, 62142, 5767}, +{0, 62083, 5768}, +{0, 62217, 5782}, +{0, 62529, 5786}, +{0, 62895, 5785}, +{0, 63360, 5783}, +{0, 63766, 5790}, +{0, 63999, 5791}, +{0, 63939, 5785}, +{0, 63510, 5796}, +{0, 63254, 5793}, +{0, 63078, 5789}, +{0, 62948, 5798}, +{0, 62889, 5789}, +{0, 62802, 5789}, +{0, 62642, 5783}, +{0, 62496, 5771}, +{0, 62349, 5788}, +{0, 62173, 5776}, +{0, 61617, 5770}, +{0, 61141, 5772}, +{0, 60906, 5762}, +{0, 60834, 5761}, +{0, 60871, 5751}, +{0, 60932, 5757}, +{0, 61100, 5759}, +{0, 61308, 5760}, +{0, 61524, 5780}, +{0, 61754, 5773}, +{0, 61506, 5766}, +{0, 61086, 5773}, +{0, 61049, 5770}, +{0, 61115, 5770}, +{0, 61247, 5781}, +{0, 61427, 5769}, +{0, 61613, 5773}, +{0, 61668, 5765}, +{0, 61806, 5766}, +{0, 62008, 5774}, +{0, 61886, 5763}, +{0, 61188, 5751}, +{0, 60639, 5748}, +{0, 60412, 5752}, +{0, 60316, 5757}, +{0, 60310, 5761}, +{0, 60356, 5763}, +{0, 60405, 5761}, +{0, 60464, 5760}, +{0, 60630, 5762}, +{0, 60863, 5763}, +{0, 60954, 5765}, +{0, 60572, 5751}, +{0, 60416, 5757}, +{0, 60448, 5754}, +{0, 60505, 5759}, +{0, 60713, 5773}, +{0, 60769, 5766}, +{0, 60714, 5757}, +{0, 60657, 5755}, +{0, 60591, 5760}, +{0, 60567, 5755}, +{0, 60112, 5743}, +{0, 59439, 5753}, +{0, 59128, 5731}, +{0, 59000, 5746}, +{0, 59138, 5739}, +{0, 59421, 5744}, +{0, 59689, 5752}, +{0, 60117, 5751}, +{0, 60761, 5757}, +{0, 61771, 5789}, +{0, 62517, 5791}, +{0, 62664, 5798}, +{0, 62968, 5801}, +{0, 63303, 5791}, +{0, 63803, 5800}, +{0, 64494, 5805}, +{0, 65280, 5821}, +{0, 66256, 5819}, +{0, 67130, 5848}, +{0, 67923, 5853}, +{0, 68576, 5847}, +{0, 68487, 5828}, +{0, 67761, 5822}, +{0, 67183, 5810}, +{0, 66736, 5800}, +{0, 66396, 5800}, +{0, 66196, 5800}, +{0, 66150, 5812}, +{0, 66140, 5808}, +{0, 66223, 5807}, +{0, 66268, 5807}, +{0, 66370, 5801}, +{0, 65916, 5803}, +{0, 65289, 5797}, +{0, 64821, 5792}, +{0, 64674, 5784}, +{0, 64593, 5783}, +{0, 64812, 5790}, +{0, 65189, 5802}, +{0, 65670, 5820}, +{0, 66247, 5823}, +{0, 66900, 5832}, +{0, 67635, 5835}, +{0, 67749, 5830}, +{0, 67574, 5832}, +{0, 67596, 5835}, +{0, 67845, 5853}, +{0, 68130, 5834}, +{0, 68102, 5839}, +{0, 67864, 5832}, +{0, 67565, 5817}, +{0, 67381, 5813}, +{0, 67659, 5813}, +{0, 67756, 5819}, +{0, 67225, 5809}, +{0, 66788, 5813}, +{0, 66727, 5810}, +{0, 66886, 5812}, +{0, 67216, 5828}, +{0, 67493, 5832}, +{0, 67616, 5831}, +{0, 67729, 5828}, +{0, 67878, 5821}, +{0, 68146, 5828}, +{0, 68091, 5833}, +{0, 67867, 5838}, +{0, 68003, 5833}, +{0, 68079, 5834}, +{0, 67937, 5828}, +{0, 67850, 5834}, +{0, 67800, 5833}, +{0, 67676, 5819}, +{0, 67331, 5828}, +{0, 66976, 5818}, +{0, 66549, 5813}, +{0, 65528, 5792}, +{0, 64550, 5784}, +{0, 63974, 5792}, +{0, 63567, 5775}, +{0, 63210, 5783}, +{0, 63037, 5785}, +{0, 63024, 5771}, +{0, 62869, 5789}, +{0, 62621, 5779}, +{0, 62435, 5776}, +{0, 62339, 5775}, +{0, 61775, 5769}, +{0, 61353, 5765}, +{0, 61326, 5760}, +{0, 61299, 5772}, +{0, 61406, 5767}, +{0, 61483, 5767}, +{0, 61587, 5776}, +{0, 61659, 5764}, +{0, 61663, 5775}, +{0, 61582, 5779}, +{0, 61102, 5767}, +{0, 60299, 5770}, +{0, 59889, 5750}, +{0, 59580, 5755}, +{0, 59491, 5756}, +{0, 59531, 5760}, +{0, 59514, 5756}, +{0, 59516, 5766}, +{0, 59580, 5769}, +{0, 59621, 5763}, +{0, 59592, 5770}, +{0, 59062, 5761}, +{0, 58561, 5749}, +{0, 58431, 5756}, +{0, 58411, 5751}, +{0, 58573, 5750}, +{0, 58764, 5749}, +{0, 58822, 5753}, +{0, 58958, 5756}, +{0, 58950, 5749}, +{0, 58893, 5751}, +{0, 58397, 5752}, +{0, 57606, 5737}, +{0, 57424, 5743}, +{0, 57486, 5744}, +{0, 57633, 5747}, +{0, 57848, 5741}, +{0, 58040, 5749}, +{0, 58217, 5757}, +{0, 58392, 5764}, +{0, 58635, 5751}, +{0, 58852, 5764}, +{0, 58597, 5767}, +{0, 58185, 5757}, +{0, 58137, 5756}, +{0, 58330, 5762}, +{0, 58589, 5770}, +{0, 58916, 5764}, +{0, 59214, 5765}, +{0, 59515, 5769}, +{0, 59834, 5779}, +{0, 60227, 5769}, +{0, 60469, 5777}, +{0, 59967, 5764}, +{0, 59520, 5759}, +{0, 59356, 5752}, +{0, 59217, 5761}, +{0, 59071, 5750}, +{0, 59034, 5751}, +{0, 59003, 5744}, +{0, 58991, 5752}, +{0, 58937, 5750}, +{0, 58924, 5748}, +{0, 58454, 5738}, +{0, 58087, 5738}, +{0, 58107, 5734}, +{0, 58230, 5745}, +{0, 58340, 5740}, +{0, 58388, 5737}, +{0, 58381, 5745}, +{0, 58354, 5728}, +{0, 58366, 5737}, +{0, 58590, 5741}, +{0, 58713, 5734}, +{0, 58377, 5737}, +{0, 58177, 5748}, +{0, 58197, 5749}, +{0, 58062, 5748}, +{0, 57978, 5741}, +{0, 57882, 5752}, +{0, 57678, 5731}, +{0, 57587, 5724}, +{0, 57539, 5726}, +{0, 57666, 5733}, +{0, 57404, 5729}, +{0, 56725, 5725}, +{0, 56332, 5715}, +{0, 56194, 5713}, +{0, 56214, 5723}, +{0, 56322, 5732}, +{0, 56364, 5712}, +{0, 56641, 5722}, +{0, 57064, 5729}, +{0, 57575, 5739}, +{0, 57817, 5747}, +{0, 57687, 5748}, +{0, 57893, 5775}, +{0, 58419, 5768}, +{0, 58955, 5779}, +{0, 59378, 5779}, +{0, 59833, 5787}, +{0, 60090, 5779}, +{0, 60183, 5782}, +{0, 60170, 5779}, +{0, 60060, 5773}, +{0, 59675, 5754}, +{0, 59371, 5761}, +{0, 59183, 5759}, +{0, 59076, 5766}, +{0, 59091, 5759}, +{0, 59158, 5763}, +{0, 59216, 5767}, +{0, 59323, 5768}, +{0, 59399, 5748}, +{0, 59512, 5755}, +{0, 59429, 5746}, +{0, 59066, 5752}, +{0, 58959, 5743}, +{0, 59186, 5754}, +{0, 59638, 5765}, +{0, 60181, 5784}, +{0, 60936, 5800}, +{0, 61657, 5809}, +{0, 62331, 5817}, +{0, 62850, 5829}, +{0, 63079, 5819}, +{0, 62691, 5803}, +{0, 62403, 5797}, +{0, 62247, 5786}, +{0, 62108, 5783}, +{0, 61555, 5762}, +{0, 61147, 5759}, +{0, 61019, 5762}, +{0, 61070, 5766}, +{0, 61315, 5766}, +{0, 61772, 5788}, +{0, 61988, 5776}, +{0, 62173, 5791}, +{0, 62663, 5803}, +{0, 63542, 5812}, +{0, 64690, 5832}, +{0, 66229, 5843}, +{0, 67894, 5855}, +{0, 69538, 5866}, +{0, 71053, 5877}, +{0, 72442, 5889}, +{0, 73620, 5884}, +{0, 74230, 5880}, +{0, 74560, 5873}, +{0, 74737, 5875}, +{0, 74832, 5874}, +{0, 74956, 5873}, +{0, 74951, 5864}, +{0, 74822, 5857}, +{0, 74693, 5866}, +{0, 74461, 5861}, +{0, 74480, 5857}, +{0, 74253, 5856}, +{0, 74028, 5859}, +{0, 74087, 5863}, +{0, 74329, 5869}, +{0, 74604, 5869}, +{0, 74985, 5872}, +{0, 75312, 5874}, +{0, 75745, 5877}, +{0, 76194, 5893}, +{0, 76682, 5889}, +{0, 76737, 5877}, +{0, 76508, 5883}, +{0, 76662, 5895}, +{0, 76768, 5873}, +{0, 76785, 5878}, +{0, 76680, 5875}, +{0, 76524, 5863}, +{0, 76236, 5869}, +{0, 75933, 5864}, +{0, 75706, 5864}, +{0, 75246, 5848}, +{0, 74109, 5834}, +{0, 73140, 5829}, +{0, 72645, 5818}, +{0, 72371, 5817}, +{0, 72475, 5824}, +{0, 72654, 5823}, +{0, 72765, 5830}, +{0, 72691, 5835}, +{0, 72530, 5832}, +{0, 72256, 5837}, +{0, 71277, 5825}, +{0, 70128, 5815}, +{0, 69529, 5806}, +{0, 69262, 5810}, +{0, 69252, 5816}, +{0, 69429, 5813}, +{0, 69521, 5814}, +{0, 69398, 5808}, +{0, 69071, 5809}, +{0, 68771, 5810}, +{0, 68021, 5803}, +{0, 66642, 5792}, +{0, 65608, 5774}, +{0, 65018, 5777}, +{0, 64687, 5772}, +{0, 64674, 5762}, +{0, 65014, 5768}, +{0, 65759, 5787}, +{0, 66432, 5799}, +{0, 66646, 5787}, +{0, 67223, 5804}, +{0, 67929, 5815}, +{0, 68566, 5820}, +{0, 69257, 5830}, +{0, 69328, 5843}, +{0, 68808, 5829}, +{0, 68356, 5832}, +{0, 67702, 5829}, +{0, 67236, 5818}, +{0, 67059, 5822}, +{0, 67074, 5812}, +{0, 66592, 5811}, +{0, 66123, 5826}, +{0, 65668, 5814}, +{0, 65264, 5805}, +{0, 64861, 5811}, +{0, 64532, 5808}, +{0, 64333, 5818}, +{0, 64260, 5824}, +{0, 64172, 5831}, +{0, 64121, 5830}, +{0, 63886, 5824}, +{0, 63395, 5839}, +{0, 63283, 5831}, +{0, 63627, 5836}, +{0, 64740, 5851}, +{0, 66508, 5878}, +{0, 68738, 5908}, +{0, 70560, 5895}, +{0, 71276, 5922}, +{0, 72054, 5922}, +{0, 72124, 5912}, +{0, 71485, 5917}, +{0, 71691, 5902}, +{0, 70895, 5857}, +{0, 70368, 5851}, +{0, 70082, 5845}, +{0, 69925, 5843}, +{0, 69905, 5847}, +{0, 69942, 5852}, +{0, 70040, 5841}, +{0, 69994, 5837}, +{0, 69472, 5839}, +{0, 69057, 5846}, +{0, 68970, 5842}, +{0, 69231, 5851}, +{0, 69660, 5851}, +{0, 70155, 5869}, +{0, 70734, 5875}, +{0, 71378, 5881}, +{0, 72055, 5891}, +{0, 72588, 5879}, +{0, 72942, 5898}, +{0, 72781, 5882}, +{0, 73013, 5897}, +{0, 73351, 5887}, +{0, 73884, 5902}, +{0, 74289, 5901}, +{0, 74571, 5887}, +{0, 74683, 5891}, +{0, 74872, 5906}, +{0, 75047, 5900}, +{0, 74844, 5905}, +{0, 74167, 5891}, +{0, 73993, 5890}, +{0, 74094, 5896}, +{0, 74312, 5888}, +{0, 74558, 5894}, +{0, 74754, 5885}, +{0, 74920, 5899}, +{0, 75189, 5895}, +{0, 75489, 5888}, +{0, 75178, 5893}, +{0, 74596, 5882}, +{0, 74433, 5879}, +{0, 74408, 5886}, +{0, 74345, 5884}, +{0, 74341, 5877}, +{0, 74239, 5877}, +{0, 74135, 5869}, +{0, 74031, 5869}, +{0, 73905, 5879}, +{0, 73164, 5860}, +{0, 72268, 5851}, +{0, 71838, 5867}, +{0, 71706, 5854}, +{0, 71727, 5861}, +{0, 71907, 5857}, +{0, 72125, 5872}, +{0, 72408, 5868}, +{0, 72895, 5877}, +{0, 73338, 5881}, +{0, 73321, 5878}, +{0, 72919, 5878}, +{0, 72972, 5873}, +{0, 73083, 5870}, +{0, 73309, 5878}, +{0, 73530, 5869}, +{0, 73618, 5872}, +{0, 73596, 5885}, +{0, 73587, 5864}, +{0, 73547, 5868}, +{0, 73019, 5858}, +{0, 72151, 5853}, +{0, 71781, 5846}, +{0, 71687, 5852}, +{0, 71796, 5853}, +{0, 71949, 5857}, +{0, 72062, 5857}, +{0, 72167, 5856}, +{0, 72338, 5863}, +{0, 72655, 5873}, +{0, 72417, 5856}, +{0, 71948, 5861}, +{0, 71695, 5852}, +{0, 71640, 5850}, +{0, 71668, 5853}, +{0, 71761, 5849}, +{0, 71731, 5851}, +{0, 71692, 5849}, +{0, 71601, 5835}, +{0, 71472, 5843}, +{0, 70814, 5831}, +{0, 69756, 5818}, +{0, 69035, 5816}, +{0, 68569, 5805}, +{0, 68414, 5808}, +{0, 68345, 5801}, +{0, 68178, 5804}, +{0, 67999, 5794}, +{0, 67861, 5810}, +{0, 67663, 5807}, +{0, 66724, 5808}, +{0, 65861, 5795}, +{0, 65417, 5801}, +{0, 65260, 5785}, +{0, 65332, 5793}, +{0, 65283, 5795}, +{0, 64988, 5792}, +{0, 64675, 5786}, +{0, 64347, 5788}, +{0, 63951, 5783}, +{0, 62852, 5765}, +{0, 61867, 5770}, +{0, 61368, 5769}, +{0, 61239, 5778}, +{0, 61486, 5767}, +{0, 61988, 5774}, +{0, 62632, 5799}, +{0, 63408, 5796}, +{0, 64151, 5805}, +{0, 64517, 5813}, +{0, 63974, 5807}, +{0, 63699, 5805}, +{0, 63722, 5807}, +{0, 63989, 5806}, +{0, 64370, 5819}, +{0, 64688, 5805}, +{0, 64879, 5813}, +{0, 65024, 5816}, +{0, 65176, 5815}, +{0, 65004, 5808}, +{0, 64410, 5809}, +{0, 64106, 5817}, +{0, 63971, 5800}, +{0, 63992, 5799}, +{0, 64194, 5820}, +{0, 64332, 5812}, +{0, 64431, 5805}, +{0, 64604, 5800}, +{0, 64817, 5813}, +{0, 64292, 5806}, +{0, 63632, 5795}, +{0, 63383, 5804}, +{0, 63220, 5796}, +{0, 63175, 5793}, +{0, 63247, 5796}, +{0, 63233, 5804}, +{0, 63277, 5804}, +{0, 63287, 5797}, +{0, 63344, 5799}, +{0, 62868, 5787}, +{0, 62286, 5785}, +{0, 62076, 5784}, +{0, 62090, 5775}, +{0, 62301, 5781}, +{0, 62520, 5784}, +{0, 62761, 5789}, +{0, 62998, 5788}, +{0, 63236, 5788}, +{0, 63448, 5790}, +{0, 62970, 5788}, +{0, 62468, 5779}, +{0, 62254, 5775}, +{0, 62212, 5777}, +{0, 62281, 5775}, +{0, 62401, 5772}, +{0, 62447, 5780}, +{0, 62508, 5773}, +{0, 62578, 5768}, +{0, 62634, 5771}, +{0, 62224, 5761}, +{0, 61786, 5764}, +{0, 61571, 5758}, +{0, 61532, 5764}, +{0, 61525, 5764}, +{0, 61630, 5759}, +{0, 61746, 5766}, +{0, 61978, 5764}, +{0, 62241, 5771}, +{0, 62393, 5766}, +{0, 62041, 5760}, +{0, 61717, 5759}, +{0, 61744, 5750}, +{0, 61798, 5768}, +{0, 61958, 5764}, +{0, 62164, 5765}, +{0, 62281, 5764}, +{0, 62350, 5759}, +{0, 62417, 5768}, +{0, 62321, 5760}, +{0, 61874, 5756}, +{0, 61570, 5763}, +{0, 61516, 5769}, +{0, 61562, 5749}, +{0, 61738, 5742}, +{0, 61918, 5758}, +{0, 62105, 5751}, +{0, 62273, 5760}, +{0, 62529, 5749}, +{0, 62418, 5747}, +{0, 62035, 5750}, +{0, 61840, 5746}, +{0, 61803, 5759}, +{0, 61857, 5757}, +{0, 62023, 5745}, +{0, 62152, 5746}, +{0, 62293, 5747}, +{0, 62456, 5754}, +{0, 62602, 5756}, +{0, 62479, 5760}, +{0, 62059, 5758}, +{0, 61748, 5763}, +{0, 61755, 5754}, +{0, 62085, 5762}, +{0, 62519, 5778}, +{0, 63003, 5785}, +{0, 63486, 5788}, +{0, 63995, 5786}, +{0, 64508, 5784}, +{0, 64561, 5794}, +{0, 64397, 5786}, +{0, 64457, 5788}, +{0, 64575, 5796}, +{0, 64673, 5792}, +{0, 64803, 5785}, +{0, 64980, 5778}, +{0, 65071, 5783}, +{0, 65174, 5780}, +{0, 65294, 5781}, +{0, 65023, 5777}, +{0, 64700, 5781}, +{0, 64722, 5794}, +{0, 64954, 5779}, +{0, 65308, 5796}, +{0, 65654, 5803}, +{0, 66008, 5808}, +{0, 66386, 5811}, +{0, 66740, 5810}, +{0, 67062, 5798}, +{0, 66763, 5791}, +{0, 66183, 5779}, +{0, 65919, 5783}, +{0, 65646, 5777}, +{0, 65664, 5776}, +{0, 65711, 5785}, +{0, 65683, 5773}, +{0, 65671, 5785}, +{0, 65738, 5774}, +{0, 65819, 5787}, +{0, 65451, 5779}, +{0, 65118, 5771}, +{0, 65027, 5774}, +{0, 65271, 5782}, +{0, 65605, 5789}, +{0, 65948, 5793}, +{0, 66186, 5783}, +{0, 66328, 5788}, +{0, 66427, 5789}, +{0, 66466, 5792}, +{0, 65897, 5776}, +{0, 65270, 5771}, +{0, 64912, 5764}, +{0, 64731, 5766}, +{0, 64702, 5767}, +{0, 64758, 5761}, +{0, 64787, 5759}, +{0, 64938, 5753}, +{0, 65112, 5759}, +{0, 65230, 5762}, +{0, 65048, 5765}, +{0, 64882, 5767}, +{0, 64873, 5778}, +{0, 65103, 5769}, +{0, 65276, 5784}, +{0, 65464, 5784}, +{0, 65575, 5772}, +{0, 65649, 5774}, +{0, 65761, 5780}, +{0, 65777, 5775}, +{0, 65414, 5770}, +{0, 65099, 5769}, +{0, 65000, 5764}, +{0, 65025, 5770}, +{0, 65040, 5759}, +{0, 65073, 5765}, +{0, 65220, 5765}, +{0, 65406, 5760}, +{0, 65631, 5766}, +{0, 65865, 5770}, +{0, 65764, 5769}, +{0, 65743, 5777}, +{0, 65831, 5778}, +{0, 65952, 5775}, +{0, 66226, 5781}, +{0, 66401, 5784}, +{0, 66447, 5791}, +{0, 66398, 5780}, +{0, 66371, 5779}, +{0, 66423, 5780}, +{0, 66029, 5771}, +{0, 65662, 5765}, +{0, 65568, 5775}, +{0, 65594, 5771}, +{0, 65686, 5774}, +{0, 65890, 5776}, +{0, 66024, 5787}, +{0, 66182, 5775}, +{0, 66399, 5779}, +{0, 66569, 5771}, +{0, 66266, 5783}, +{0, 66114, 5786}, +{0, 66074, 5772}, +{0, 66060, 5784}, +{0, 66115, 5785}, +{0, 66105, 5783}, +{0, 66012, 5780}, +{0, 65946, 5782}, +{0, 65920, 5778}, +{0, 65734, 5790}, +{0, 65300, 5771}, +{0, 65110, 5768}, +{0, 65090, 5767}, +{0, 65144, 5777}, +{0, 65246, 5773}, +{0, 65414, 5770}, +{0, 65557, 5781}, +{0, 65740, 5768}, +{0, 65934, 5782}, +{0, 65981, 5768}, +{0, 65614, 5770}, +{0, 65409, 5768}, +{0, 65337, 5783}, +{0, 65317, 5779}, +{0, 65347, 5775}, +{0, 65401, 5779}, +{0, 65399, 5776}, +{0, 65420, 5777}, +{0, 65465, 5782}, +{0, 65206, 5776}, +{0, 64708, 5765}, +{0, 64445, 5773}, +{0, 64390, 5759}, +{0, 64474, 5761}, +{0, 64616, 5760}, +{0, 64708, 5766}, +{0, 64787, 5768}, +{0, 64904, 5764}, +{0, 65010, 5760}, +{0, 64665, 5743}, +{0, 64290, 5753}, +{0, 64118, 5758}, +{0, 64036, 5746}, +{0, 64071, 5753}, +{0, 64079, 5771}, +{0, 64008, 5758}, +{0, 63954, 5757}, +{0, 63947, 5762}, +{0, 63745, 5769}, +{0, 63147, 5749}, +{0, 62753, 5751}, +{0, 62511, 5745}, +{0, 62522, 5743}, +{0, 62658, 5738}, +{0, 62850, 5751}, +{0, 63096, 5758}, +{0, 63219, 5764}, +{0, 63397, 5760}, +{0, 63139, 5750}, +{0, 62637, 5742}, +{0, 62332, 5758}, +{0, 62161, 5737}, +{0, 62134, 5744}, +{0, 62162, 5727}, +{0, 62146, 5740}, +{0, 62211, 5742}, +{0, 62268, 5741}, +{0, 62296, 5735}, +{0, 61821, 5727}, +{0, 61329, 5731}, +{0, 61131, 5733}, +{0, 61167, 5723}, +{0, 61340, 5729}, +{0, 61444, 5732}, +{0, 61536, 5734}, +{0, 61631, 5747}, +{0, 61716, 5743}, +{0, 61505, 5735}, +{0, 60787, 5722}, +{0, 60345, 5731}, +{0, 60181, 5741}, +{0, 60248, 5729}, +{0, 60367, 5737}, +{0, 60461, 5731}, +{0, 60632, 5730}, +{0, 60762, 5744}, +{0, 60915, 5718}, +{0, 60493, 5732}, +{0, 60104, 5731}, +{0, 59990, 5723}, +{0, 60105, 5727}, +{0, 60318, 5729}, +{0, 60557, 5738}, +{0, 60774, 5735}, +{0, 60965, 5726}, +{0, 61098, 5739}, +{0, 60909, 5738}, +{0, 60327, 5738}, +{0, 59928, 5732}, +{0, 59877, 5738}, +{0, 59907, 5723}, +{0, 60155, 5737}, +{0, 60278, 5744}, +{0, 60408, 5733}, +{0, 60642, 5738}, +{0, 60747, 5738}, +{0, 60382, 5735}, +{0, 60107, 5730}, +{0, 60189, 5733}, +{0, 60398, 5731}, +{0, 60675, 5735}, +{0, 60925, 5743}, +{0, 61206, 5762}, +{0, 61511, 5754}, +{0, 61864, 5773}, +{0, 61935, 5746}, +{0, 61608, 5752}, +{0, 61605, 5754}, +{0, 61722, 5757}, +{0, 61819, 5756}, +{0, 61935, 5754}, +{0, 62005, 5755}, +{0, 62119, 5737}, +{0, 62356, 5755}, +{0, 62664, 5758}, +{0, 62743, 5758}, +{0, 62874, 5759}, +{0, 63192, 5772}, +{0, 63557, 5776}, +{0, 63993, 5791}, +{0, 64457, 5788}, +{0, 64667, 5808}, +{0, 64672, 5779}, +{0, 64583, 5778}, +{0, 64148, 5768}, +{0, 63687, 5762}, +{0, 63436, 5761}, +{0, 63363, 5751}, +{0, 63396, 5768}, +{0, 63591, 5753}, +{0, 63767, 5756}, +{0, 63919, 5763}, +{0, 64148, 5773}, +{0, 64423, 5776}, +{0, 64354, 5782}, +{0, 64326, 5774}, +{0, 64347, 5775}, +{0, 64417, 5781}, +{0, 64483, 5770}, +{0, 64511, 5768}, +{0, 64398, 5758}, +{0, 64234, 5750}, +{0, 64125, 5749}, +{0, 63702, 5748}, +{0, 63276, 5737}, +{0, 63115, 5742}, +{0, 63116, 5736}, +{0, 63333, 5760}, +{0, 63639, 5754}, +{0, 63971, 5768}, +{0, 64317, 5771}, +{0, 64662, 5779}, +{0, 64835, 5766}, +{0, 64640, 5774}, +{0, 64461, 5762}, +{0, 64329, 5772}, +{0, 64323, 5765}, +{0, 64358, 5771}, +{0, 64365, 5752}, +{0, 64315, 5762}, +{0, 64374, 5760}, +{0, 64409, 5775}, +{0, 64065, 5755}, +{0, 63710, 5764}, +{0, 63622, 5751}, +{0, 63622, 5763}, +{0, 63793, 5758}, +{0, 64031, 5763}, +{0, 64245, 5764}, +{0, 64488, 5756}, +{0, 64749, 5766}, +{0, 64617, 5757}, +{0, 64352, 5759}, +{0, 64136, 5758}, +{0, 64014, 5749}, +{0, 64040, 5754}, +{0, 64046, 5756}, +{0, 64095, 5763}, +{0, 64098, 5755}, +{0, 64138, 5759}, +{0, 63955, 5753}, +{0, 63361, 5760}, +{0, 63008, 5748}, +{0, 62864, 5747}, +{0, 62913, 5756}, +{0, 63108, 5748}, +{0, 63239, 5748}, +{0, 63376, 5747}, +{0, 63590, 5752}, +{0, 63659, 5756}, +{0, 63189, 5736}, +{0, 62855, 5750}, +{0, 62591, 5741}, +{0, 62464, 5747}, +{0, 62395, 5736}, +{0, 62361, 5739}, +{0, 62420, 5746}, +{0, 62539, 5740}, +{0, 62640, 5733}, +{0, 62287, 5744}, +{0, 61802, 5721}, +{0, 61712, 5732}, +{0, 61717, 5734}, +{0, 61936, 5731}, +{0, 62140, 5733}, +{0, 62389, 5746}, +{0, 62592, 5751}, +{0, 62793, 5754}, +{0, 62674, 5743}, +{0, 62331, 5746}, +{0, 62134, 5745}, +{0, 62047, 5740}, +{0, 62065, 5749}, +{0, 62175, 5738}, +{0, 62296, 5762}, +{0, 62479, 5745}, +{0, 62641, 5745}, +{0, 62776, 5754}, +{0, 62507, 5738}, +{0, 62360, 5742}, +{0, 62422, 5746}, +{0, 62578, 5742}, +{0, 62801, 5740}, +{0, 62981, 5744}, +{0, 63075, 5748}, +{0, 63254, 5757}, +{0, 63363, 5748}, +{0, 63030, 5745}, +{0, 62689, 5741}, +{0, 62470, 5740}, +{0, 62370, 5744}, +{0, 62403, 5750}, +{0, 62483, 5742}, +{0, 62575, 5738}, +{0, 62695, 5745}, +{0, 63069, 5756}, +{0, 63296, 5751}, +{0, 63314, 5749}, +{0, 63217, 5758}, +{0, 63309, 5760}, +{0, 63452, 5758}, +{0, 63635, 5744}, +{0, 63826, 5756}, +{0, 63935, 5759}, +{0, 63999, 5757}, +{0, 63655, 5750}, +{0, 63351, 5755}, +{0, 63208, 5745}, +{0, 63206, 5748}, +{0, 63277, 5749}, +{0, 63469, 5753}, +{0, 63729, 5755}, +{0, 63966, 5764}, +{0, 64137, 5752}, +{0, 64112, 5757}, +{0, 63987, 5759}, +{0, 63732, 5781}, +{0, 63601, 5766}, +{0, 63678, 5769}, +{0, 63797, 5772}, +{0, 63884, 5769}, +{0, 63884, 5768}, +{0, 63918, 5761}, +{0, 63836, 5765}, +{0, 63581, 5762}, +{0, 63400, 5760}, +{0, 63287, 5760}, +{0, 63299, 5762}, +{0, 63377, 5759}, +{0, 63602, 5756}, +{0, 63770, 5753}, +{0, 64167, 5770}, +{0, 64532, 5774}, +{0, 64516, 5779}, +{0, 64481, 5769}, +{0, 64437, 5773}, +{0, 64521, 5778}, +{0, 64509, 5767}, +{0, 64520, 5778}, +{0, 64447, 5777}, +{0, 64397, 5770}, +{0, 64370, 5765}, +{0, 64160, 5768}, +{0, 63821, 5759}, +{0, 63573, 5761}, +{0, 63482, 5763}, +{0, 63505, 5757}, +{0, 63565, 5761}, +{0, 63695, 5755}, +{0, 63855, 5770}, +{0, 63950, 5762}, +{0, 63716, 5763}, +{0, 63219, 5762}, +{0, 62846, 5748}, +{0, 62658, 5752}, +{0, 62592, 5761}, +{0, 62540, 5735}, +{0, 62563, 5750}, +{0, 62569, 5757}, +{0, 62628, 5747}, +{0, 62420, 5743}, +{0, 61910, 5741}, +{0, 61690, 5742}, +{0, 61672, 5757}, +{0, 61870, 5747}, +{0, 62132, 5740}, +{0, 62472, 5755}, +{0, 62911, 5765}, +{0, 63297, 5773}, +{0, 63437, 5765}, +{0, 63107, 5773}, +{0, 63006, 5772}, +{0, 62997, 5769}, +{0, 62962, 5762}, +{0, 63064, 5765}, +{0, 63159, 5763}, +{0, 63242, 5770}, +{0, 63358, 5761}, +{0, 63449, 5761}, +{0, 63321, 5766}, +{0, 63150, 5761}, +{0, 63133, 5762}, +{0, 63367, 5782}, +{0, 63649, 5759}, +{0, 64041, 5781}, +{0, 64376, 5779}, +{0, 64717, 5792}, +{0, 65015, 5789}, +{0, 64825, 5787}, +{0, 64526, 5781}, +{0, 64226, 5784}, +{0, 64006, 5777}, +{0, 63941, 5784}, +{0, 64014, 5776}, +{0, 64072, 5789}, +{0, 64077, 5770}, +{0, 64241, 5770}, +{0, 64040, 5772}, +{0, 63628, 5763}, +{0, 63414, 5762}, +{0, 63471, 5768}, +{0, 63684, 5773}, +{0, 63888, 5776}, +{0, 64024, 5770}, +{0, 64124, 5775}, +{0, 64260, 5777}, +{0, 64026, 5763}, +{0, 63414, 5776}, +{0, 62978, 5760}, +{0, 62713, 5760}, +{0, 62586, 5756}, +{0, 62588, 5743}, +{0, 62620, 5759}, +{0, 62765, 5748}, +{0, 62946, 5760}, +{0, 62902, 5754}, +{0, 62456, 5748}, +{0, 62211, 5749}, +{0, 62172, 5759}, +{0, 62189, 5746}, +{0, 62341, 5764}, +{0, 62470, 5762}, +{0, 62529, 5759}, +{0, 62579, 5764}, +{0, 62535, 5747}, +{0, 61983, 5739}, +{0, 61407, 5751}, +{0, 61151, 5747}, +{0, 61085, 5743}, +{0, 61183, 5736}, +{0, 61289, 5736}, +{0, 61472, 5737}, +{0, 61717, 5748}, +{0, 61983, 5754}, +{0, 61816, 5744}, +{0, 61361, 5754}, +{0, 61275, 5736}, +{0, 61235, 5741}, +{0, 61351, 5747}, +{0, 61462, 5755}, +{0, 61521, 5754}, +{0, 61551, 5747}, +{0, 61576, 5754}, +{0, 61585, 5764}, +{0, 61220, 5745}, +{0, 60991, 5743}, +{0, 61000, 5747}, +{0, 61196, 5740}, +{0, 61561, 5753}, +{0, 61866, 5754}, +{0, 62172, 5747}, +{0, 62484, 5759}, +{0, 62803, 5768}, +{0, 62628, 5752}, +{0, 62286, 5766}, +{0, 62272, 5762}, +{0, 62382, 5767}, +{0, 62551, 5763}, +{0, 62704, 5758}, +{0, 62756, 5755}, +{0, 62805, 5769}, +{0, 62874, 5762}, +{0, 62686, 5758}, +{0, 62017, 5756}, +{0, 61656, 5755}, +{0, 61481, 5747}, +{0, 61410, 5752}, +{0, 61404, 5751}, +{0, 61426, 5754}, +{0, 61636, 5756}, +{0, 61908, 5752}, +{0, 62211, 5760}, +{0, 62010, 5755}, +{0, 61685, 5756}, +{0, 61541, 5749}, +{0, 61511, 5746}, +{0, 61593, 5757}, +{0, 61610, 5760}, +{0, 61607, 5762}, +{0, 61511, 5753}, +{0, 61551, 5748}, +{0, 61497, 5747}, +{0, 61484, 5748}, +{0, 61526, 5750}, +{0, 61645, 5739}, +{0, 61786, 5751}, +{0, 62042, 5756}, +{0, 62390, 5757}, +{0, 62832, 5771}, +{0, 63289, 5769}, +{0, 63709, 5784}, +{0, 63647, 5782}, +{0, 63323, 5767}, +{0, 63181, 5771}, +{0, 63174, 5771}, +{0, 63162, 5763}, +{0, 63154, 5768}, +{0, 63011, 5762}, +{0, 63026, 5759}, +{0, 63142, 5753}, +{0, 62934, 5757}, +{0, 62515, 5760}, +{0, 62312, 5757}, +{0, 62297, 5754}, +{0, 62433, 5751}, +{0, 62682, 5754}, +{0, 62858, 5770}, +{0, 63028, 5755}, +{0, 63303, 5764}, +{0, 63398, 5755}, +{0, 62993, 5757}, +{0, 62608, 5753}, +{0, 62458, 5751}, +{0, 62346, 5743}, +{0, 62280, 5754}, +{0, 62242, 5763}, +{0, 62303, 5758}, +{0, 62358, 5765}, +{0, 62472, 5752}, +{0, 62424, 5752}, +{0, 62311, 5755}, +{0, 62270, 5752}, +{0, 62418, 5742}, +{0, 62654, 5760}, +{0, 62962, 5759}, +{0, 63310, 5777}, +{0, 63590, 5766}, +{0, 63899, 5772}, +{0, 64095, 5770}, +{0, 63684, 5757}, +{0, 63343, 5759}, +{0, 63230, 5759}, +{0, 63190, 5761}, +{0, 63277, 5762}, +{0, 63404, 5762}, +{0, 63526, 5775}, +{0, 63639, 5768}, +{0, 63752, 5771}, +{0, 63594, 5767}, +{0, 63147, 5760}, +{0, 62958, 5761}, +{0, 63029, 5754}, +{0, 63132, 5751}, +{0, 63350, 5763}, +{0, 63580, 5762}, +{0, 63728, 5762}, +{0, 63925, 5768}, +{0, 63941, 5769}, +{0, 63374, 5768}, +{0, 63028, 5750}, +{0, 62776, 5750}, +{0, 62640, 5756}, +{0, 62609, 5752}, +{0, 62681, 5755}, +{0, 62738, 5758}, +{0, 62820, 5763}, +{0, 62920, 5766}, +{0, 62639, 5759}, +{0, 62154, 5747}, +{0, 61864, 5743}, +{0, 61888, 5754}, +{0, 61960, 5753}, +{0, 62239, 5756}, +{0, 62466, 5758}, +{0, 62673, 5744}, +{0, 62900, 5764}, +{0, 62949, 5756}, +{0, 62397, 5750}, +{0, 61978, 5739}, +{0, 61755, 5753}, +{0, 61742, 5750}, +{0, 61845, 5753}, +{0, 62054, 5757}, +{0, 62186, 5766}, +{0, 62475, 5747}, +{0, 62930, 5770}, +{0, 63060, 5779}, +{0, 63022, 5779}, +{0, 63195, 5789}, +{0, 63697, 5783}, +{0, 64224, 5793}, +{0, 64910, 5810}, +{0, 65466, 5818}, +{0, 65995, 5809}, +{0, 66372, 5816}, +{0, 66701, 5813}, +{0, 66300, 5808}, +{0, 65946, 5809}, +{0, 65914, 5801}, +{0, 66021, 5804}, +{0, 66248, 5800}, +{0, 66482, 5807}, +{0, 66756, 5813}, +{0, 67131, 5814}, +{0, 67588, 5818}, +{0, 67899, 5825}, +{0, 67683, 5829}, +{0, 67813, 5826}, +{0, 68164, 5831}, +{0, 68446, 5820}, +{0, 68572, 5827}, +{0, 68717, 5829}, +{0, 68651, 5818}, +{0, 68414, 5813}, +{0, 67988, 5809}, +{0, 66941, 5788}, +{0, 65900, 5771}, +{0, 65298, 5767}, +{0, 64972, 5767}, +{0, 64967, 5779}, +{0, 65180, 5779}, +{0, 65468, 5791}, +{0, 65798, 5789}, +{0, 66108, 5798}, +{0, 66179, 5801}, +{0, 65593, 5790}, +{0, 65138, 5785}, +{0, 64874, 5788}, +{0, 64714, 5776}, +{0, 64530, 5775}, +{0, 64268, 5760}, +{0, 63955, 5763}, +{0, 63708, 5756}, +{0, 63417, 5753}, +{0, 62657, 5751}, +{0, 61682, 5742}, +{0, 61233, 5736}, +{0, 61069, 5742}, +{0, 61310, 5746}, +{0, 61715, 5746}, +{0, 62000, 5746}, +{0, 62230, 5752}, +{0, 62449, 5757}, +{0, 62507, 5774}, +{0, 61654, 5746}, +{0, 60821, 5744}, +{0, 60387, 5737}, +{0, 59880, 5735}, +{0, 59496, 5728}, +{0, 59358, 5732}, +{0, 59354, 5723}, +{0, 59329, 5742}, +{0, 59331, 5737}, +{0, 59350, 5734}, +{0, 58819, 5728}, +{0, 58525, 5740}, +{0, 58515, 5728}, +{0, 58705, 5738}, +{0, 59026, 5744}, +{0, 59270, 5742}, +{0, 59452, 5751}, +{0, 59545, 5756}, +{0, 59445, 5766}, +{0, 58818, 5743}, +{0, 58052, 5742}, +{0, 57569, 5734}, +{0, 57291, 5741}, +{0, 57174, 5719}, +{0, 57123, 5728}, +{0, 57029, 5735}, +{0, 57037, 5725}, +{0, 57128, 5732}, +{0, 57275, 5739}, +{0, 57110, 5733}, +{0, 56866, 5719}, +{0, 56784, 5736}, +{0, 56829, 5726}, +{0, 56994, 5735}, +{0, 57163, 5734}, +{0, 57203, 5731}, +{0, 57254, 5731}, +{0, 57384, 5735}, +{0, 57097, 5737}, +{0, 56576, 5730}, +{0, 56363, 5713}, +{0, 56377, 5712}, +{0, 56788, 5709}, +{0, 57322, 5724}, +{0, 57840, 5728}, +{0, 58287, 5746}, +{0, 58599, 5765}, +{0, 58873, 5755}, +{0, 58992, 5759}, +{0, 59133, 5769}, +{0, 59547, 5776}, +{0, 59909, 5776}, +{0, 60181, 5785}, +{0, 60555, 5793}, +{0, 61020, 5794}, +{0, 61340, 5797}, +{0, 61674, 5807}, +{0, 62036, 5793}, +{0, 61854, 5794}, +{0, 61705, 5814}, +{0, 61585, 5800}, +{0, 61722, 5805}, +{0, 62005, 5809}, +{0, 62302, 5810}, +{0, 62595, 5805}, +{0, 62918, 5820}, +{0, 63313, 5820}, +{0, 63635, 5831}, +{0, 63577, 5836}, +{0, 63674, 5823}, +{0, 64003, 5819}, +{0, 64328, 5816}, +{0, 64621, 5828}, +{0, 64843, 5829}, +{0, 64937, 5817}, +{0, 65114, 5801}, +{0, 65204, 5813}, +{0, 64832, 5809}, +{0, 64433, 5810}, +{0, 64394, 5802}, +{0, 64461, 5801}, +{0, 64496, 5809}, +{0, 64595, 5796}, +{0, 64774, 5791}, +{0, 65024, 5797}, +{0, 65207, 5801}, +{0, 65222, 5796}, +{0, 64850, 5784}, +{0, 64501, 5796}, +{0, 64304, 5796}, +{0, 64228, 5791}, +{0, 64207, 5780}, +{0, 64083, 5781}, +{0, 63955, 5779}, +{0, 63836, 5782}, +{0, 63848, 5786}, +{0, 63637, 5773}, +{0, 63210, 5761}, +{0, 62985, 5764}, +{0, 63039, 5767}, +{0, 63197, 5760}, +{0, 63341, 5778}, +{0, 63544, 5769}, +{0, 63739, 5767}, +{0, 63995, 5772}, +{0, 64323, 5767}, +{0, 64049, 5771}, +{0, 63642, 5765}, +{0, 63411, 5776}, +{0, 63356, 5765}, +{0, 63354, 5760}, +{0, 63317, 5751}, +{0, 63314, 5766}, +{0, 63295, 5763}, +{0, 63400, 5766}, +{0, 63437, 5758}, +{0, 63369, 5753}, +{0, 63327, 5767}, +{0, 63399, 5759}, +{0, 63467, 5750}, +{0, 63522, 5749}, +{0, 63643, 5760}, +{0, 63746, 5760}, +{0, 63901, 5755}, +{0, 63995, 5758}, +{0, 63701, 5752}, +{0, 63011, 5745}, +{0, 62404, 5752}, +{0, 62038, 5750}, +{0, 61801, 5749}, +{0, 61751, 5745}, +{0, 61743, 5751}, +{0, 61793, 5749}, +{0, 61898, 5745}, +{0, 62023, 5747}, +{0, 61989, 5745}, +{0, 61826, 5761}, +{0, 61562, 5750}, +{0, 61468, 5744}, +{0, 61576, 5749}, +{0, 61709, 5746}, +{0, 61772, 5750}, +{0, 61894, 5748}, +{0, 62009, 5755}, +{0, 61689, 5750}, +{0, 60954, 5751}, +{0, 60651, 5746}, +{0, 60585, 5749}, +{0, 60813, 5753}, +{0, 61144, 5773}, +{0, 61595, 5769}, +{0, 62118, 5771}, +{0, 62545, 5772}, +{0, 63013, 5782}, +{0, 62921, 5776}, +{0, 62850, 5789}, +{0, 63039, 5782}, +{0, 63403, 5789}, +{0, 63687, 5795}, +{0, 64014, 5791}, +{0, 64196, 5800}, +{0, 64372, 5798}, +{0, 64558, 5792}, +{0, 64607, 5795}, +{0, 64151, 5787}, +{0, 63895, 5787}, +{0, 63954, 5799}, +{0, 64189, 5779}, +{0, 64587, 5797}, +{0, 64970, 5815}, +{0, 65360, 5812}, +{0, 65723, 5796}, +{0, 66100, 5807}, +{0, 65975, 5796}, +{0, 65534, 5808}, +{0, 65351, 5795}, +{0, 65235, 5793}, +{0, 65136, 5783}, +{0, 64956, 5786}, +{0, 64777, 5778}, +{0, 64592, 5776}, +{0, 64480, 5778}, +{0, 64341, 5773}, +{0, 63685, 5778}, +{0, 63290, 5765}, +{0, 63096, 5767}, +{0, 63082, 5765}, +{0, 63151, 5769}, +{0, 63320, 5775}, +{0, 63511, 5790}, +{0, 63711, 5780}, +{0, 63809, 5779}, +{0, 63518, 5773}, +{0, 63015, 5767}, +{0, 62667, 5757}, +{0, 62371, 5760}, +{0, 62291, 5769}, +{0, 62318, 5751}, +{0, 62416, 5759}, +{0, 62491, 5772}, +{0, 62615, 5768}, +{0, 62820, 5780}, +{0, 62766, 5766}, +{0, 62747, 5767}, +{0, 63006, 5772}, +{0, 63298, 5786}, +{0, 63805, 5800}, +{0, 64308, 5792}, +{0, 64580, 5798}, +{0, 64543, 5797}, +{0, 64519, 5794}, +{0, 64231, 5788}, +{0, 63415, 5779}, +{0, 62813, 5780}, +{0, 62529, 5770}, +{0, 62474, 5761}, +{0, 62398, 5768}, +{0, 62397, 5763}, +{0, 62343, 5759}, +{0, 62261, 5762}, +{0, 62380, 5747}, +{0, 62215, 5753}, +{0, 61797, 5751}, +{0, 61596, 5748}, +{0, 61604, 5756}, +{0, 61836, 5762}, +{0, 62020, 5772}, +{0, 62051, 5761}, +{0, 62117, 5753}, +{0, 62315, 5767}, +{0, 62360, 5753}, +{0, 61815, 5764}, +{0, 61413, 5765}, +{0, 61228, 5760}, +{0, 61243, 5763}, +{0, 61355, 5763}, +{0, 61465, 5763}, +{0, 61588, 5761}, +{0, 61827, 5756}, +{0, 62006, 5774}, +{0, 61740, 5766}, +{0, 61107, 5748}, +{0, 60842, 5763}, +{0, 60838, 5763}, +{0, 60879, 5764}, +{0, 60958, 5768}, +{0, 61025, 5765}, +{0, 61060, 5758}, +{0, 61128, 5766}, +{0, 61120, 5766}, +{0, 60481, 5756}, +{0, 59914, 5755}, +{0, 59784, 5756}, +{0, 59777, 5762}, +{0, 59909, 5754}, +{0, 60083, 5757}, +{0, 60273, 5750}, +{0, 60514, 5752}, +{0, 60767, 5765}, +{0, 60808, 5754}, +{0, 60216, 5760}, +{0, 59910, 5738}, +{0, 59901, 5752}, +{0, 60023, 5769}, +{0, 60248, 5747}, +{0, 60533, 5744}, +{0, 60757, 5758}, +{0, 60971, 5770}, +{0, 61228, 5762}, +{0, 61118, 5753}, +{0, 60529, 5747}, +{0, 60192, 5745}, +{0, 60154, 5760}, +{0, 60270, 5749}, +{0, 60504, 5748}, +{0, 60755, 5762}, +{0, 60987, 5762}, +{0, 61232, 5763}, +{0, 61545, 5772}, +{0, 61119, 5764}, +{0, 60678, 5754}, +{0, 60493, 5762}, +{0, 60521, 5758}, +{0, 60591, 5754}, +{0, 60694, 5764}, +{0, 60803, 5757}, +{0, 60882, 5765}, +{0, 61101, 5764}, +{0, 61053, 5762}, +{0, 60476, 5753}, +{0, 60163, 5745}, +{0, 60176, 5754}, +{0, 60286, 5753}, +{0, 60471, 5761}, +{0, 60597, 5762}, +{0, 60765, 5750}, +{0, 60997, 5761}, +{0, 61186, 5760}, +{0, 61057, 5762}, +{0, 60504, 5741}, +{0, 60319, 5755}, +{0, 60354, 5755}, +{0, 60391, 5750}, +{0, 60439, 5751}, +{0, 60638, 5759}, +{0, 60767, 5754}, +{0, 60935, 5758}, +{0, 61126, 5760}, +{0, 60949, 5745}, +{0, 60527, 5750}, +{0, 60443, 5760}, +{0, 60562, 5750}, +{0, 60801, 5748}, +{0, 61128, 5754}, +{0, 61414, 5750}, +{0, 61637, 5757}, +{0, 61799, 5764}, +{0, 61925, 5765}, +{0, 61318, 5750}, +{0, 60805, 5743}, +{0, 60637, 5753}, +{0, 60530, 5749}, +{0, 60663, 5751}, +{0, 60765, 5756}, +{0, 60836, 5761}, +{0, 61034, 5764}, +{0, 61247, 5756}, +{0, 61305, 5746}, +{0, 60906, 5748}, +{0, 60653, 5750}, +{0, 60763, 5755}, +{0, 60995, 5751}, +{0, 61257, 5750}, +{0, 61507, 5756}, +{0, 61611, 5763}, +{0, 61801, 5767}, +{0, 62006, 5761}, +{0, 61518, 5762}, +{0, 60908, 5756}, +{0, 60678, 5741}, +{0, 60636, 5741}, +{0, 60638, 5755}, +{0, 60782, 5742}, +{0, 60932, 5749}, +{0, 61152, 5753}, +{0, 61356, 5757}, +{0, 61590, 5752}, +{0, 61185, 5753}, +{0, 60885, 5744}, +{0, 60924, 5749}, +{0, 61051, 5745}, +{0, 61224, 5755}, +{0, 61432, 5758}, +{0, 61663, 5753}, +{0, 61788, 5757}, +{0, 61848, 5763}, +{0, 61655, 5762}, +{0, 61100, 5749}, +{0, 60799, 5753}, +{0, 60930, 5756}, +{0, 61177, 5769}, +{0, 61555, 5760}, +{0, 61857, 5761}, +{0, 62092, 5772}, +{0, 62220, 5776}, +{0, 62445, 5767}, +{0, 62334, 5773}, +{0, 61905, 5771}, +{0, 61789, 5772}, +{0, 61878, 5775}, +{0, 62054, 5771}, +{0, 62205, 5772}, +{0, 62328, 5766}, +{0, 62407, 5769}, +{0, 62495, 5765}, +{0, 62495, 5759}, +{0, 62005, 5761}, +{0, 61616, 5767}, +{0, 61503, 5766}, +{0, 61602, 5758}, +{0, 61782, 5765}, +{0, 61961, 5753}, +{0, 62120, 5769}, +{0, 62290, 5768}, +{0, 62478, 5762}, +{0, 62490, 5762}, +{0, 61913, 5760}, +{0, 61594, 5758}, +{0, 61515, 5765}, +{0, 61640, 5761}, +{0, 61692, 5759}, +{0, 61827, 5755}, +{0, 61797, 5751}, +{0, 61813, 5742}, +{0, 62036, 5745}, +{0, 61561, 5728}, +{0, 61086, 5738}, +{0, 60923, 5739}, +{0, 60929, 5749}, +{0, 61136, 5744}, +{0, 61373, 5761}, +{0, 61605, 5756}, +{0, 61880, 5768}, +{0, 62064, 5774}, +{0, 62169, 5777}, +{0, 61895, 5761}, +{0, 62248, 5790}, +{0, 62649, 5785}, +{0, 63056, 5790}, +{0, 63459, 5794}, +{0, 63755, 5790}, +{0, 63968, 5803}, +{0, 63975, 5787}, +{0, 64034, 5803}, +{0, 63465, 5792}, +{0, 62798, 5789}, +{0, 62708, 5780}, +{0, 62791, 5788}, +{0, 62952, 5778}, +{0, 63170, 5772}, +{0, 63326, 5790}, +{0, 63500, 5789}, +{0, 63731, 5793}, +{0, 63953, 5791}, +{0, 63556, 5791}, +{0, 63278, 5797}, +{0, 63188, 5799}, +{0, 63161, 5783}, +{0, 63197, 5793}, +{0, 63261, 5793}, +{0, 63118, 5795}, +{0, 63035, 5797}, +{0, 62978, 5804}, +{0, 62831, 5781}, +{0, 62288, 5783}, +{0, 61923, 5779}, +{0, 61893, 5786}, +{0, 62082, 5781}, +{0, 62299, 5780}, +{0, 62488, 5772}, +{0, 62663, 5784}, +{0, 62891, 5785}, +{0, 63095, 5783}, +{0, 62599, 5780}, +{0, 62140, 5774}, +{0, 61934, 5768}, +{0, 61857, 5781}, +{0, 61991, 5782}, +{0, 62116, 5770}, +{0, 62133, 5780}, +{0, 62187, 5793}, +{0, 62388, 5779}, +{0, 62226, 5771}, +{0, 61572, 5774}, +{0, 61252, 5767}, +{0, 61281, 5764}, +{0, 61458, 5774}, +{0, 61656, 5776}, +{0, 61844, 5780}, +{0, 62050, 5790}, +{0, 62420, 5782}, +{0, 62644, 5777}, +{0, 62145, 5781}, +{0, 61751, 5780}, +{0, 61625, 5777}, +{0, 61618, 5789}, +{0, 61696, 5782}, +{0, 61788, 5782}, +{0, 61874, 5777}, +{0, 62052, 5785}, +{0, 62266, 5778}, +{0, 62277, 5786}, +{0, 61693, 5772}, +{0, 61435, 5778}, +{0, 61478, 5774}, +{0, 61711, 5764}, +{0, 61963, 5774}, +{0, 62215, 5776}, +{0, 62488, 5775}, +{0, 62743, 5788}, +{0, 63075, 5777}, +{0, 62594, 5783}, +{0, 62240, 5774}, +{0, 62145, 5775}, +{0, 62187, 5777}, +{0, 62278, 5776}, +{0, 62370, 5787}, +{0, 62541, 5776}, +{0, 62705, 5782}, +{0, 62874, 5783}, +{0, 62884, 5776}, +{0, 62389, 5773}, +{0, 62256, 5777}, +{0, 62397, 5768}, +{0, 62622, 5762}, +{0, 62894, 5773}, +{0, 63120, 5786}, +{0, 63277, 5773}, +{0, 63460, 5786}, +{0, 63655, 5783}, +{0, 63108, 5776}, +{0, 62718, 5775}, +{0, 62604, 5767}, +{0, 62563, 5769}, +{0, 62588, 5765}, +{0, 62552, 5769}, +{0, 62597, 5777}, +{0, 62628, 5780}, +{0, 62750, 5772}, +{0, 62529, 5768}, +{0, 61909, 5758}, +{0, 61576, 5762}, +{0, 61491, 5766}, +{0, 61657, 5759}, +{0, 61816, 5770}, +{0, 61928, 5765}, +{0, 62069, 5770}, +{0, 62260, 5770}, +{0, 62413, 5767}, +{0, 61801, 5770}, +{0, 61443, 5760}, +{0, 61378, 5762}, +{0, 61482, 5765}, +{0, 61646, 5765}, +{0, 61804, 5770}, +{0, 61832, 5771}, +{0, 61897, 5765}, +{0, 62009, 5767}, +{0, 61689, 5760}, +{0, 61014, 5750}, +{0, 60775, 5767}, +{0, 60705, 5755}, +{0, 60819, 5763}, +{0, 61163, 5762}, +{0, 61478, 5768}, +{0, 61753, 5764}, +{0, 62056, 5767}, +{0, 62274, 5765}, +{0, 61735, 5768}, +{0, 61425, 5760}, +{0, 61502, 5765}, +{0, 61651, 5762}, +{0, 61912, 5769}, +{0, 62253, 5775}, +{0, 62469, 5770}, +{0, 62734, 5774}, +{0, 62879, 5780}, +{0, 62580, 5783}, +{0, 61939, 5776}, +{0, 61669, 5771}, +{0, 61602, 5767}, +{0, 61671, 5786}, +{0, 61839, 5781}, +{0, 61977, 5771}, +{0, 62185, 5776}, +{0, 62400, 5783}, +{0, 62562, 5778}, +{0, 61962, 5760}, +{0, 61616, 5757}, +{0, 61672, 5776}, +{0, 61838, 5778}, +{0, 62090, 5758}, +{0, 62358, 5772}, +{0, 62582, 5779}, +{0, 62693, 5792}, +{0, 62966, 5791}, +{0, 62697, 5791}, +{0, 62455, 5783}, +{0, 62467, 5769}, +{0, 62605, 5783}, +{0, 62840, 5782}, +{0, 63168, 5786}, +{0, 63532, 5784}, +{0, 63896, 5794}, +{0, 64291, 5805}, +{0, 64758, 5804}, +{0, 64611, 5794}, +{0, 64211, 5797}, +{0, 64158, 5792}, +{0, 64267, 5801}, +{0, 64491, 5802}, +{0, 64811, 5805}, +{0, 65062, 5815}, +{0, 65306, 5812}, +{0, 65441, 5804}, +{0, 65284, 5799}, +{0, 64434, 5774}, +{0, 63854, 5784}, +{0, 63529, 5769}, +{0, 63279, 5760}, +{0, 63190, 5774}, +{0, 63219, 5760}, +{0, 63263, 5769}, +{0, 63351, 5765}, +{0, 63564, 5787}, +{0, 63277, 5774}, +{0, 62796, 5769}, +{0, 62506, 5764}, +{0, 62471, 5767}, +{0, 62562, 5770}, +{0, 62702, 5773}, +{0, 62732, 5769}, +{0, 62756, 5769}, +{0, 62713, 5764}, +{0, 62552, 5751}, +{0, 61826, 5756}, +{0, 61372, 5737}, +{0, 61237, 5751}, +{0, 61209, 5748}, +{0, 61388, 5754}, +{0, 61627, 5755}, +{0, 61730, 5766}, +{0, 61872, 5759}, +{0, 62014, 5754}, +{0, 61843, 5745}, +{0, 61188, 5759}, +{0, 60888, 5747}, +{0, 60594, 5760}, +{0, 60498, 5748}, +{0, 60528, 5757}, +{0, 60562, 5760}, +{0, 60561, 5753}, +{0, 60578, 5761}, +{0, 60557, 5750}, +{0, 59837, 5740}, +{0, 59182, 5725}, +{0, 58867, 5734}, +{0, 58708, 5732}, +{0, 58715, 5737}, +{0, 59117, 5744}, +{0, 59494, 5750}, +{0, 59745, 5759}, +{0, 60013, 5751}, +{0, 60076, 5742}, +{0, 59533, 5746}, +{0, 59173, 5744}, +{0, 59078, 5750}, +{0, 59113, 5750}, +{0, 59176, 5736}, +{0, 59239, 5744}, +{0, 59261, 5742}, +{0, 59241, 5745}, +{0, 59107, 5738}, +{0, 58684, 5723}, +{0, 58056, 5724}, +{0, 58010, 5735}, +{0, 58179, 5725}, +{0, 58548, 5737}, +{0, 59193, 5734}, +{0, 60022, 5738}, +{0, 61146, 5744}, +{0, 62468, 5761}, +{0, 63258, 5771}, +{0, 63210, 5769}, +{0, 63247, 5785}, +{0, 63493, 5783}, +{0, 63955, 5803}, +{0, 64734, 5807}, +{0, 65604, 5823}, +{0, 66555, 5835}, +{0, 67298, 5832}, +{0, 68032, 5844}, +{0, 68529, 5855}, +{0, 68500, 5848}, +{0, 68548, 5838}, +{0, 68630, 5840}, +{0, 68718, 5842}, +{0, 68746, 5839}, +{0, 68648, 5832}, +{0, 68411, 5830}, +{0, 68303, 5823}, +{0, 68230, 5824}, +{0, 67843, 5833}, +{0, 67282, 5807}, +{0, 67002, 5809}, +{0, 66832, 5822}, +{0, 66800, 5821}, +{0, 66781, 5823}, +{0, 66724, 5813}, +{0, 66764, 5822}, +{0, 66858, 5811}, +{0, 67014, 5811}, +{0, 66649, 5821}, +{0, 66162, 5810}, +{0, 65993, 5806}, +{0, 65948, 5800}, +{0, 66044, 5805}, +{0, 66143, 5811}, +{0, 66272, 5808}, +{0, 66337, 5807}, +{0, 66426, 5796}, +{0, 66364, 5809}, +{0, 65737, 5791}, +{0, 65333, 5797}, +{0, 65088, 5803}, +{0, 65079, 5785}, +{0, 65175, 5788}, +{0, 65235, 5798}, +{0, 65320, 5797}, +{0, 65371, 5797}, +{0, 65491, 5798}, +{0, 65058, 5780}, +{0, 64592, 5780}, +{0, 64366, 5793}, +{0, 64345, 5779}, +{0, 64479, 5778}, +{0, 64627, 5785}, +{0, 64727, 5778}, +{0, 64825, 5788}, +{0, 64874, 5782}, +{0, 64721, 5783}, +{0, 63950, 5786}, +{0, 63438, 5779}, +{0, 63242, 5777}, +{0, 63245, 5777}, +{0, 63368, 5781}, +{0, 63546, 5783}, +{0, 63663, 5789}, +{0, 63828, 5786}, +{0, 63995, 5789}, +{0, 63575, 5788}, +{0, 62933, 5784}, +{0, 62672, 5774}, +{0, 62758, 5769}, +{0, 62906, 5767}, +{0, 63141, 5777}, +{0, 63371, 5775}, +{0, 63553, 5780}, +{0, 63762, 5789}, +{0, 63802, 5792}, +{0, 62974, 5774}, +{0, 62377, 5777}, +{0, 62180, 5768}, +{0, 62152, 5770}, +{0, 62287, 5782}, +{0, 62424, 5782}, +{0, 62565, 5777}, +{0, 62763, 5785}, +{0, 62931, 5785}, +{0, 62525, 5779}, +{0, 61871, 5769}, +{0, 61663, 5767}, +{0, 61701, 5765}, +{0, 61877, 5774}, +{0, 62115, 5768}, +{0, 62270, 5775}, +{0, 62541, 5777}, +{0, 62833, 5772}, +{0, 62867, 5769}, +{0, 62178, 5770}, +{0, 61743, 5766}, +{0, 61632, 5765}, +{0, 61631, 5767}, +{0, 61840, 5772}, +{0, 61915, 5773}, +{0, 62116, 5774}, +{0, 62273, 5785}, +{0, 62462, 5782}, +{0, 62189, 5763}, +{0, 61577, 5771}, +{0, 61343, 5765}, +{0, 61373, 5776}, +{0, 61595, 5779}, +{0, 61835, 5772}, +{0, 62136, 5770}, +{0, 62389, 5774}, +{0, 62707, 5767}, +{0, 62890, 5778}, +{0, 62388, 5772}, +{0, 62031, 5768}, +{0, 61919, 5766}, +{0, 62038, 5766}, +{0, 62217, 5767}, +{0, 62342, 5770}, +{0, 62421, 5779}, +{0, 62534, 5775}, +{0, 62860, 5787}, +{0, 62865, 5785}, +{0, 62653, 5787}, +{0, 62773, 5770}, +{0, 63067, 5791}, +{0, 63408, 5789}, +{0, 63896, 5794}, +{0, 64195, 5796}, +{0, 64389, 5795}, +{0, 64516, 5796}, +{0, 64547, 5792}, +{0, 63648, 5790}, +{0, 62962, 5769}, +{0, 62591, 5780}, +{0, 62426, 5771}, +{0, 62464, 5774}, +{0, 62530, 5775}, +{0, 62655, 5774}, +{0, 62848, 5764}, +{0, 63071, 5762}, +{0, 62915, 5775}, +{0, 62279, 5765}, +{0, 62044, 5761}, +{0, 62044, 5760}, +{0, 62180, 5768}, +{0, 62331, 5767}, +{0, 62405, 5779}, +{0, 62539, 5781}, +{0, 62760, 5778}, +{0, 62957, 5778}, +{0, 62434, 5768}, +{0, 61954, 5766}, +{0, 61722, 5762}, +{0, 61691, 5765}, +{0, 61757, 5767}, +{0, 61894, 5758}, +{0, 62029, 5770}, +{0, 62164, 5769}, +{0, 62290, 5776}, +{0, 62143, 5773}, +{0, 61442, 5766}, +{0, 61082, 5754}, +{0, 61039, 5755}, +{0, 61151, 5761}, +{0, 61337, 5762}, +{0, 61538, 5760}, +{0, 61818, 5772}, +{0, 62053, 5768}, +{0, 62239, 5763}, +{0, 61566, 5760}, +{0, 60885, 5753}, +{0, 60757, 5757}, +{0, 60844, 5753}, +{0, 61042, 5757}, +{0, 61332, 5756}, +{0, 61622, 5756}, +{0, 61812, 5770}, +{0, 61931, 5763}, +{0, 61776, 5761}, +{0, 61115, 5756}, +{0, 60638, 5749}, +{0, 60487, 5749}, +{0, 60707, 5761}, +{0, 60958, 5741}, +{0, 61158, 5756}, +{0, 61232, 5749}, +{0, 61287, 5747}, +{0, 61422, 5757}, +{0, 60814, 5744}, +{0, 60165, 5735}, +{0, 59844, 5727}, +{0, 59797, 5725}, +{0, 59908, 5732}, +{0, 59991, 5739}, +{0, 59970, 5736}, +{0, 60230, 5727}, +{0, 60650, 5722}, +{0, 60913, 5729}, +{0, 60711, 5720}, +{0, 60289, 5718}, +{0, 59960, 5734}, +{0, 59757, 5715}, +{0, 59668, 5722}, +{0, 59582, 5723}, +{0, 59557, 5726}, +{0, 59620, 5734}, +{0, 59743, 5732}, +{0, 59203, 5731}, +{0, 58719, 5717}, +{0, 58536, 5716}, +{0, 58412, 5724}, +{0, 58451, 5723}, +{0, 58468, 5720}, +{0, 58452, 5733}, +{0, 58319, 5726}, +{0, 58223, 5732}, +{0, 58068, 5725}, +{0, 57694, 5717}, +{0, 57391, 5719}, +{0, 57123, 5707}, +{0, 57030, 5715}, +{0, 56991, 5721}, +{0, 57046, 5732}, +{0, 57170, 5730}, +{0, 57315, 5726}, +{0, 57433, 5728}, +{0, 57085, 5717}, +{0, 56826, 5730}, +{0, 56789, 5732}, +{0, 56786, 5714}, +{0, 56961, 5734}, +{0, 57075, 5743}, +{0, 57095, 5732}, +{0, 57127, 5726}, +{0, 57015, 5728}, +{0, 56576, 5730}, +{0, 55986, 5730}, +{0, 55667, 5724}, +{0, 55510, 5734}, +{0, 55469, 5732}, +{0, 55538, 5731}, +{0, 55559, 5733}, +{0, 55658, 5733}, +{0, 55836, 5742}, +{0, 56030, 5735}, +{0, 55839, 5739}, +{0, 55578, 5724}, +{0, 55592, 5732}, +{0, 55720, 5734}, +{0, 55944, 5735}, +{0, 56176, 5745}, +{0, 56352, 5748}, +{0, 56539, 5737}, +{0, 56714, 5750}, +{0, 56522, 5728}, +{0, 56097, 5738}, +{0, 55919, 5735}, +{0, 55870, 5735}, +{0, 55922, 5740}, +{0, 56056, 5751}, +{0, 56190, 5758}, +{0, 56245, 5751}, +{0, 56441, 5750}, +{0, 56457, 5745}, +{0, 56152, 5742}, +{0, 55996, 5746}, +{0, 56028, 5738}, +{0, 56175, 5745}, +{0, 56364, 5746}, +{0, 56600, 5746}, +{0, 56790, 5741}, +{0, 57027, 5749}, +{0, 57145, 5758}, +{0, 56925, 5744}, +{0, 56706, 5738}, +{0, 56700, 5745}, +{0, 56700, 5735}, +{0, 56770, 5746}, +{0, 56851, 5742}, +{0, 56970, 5743}, +{0, 57079, 5742}, +{0, 57204, 5748}, +{0, 57197, 5756}, +{0, 56916, 5738}, +{0, 56684, 5732}, +{0, 56706, 5730}, +{0, 56826, 5735}, +{0, 57092, 5732}, +{0, 57270, 5748}, +{0, 57462, 5739}, +{0, 57681, 5743}, +{0, 57812, 5743}, +{0, 57435, 5732}, +{0, 57147, 5740}, +{0, 57097, 5731}, +{0, 57157, 5734}, +{0, 57390, 5735}, +{0, 57618, 5750}, +{0, 57691, 5749}, +{0, 57788, 5748}, +{0, 57849, 5754}, +{0, 57736, 5756}, +{0, 57358, 5752}, +{0, 57049, 5732}, +{0, 56992, 5749}, +{0, 57064, 5739}, +{0, 57221, 5745}, +{0, 57493, 5737}, +{0, 57816, 5739}, +{0, 57955, 5753}, +{0, 57976, 5752}, +{0, 57485, 5749}, +{0, 57193, 5732}, +{0, 57121, 5742}, +{0, 56931, 5745}, +{0, 56800, 5743}, +{0, 56758, 5740}, +{0, 56842, 5736}, +{0, 56831, 5736}, +{0, 56778, 5749}, +{0, 56617, 5737}, +{0, 56046, 5736}, +{0, 55890, 5734}, +{0, 56052, 5730}, +{0, 56415, 5740}, +{0, 56673, 5735}, +{0, 56920, 5747}, +{0, 57196, 5743}, +{0, 57563, 5739}, +{0, 57915, 5749}, +{0, 57932, 5749}, +{0, 57920, 5732}, +{0, 57985, 5747}, +{0, 58101, 5759}, +{0, 58398, 5756}, +{0, 58657, 5749}, +{0, 59000, 5760}, +{0, 59327, 5760}, +{0, 59683, 5764}, +{0, 59682, 5757}, +{0, 59383, 5768}, +{0, 59284, 5749}, +{0, 59326, 5754}, +{0, 59510, 5762}, +{0, 59662, 5765}, +{0, 59903, 5764}, +{0, 60130, 5764}, +{0, 60352, 5753}, +{0, 60435, 5782}, +{0, 60048, 5753}, +{0, 59756, 5758}, +{0, 59621, 5756}, +{0, 59580, 5752}, +{0, 59641, 5761}, +{0, 59830, 5760}, +{0, 59982, 5766}, +{0, 60149, 5766}, +{0, 60287, 5766}, +{0, 60185, 5761}, +{0, 59823, 5761}, +{0, 59783, 5752}, +{0, 59734, 5753}, +{0, 59608, 5752}, +{0, 59343, 5744}, +{0, 59035, 5766}, +{0, 58994, 5754}, +{0, 59095, 5757}, +{0, 58951, 5751}, +{0, 58311, 5753}, +{0, 57810, 5751}, +{0, 57513, 5739}, +{0, 57431, 5744}, +{0, 57433, 5757}, +{0, 57538, 5760}, +{0, 57600, 5756}, +{0, 57706, 5760}, +{0, 57906, 5766}, +{0, 57933, 5761}, +{0, 57692, 5753}, +{0, 57595, 5759}, +{0, 57634, 5749}, +{0, 57804, 5753}, +{0, 57975, 5766}, +{0, 58127, 5756}, +{0, 58261, 5764}, +{0, 58500, 5764}, +{0, 58681, 5764}, +{0, 58418, 5741}, +{0, 58108, 5760}, +{0, 57945, 5755}, +{0, 57934, 5753}, +{0, 58145, 5755}, +{0, 58416, 5773}, +{0, 58614, 5759}, +{0, 58815, 5765}, +{0, 58994, 5764}, +{0, 58933, 5762}, +{0, 58552, 5761}, +{0, 58483, 5755}, +{0, 58520, 5769}, +{0, 58665, 5753}, +{0, 58897, 5752}, +{0, 59088, 5760}, +{0, 59329, 5766}, +{0, 59615, 5761}, +{0, 59787, 5763}, +{0, 59506, 5768}, +{0, 59280, 5761}, +{0, 59177, 5762}, +{0, 59261, 5756}, +{0, 59249, 5760}, +{0, 59316, 5765}, +{0, 59307, 5767}, +{0, 59357, 5772}, +{0, 59403, 5771}, +{0, 59406, 5764}, +{0, 59254, 5754}, +{0, 59190, 5761}, +{0, 59291, 5763}, +{0, 59545, 5762}, +{0, 59840, 5762}, +{0, 60165, 5765}, +{0, 60390, 5763}, +{0, 60620, 5769}, +{0, 60771, 5775}, +{0, 60512, 5761}, +{0, 60360, 5761}, +{0, 60213, 5770}, +{0, 60156, 5766}, +{0, 60120, 5765}, +{0, 60130, 5784}, +{0, 60283, 5778}, +{0, 60401, 5769}, +{0, 60492, 5776}, +{0, 60330, 5764}, +{0, 60068, 5763}, +{0, 59978, 5767}, +{0, 59953, 5759}, +{0, 60063, 5773}, +{0, 60169, 5752}, +{0, 60333, 5762}, +{0, 60513, 5755}, +{0, 60772, 5757}, +{0, 60695, 5764}, +{0, 60163, 5752}, +{0, 59778, 5756}, +{0, 59684, 5753}, +{0, 59685, 5753}, +{0, 59651, 5761}, +{0, 59614, 5756}, +{0, 59552, 5757}, +{0, 59510, 5753}, +{0, 59595, 5755}, +{0, 59255, 5753}, +{0, 58770, 5759}, +{0, 58577, 5757}, +{0, 58560, 5755}, +{0, 58583, 5753}, +{0, 58583, 5752}, +{0, 58582, 5750}, +{0, 58583, 5757}, +{0, 58737, 5757}, +{0, 58552, 5744}, +{0, 58014, 5751}, +{0, 57624, 5744}, +{0, 57584, 5737}, +{0, 57686, 5745}, +{0, 57722, 5751}, +{0, 57675, 5747}, +{0, 57624, 5748}, +{0, 57671, 5756}, +{0, 57748, 5740}, +{0, 57307, 5740}, +{0, 56921, 5737}, +{0, 56786, 5749}, +{0, 56851, 5745}, +{0, 57043, 5747}, +{0, 57191, 5747}, +{0, 57347, 5734}, +{0, 57539, 5741}, +{0, 57752, 5738}, +{0, 57509, 5721}, +{0, 57133, 5731}, +{0, 56986, 5728}, +{0, 56996, 5738}, +{0, 57230, 5743}, +{0, 57410, 5739}, +{0, 57515, 5739}, +{0, 57627, 5743}, +{0, 57699, 5740}, +{0, 57510, 5735}, +{0, 57097, 5742}, +{0, 56980, 5734}, +{0, 56984, 5725}, +{0, 57093, 5748}, +{0, 57203, 5733}, +{0, 57436, 5742}, +{0, 57640, 5750}, +{0, 57861, 5746}, +{0, 57906, 5730}, +{0, 57431, 5722}, +{0, 57308, 5725}, +{0, 57289, 5729}, +{0, 57486, 5730}, +{0, 57666, 5740}, +{0, 57832, 5742}, +{0, 58065, 5735}, +{0, 58216, 5731}, +{0, 58216, 5734}, +{0, 57671, 5735}, +{0, 57250, 5733}, +{0, 57038, 5727}, +{0, 57094, 5731}, +{0, 57244, 5733}, +{0, 57376, 5728}, +{0, 57454, 5735}, +{0, 57602, 5727}, +{0, 57737, 5719}, +{0, 57455, 5718}, +{0, 57109, 5721}, +{0, 57022, 5720}, +{0, 57099, 5732}, +{0, 57309, 5724}, +{0, 57564, 5732}, +{0, 57830, 5735}, +{0, 57975, 5728}, +{0, 58161, 5740}, +{0, 58118, 5737}, +{0, 57710, 5719}, +{0, 57527, 5728}, +{0, 57501, 5724}, +{0, 57592, 5722}, +{0, 57661, 5727}, +{0, 57671, 5732}, +{0, 57641, 5741}, +{0, 57605, 5734}, +{0, 57559, 5734}, +{0, 57396, 5723}, +{0, 57569, 5738}, +{0, 58093, 5756}, +{0, 58718, 5779}, +{0, 59324, 5776}, +{0, 59817, 5780}, +{0, 60291, 5792}, +{0, 60676, 5785}, +{0, 60910, 5786}, +{0, 60723, 5785}, +{0, 60731, 5783}, +{0, 60825, 5783}, +{0, 60989, 5788}, +{0, 61151, 5780}, +{0, 61360, 5794}, +{0, 61532, 5795}, +{0, 61786, 5794}, +{0, 61971, 5790}, +{0, 61843, 5791}, +{0, 61696, 5798}, +{0, 61734, 5793}, +{0, 61824, 5790}, +{0, 61995, 5783}, +{0, 62082, 5795}, +{0, 62183, 5798}, +{0, 62341, 5794}, +{0, 62467, 5798}, +{0, 62186, 5797}, +{0, 61929, 5794}, +{0, 61792, 5793}, +{0, 61775, 5788}, +{0, 61872, 5790}, +{0, 61929, 5782}, +{0, 61920, 5787}, +{0, 61914, 5790}, +{0, 61872, 5778}, +{0, 61670, 5778}, +{0, 61182, 5774}, +{0, 60971, 5761}, +{0, 60887, 5776}, +{0, 60914, 5772}, +{0, 61053, 5777}, +{0, 61298, 5777}, +{0, 61471, 5766}, +{0, 61733, 5766}, +{0, 61731, 5761}, +{0, 61416, 5763}, +{0, 61276, 5766}, +{0, 60872, 5759}, +{0, 60318, 5765}, +{0, 59821, 5768}, +{0, 59663, 5762}, +{0, 59724, 5768}, +{0, 59571, 5774}, +{0, 59225, 5767}, +{0, 58531, 5752}, +{0, 58153, 5761}, +{0, 58064, 5755}, +{0, 58052, 5752}, +{0, 58131, 5769}, +{0, 58161, 5762}, +{0, 58336, 5765}, +{0, 58513, 5767}, +{0, 58586, 5757}, +{0, 58015, 5762}, +{0, 57681, 5744}, +{0, 57555, 5753}, +{0, 57602, 5755}, +{0, 57802, 5748}, +{0, 57908, 5763}, +{0, 58042, 5768}, +{0, 58226, 5754}, +{0, 58298, 5745}, +{0, 57702, 5743}, +{0, 57215, 5751}, +{0, 57052, 5760}, +{0, 56961, 5749}, +{0, 57115, 5746}, +{0, 57342, 5768}, +{0, 57435, 5762}, +{0, 57506, 5762}, +{0, 57588, 5764}, +{0, 57205, 5760}, +{0, 56804, 5761}, +{0, 56664, 5745}, +{0, 56707, 5753}, +{0, 56811, 5762}, +{0, 56943, 5762}, +{0, 57149, 5754}, +{0, 57383, 5758}, +{0, 57559, 5767}, +{0, 57256, 5752}, +{0, 56872, 5742}, +{0, 56762, 5746}, +{0, 56790, 5745}, +{0, 56834, 5749}, +{0, 57029, 5737}, +{0, 57260, 5736}, +{0, 57682, 5739}, +{0, 58314, 5754}, +{0, 58656, 5770}, +{0, 58643, 5764}, +{0, 58539, 5761}, +{0, 58542, 5768}, +{0, 58596, 5765}, +{0, 58691, 5765}, +{0, 58731, 5774}, +{0, 58934, 5772}, +{0, 59123, 5761}, +{0, 59054, 5768}, +{0, 58660, 5759}, +{0, 58449, 5757}, +{0, 58359, 5759}, +{0, 58418, 5751}, +{0, 58399, 5759}, +{0, 58423, 5759}, +{0, 58394, 5764}, +{0, 58424, 5756}, +{0, 58387, 5754}, +{0, 58087, 5749}, +{0, 57859, 5749}, +{0, 57822, 5747}, +{0, 57919, 5751}, +{0, 58108, 5753}, +{0, 58344, 5748}, +{0, 58588, 5747}, +{0, 58813, 5756}, +{0, 58906, 5751}, +{0, 58689, 5746}, +{0, 58544, 5744}, +{0, 58565, 5745}, +{0, 58666, 5745}, +{0, 58771, 5744}, +{0, 58778, 5738}, +{0, 58750, 5758}, +{0, 58706, 5738}, +{0, 58619, 5747}, +{0, 58347, 5752}, +{0, 58253, 5750}, +{0, 58209, 5737}, +{0, 58327, 5749}, +{0, 58465, 5747}, +{0, 58677, 5773}, +{0, 58822, 5754}, +{0, 58988, 5770}, +{0, 59120, 5763}, +{0, 58836, 5753}, +{0, 58669, 5756}, +{0, 58673, 5750}, +{0, 58754, 5765}, +{0, 58889, 5752}, +{0, 59021, 5757}, +{0, 59062, 5777}, +{0, 59104, 5766}, +{0, 59146, 5760}, +{0, 58839, 5765}, +{0, 58500, 5767}, +{0, 58373, 5749}, +{0, 58279, 5756}, +{0, 58422, 5762}, +{0, 58559, 5765}, +{0, 58758, 5764}, +{0, 58937, 5768}, +{0, 59153, 5770}, +{0, 58995, 5766}, +{0, 58621, 5757}, +{0, 58507, 5756}, +{0, 58526, 5759}, +{0, 58618, 5752}, +{0, 58798, 5757}, +{0, 58994, 5757}, +{0, 59106, 5759}, +{0, 59158, 5761}, +{0, 58934, 5764}, +{0, 58364, 5763}, +{0, 58120, 5759}, +{0, 58090, 5757}, +{0, 58150, 5760}, +{0, 58238, 5758}, +{0, 58464, 5767}, +{0, 58693, 5760}, +{0, 58911, 5771}, +{0, 59013, 5762}, +{0, 58653, 5762}, +{0, 58510, 5743}, +{0, 58587, 5754}, +{0, 58661, 5758}, +{0, 58808, 5754}, +{0, 58986, 5763}, +{0, 59128, 5760}, +{0, 59136, 5765}, +{0, 59133, 5764}, +{0, 58746, 5762}, +{0, 58407, 5751}, +{0, 58295, 5754}, +{0, 58307, 5751}, +{0, 58368, 5763}, +{0, 58517, 5758}, +{0, 58731, 5752}, +{0, 58854, 5756}, +{0, 59067, 5765}, +{0, 58864, 5749}, +{0, 58655, 5752}, +{0, 58601, 5741}, +{0, 58679, 5745}, +{0, 58786, 5756}, +{0, 58916, 5763}, +{0, 58981, 5758}, +{0, 58914, 5763}, +{0, 58891, 5759}, +{0, 58888, 5764}, +{0, 58676, 5747}, +{0, 58834, 5759}, +{0, 59073, 5776}, +{0, 59332, 5767}, +{0, 59562, 5773}, +{0, 59824, 5773}, +{0, 60261, 5768}, +{0, 60683, 5770}, +{0, 61001, 5771}, +}; +static const int16_t PAH8009_mems_HRD[][3*NF_PPG_PER_CHANNEL] = +{ +{6305, -1007, 8865}, +{5777, -95, 9889}, +{6385, 1137, 8897}, +{4401, 833, 5425}, +{4465, -1647, 3153}, +{19985, 3937, 1713}, +{-2447, -3775, 8273}, +{5009, 4017, 12657}, +{6769, 1329, 6033}, +{5025, -1567, 6145}, +{6225, 1025, 5889}, +{5681, -351, 5057}, +{5905, 113, 5745}, +{5793, -31, 6369}, +{5297, 193, 5857}, +{5121, 657, 6321}, +{5121, 1041, 5937}, +{5873, 17, 6753}, +{6577, -1583, 6065}, +{5825, -63, 6385}, +{5601, 33, 4961}, +{6097, -303, 4785}, +{6001, 433, 5697}, +{6001, 929, 5553}, +{6145, 561, 5201}, +{6353, 1009, 5009}, +{6481, 1697, 5153}, +{6049, 1633, 5441}, +{6033, 1361, 5697}, +{6113, 1313, 5681}, +{6161, 1697, 5409}, +{6145, 1345, 5537}, +{6081, 1889, 5505}, +{5985, 1425, 5409}, +{5985, 1809, 5505}, +{5953, 1729, 5553}, +{5953, 1569, 5681}, +{5889, 1649, 5489}, +{6065, 1409, 5713}, +{6017, 1761, 5457}, +{6001, 1953, 5521}, +{5985, 2065, 5617}, +{5777, 1793, 5633}, +{5633, 1601, 5745}, +{5809, 1601, 5857}, +{5809, 1633, 5665}, +{5713, 1761, 5633}, +{5841, 1697, 5777}, +{5745, 1713, 5617}, +{5825, 1713, 5793}, +{5905, 1633, 5713}, +{5841, 1601, 5681}, +{5921, 1761, 5649}, +{5889, 1649, 5553}, +{5985, 1649, 5569}, +{5825, 1857, 5937}, +{5809, 1585, 5601}, +{6017, 1569, 5441}, +{5601, 1377, 5697}, +{5841, 1265, 5825}, +{6049, 1857, 6145}, +{5889, 1585, 4977}, +{6609, 1185, 5521}, +{6161, 1697, 5441}, +{6065, 1633, 5489}, +{6193, 1633, 5505}, +{6225, 1569, 5441}, +{6129, 1521, 5329}, +{6129, 1569, 5409}, +{6081, 1473, 5345}, +{5857, 1377, 5537}, +{5905, 1153, 5665}, +{6113, 1217, 5441}, +{6209, 1441, 5409}, +{6145, 1121, 5505}, +{6097, 1121, 5585}, +{6177, 1089, 5473}, +{6193, 1281, 5345}, +{6225, 1265, 5457}, +{5985, 1249, 5361}, +{6209, 1425, 5761}, +{6049, 1057, 5585}, +{5969, 1009, 5793}, +{6017, 1153, 5649}, +{6065, 1377, 5569}, +{6001, 1345, 5617}, +{6033, 1345, 5457}, +{6241, 1473, 5457}, +{6097, 1425, 5473}, +{6161, 1521, 5441}, +{6129, 1569, 5441}, +{6097, 1537, 5441}, +{6065, 1505, 5425}, +{6177, 1681, 5441}, +{6113, 1745, 5505}, +{6337, 1505, 5233}, +{6129, 1649, 5393}, +{6225, 1617, 5361}, +{6177, 1553, 5329}, +{6305, 1569, 5201}, +{6209, 1633, 5265}, +{6401, 1745, 5233}, +{6225, 1569, 5281}, +{6385, 1585, 5217}, +{6321, 1665, 5217}, +{6289, 1521, 5121}, +{6321, 1761, 5249}, +{6289, 1569, 5201}, +{6273, 1601, 5217}, +{6273, 1649, 5233}, +{6321, 1649, 5313}, +{6321, 1601, 5249}, +{6321, 1569, 5249}, +{6273, 1569, 5297}, +{6161, 1441, 5249}, +{6257, 1537, 5329}, +{6225, 1425, 5313}, +{6289, 1697, 5425}, +{6257, 1281, 5153}, +{6305, 1281, 5249}, +{6337, 1393, 5393}, +{6321, 1201, 5313}, +{6369, 1425, 5361}, +{6257, 1537, 5201}, +{6385, 1473, 5137}, +{6433, 1569, 5137}, +{6369, 1745, 4977}, +{6417, 1585, 5153}, +{6289, 1585, 5105}, +{6289, 1585, 5185}, +{6321, 1649, 5185}, +{6241, 1569, 5329}, +{6337, 1713, 5313}, +{6209, 1537, 5281}, +{6369, 1569, 5265}, +{6049, 1713, 5265}, +{6241, 1649, 5489}, +{6353, 1409, 5169}, +{6177, 1409, 5041}, +{6369, 1505, 5377}, +{6273, 1521, 5393}, +{6289, 1553, 5329}, +{6289, 1633, 5185}, +{6273, 1617, 5217}, +{6257, 1761, 5089}, +{6337, 1777, 5201}, +{6209, 1617, 5297}, +{6257, 1729, 5185}, +{6401, 1841, 5121}, +{6353, 1745, 5169}, +{6273, 1601, 5137}, +{6369, 1793, 5153}, +{6337, 1713, 5153}, +{6369, 1713, 5201}, +{6385, 1665, 5217}, +{6241, 2017, 5025}, +{6369, 1761, 5025}, +{6337, 1697, 5105}, +{6369, 1761, 5137}, +{6401, 1809, 5057}, +{6353, 1793, 5089}, +{6417, 1841, 5073}, +{6385, 1873, 5041}, +{6385, 1809, 5073}, +{6417, 1905, 5089}, +{6353, 1841, 5057}, +{6353, 1873, 5073}, +{6337, 1873, 5073}, +{6353, 1889, 5025}, +{6385, 1857, 5153}, +{6305, 1873, 5121}, +{6337, 1857, 5089}, +{6289, 1889, 4961}, +{6241, 1825, 4769}, +{6225, 1841, 4737}, +{6305, 1921, 4977}, +{6353, 2177, 4561}, +{6161, 1697, 4225}, +{6401, 3089, 6225}, +{6321, 2769, 5537}, +{6177, 2449, 5153}, +{6177, 2545, 5057}, +{6145, 2545, 5153}, +{6177, 2561, 5025}, +{6161, 2561, 5073}, +{6145, 2513, 5057}, +{6161, 2385, 5025}, +{6161, 2657, 5121}, +{6161, 2753, 4897}, +{6145, 2689, 4913}, +{6145, 2753, 4977}, +{6145, 2801, 5009}, +{6161, 2673, 5073}, +{6129, 2657, 5025}, +{6145, 2705, 5041}, +{6145, 2625, 5041}, +{6129, 2577, 5089}, +{6113, 2625, 5073}, +{6081, 2641, 5041}, +{6081, 2593, 5105}, +{6161, 2689, 5233}, +{6033, 2449, 5121}, +{6081, 2497, 5137}, +{6097, 2577, 5233}, +{6097, 2465, 5169}, +{6113, 2481, 5153}, +{6097, 2561, 5121}, +{6081, 2513, 5105}, +{6113, 2561, 5153}, +{6129, 2545, 5105}, +{6129, 2529, 5089}, +{6097, 2497, 5169}, +{6113, 2513, 5185}, +{6097, 2401, 5169}, +{6193, 2529, 5217}, +{6161, 2801, 5153}, +{6113, 2737, 5009}, +{6129, 2577, 4961}, +{6081, 2561, 5217}, +{6049, 2449, 5057}, +{6049, 2321, 5169}, +{6097, 2497, 5249}, +{6065, 2449, 5313}, +{6017, 2513, 5185}, +{6049, 2529, 5201}, +{6097, 2481, 5201}, +{6065, 2369, 5297}, +{6001, 2401, 5233}, +{6017, 2417, 5313}, +{6033, 2385, 5281}, +{5985, 2337, 5217}, +{5969, 2385, 5329}, +{6049, 2337, 5457}, +{6081, 2577, 5329}, +{5969, 2481, 5249}, +{5953, 2257, 5409}, +{5953, 2353, 5521}, +{5873, 2289, 5393}, +{5473, 3185, 5297}, +{6081, 2817, 3889}, +{6161, 3313, 5569}, +{5745, 2769, 5249}, +{6449, 2849, 4913}, +{5857, 2593, 5009}, +{5953, 2481, 5233}, +{6273, 2369, 4817}, +{6353, 2609, 4929}, +{6209, 2385, 4849}, +{6337, 2177, 5073}, +{6225, 2129, 5041}, +{6353, 2033, 5057}, +{6321, 2193, 4945}, +{6417, 2017, 5057}, +{6321, 2001, 4993}, +{6417, 2017, 4833}, +{6385, 1969, 4961}, +{6353, 1953, 4961}, +{6321, 2049, 5025}, +{6401, 2209, 4945}, +{6449, 2049, 5041}, +{6465, 2161, 4961}, +{6337, 2113, 5009}, +{6417, 2225, 4897}, +{6481, 2305, 4961}, +{6465, 2049, 4673}, +{6225, 2897, 5377}, +{6193, 2657, 5537}, +{6449, 2385, 4673}, +{6353, 2273, 4753}, +{6273, 2369, 4529}, +{6369, 3169, 6049}, +{6337, 2753, 5361}, +{6113, 2417, 5009}, +{6273, 2257, 5009}, +{6225, 2433, 4897}, +{6225, 2129, 5153}, +{6257, 2641, 5137}, +{6001, 2353, 5281}, +{6193, 2241, 4849}, +{6305, 2481, 5617}, +{6529, 2817, 5809}, +{6337, 3473, 5441}, +{6129, 1345, 3569}, +{6049, 1585, 3985}, +{6241, 1633, 4177}, +{6225, 2081, 5009}, +{6273, 1985, 4977}, +{6145, 1969, 5265}, +{6289, 1713, 4577}, +{6401, 1649, 4769}, +{6273, 1505, 4993}, +{6305, 1553, 5521}, +{6145, 1617, 5393}, +{6193, 1505, 5185}, +{6305, 1761, 5313}, +{6081, 1569, 5425}, +{6177, 1537, 5297}, +{6209, 1473, 5441}, +{6257, 1569, 5441}, +{6177, 1409, 5297}, +{6241, 1473, 5185}, +{6177, 1601, 4913}, +{6177, 1553, 5137}, +{6257, 1361, 5633}, +{6193, 1729, 5617}, +{6193, 1425, 5409}, +{6241, 1569, 5329}, +{6193, 1665, 5217}, +{6289, 1489, 5201}, +{6257, 1521, 5297}, +{6225, 1553, 5297}, +{6113, 1713, 5249}, +{6209, 1713, 5281}, +{6225, 1697, 5329}, +{6209, 1745, 5217}, +{6241, 1697, 5233}, +{6193, 1697, 5233}, +{6193, 1809, 5297}, +{6273, 1825, 5217}, +{6241, 1841, 5233}, +{6241, 1697, 5265}, +{6225, 1905, 5233}, +{6209, 1793, 5265}, +{6193, 1873, 5233}, +{6257, 1873, 5265}, +{6209, 1825, 5249}, +{6257, 1809, 5233}, +{6209, 1793, 5185}, +{6241, 1825, 5217}, +{6193, 1857, 5297}, +{6225, 1729, 5329}, +{6097, 1633, 5361}, +{6161, 1841, 5377}, +{6129, 1841, 5377}, +{6129, 1841, 5345}, +{6113, 1713, 5393}, +{6129, 1681, 5393}, +{6113, 1697, 5425}, +{6129, 1649, 5409}, +{6081, 1601, 5457}, +{6113, 1713, 5425}, +{6097, 1713, 5505}, +{6113, 1601, 5441}, +{6081, 1649, 5409}, +{6081, 1617, 5521}, +{6017, 1649, 5473}, +{6065, 1601, 5441}, +{6081, 1585, 5441}, +{6113, 1713, 5473}, +{6097, 1793, 5441}, +{6081, 1713, 5425}, +{6081, 1745, 5457}, +{6097, 1665, 5441}, +{6113, 1697, 5441}, +{6097, 1729, 5425}, +{6081, 1713, 5441}, +{6097, 1697, 5425}, +{6113, 1697, 5425}, +{6113, 1745, 5409}, +{6081, 1745, 5473}, +{6049, 1713, 5377}, +{6097, 1681, 5409}, +{6081, 1873, 5409}, +{6097, 1809, 5377}, +{6145, 1777, 5489}, +{6193, 1761, 5281}, +{6113, 1489, 5281}, +{6209, 1521, 5393}, +{6129, 1793, 5265}, +{6145, 1937, 5377}, +{6225, 1905, 5361}, +{6145, 1713, 5473}, +{6145, 1473, 5489}, +{5873, 1793, 5473}, +{5985, 1729, 5553}, +{6017, 1473, 5457}, +{6033, 1697, 5665}, +{6033, 1873, 5953}, +{6065, 1713, 5425}, +{5985, 1425, 5489}, +{5889, 1329, 5537}, +{5953, 1233, 5489}, +{6033, 1233, 5601}, +{5729, 849, 5761}, +{5681, 705, 5969}, +{5761, 833, 6161}, +{5729, 689, 6017}, +{5841, 705, 5953}, +{5713, 305, 5953}, +{5537, 481, 6001}, +{5665, 545, 6145}, +{5601, 465, 6081}, +{5601, 417, 6049}, +{5681, 449, 6081}, +{5633, 305, 6209}, +{5617, 529, 6049}, +{5633, 513, 6001}, +{5745, 481, 5969}, +{5697, 561, 5937}, +{5745, 641, 5985}, +{5921, 929, 5793}, +{5857, 737, 5681}, +{5985, 913, 5681}, +{6001, 961, 5633}, +{6097, 1473, 5393}, +{6033, 1217, 5489}, +{6145, 1233, 5649}, +{6289, 1457, 5361}, +{6273, 1441, 5249}, +{6273, 1265, 5265}, +{6145, 1665, 5377}, +{6241, 1633, 5409}, +{6161, 1617, 5377}, +{6177, 1729, 5297}, +{6177, 1665, 5409}, +{6129, 1553, 5361}, +{6161, 1569, 5345}, +{6193, 1745, 5377}, +{6273, 1361, 5393}, +{6177, 1505, 5489}, +{5905, 1073, 5553}, +{5953, 1441, 5681}, +{5873, 1249, 5777}, +{5745, 1233, 5777}, +{5921, 849, 5921}, +{5825, 913, 5873}, +{5777, 801, 5873}, +{5745, 1185, 5841}, +{5793, 1089, 5873}, +{5761, 945, 5921}, +{5793, 1041, 5841}, +{5889, 1281, 5681}, +{5793, 1153, 5777}, +{5649, 1425, 5713}, +{5809, 1553, 5809}, +{5441, 1745, 5841}, +{5537, 1841, 5729}, +{6945, 641, 5521}, +{6097, 2113, 4945}, +{5953, 2705, 5329}, +{6193, 2449, 5585}, +{5841, 1953, 5249}, +{6321, 1793, 5329}, +{6369, 1633, 5425}, +{6177, 1745, 5185}, +{6305, 1457, 4833}, +{6353, 769, 5201}, +{6529, 817, 5265}, +{6305, 641, 5473}, +{6289, 497, 5313}, +{6241, 337, 5361}, +{6321, 145, 5409}, +{6257, -63, 5441}, +{6177, 273, 5489}, +{6129, 193, 5585}, +{6241, -79, 5633}, +{6017, 65, 5665}, +{6257, 49, 5617}, +{5985, -255, 5873}, +{6049, -111, 5537}, +{6273, -15, 5585}, +{6113, 17, 5585}, +{6033, -255, 5649}, +{6017, 17, 5569}, +{6225, -287, 5553}, +{6321, -127, 5489}, +{6081, 97, 5601}, +{6193, 209, 5201}, +{6385, 241, 5217}, +{6273, 321, 5233}, +{6769, 449, 5697}, +{6433, 257, 5249}, +{6545, 689, 5089}, +{6305, 1313, 5281}, +{6177, 721, 5505}, +{6193, 1825, 5649}, +{6129, 961, 4705}, +{6641, 1121, 4961}, +{6513, 801, 4945}, +{6673, 641, 5345}, +{6241, -159, 5185}, +{6353, 657, 4977}, +{6305, 1377, 5361}, +{6433, 561, 5265}, +{6129, 1745, 5265}, +{6561, 465, 5329}, +{6417, 1089, 5505}, +{6193, 785, 5745}, +{6065, 1233, 5729}, +{5793, 1777, 5521}, +{6001, 993, 5937}, +{5905, 769, 5697}, +{6033, 1105, 5489}, +{6049, 1377, 5537}, +{5873, 1153, 5649}, +{5937, 1281, 5665}, +{6097, 2001, 5409}, +{6081, 2065, 5217}, +{6177, 1953, 5217}, +{6129, 2081, 5297}, +{6385, 1873, 5313}, +{5745, 1761, 5457}, +{6081, 2385, 5361}, +{6273, 1537, 5041}, +{6433, 1857, 4737}, +{6529, 1905, 4881}, +{6801, 1857, 4929}, +{6401, 1649, 5201}, +{6017, 1713, 4865}, +{6497, 1793, 5217}, +{5985, 1377, 4977}, +{6177, 1521, 5425}, +{6161, 1697, 5457}, +{5985, 1169, 5345}, +{6033, 1713, 5473}, +{6193, 1473, 5649}, +{5873, 1761, 5873}, +{6289, 1761, 5665}, +{5873, 1505, 5649}, +{5985, 1441, 5473}, +{6081, 1057, 5713}, +{6097, 1057, 5585}, +{6049, 1057, 5553}, +{5873, 1377, 5505}, +{6049, 1313, 5521}, +{6161, 1521, 5489}, +{6097, 1841, 5617}, +{6273, 2209, 5329}, +{6273, 2081, 5233}, +{6161, 1537, 5473}, +{6049, 2225, 4817}, +{6385, 2753, 4721}, +{6513, 2593, 4465}, +{6641, 2545, 4625}, +{6561, 2337, 4785}, +{6449, 2209, 4705}, +{6113, 1633, 4993}, +{6257, 2273, 5057}, +{6193, 1953, 5153}, +{6081, 1969, 5393}, +{5969, 1729, 5601}, +{5905, 1489, 5617}, +{6001, 1681, 5569}, +{5953, 1233, 5457}, +{5905, 1601, 5649}, +{6049, 1473, 5889}, +{5825, 1025, 6001}, +{6033, 1185, 5649}, +{6113, 1409, 5361}, +{6145, 1329, 5505}, +{6097, 1569, 5377}, +{6257, 1489, 5361}, +{6353, 1777, 5121}, +{6385, 2225, 4881}, +{6305, 2769, 5041}, +{6001, 2145, 4785}, +{6513, 1713, 5281}, +{6481, 641, 4769}, +{6657, 1297, 5137}, +{6609, 1425, 5025}, +{6529, 1185, 5201}, +{6369, 1233, 5057}, +{6465, 1441, 5041}, +{6401, 1473, 5137}, +{6417, 1473, 5025}, +{6337, 1633, 5073}, +{6305, 1521, 5313}, +{6273, 1313, 5425}, +{6129, 1089, 5601}, +{6273, 1185, 5329}, +{6225, 481, 5185}, +{6033, 193, 5153}, +{6161, 929, 5377}, +{6145, 385, 5553}, +{6065, -95, 5953}, +{5809, 33, 5969}, +{5857, 81, 5617}, +{6097, -15, 5601}, +{6001, 113, 5569}, +{6193, 465, 5633}, +{6065, 337, 5633}, +{6161, 513, 5649}, +{6257, 145, 5393}, +{6145, 497, 5505}, +{6305, 817, 5233}, +{6449, 769, 5281}, +{6385, 801, 5537}, +{6241, 1057, 5313}, +{6273, 977, 5121}, +{6529, 1137, 4897}, +{6609, 1329, 4849}, +{6801, 1649, 4897}, +{6561, 1713, 4961}, +{6545, 1537, 4817}, +{6545, 1457, 5153}, +{6401, 1553, 5057}, +{6513, 1169, 5137}, +{6513, 833, 5217}, +{6529, 1393, 4913}, +{6049, 1697, 5041}, +{5969, 2929, 5729}, +{6049, 2481, 6001}, +{5985, 2289, 5521}, +{5937, 1553, 5681}, +{5985, 1937, 5649}, +{6081, 1953, 5521}, +{6065, 1857, 5441}, +{5953, 1457, 5489}, +{5937, 1393, 5521}, +{5937, 1841, 5489}, +{6081, 1953, 5377}, +{5969, 1809, 5265}, +{6129, 2289, 5217}, +{6097, 1953, 5377}, +{6081, 2433, 5185}, +{6097, 2689, 5025}, +{6065, 2977, 5025}, +{6161, 2625, 5041}, +{6177, 2689, 5041}, +{6193, 2785, 5025}, +{5985, 2913, 4001}, +{7281, 2417, 4865}, +{6481, 3697, 5569}, +{6161, 2993, 4289}, +{6289, 2465, 4769}, +{6001, 3041, 5105}, +{6017, 2369, 5649}, +{6033, 2753, 5297}, +{5921, 2321, 5393}, +{5857, 2033, 5345}, +{5809, 1905, 5377}, +{5841, 1953, 5489}, +{5889, 2225, 5729}, +{5825, 1985, 5729}, +{6033, 1793, 5633}, +{6049, 1553, 5521}, +{5521, 1505, 5313}, +{6545, 705, 5585}, +{5553, 1905, 5713}, +{6049, 1633, 5633}, +{6369, 1073, 5121}, +{6193, 1313, 4961}, +{6273, 1873, 5201}, +{6481, 1681, 5841}, +{6113, 945, 5729}, +{6369, 1217, 4833}, +{6049, 1409, 5553}, +{6017, 1, 5745}, +{6209, 257, 5457}, +{6049, 929, 5681}, +{6001, 465, 5777}, +{5937, 257, 5921}, +{6001, 433, 5793}, +{6033, 433, 5601}, +{5937, 481, 5473}, +{6017, 529, 5585}, +{6049, 305, 5777}, +{6081, 97, 5649}, +{6065, 209, 5729}, +{5937, -15, 5649}, +{5857, 145, 5921}, +{5905, -143, 6065}, +{5681, -79, 6161}, +{5921, -239, 5649}, +{5761, -111, 5665}, +{5889, 113, 5697}, +{5841, -31, 5713}, +{5761, -399, 5809}, +{5489, -911, 5633}, +{5521, -767, 5585}, +{6433, 449, 5729}, +{6145, 33, 5793}, +{6385, 273, 5505}, +{6401, 961, 5057}, +{6385, 1505, 5185}, +{6273, 1377, 5409}, +{5985, 1841, 5201}, +{5857, 1825, 5489}, +{5889, 2209, 5777}, +{6177, 1601, 5473}, +{6113, 1969, 5601}, +{6033, 1953, 5473}, +{6193, 1857, 5601}, +{6225, 1697, 5617}, +{5985, 2353, 5601}, +{6481, 2161, 6273}, +{5713, 1585, 4849}, +{5921, 1377, 4849}, +{5825, 1009, 6209}, +{5089, 529, 5537}, +{5409, 129, 6113}, +{5761, 177, 5697}, +{6193, 289, 5249}, +{6193, 449, 5665}, +{6049, 657, 5425}, +{5905, 1329, 5153}, +{6145, 1409, 5265}, +{5329, 1137, 5857}, +{6001, 817, 5793}, +{6097, 769, 5697}, +{6513, 1393, 5297}, +{6433, 1729, 5265}, +{6321, 1537, 5169}, +{6305, 1329, 5249}, +{6097, 1185, 5265}, +{6161, 833, 5537}, +{5825, 641, 5537}, +{5889, 513, 5809}, +{6049, 401, 5969}, +{5697, 177, 6049}, +{5681, -63, 6081}, +{5601, -191, 6113}, +{5505, -863, 6289}, +{5329, -559, 6161}, +{5489, -911, 6001}, +{5441, -735, 6209}, +{5521, -959, 6225}, +{5841, -303, 5745}, +{5825, -367, 5921}, +{5825, -159, 5761}, +{6001, -47, 5681}, +{5969, 49, 5697}, +{6257, 529, 5345}, +{6241, 449, 5601}, +{5969, 769, 5617}, +{6145, 497, 5649}, +{5953, 513, 5537}, +{6097, 625, 5521}, +{6145, 993, 5313}, +{5857, 289, 5745}, +{6001, 737, 5697}, +{6065, 353, 5825}, +{5873, 641, 5905}, +{6193, 1137, 5569}, +{6145, 929, 5633}, +{6129, 1153, 5505}, +{6081, 913, 5921}, +{5873, 833, 5777}, +{5937, 193, 5809}, +{5953, 689, 5921}, +{5857, 145, 5809}, +{5873, 289, 5665}, +{5889, 241, 5633}, +{5937, 433, 5793}, +{6001, 225, 5841}, +{5921, 417, 5697}, +{6033, 1041, 5633}, +{6049, 1057, 5409}, +{5809, 1233, 5841}, +{5985, 1441, 5633}, +{6001, 1313, 5697}, +{6049, 1137, 5777}, +{6385, 1473, 5537}, +{6465, 1697, 4977}, +{6465, 1505, 4865}, +{6513, 1649, 5073}, +{6209, 1633, 4945}, +{6705, 1601, 5073}, +{6369, 1633, 5137}, +{6625, 1393, 5345}, +{6113, 1633, 4993}, +{6193, 1217, 5105}, +{6097, 1297, 5649}, +{5905, 1057, 5841}, +{5649, 897, 5937}, +{5553, 417, 6209}, +{5729, 945, 5825}, +{5921, 721, 5553}, +{5761, 593, 5297}, +{5345, 721, 5905}, +{5665, 641, 6113}, +{5697, 625, 5953}, +{5937, 705, 6209}, +{5745, 1121, 6177}, +{5953, 1105, 5329}, +{5889, 1393, 5233}, +{5745, 1217, 5937}, +{5857, 1441, 6033}, +{5889, 1585, 6065}, +{6833, 1921, 4721}, +{6801, 1969, 4417}, +{6737, 1905, 4561}, +{6657, 1921, 4785}, +{6305, 1953, 5089}, +{6065, 1937, 5281}, +{6177, 1985, 5377}, +{5985, 1905, 5553}, +{6049, 1601, 5713}, +{6001, 1313, 5713}, +{5793, 689, 5697}, +{5601, 561, 5937}, +{5505, 657, 6225}, +{5457, 433, 6449}, +{5521, 609, 6305}, +{5457, 353, 6193}, +{5361, -79, 6385}, +{5553, -223, 6017}, +{5521, -143, 6049}, +{5489, -15, 5905}, +{5505, 401, 6193}, +{5809, 689, 5793}, +{5857, 273, 5681}, +{5697, 817, 5841}, +{6177, 1137, 5441}, +{6065, 1089, 5633}, +{5969, 1313, 5745}, +{6161, 1697, 5521}, +{6241, 1761, 5329}, +{6385, 1729, 5233}, +{6353, 1617, 5137}, +{6289, 1441, 5281}, +{6145, 1601, 5425}, +{6177, 1553, 5425}, +{6065, 1393, 5553}, +{6161, 1873, 5393}, +{5889, 705, 5649}, +{5953, 881, 5777}, +{5745, 609, 5873}, +{5681, 1089, 6033}, +{5697, 721, 6033}, +{5505, 433, 6273}, +{5649, 769, 6033}, +{5809, 385, 5969}, +{5809, 305, 5665}, +{6049, 209, 5553}, +{5697, 337, 5985}, +{5809, 577, 5953}, +{5745, 721, 5921}, +{5697, 689, 5873}, +{5713, 961, 5665}, +{6049, 1105, 5649}, +{6145, 881, 5713}, +{6289, 961, 4961}, +{6465, 1425, 4689}, +{6625, 1969, 4817}, +{6241, 1425, 5265}, +{6257, 1425, 5313}, +{6001, 1793, 5377}, +{6113, 1697, 5585}, +{6097, 1905, 5393}, +{6145, 1249, 5537}, +{6177, 1601, 5489}, +{6049, 1073, 5553}, +{5889, 1521, 5681}, +{5857, 1169, 5873}, +{6001, 897, 5601}, +{6129, 1041, 5505}, +{6193, 881, 5377}, +{6289, 353, 5313}, +{5393, 1281, 6017}, +{5377, 1793, 5345}, +{5585, 1601, 6433}, +{6385, -463, 5361}, +{6449, 705, 5153}, +{6449, 577, 5425}, +{5969, 1329, 5505}, +{6529, -351, 5473}, +{6625, -79, 4689}, +{6657, 65, 4737}, +{6257, 721, 5249}, +{6129, 577, 5473}, +{6353, 161, 5441}, +{6465, 289, 5217}, +{6481, 465, 5105}, +{6465, 993, 4913}, +{6625, 673, 4865}, +{6465, 97, 5217}, +{6529, -463, 5601}, +{6513, 465, 5297}, +{6689, 17, 4721}, +{6401, -95, 4993}, +{6241, -319, 5729}, +{6193, -543, 5457}, +{6177, -495, 5361}, +{6273, -543, 5441}, +{6097, -879, 5201}, +{5393, -1551, 5457}, +{6113, -1183, 5361}, +{6225, -847, 5889}, +{6033, -879, 5809}, +{6289, -783, 5457}, +{6529, -239, 4865}, +{6545, 145, 5137}, +{6113, 593, 5249}, +{6609, 737, 5665}, +{5953, 209, 5569}, +{6241, 833, 5553}, +{6241, 769, 5489}, +{6353, 497, 5201}, +{5905, 1617, 4849}, +{6801, 865, 5553}, +{6145, -399, 5569}, +{6193, 545, 5649}, +{6113, 177, 5377}, +{6369, 481, 5409}, +{6241, 113, 5393}, +{5921, 161, 5633}, +{5729, 289, 6033}, +{5873, 449, 5969}, +{6001, 433, 6001}, +{5873, 417, 5761}, +{5985, -143, 5617}, +{6145, 209, 5489}, +{6097, 593, 5633}, +{5953, 577, 5713}, +{6017, 497, 5665}, +{6145, 769, 5665}, +{6289, 737, 5553}, +{6289, 785, 5409}, +{6337, 561, 5313}, +{6321, 881, 5121}, +{6337, 1457, 4561}, +{6273, 1313, 5057}, +{6321, 657, 4961}, +{6657, 1457, 4737}, +{6497, 1041, 4721}, +{6049, 1569, 6017}, +{5937, 945, 6017}, +{6161, 1441, 5601}, +{5985, 753, 5457}, +{6017, 737, 5537}, +{5905, 1137, 5745}, +{5761, -143, 4977}, +{5809, -127, 4097}, +{6145, 81, 5649}, +{5825, -191, 7201}, +{6017, -127, 6049}, +{6161, -383, 5633}, +{6337, 353, 5425}, +{6161, 225, 5665}, +{5937, 353, 5521}, +{6257, 465, 5137}, +{6417, 1041, 4785}, +{5873, 1937, 6305}, +{5905, 1297, 6593}, +{5713, 961, 6065}, +{5889, 1521, 5345}, +{5889, 2193, 5409}, +{5777, 1489, 6193}, +{6033, 1473, 5777}, +{5857, 1409, 5473}, +{6081, 1361, 5217}, +{6225, 1569, 4913}, +{5905, 1681, 5841}, +{5825, 1729, 5985}, +{5889, 1617, 5841}, +{6033, 1697, 5329}, +{6209, 977, 5425}, +{5857, 1521, 5921}, +{5841, 1761, 5697}, +{6097, 1665, 5553}, +{6097, 1457, 5473}, +{6033, 1393, 5473}, +{5937, 1857, 5649}, +{5905, 2001, 5649}, +{5809, 1873, 5633}, +{5825, 2017, 5761}, +{5985, 2081, 5713}, +{6049, 1825, 5185}, +{5953, 2145, 5217}, +{5937, 2305, 5489}, +{6033, 2433, 5873}, +{6177, 2161, 5441}, +{6001, 2113, 5073}, +{6177, 1889, 5185}, +{6097, 2017, 5441}, +{6033, 2033, 5537}, +{6033, 1633, 5553}, +{5921, 1521, 5761}, +{5889, 1633, 5729}, +{5873, 1825, 5553}, +{5937, 1601, 5361}, +{5937, 1745, 5569}, +{5937, 1601, 5761}, +{5809, 1329, 5649}, +{6049, 1313, 5441}, +{6001, 1569, 5441}, +{5969, 1329, 5633}, +{5921, 1521, 5697}, +{5873, 1841, 5489}, +{5665, 2161, 5233}, +{6177, 2193, 5217}, +{6113, 2321, 5521}, +{5985, 1857, 5393}, +{5841, 2753, 5217}, +{6097, 2513, 5441}, +{6049, 2497, 5297}, +{6081, 2129, 5153}, +{6065, 2433, 5201}, +{6129, 2449, 5297}, +{6033, 2113, 5361}, +{6049, 2209, 5249}, +{5953, 1921, 5425}, +{5889, 1921, 5633}, +{5745, 1617, 5745}, +{5649, 1889, 5889}, +{5649, 1809, 5777}, +{5729, 1217, 5857}, +{5633, 1521, 5953}, +{5585, 1489, 5969}, +{5713, 1425, 5793}, +{5697, 1393, 5729}, +{5889, 1905, 5713}, +{5809, 1969, 5665}, +{5777, 2065, 5569}, +{6033, 2081, 5169}, +{5905, 3217, 5393}, +{5681, 2865, 5457}, +{6033, 2977, 5345}, +{6033, 2881, 4865}, +{6017, 3121, 5041}, +{5921, 3089, 5121}, +{6017, 2689, 5217}, +{6113, 2673, 5201}, +{5937, 2913, 4961}, +{6001, 2449, 5185}, +{5921, 2401, 5377}, +{5953, 2353, 5409}, +{5777, 2577, 5521}, +{5585, 2129, 5873}, +{5553, 2081, 5889}, +{5601, 2177, 5729}, +{5729, 1825, 5697}, +{5745, 1569, 5713}, +{5761, 1345, 5889}, +{5617, 1953, 5777}, +{5649, 2065, 5729}, +{5713, 2065, 5649}, +{5633, 2209, 5537}, +{5745, 1921, 5857}, +{5809, 2849, 5745}, +{5793, 2577, 5521}, +{6017, 2689, 5041}, +{6049, 2929, 5025}, +{6001, 2369, 5409}, +{6065, 2593, 5025}, +{6065, 2289, 5345}, +{6033, 2705, 5185}, +{5953, 2673, 5249}, +{5889, 2289, 5393}, +{5921, 2417, 5521}, +{5809, 2193, 5665}, +{5889, 2161, 5521}, +{5889, 2145, 5441}, +{5969, 1873, 5505}, +{5969, 1713, 5537}, +{5649, 1713, 5777}, +{5713, 1521, 5793}, +{5793, 1489, 5857}, +{5729, 1345, 5841}, +{5841, 1681, 5857}, +{5777, 2097, 5617}, +{5729, 2193, 5537}, +{5905, 2353, 5777}, +{5697, 2273, 5697}, +{5745, 2321, 5569}, +{6129, 2945, 4241}, +{6033, 3089, 4129}, +{6657, 1537, 5345}, +{6529, 2641, 5969}, +{5809, 3153, 5137}, +{6145, 2337, 5281}, +{6385, 1553, 5025}, +{6305, 1041, 5121}, +{6177, 545, 5521}, +{5873, 609, 5777}, +{5697, 657, 6145}, +{5553, 273, 5713}, +{5217, -447, 6545}, +{5393, 273, 6129}, +{5873, 257, 5713}, +{5985, 385, 5905}, +{5841, 369, 5953}, +{5889, 529, 5905}, +{5681, 385, 5985}, +{5921, 913, 5793}, +{6033, 961, 5937}, +{5969, 801, 5649}, +{6001, 1297, 5873}, +{6017, 1409, 5937}, +{6001, 1121, 5809}, +{5953, 817, 5697}, +{6289, 1057, 5217}, +{6017, 1409, 5329}, +{6385, 929, 5297}, +{6049, -895, 5729}, +{5953, -479, 5569}, +{6529, 273, 5713}, +{6273, 17, 5185}, +{5889, -63, 4353}, +{5713, -207, 5537}, +{6257, 17, 5009}, +{5505, -527, 7665}, +{5073, -911, 6673}, +{5777, -303, 5825}, +{6065, 17, 5569}, +{5905, 401, 6081}, +{6193, 1281, 5761}, +{6049, 321, 5233}, +{5953, 1505, 5569}, +{5745, 1345, 5537}, +{6193, 769, 5937}, +{6193, 1233, 5569}, +{6129, 1457, 5457}, +{6337, 1681, 5457}, +{5777, 529, 5009}, +{5825, 2161, 5953}, +{5841, 2865, 6417}, +{6609, 2657, 5665}, +{6017, 2913, 4353}, +{6081, 3281, 4401}, +{5873, 3713, 5025}, +{5969, 1105, 5905}, +{5345, 1089, 6721}, +{5137, 977, 6129}, +{5441, 961, 6433}, +{5649, 257, 5585}, +{5905, -111, 5489}, +{6001, 1969, 6001}, +{5873, 1633, 5681}, +{6145, 1377, 5121}, +{6513, 1841, 4337}, +{6305, 3121, 5169}, +{6465, 2529, 4977}, +{6465, 2625, 4801}, +{6769, 2305, 4593}, +{6657, 1521, 4945}, +{6241, 1601, 4817}, +{6065, 1073, 5665}, +{5937, 1265, 5617}, +{6033, 1169, 5729}, +{5969, 1185, 5777}, +{5841, 929, 6049}, +{5585, 1169, 6177}, +{5809, 801, 5985}, +{5585, 337, 5953}, +{5441, -495, 6193}, +{5233, -223, 6209}, +{5329, -463, 6321}, +{5297, -351, 6113}, +{5569, -367, 6049}, +{5697, 113, 6097}, +{5889, 273, 5857}, +{6097, 849, 5569}, +{6097, 673, 5649}, +{6097, 1377, 5473}, +{6113, 993, 5521}, +{6065, 753, 5633}, +{5921, 993, 5841}, +{5825, 1137, 5921}, +{6129, 945, 5617}, +{6161, 1233, 5425}, +{6001, 1233, 5553}, +{5873, 881, 5841}, +{5825, 1297, 5825}, +{5649, 1329, 5985}, +{5649, 1761, 5937}, +{5569, 1233, 6049}, +{5489, 689, 6081}, +{5761, 945, 6017}, +{5793, 753, 5809}, +{5649, 561, 5857}, +{5761, 513, 5937}, +{5665, 817, 5953}, +{5889, 929, 5937}, +{5841, 1217, 5681}, +{5761, 977, 5761}, +{5745, 1393, 5809}, +{5825, 1217, 5809}, +{6097, 2081, 5521}, +{6097, 1681, 5457}, +{6001, 1585, 5537}, +{6177, 1793, 5345}, +{6241, 1841, 5297}, +{6257, 1601, 5329}, +{6289, 1345, 5409}, +{6017, 1121, 5505}, +{5873, 1009, 5633}, +{5857, 1025, 5665}, +{5489, 753, 6305}, +{5521, 273, 6113}, +{5633, 673, 6113}, +{5681, 769, 5985}, +{5729, 465, 6017}, +{5873, 545, 5857}, +{5777, 257, 5889}, +{5889, 833, 5857}, +{6065, 449, 5921}, +{5761, 577, 5953}, +{5809, 1105, 5729}, +{5633, 1393, 5937}, +{5889, 1601, 5649}, +{5953, 1649, 5441}, +{5985, 705, 5585}, +{5873, 1009, 5457}, +{6401, 1713, 5281}, +{6225, 2081, 5361}, +{6177, 2337, 5409}, +{6065, 2001, 5521}, +{6033, 1985, 5457}, +{5937, 1457, 5585}, +{5841, 1201, 5665}, +{5649, 1521, 5745}, +{5665, 1393, 5937}, +{5745, 1633, 5905}, +{5761, 865, 5761}, +{5953, 721, 5729}, +{5681, 545, 5857}, +{5521, 721, 6129}, +{5569, 529, 6225}, +{5617, 817, 5953}, +{5649, 1233, 5985}, +{5473, 945, 5905}, +{5825, 945, 5777}, +{5969, 1569, 5745}, +{6161, 2353, 5185}, +{6161, 2721, 4977}, +{6321, 2577, 5057}, +{6033, 2433, 5249}, +{6225, 2865, 4929}, +{6225, 2465, 5105}, +{6289, 2273, 5185}, +{6081, 2417, 5265}, +{6209, 2257, 5121}, +{6129, 2225, 5233}, +{5921, 1521, 5697}, +{5921, 1681, 5761}, +{5889, 1505, 5553}, +{5681, 1329, 6049}, +{5745, 1281, 6017}, +{5793, 1425, 5745}, +{5761, 1201, 5761}, +{5809, 961, 5825}, +{5905, 721, 5793}, +{5857, 1009, 5665}, +{5841, 593, 5889}, +{5889, 1681, 5809}, +{5921, 1377, 5665}, +{6033, 1441, 5361}, +{6017, 1601, 5425}, +{5825, 2225, 5633}, +{6241, 2321, 4865}, +{6465, 2273, 4929}, +{6257, 2529, 5057}, +{6193, 2673, 5009}, +{6225, 2625, 4833}, +{6289, 2129, 5217}, +{6097, 2209, 5297}, +{6113, 2065, 5345}, +{5905, 2353, 5393}, +{5969, 2177, 5505}, +{5857, 1697, 5633}, +{5697, 1729, 5809}, +{5633, 1793, 5841}, +{5601, 1569, 5953}, +{5665, 1681, 5969}, +{5681, 961, 6113}, +{5665, 1105, 6001}, +{5953, 1377, 5601}, +{5921, 577, 5825}, +{5713, 865, 5921}, +{6017, 1393, 5585}, +{6033, 1473, 5457}, +{6065, 1409, 5345}, +{6225, 1425, 5297}, +{6241, 1873, 5201}, +{6321, 1841, 5105}, +{5921, 2257, 4737}, +{5761, 2705, 5601}, +{5969, 2497, 5169}, +{6177, 2081, 5217}, +{6193, 2129, 5265}, +{6033, 2417, 5489}, +{5969, 1937, 5425}, +{6225, 1697, 5457}, +{6609, 977, 5185}, +{6305, -415, 5361}, +{6417, 913, 5313}, +{6209, -31, 5393}, +{6193, -511, 5569}, +{6337, -511, 5249}, +{6289, -207, 5073}, +{5729, -927, 6177}, +{5729, -991, 5985}, +{6017, -687, 5681}, +{6145, -367, 5377}, +{6273, -207, 5409}, +{6033, -575, 5633}, +{6193, -543, 5553}, +{6305, -271, 5521}, +{6273, -255, 5441}, +{6353, -335, 5681}, +{6321, 497, 5089}, +{6193, 705, 5425}, +{6369, 209, 5553}, +{6417, 337, 5265}, +{6577, 225, 5201}, +{6497, 1, 4689}, +{6497, -95, 5649}, +{6465, -735, 5345}, +{6849, 273, 5105}, +{6657, 97, 5153}, +{6385, 433, 5057}, +{6161, -63, 5681}, +{5393, 209, 4881}, +{5313, -591, 6641}, +{3681, -639, 5713}, +{5585, -2383, 7441}, +{5409, -447, 6241}, +{5313, -927, 6321}, +{5265, -399, 6369}, +{5601, -367, 6177}, +{5729, -287, 6113}, +{5809, -223, 5825}, +{5937, 561, 5457}, +{5793, 561, 5521}, +{6257, -383, 6001}, +{5793, 865, 5825}, +{6113, 881, 5857}, +{5969, 1265, 5377}, +{6017, 593, 5809}, +{5969, 593, 5745}, +{6049, 641, 5889}, +{5921, 1089, 5473}, +{5809, 609, 5569}, +{5745, 353, 5585}, +{5745, 369, 6257}, +{5713, -95, 6225}, +{5857, 385, 6129}, +{5281, 673, 5793}, +{5633, -559, 6401}, +{4961, -511, 6097}, +{5073, -783, 6145}, +{5185, -415, 6913}, +{4961, 241, 6401}, +{5281, 913, 6273}, +{5761, 657, 5569}, +{6081, 401, 5201}, +{5777, 2481, 5729}, +{6385, 753, 5537}, +{6145, 1569, 5265}, +{6465, 2049, 4929}, +{6161, 2017, 5169}, +{6417, 1953, 4961}, +{6241, 1553, 5297}, +{6097, 1617, 5617}, +{5937, 1953, 5345}, +{6193, 1649, 5425}, +{6177, 929, 5169}, +{6017, 945, 5441}, +{5985, 977, 5809}, +{5505, 609, 6385}, +{5265, 545, 6497}, +{5185, 385, 6753}, +{5665, 737, 5985}, +{5633, 225, 5617}, +{5761, 625, 5665}, +{5889, 1297, 5873}, +{6001, 1665, 5697}, +{6113, 1249, 5409}, +{6129, 1825, 4961}, +{6353, 2305, 5025}, +{6401, 2593, 5025}, +{6305, 2673, 4881}, +{6081, 2929, 4865}, +{6209, 2385, 5297}, +{6193, 2881, 5633}, +{6465, 2769, 6145}, +{5969, 4161, 6209}, +{6961, 1489, 2113}, +{6289, 2673, 5569}, +{6177, 1729, 5345}, +{6049, 1729, 5393}, +{6145, 1761, 5585}, +{6081, 785, 5649}, +{6113, 577, 5889}, +{5761, 177, 5617}, +{5329, 65, 5681}, +{5297, 1, 6305}, +{5825, -831, 5505}, +{6049, -623, 5201}, +{5649, 113, 5761}, +{5553, 321, 5713}, +{5665, 449, 6065}, +{5857, 1073, 6081}, +{6641, 673, 4961}, +{6545, 1073, 5345}, +{6177, 977, 5393}, +{6129, 1297, 5457}, +{6129, 817, 5649}, +{6081, 961, 5409}, +{5921, 1137, 5745}, +{5793, 993, 5921}, +{5873, 1073, 6001}, +{5873, 801, 5969}, +{6145, 1169, 5569}, +{6225, 1313, 5409}, +{6257, 897, 5457}, +{5617, -687, 5841}, +{5425, -191, 6225}, +{5489, -287, 6353}, +{5393, -703, 6241}, +{5569, -191, 5953}, +{5841, -751, 5617}, +{5185, -2287, 5969}, +{1905, -2751, 6785}, +{2049, -1903, 6993}, +{3505, -639, 7633}, +{4641, -1295, 7649}, +{4049, -2447, 7313}, +{4337, -1791, 7617}, +{6001, -319, 5953}, +{5857, -47, 5873}, +{5393, -863, 5153}, +{6001, -223, 5121}, +{5905, 577, 6161}, +{5825, -463, 5713}, +{5809, -15, 5633}, +{5761, -591, 5537}, +{5633, -207, 5841}, +{5649, -367, 6177}, +{6065, 225, 5569}, +{6113, 17, 5393}, +{6145, -287, 5473}, +{5713, 929, 5697}, +{4785, -319, 5921}, +{4465, -1951, 6753}, +{4705, -3103, 6465}, +{4465, -655, 7633}, +{4449, -927, 7297}, +{5009, -751, 6833}, +{5249, -1103, 5777}, +{5473, -1679, 5633}, +{5825, -543, 5953}, +{5777, 289, 6097}, +{5649, 625, 6129}, +{5985, 257, 5697}, +{6161, 385, 5313}, +{6161, 865, 5537}, +{6065, 1505, 5825}, +{6321, 257, 6177}, +{6209, 529, 5137}, +{6273, 513, 5009}, +{5969, 401, 5921}, +{5713, -95, 6321}, +{6801, 1729, 4705}, +{6241, 529, 5185}, +{6209, 257, 5729}, +{6145, 609, 5489}, +{6049, -335, 6113}, +{5921, -735, 5745}, +{6081, 657, 5921}, +{6321, -15, 5505}, +{6241, -735, 5105}, +{6097, 385, 5489}, +{6145, 1025, 5553}, +{6049, 1681, 5537}, +{5937, 353, 5729}, +{5745, 1585, 5841}, +{5841, 1825, 5857}, +{6017, 1409, 5553}, +{6769, 1313, 5329}, +{6097, 1889, 5633}, +{6225, 2129, 5313}, +{6177, 1361, 5233}, +{5777, 2433, 5313}, +{6129, 1729, 5857}, +{5825, 881, 5713}, +{5713, 625, 5713}, +{5601, 1265, 5889}, +{5665, 1105, 6145}, +{5585, 1009, 5985}, +{5681, 689, 6001}, +{5649, 1233, 6065}, +{5585, 273, 5905}, +{5425, 209, 5585}, +{6129, 225, 5537}, +{6513, 2369, 5921}, +{6737, 1025, 5681}, +{6065, 753, 5073}, +{6289, 1089, 4865}, +{6241, 1649, 5409}, +{6305, 641, 5377}, +{6209, 769, 5249}, +{6257, 1681, 5521}, +{6353, 1425, 5345}, +{6321, 1137, 5089}, +{6289, 881, 5105}, +{6737, 769, 5265}, +{6449, 1025, 5153}, +{6289, 401, 5153}, +{6449, 385, 5361}, +{6497, 481, 5217}, +{6577, 353, 5105}, +{6385, 257, 5361}, +{6289, 273, 5361}, +{6257, -143, 5441}, +{5825, -159, 6385}, +{4881, -303, 5505}, +{5425, -751, 7169}, +{5681, 273, 6961}, +{5585, 1, 5921}, +{6017, 65, 6017}, +{6145, 337, 5457}, +{6305, 1137, 5025}, +{6545, 1441, 4641}, +{5457, 305, 5025}, +{6209, -671, 6689}, +{6161, 849, 5825}, +{6081, 625, 5169}, +{5985, 65, 5457}, +{5569, 529, 6017}, +{5265, 321, 5953}, +{5441, 577, 6433}, +{5857, 289, 6017}, +{5697, 145, 5873}, +{5745, 1105, 5313}, +{6097, 1153, 5489}, +{5601, 481, 5921}, +{5409, 49, 6193}, +{4769, 241, 5921}, +{4273, 177, 6833}, +{5377, -47, 7265}, +{5521, -15, 6481}, +{5729, -703, 5889}, +{5905, -31, 5761}, +{5889, 577, 5585}, +{5905, 1297, 5137}, +{5777, 1537, 6305}, +{5441, 449, 6625}, +{5473, -319, 6465}, +{6193, 369, 5617}, +{6273, 881, 5393}, +{6321, 849, 5249}, +{6065, 737, 5329}, +{6177, 1025, 5649}, +{6113, 1617, 5617}, +{6065, 1217, 5329}, +{5489, -175, 6049}, +{5329, -303, 6193}, +{5521, -207, 6033}, +{5249, 161, 6161}, +{5169, -31, 6449}, +{4737, -207, 6241}, +{3729, -1407, 7473}, +{4369, -2463, 7729}, +{4305, -1775, 7345}, +{4353, -927, 6881}, +{4737, -1407, 6753}, +{4993, -863, 6001}, +{5409, -687, 5761}, +{6081, -367, 5905}, +{5585, 321, 5857}, +{5681, -671, 6225}, +{5569, 209, 5937}, +{5457, 49, 6321}, +{5281, -415, 6497}, +{5297, -255, 6545}, +{5425, -271, 6209}, +{5857, 417, 6225}, +{5809, 593, 5937}, +{5841, 497, 5697}, +{5809, 497, 5457}, +{5953, 481, 5601}, +{3889, 801, 5921}, +{5169, -1583, 6929}, +{3889, -1455, 7249}, +{3985, -1807, 7249}, +{3009, -2479, 7825}, +{2897, -1279, 8353}, +{2881, -1055, 7969}, +{3105, -1487, 7441}, +{3217, -1679, 7345}, +{3745, -1407, 7761}, +{6561, -1135, 2257}, +{6993, -3679, 1905}, +{5217, -1023, 6945}, +{5137, 305, 7137}, +{5857, -783, 5553}, +{5649, -1103, 6305}, +{5633, 337, 6561}, +{5745, -1407, 5617}, +{5873, -367, 5569}, +{6369, -831, 4913}, +{5521, -2015, 5217}, +{4833, -2847, 5409}, +{4097, -2559, 6817}, +{3985, -2479, 7025}, +{3185, -2911, 6673}, +{2817, -2991, 6817}, +{1153, -3359, 8033}, +{993, -2863, 8273}, +{1441, -3311, 7473}, +{1425, -3263, 7617}, +{2129, -2959, 7409}, +{3361, -2879, 6721}, +{3825, -2575, 6641}, +{4513, -2463, 5921}, +{4689, -1967, 6321}, +{4737, -2111, 6209}, +{5345, -239, 6385}, +{5633, -239, 5665}, +{4737, -1215, 5361}, +{4657, -911, 6305}, +{3633, -1695, 7025}, +{4625, -1263, 7345}, +{4593, -1823, 6865}, +{4689, -1711, 6001}, +{4641, -2159, 5793}, +{4465, -2095, 5953}, +{3905, -2191, 6785}, +{3841, -1519, 6817}, +{3457, -2031, 6833}, +{2833, -2735, 7345}, +{2641, -1535, 8193}, +{3057, -1583, 7873}, +{3249, -1871, 7537}, +{3345, -1487, 7473}, +{4321, -735, 6945}, +{4417, -1471, 6609}, +{4401, -2175, 6273}, +{5793, -1391, 5489}, +{5457, -975, 6033}, +{5537, -767, 6417}, +{5857, -591, 5985}, +{5729, -383, 6033}, +{5553, -799, 5921}, +{5553, -15, 6273}, +{5505, 369, 5761}, +{6033, -143, 5345}, +{5985, -879, 4481}, +{5857, -367, 5585}, +{5905, -399, 5985}, +{5873, 1, 5857}, +{5953, -223, 5985}, +{5825, 657, 5857}, +{5665, -207, 6193}, +{5361, -399, 6209}, +{5345, -623, 6257}, +{5121, -1263, 6273}, +{5553, -991, 6129}, +{5985, -767, 5601}, +{5841, -175, 5889}, +{6177, 449, 5729}, +{6433, 97, 5121}, +{6337, 481, 5409}, +{6641, 1649, 5057}, +{6481, 337, 5265}, +{6289, 817, 5297}, +{6673, 369, 4881}, +{6561, 513, 4961}, +{7025, 1121, 4209}, +{6129, -3407, 3809}, +{6641, -767, 8721}, +{5169, -1807, 7265}, +{2689, -2703, 6801}, +{1649, -735, 8769}, +{2625, -3599, 4865}, +{4945, -5679, 4913}, +{5457, -3967, 5233}, +{5489, -6543, 3473}, +{3105, -5199, 4049}, +{3169, -6127, 5345}, +{3521, -5727, 4833}, +{3841, -5087, 5105}, +{3889, -5663, 5169}, +{3793, -5695, 5089}, +{4161, -4959, 4625}, +{3825, -4015, 4609}, +{4529, -4527, 5665}, +{4769, -4879, 6209}, +{4529, -4191, 4817}, +{4545, -4095, 5409}, +{4657, -4111, 5233}, +{4849, -4255, 5601}, +{4913, -4431, 5585}, +{4833, -4287, 5345}, +{4897, -4879, 5793}, +{4673, -3903, 5649}, +{5521, -4511, 5537}, +{5201, -4943, 5217}, +{5601, -5439, 5953}, +{2977, -3487, 3777}, +{2609, -3775, 4929}, +{641, -1983, 6865}, +{-207, -3631, 3857}, +{-719, -543, 481}, +{13217, -4719, 12625}, +{4305, 1057, 11297}, +{6593, -655, 4145}, +{7249, 1937, 5025}, +{6513, 737, 4961}, +{6305, 1521, 4417}, +{6193, 689, 5585}, +{6289, 1057, 5121}, +{6193, 1489, 5393}, +{6273, 2081, 4977}, +{6257, 1265, 4849}, +{6433, 1201, 5041}, +{6529, 945, 5201}, +{6673, 1505, 4897}, +{6801, 881, 5233}, +{6753, 1121, 5073}, +{6561, 529, 4897}, +{6161, 145, 5441}, +{6209, 65, 5473}, +{6257, -175, 5313}, +{6225, -31, 5313}, +{6241, -623, 5569}, +{6353, -399, 5505}, +{6481, -703, 5169}, +{6545, -111, 4945}, +{6529, 353, 5057}, +{6401, 17, 5409}, +{6609, 353, 5169}, +{6545, 273, 5041}, +{6593, 593, 4945}, +{6641, 993, 4817}, +{6689, 481, 5073}, +{6689, 721, 5041}, +{6737, 625, 4929}, +{6545, 673, 4865}, +{6801, 625, 4849}, +{6833, 529, 4673}, +{6545, 241, 5073}, +{6481, 161, 5217}, +{6449, 65, 5313}, +{6369, 209, 5185}, +{6481, 209, 5153}, +{6497, 81, 5297}, +{6641, 321, 5201}, +{6689, 513, 4897}, +{6657, 753, 4881}, +{6737, 753, 5009}, +{6753, 849, 4977}, +{6513, 1025, 5025}, +{6449, 1281, 5185}, +{6385, 1137, 5249}, +{6465, 1441, 5025}, +{6385, 1265, 5009}, +{6625, 625, 5201}, +{6801, 929, 5009}, +{6625, 1009, 5057}, +{6593, 577, 4929}, +{6369, 369, 5425}, +{6273, -15, 5569}, +{6241, -111, 5441}, +{6305, 225, 5217}, +{6305, 81, 5249}, +{6193, -255, 5473}, +{6513, -399, 5265}, +{6145, -351, 5345}, +{6353, 225, 5409}, +{6417, 257, 5281}, +{6561, 241, 5169}, +{6369, 353, 5185}, +{6433, 481, 5345}, +{6513, 801, 5009}, +{6513, 721, 5105}, +{6449, 641, 5201}, +{6513, 801, 5025}, +{6673, 1041, 4865}, +{6737, 225, 5089}, +{6497, 33, 5089}, +{6497, 417, 5281}, +{6337, 113, 5249}, +{6385, -15, 5329}, +{6353, 33, 5105}, +{6321, -191, 5281}, +{6225, -511, 5537}, +{6401, -287, 5281}, +{5953, 177, 5425}, +{7201, 273, 4849}, +{6305, -447, 5473}, +{6545, 817, 5553}, +{6113, 1009, 5297}, +{6705, 833, 5329}, +{6561, 1761, 4881}, +{6657, 1793, 4913}, +{6417, 1281, 4993}, +{6641, 1281, 4945}, +{6929, 1409, 4785}, +{6817, 1457, 4673}, +{6561, 1649, 4577}, +{6465, 865, 5473}, +{6161, 1329, 5425}, +{6081, 1153, 5793}, +{6241, 833, 6241}, +{5697, 1329, 6065}, +{5745, 2593, 5169}, +{6353, 1969, 4721}, +{6289, 1409, 4929}, +{5969, 1841, 4817}, +{6385, 2433, 4913}, +{6305, 1857, 5505}, +{6305, 1793, 5217}, +{6401, 2257, 4705}, +{6449, 2321, 5089}, +{6321, 2273, 5249}, +{6561, 2209, 5249}, +{6401, 2161, 5729}, +{6161, 1601, 4945}, +{6273, 1921, 4641}, +{6257, 1585, 4241}, +{6097, 1409, 5217}, +{5953, 1425, 4993}, +{5905, 1505, 5889}, +{5905, 1697, 6305}, +{5745, 1761, 5745}, +{6273, 1329, 5297}, +{6529, 945, 5105}, +{5985, 1921, 5313}, +{6049, 2065, 5553}, +{6001, 1697, 5905}, +{6033, 1457, 5569}, +{6193, 1697, 5377}, +{6305, 2001, 5137}, +{6065, 1617, 5617}, +{6113, 1921, 5441}, +{6225, 1665, 5361}, +{6177, 1649, 5281}, +{6001, 1841, 5409}, +{6225, 1905, 5409}, +{6257, 1521, 5553}, +{6257, 1121, 5249}, +{6193, 1041, 5441}, +{6065, 1649, 5585}, +{6065, 1777, 5313}, +{6225, 1441, 5217}, +{6257, 1489, 5329}, +{6225, 1489, 5361}, +{6081, 2209, 5265}, +{6161, 2033, 5265}, +{6385, 2017, 5265}, +{6385, 1937, 4977}, +{6497, 2305, 4929}, +{6305, 1921, 5249}, +{6273, 1953, 5137}, +{6305, 1857, 5185}, +{6241, 1985, 5073}, +{6273, 1857, 5217}, +{6161, 1521, 5361}, +{5921, 1857, 5617}, +{6001, 1809, 5553}, +{6065, 1457, 5361}, +{6145, 1681, 5281}, +{5969, 1185, 5553}, +{5985, 1297, 5825}, +{6049, 1633, 5457}, +{6225, 1681, 5169}, +{6097, 1521, 5313}, +{5937, 1985, 5377}, +{5985, 2081, 5777}, +{6065, 1841, 5457}, +{6161, 2193, 5249}, +{6209, 2321, 5137}, +{6257, 2337, 5009}, +{6129, 2033, 5249}, +{6337, 2433, 5313}, +{6289, 2577, 5249}, +{6289, 2033, 5073}, +{6257, 1649, 5089}, +{5921, 2385, 5457}, +{5793, 1633, 5953}, +{6129, 1393, 5393}, +{6273, 1585, 5425}, +{5873, 1969, 5617}, +{6017, 1569, 5489}, +{6161, 1825, 5441}, +{6033, 1537, 5585}, +{5969, 1857, 5441}, +{5761, 2177, 5617}, +{6033, 2113, 5521}, +{5985, 2017, 5281}, +{6193, 2257, 5185}, +{6225, 2401, 5217}, +{6065, 2033, 5457}, +{6129, 2001, 5441}, +{6305, 2497, 5121}, +{6241, 2305, 5057}, +{6209, 1441, 5153}, +{5905, 1889, 5505}, +{5729, 1697, 5889}, +{6065, 1585, 5505}, +{5905, 1617, 5633}, +{5937, 1937, 5617}, +{5905, 1889, 5569}, +{6129, 1569, 5505}, +{6193, 1361, 5345}, +{6193, 1873, 5249}, +{6145, 2129, 5137}, +{6337, 2129, 5249}, +{6065, 1761, 5633}, +{6081, 2081, 5265}, +{5921, 2113, 5441}, +{5793, 2305, 5585}, +{6081, 2113, 5265}, +{6369, 2673, 6081}, +{6081, 2449, 4961}, +{6129, 1313, 5297}, +{5761, 1441, 5665}, +{6465, 1265, 5681}, +{6001, 625, 5377}, +{6097, 1089, 5537}, +{6065, 945, 5441}, +{6289, 129, 5361}, +{6481, 257, 5553}, +{6273, 577, 5217}, +{6289, 1505, 5281}, +{6273, 801, 5489}, +{6049, 977, 5553}, +{6161, 1297, 5409}, +{6449, 1553, 5201}, +{6353, 1393, 5425}, +{6433, 1521, 5313}, +{6385, 849, 5137}, +{6641, 1537, 4961}, +{6481, 993, 5073}, +{6289, 1009, 5249}, +{6097, 945, 5521}, +{6273, 545, 5329}, +{6033, 641, 5393}, +{6001, 801, 5697}, +{5809, 449, 6017}, +{6385, 465, 4849}, +{6513, 1041, 4737}, +{6625, 2129, 4785}, +{6721, 1473, 4881}, +{6625, 1265, 4833}, +{6545, 1873, 4753}, +{6801, 2145, 4593}, +{6625, 1697, 4929}, +{6449, 1489, 4801}, +{6481, 1393, 5329}, +{6673, 1265, 4961}, +{6641, 993, 4961}, +{6417, 1505, 4993}, +{6081, 785, 5393}, +{6017, 977, 5617}, +{6033, 769, 5633}, +{6401, 1057, 5409}, +{6257, 705, 5489}, +{6369, 689, 5361}, +{6385, 993, 5201}, +{6353, 1825, 4817}, +{6385, 1921, 4945}, +{6433, 1585, 5201}, +{6449, 1809, 4721}, +{6705, 2065, 4641}, +{6593, 2289, 4881}, +{6385, 1985, 4833}, +{6369, 1777, 5057}, +{6449, 1489, 5185}, +{6337, 1889, 5089}, +{6321, 1281, 5521}, +{5713, 1345, 5745}, +{6225, 1105, 5649}, +{6097, 1361, 5281}, +{6001, 1441, 5601}, +{5985, 2081, 5537}, +{6129, 1505, 5377}, +{5905, 1937, 5201}, +{5873, 993, 5633}, +{5905, 2161, 5457}, +{6417, 2305, 5169}, +{6529, 2177, 4465}, +{6641, 2641, 4161}, +{6353, 2673, 4897}, +{6305, 2849, 4929}, +{6401, 2593, 4929}, +{6353, 2193, 5153}, +{6513, 1521, 5489}, +{6353, 2049, 5313}, +{6129, 2161, 4833}, +{6001, 1425, 5201}, +{6273, 1201, 5185}, +{6289, 1361, 5345}, +{5873, 1233, 5681}, +{5889, 1153, 5873}, +{5857, 1361, 5665}, +{6881, 1873, 4801}, +{6593, 1825, 4993}, +{6273, 1585, 5105}, +{6497, 1713, 5137}, +{6273, 2161, 4945}, +{6513, 2001, 4961}, +{6369, 2049, 5057}, +{6257, 1985, 5153}, +{6289, 2017, 5137}, +{6417, 2177, 4993}, +{6369, 1489, 5153}, +{6257, 1457, 5265}, +{6193, 1681, 5233}, +{6145, 1649, 5457}, +{6001, 1585, 5393}, +{6129, 993, 5457}, +{6017, 1601, 5329}, +{5953, 1889, 5489}, +{6305, 1201, 5377}, +{6561, 1153, 5105}, +{6481, 1921, 4993}, +{6017, 2081, 5345}, +{6001, 1521, 5937}, +{5649, 2017, 6561}, +{5633, 2145, 5969}, +{6129, 2401, 4961}, +{6561, 1745, 4721}, +{5985, 1825, 5681}, +{6113, 2289, 5521}, +{6385, 1873, 5361}, +{6177, 1809, 5249}, +{6081, 1889, 5281}, +{6081, 1617, 5345}, +{6129, 1377, 5569}, +{6129, 1217, 5441}, +{5985, 1265, 5489}, +{6065, 1793, 5489}, +{6273, 1329, 5409}, +{6465, 1521, 5249}, +{6337, 1601, 5169}, +{6225, 1745, 5121}, +{6177, 1665, 5553}, +{5889, 2065, 5569}, +{6081, 1921, 5409}, +{6193, 2241, 5025}, +{6241, 2097, 5185}, +{5937, 2257, 5361}, +{6369, 1601, 5409}, +{6129, 2017, 5041}, +{6417, 1329, 5169}, +{5969, 1233, 5393}, +{5985, 1617, 6049}, +{6273, 1345, 5265}, +{6369, 1137, 5105}, +{5969, 1553, 5489}, +{6257, 1265, 5553}, +{5985, 1249, 5905}, +{6065, 1697, 5185}, +{6305, 2033, 4897}, +{6481, 1825, 5121}, +{6321, 1697, 5377}, +{6353, 1713, 5041}, +{6065, 2593, 5137}, +{6241, 1985, 5425}, +{6481, 2529, 4721}, +{6577, 1937, 4881}, +{6465, 1569, 5153}, +{6273, 1729, 5329}, +{6081, 2033, 5281}, +{6305, 1681, 5281}, +{6161, 1377, 5073}, +{5937, 1585, 5169}, +{5825, 2369, 6225}, +{6225, 1473, 5169}, +{6433, 1889, 4833}, +{6353, 1745, 4849}, +{6321, 2321, 4737}, +{6129, 2449, 5153}, +{6257, 2177, 4929}, +{6241, 2417, 4769}, +{6273, 2417, 5249}, +{6305, 2257, 5313}, +{6353, 1921, 5009}, +{6225, 2241, 5137}, +{6145, 1969, 5265}, +{6161, 2129, 5105}, +{6369, 2001, 5137}, +{6337, 1681, 5009}, +{6145, 1905, 5169}, +{6177, 2209, 5249}, +{6129, 1697, 5489}, +{6241, 1921, 5009}, +{6545, 1793, 4769}, +{6321, 2241, 5313}, +{6161, 2081, 5505}, +{6209, 2241, 5153}, +{6289, 2209, 4865}, +{6209, 2545, 5041}, +{6289, 2113, 5329}, +{6257, 2305, 5185}, +{6465, 2225, 5041}, +{6273, 1873, 5137}, +{6145, 1681, 5185}, +{6081, 1937, 5537}, +{6113, 1697, 5377}, +{6097, 1521, 5249}, +{6097, 1713, 5345}, +{5953, 1889, 5537}, +{6337, 1489, 5329}, +{6049, 1601, 5457}, +{6289, 1761, 5265}, +{6193, 2081, 5089}, +{6289, 2177, 5041}, +{6177, 2001, 5121}, +{6289, 1953, 5057}, +{6257, 2241, 5073}, +{6225, 2225, 5137}, +{6161, 2129, 5233}, +{6353, 1857, 4993}, +{6257, 1745, 5057}, +{6705, 1265, 6097}, +{5425, 2721, 5409}, +{6577, 1441, 4993}, +{6033, 1745, 5329}, +{6129, 1905, 5585}, +{5969, 1473, 5649}, +{6177, 1473, 5633}, +{6241, 865, 5201}, +{6321, 1121, 5153}, +{6609, 1345, 4865}, +{6353, 1057, 5297}, +{6305, 785, 5457}, +{6401, 1169, 5281}, +{6465, 1281, 4961}, +{6529, 1169, 4737}, +{6769, 1729, 4593}, +{7169, 1121, 4865}, +{6721, 1217, 4737}, +{6737, 897, 4865}, +{6497, 417, 5233}, +{6529, 609, 5025}, +{6625, 289, 5009}, +{6513, 369, 4977}, +{6129, 209, 5217}, +{6273, 177, 5377}, +{6481, 49, 5185}, +{6401, 353, 4993}, +{6833, 1057, 4833}, +{6593, 1953, 4625}, +{6289, 801, 4849}, +{6737, 897, 5473}, +{6257, 1665, 4833}, +{6577, 1921, 4881}, +{6465, 913, 5457}, +{6737, 689, 5121}, +{6513, 897, 4945}, +{6305, 1489, 5121}, +{6241, 1393, 5585}, +{6241, 513, 5569}, +{6241, 801, 5377}, +{6241, 1393, 5553}, +{6097, 977, 5553}, +{6177, 449, 5585}, +{6385, 1089, 5329}, +{6449, 1793, 4705}, +{6369, 2257, 4945}, +{6849, 1457, 5489}, +{6465, 1697, 4689}, +{6801, 2001, 4769}, +{6529, 2113, 4849}, +{6593, 1713, 4913}, +{6385, 1265, 5105}, +{6481, 1329, 5585}, +{5905, 1409, 5361}, +{6321, 1633, 5313}, +{6209, 689, 5473}, +{6113, 401, 5713}, +{6049, 1265, 5473}, +{5969, 1409, 5553}, +{6033, 1601, 5633}, +{6289, 1409, 5105}, +{6417, 1569, 4865}, +{6385, 1793, 5073}, +{6225, 2177, 5185}, +{6257, 1665, 5281}, +{6529, 1921, 4801}, +{6369, 2241, 5009}, +{6449, 1953, 5249}, +{6321, 2273, 5009}, +{6305, 2257, 4945}, +{6321, 1585, 5201}, +{6273, 1393, 5153}, +{6097, 1649, 5361}, +{6049, 1793, 5489}, +{6161, 1057, 5489}, +{6033, 1057, 5569}, +{5905, 1313, 5745}, +{6145, 1281, 5553}, +{6257, 1073, 5329}, +{6257, 2017, 5169}, +{6081, 2097, 5393}, +{6129, 1665, 5729}, +{6145, 1665, 5537}, +{6241, 2177, 5009}, +{6305, 2129, 5025}, +{6097, 2273, 5281}, +{6129, 2609, 5249}, +{6513, 1521, 5137}, +{6433, 1937, 4881}, +{6305, 1297, 5169}, +{6097, 1473, 5329}, +{5985, 1473, 5809}, +{6113, 1553, 5185}, +{6257, 1265, 5041}, +{6033, 1713, 5345}, +{6065, 1569, 5553}, +{6433, 1345, 5217}, +{6209, 2161, 4993}, +{6257, 2657, 4945}, +{6129, 2609, 5153}, +{5969, 2625, 5329}, +{6033, 2529, 4961}, +{6081, 3169, 4945}, +{6369, 2657, 4961}, +{6465, 2497, 4833}, +{6289, 1665, 5153}, +{6081, 1473, 5329}, +{5905, 2081, 5425}, +{5857, 1889, 5729}, +{6033, 1825, 5537}, +{6161, 1729, 5233}, +{6065, 1745, 5617}, +{6049, 1553, 5809}, +{6273, 2017, 5009}, +{6401, 1585, 5041}, +{6129, 1969, 5105}, +{6081, 2161, 5729}, +{6209, 2385, 5185}, +{6353, 1857, 4993}, +{6241, 2225, 4881}, +{6065, 2033, 5425}, +{6097, 2401, 5489}, +{6193, 1937, 5265}, +{6193, 1185, 5281}, +{5953, 2017, 5233}, +{6065, 1633, 5537}, +{6065, 1873, 5473}, +{6081, 1569, 5473}, +{6177, 1649, 5473}, +{6177, 1569, 5457}, +{6209, 1265, 5457}, +{6225, 1201, 5345}, +{6193, 1921, 5041}, +{6273, 2161, 5601}, +{6353, 1857, 5297}, +{6433, 1425, 4993}, +{6321, 1873, 4849}, +{6161, 2657, 5201}, +{6273, 2033, 5505}, +{6241, 1825, 5569}, +{6193, 913, 5025}, +{6097, 673, 4977}, +{6545, 1761, 5729}, +{6065, -111, 5601}, +{5969, 881, 5473}, +{6161, 1409, 5121}, +{5889, 737, 5585}, +{6097, 1713, 5057}, +{6561, 1377, 4449}, +{6673, 1697, 5313}, +{6433, 2689, 5345}, +{6401, 2049, 4737}, +{6081, 1777, 5153}, +{5969, 1793, 5969}, +{6081, 1553, 5745}, +{6081, 2049, 5201}, +{6257, 1313, 5201}, +{6433, 1297, 4801}, +{6337, 1009, 5249}, +{6081, 1121, 5601}, +{5713, 289, 6017}, +{5793, 417, 6113}, +{5729, 737, 6209}, +{6385, 913, 5345}, +{6049, 1121, 5457}, +{6177, 1553, 5153}, +{6321, 1713, 5217}, +{6113, 1921, 5665}, +{6177, 1489, 5185}, +{6225, 1825, 4993}, +{6241, 2097, 5265}, +{6369, 2241, 5201}, +{6369, 2289, 5009}, +{6385, 1761, 5409}, +{6289, 2049, 4977}, +{6129, 1553, 4657}, +{5905, 609, 5697}, +{5713, 785, 5905}, +{6193, 1073, 5553}, +{5761, 1233, 5873}, +{6129, 737, 5697}, +{6321, 1297, 5089}, +{6561, 1297, 4865}, +{6337, 1825, 5649}, +{6161, 1793, 5489}, +{6177, 1585, 5217}, +{6113, 1729, 5217}, +{6353, 2465, 5041}, +{6353, 2513, 4929}, +{6193, 1729, 5345}, +{6161, 1633, 5217}, +{6097, 1473, 5345}, +{6081, 2129, 5377}, +{6145, 2001, 5281}, +{5825, 1473, 5457}, +{6241, 1393, 5265}, +{6241, 1937, 5073}, +{6225, 1425, 5585}, +{6273, 1873, 5281}, +{6369, 1761, 5025}, +{6289, 1793, 5281}, +{5937, 1809, 5537}, +{5905, 2433, 5617}, +{6209, 2001, 5297}, +{6097, 1953, 5425}, +{6017, 2305, 5441}, +{6257, 2385, 5297}, +{5921, 1713, 5505}, +{6081, 1937, 5505}, +{6001, 2193, 5457}, +{5745, 2177, 5777}, +{5505, 993, 5393}, +{5089, 2737, 6161}, +{6737, 1953, 5041}, +{6753, 465, 5457}, +{6209, 961, 4657}, +{6849, 1057, 4817}, +{6641, 2289, 4801}, +{6593, 1617, 4785}, +{6401, 673, 5585}, +{6641, 1841, 4769}, +{6593, 1585, 4625}, +{6625, 1249, 4929}, +{6561, 1329, 5169}, +{6609, 1233, 4609}, +{6609, 1393, 4785}, +{6657, 833, 4913}, +{6241, 721, 5505}, +{6561, 593, 5473}, +{6561, 625, 4961}, +{6241, 897, 5313}, +{6481, 513, 5537}, +{6353, 369, 5313}, +{6257, 497, 5153}, +{6529, 1297, 4849}, +{6673, 1153, 5041}, +{6465, 801, 5393}, +{6609, 1057, 4961}, +{6641, 1473, 4977}, +{6241, 2113, 4657}, +{6257, 1873, 4977}, +{6689, 1121, 5185}, +{6673, 1249, 4769}, +{6641, 1393, 4849}, +{6497, 849, 5137}, +{6401, 977, 5505}, +{6289, 1249, 5457}, +{6305, 1185, 5249}, +{6081, 1633, 5457}, +{6161, 1361, 5569}, +{6353, 1633, 5009}, +{6545, 1601, 4961}, +{6337, 2081, 4865}, +{6401, 1601, 5169}, +{6385, 1569, 5185}, +{6577, 2737, 4769}, +{6321, 2001, 5009}, +{6321, 2529, 4897}, +{6337, 2161, 5121}, +{6305, 1937, 5233}, +{6193, 1409, 5393}, +{5665, 1777, 5585}, +{5889, 1457, 5857}, +{6097, 1505, 5489}, +{6065, 1585, 5425}, +{5953, 1697, 5473}, +{5921, 1361, 5777}, +{6049, 1569, 5377}, +{6369, 2049, 4929}, +{6561, 1985, 4977}, +{6001, 2481, 5185}, +{6145, 2065, 5217}, +{6273, 2161, 4881}, +{6177, 2305, 5137}, +{6177, 2465, 5409}, +{6193, 2433, 5345}, +{6337, 1985, 5057}, +{6065, 1745, 5265}, +{5873, 1665, 5649}, +{5649, 2049, 5905}, +{6209, 1761, 5233}, +{6145, 1297, 5249}, +{5921, 1601, 5617}, +{6081, 1873, 5729}, +{6257, 1825, 5137}, +{6385, 1857, 4801}, +{6033, 2545, 5537}, +{6257, 2465, 5377}, +{6289, 2033, 5137}, +{6465, 1905, 4833}, +{6593, 2353, 4737}, +{6289, 2289, 4961}, +{6353, 2273, 4785}, +{6417, 1537, 5137}, +{6257, 1617, 5137}, +{6209, 1345, 5393}, +{6001, 1697, 5249}, +{6241, 1505, 5377}, +{6001, 1281, 5425}, +{6017, 1137, 5537}, +{5793, 1377, 5921}, +{5777, 1185, 6001}, +{6257, 1409, 5169}, +{6273, 1793, 5201}, +{5889, 1873, 5521}, +{5809, 2161, 5425}, +{5921, 2065, 5409}, +{6097, 1841, 4993}, +{6305, 1761, 5473}, +{6209, 1857, 5649}, +{6449, 1393, 5217}, +{6209, 1121, 5361}, +{6273, 1041, 5361}, +{6065, 1633, 5345}, +{6321, 1297, 5777}, +{6353, 705, 5521}, +{6081, 865, 5297}, +{6017, 1009, 5649}, +{6081, 1025, 5569}, +{6289, 545, 5537}, +{6209, 1105, 5153}, +{6449, 1217, 5233}, +{6273, 1521, 5233}, +{6465, 1105, 5233}, +{6497, 1137, 4945}, +{6401, 1457, 5041}, +{6529, 1713, 5329}, +{6353, 1137, 5409}, +{6561, 1553, 5041}, +{6481, 1377, 5009}, +{6481, 1297, 5073}, +{6449, 721, 5345}, +{6305, 881, 5393}, +{6065, 369, 5649}, +{5761, 529, 5825}, +{5777, 721, 6129}, +{5585, 1217, 6081}, +{6449, 961, 5361}, +{6337, 993, 5137}, +{6305, 1329, 5201}, +{6209, 2113, 5057}, +{6353, 1793, 5361}, +{6721, 1297, 5393}, +{6497, 1841, 4817}, +{6177, 2193, 5073}, +{6225, 2017, 5377}, +{6145, 2049, 5473}, +{6497, 1505, 5105}, +{6001, 2225, 4817}, +{6273, 1649, 5217}, +{5969, 1921, 5569}, +{6161, 1521, 5457}, +{6193, 1249, 5393}, +{6033, 1169, 5649}, +{5921, 1537, 5665}, +{6129, 1409, 5585}, +{6113, 1633, 5297}, +{6273, 1457, 5121}, +{6289, 2049, 5281}, +{6145, 1969, 5569}, +{6161, 1761, 5249}, +{6273, 1761, 5009}, +{6465, 2273, 5025}, +{6433, 2081, 4961}, +{6449, 1793, 5153}, +{6449, 1905, 5201}, +{6481, 1905, 5009}, +{6385, 1761, 4817}, +{6401, 1473, 4977}, +{6081, 1713, 5217}, +{6113, 1505, 5217}, +{6145, 1489, 5201}, +{6129, 1457, 5425}, +{6113, 1761, 5585}, +{6321, 1521, 5169}, +{6561, 1537, 5025}, +{6417, 1777, 4945}, +{6193, 2289, 5153}, +{6273, 1761, 5345}, +{6001, 2017, 5185}, +{6465, 2305, 4977}, +{6321, 2401, 4865}, +{6433, 1777, 5185}, +{6353, 1633, 5281}, +{6497, 2289, 5425}, +{6337, 1473, 5217}, +{6337, 1649, 5041}, +{6161, 2097, 5441}, +{6017, 1905, 5425}, +{6209, 1569, 5249}, +{6193, 1425, 5217}, +{5937, 1713, 5313}, +{5889, 1953, 5777}, +{6113, 1457, 5985}, +{6433, 1697, 5137}, +{6337, 2241, 5137}, +{6097, 2289, 5089}, +{6161, 1633, 5521}, +{6257, 1889, 5185}, +{6353, 2161, 4929}, +{6305, 1969, 5249}, +{6305, 2033, 5281}, +{6353, 2225, 5137}, +{6401, 1841, 5041}, +{6401, 1569, 5169}, +{6097, 1889, 5377}, +{6001, 1697, 5361}, +{6033, 1713, 5217}, +{6113, 1425, 5505}, +{6017, 1649, 5649}, +{6177, 1441, 5409}, +{6481, 1425, 5153}, +{6385, 1761, 4961}, +{6081, 1953, 5217}, +{5777, 2097, 5553}, +{6609, 961, 5761}, +{6353, 2017, 4769}, +{6449, 2225, 5057}, +{6385, 1505, 5537}, +{6081, 1969, 5281}, +{6161, 497, 5553}, +{6449, 1121, 5329}, +{6177, 897, 5313}, +{6129, 753, 4929}, +{6273, -79, 5425}, +{6129, 305, 5505}, +{6033, -127, 5633}, +{6049, -223, 5777}, +{6289, 273, 5617}, +{6305, 113, 5377}, +{6433, 657, 5121}, +{6353, 209, 5361}, +{6209, 65, 5793}, +{6241, 593, 5345}, +{6561, 753, 5153}, +{6433, 673, 5233}, +{6705, 737, 5329}, +{6465, -335, 5345}, +{6161, 257, 4945}, +{6369, 145, 5073}, +{6225, 337, 5793}, +{5969, -463, 5697}, +{6065, 49, 5505}, +{6657, -847, 6177}, +{5777, 497, 5233}, +{6401, 545, 5649}, +{6449, 1057, 5137}, +{6561, 993, 5073}, +{6481, 1537, 4817}, +{6881, 1137, 4993}, +{6321, 1537, 5121}, +{6433, 1729, 4929}, +{6561, 1297, 5457}, +{6449, 1217, 5265}, +{6177, 1921, 5121}, +{6305, 1633, 5201}, +{6017, 1217, 5185}, +{6353, 785, 5441}, +{6321, 737, 5489}, +{6129, 977, 5201}, +{6193, 1329, 5137}, +{6257, 801, 5825}, +{6177, 1169, 5377}, +{6801, 1361, 4753}, +{6769, 1777, 4657}, +{6257, 2305, 4625}, +{6417, 1889, 4545}, +{6641, 1937, 4865}, +{6545, 2193, 5105}, +{6433, 2065, 5185}, +{6769, 1937, 5105}, +{6577, 1761, 5393}, +{6241, 2337, 5105}, +{6257, 1825, 5201}, +{6017, 1681, 5153}, +{5921, 1009, 5425}, +{5985, 1121, 5457}, +{5825, 1185, 5489}, +{6113, 1105, 5777}, +{6193, 1457, 5537}, +{6337, 1697, 4625}, +{6321, 1985, 4721}, +{6657, 2465, 5585}, +{6433, 2241, 4833}, +{6561, 2577, 4401}, +{6481, 2577, 4545}, +{6289, 2673, 4897}, +{6401, 2193, 5169}, +{6385, 2257, 5169}, +{6145, 2241, 4881}, +{5905, 1889, 5409}, +{5905, 1329, 5601}, +{6257, 1537, 5345}, +{6081, 1281, 5217}, +{6065, 1361, 5265}, +{5841, 1345, 5489}, +{5681, 1409, 5761}, +{6353, 1601, 5121}, +{6449, 1761, 5265}, +{6353, 1985, 5233}, +{6273, 2129, 5297}, +{6273, 1985, 5233}, +{6161, 1969, 4961}, +{6129, 2209, 5201}, +{6129, 2161, 5249}, +{6097, 2241, 5233}, +{6129, 2465, 5217}, +{6193, 1905, 5361}, +{6097, 1697, 5249}, +{6017, 1585, 5521}, +{5697, 1697, 5761}, +{5729, 1793, 5969}, +{5761, 1729, 5521}, +{5857, 1521, 6097}, +{5873, 2017, 6033}, +{5985, 1809, 5537}, +{6081, 1985, 5313}, +{6049, 2241, 5617}, +{5937, 3393, 6065}, +{6241, 3681, 4721}, +{6481, 3569, 4673}, +{6577, 3521, 4433}, +{6145, 2881, 3889}, +{6257, 2817, 5201}, +{6337, 2769, 5777}, +{6289, 2577, 5777}, +{6177, 1985, 5793}, +{5969, 2529, 4321}, +{5921, 1649, 4865}, +{6033, 1825, 5089}, +{6033, 1537, 5681}, +{6161, 929, 5841}, +{6001, 1041, 4945}, +{6385, 1201, 5153}, +{5889, 1441, 5393}, +{6113, 1633, 5297}, +{6129, 1457, 5313}, +{6001, 2145, 5537}, +{6161, 1809, 6065}, +{6161, 1745, 5105}, +{6481, 1969, 5073}, +{6481, 2113, 5073}, +{6209, 1953, 5393}, +{6113, 1889, 5601}, +{6273, 2033, 5073}, +{6177, 1681, 5201}, +{6033, 1649, 5489}, +{6001, 2145, 5297}, +{5809, 1505, 5329}, +{5713, 1249, 5873}, +{5921, 1249, 5905}, +{5745, 1057, 6049}, +{5873, 1377, 5729}, +{6289, 1089, 5265}, +{5953, 1713, 5377}, +{5793, 1425, 5953}, +{5985, 1169, 5681}, +{6049, 1185, 5489}, +{6305, 1713, 4945}, +{6225, 1905, 5681}, +{6161, 1457, 5665}, +{6177, 1233, 5409}, +{6369, 1153, 5169}, +{6097, 1345, 5345}, +{6017, 1073, 5921}, +{5841, 1201, 5729}, +{6081, 1105, 5377}, +{5969, 1217, 5729}, +{5809, 1185, 5921}, +{5857, 929, 5697}, +{6065, 2097, 5249}, +{6033, 2033, 5281}, +{6001, 2449, 5441}, +{6193, 1681, 5441}, +{6177, 1937, 5201}, +{6049, 1969, 5393}, +{6033, 1713, 5729}, +{6001, 2209, 5361}, +{6161, 1649, 5345}, +{6097, 1361, 5505}, +{5729, 1361, 5745}, +{5793, 1857, 5777}, +{6033, 1217, 5745}, +{5889, 1233, 5553}, +{5969, 1169, 5553}, +{6017, 1185, 5617}, +{5985, 1265, 5681}, +{6001, 1233, 5569}, +{6033, 1137, 5473}, +{5985, 2033, 5313}, +{5969, 1537, 5569}, +{6145, 1473, 5233}, +{6209, 1713, 5201}, +{6033, 1985, 5537}, +{6097, 1777, 5649}, +{6209, 1489, 5457}, +{6033, 1217, 5489}, +{6065, 1569, 5505}, +{6081, 1713, 5457}, +{6209, 1425, 5441}, +{6209, 945, 5393}, +{6145, 1169, 5489}, +{5937, 1569, 5569}, +{6145, 1441, 5569}, +{6225, 1569, 5265}, +{6353, 1441, 5025}, +{6209, 1937, 5521}, +{6177, 1873, 5569}, +{6145, 1953, 5137}, +{6337, 2145, 4897}, +{6337, 2081, 5137}, +{6225, 1857, 5345}, +{6321, 2017, 5281}, +{6209, 1633, 5249}, +{6113, 1745, 5377}, +{6177, 1809, 5297}, +{5905, 1169, 5617}, +{5825, 1505, 5665}, +{6001, 1601, 5617}, +{6033, 1969, 5505}, +{6113, 1153, 5585}, +{6257, 1793, 5041}, +{6225, 1617, 5137}, +{5937, 2689, 5121}, +{5521, 1345, 6049}, +{6609, 1329, 5889}, +{6577, 1729, 5457}, +{5617, 2225, 5537}, +{6753, 1521, 5489}, +{6433, 1073, 5569}, +{6497, 1617, 4961}, +{6097, 1329, 4785}, +{6049, 481, 5857}, +{6017, -79, 5521}, +{6161, 689, 5313}, +{6401, 81, 5393}, +{6241, 65, 5617}, +{6417, 353, 5441}, +{6321, 305, 5169}, +{6433, 577, 5057}, +{6241, 593, 5361}, +{6225, 465, 5569}, +{6241, 497, 5377}, +{6129, 497, 5553}, +{6177, 241, 5617}, +{6353, 1185, 5489}, +{6545, 209, 5537}, +{6289, -255, 5313}, +{6241, -191, 5409}, +{5889, -79, 6145}, +{6385, -143, 5441}, +{6273, 161, 5441}, +{6209, 257, 5393}, +{5873, -271, 6049}, +{6353, -367, 5585}, +{6385, 33, 5633}, +{6513, 1329, 4961}, +{6465, 1105, 4993}, +{6545, 993, 5105}, +{6369, 737, 5233}, +{6513, 1889, 5233}, +{6209, 1505, 5297}, +{6529, 817, 5377}, +{6625, 1009, 5441}, +{6433, 1105, 4881}, +{6273, 1569, 4689}, +{6817, 1761, 5137}, +{5905, 849, 5489}, +{6241, 1505, 5233}, +{6081, 1921, 5345}, +{6257, 1089, 5857}, +{5969, 401, 5617}, +{5921, 1249, 5361}, +{6209, 2145, 5041}, +{6337, 1825, 5521}, +{6177, 1489, 5665}, +{6113, 1425, 5313}, +{6289, 2289, 4817}, +{6177, 1233, 5521}, +{6081, 1921, 5425}, +{6417, 913, 5665}, +{6145, 1073, 5345}, +{6049, 1313, 5329}, +{5697, 1089, 6209}, +{5777, 1073, 5969}, +{5825, 849, 5697}, +{5985, 1345, 5649}, +{5729, 1505, 5729}, +{5905, 1185, 5841}, +{5937, 1185, 5585}, +{5809, 1297, 5505}, +{5681, 1761, 5745}, +{5969, 1569, 5777}, +{5937, 1393, 5649}, +{6225, 1729, 5281}, +{6241, 1697, 5281}, +{5953, 1505, 5633}, +{6049, 1905, 5585}, +{6273, 1409, 5345}, +{6257, 1073, 5473}, +{5905, 609, 5505}, +{5729, 497, 5665}, +{5665, 561, 6145}, +{5713, 257, 5793}, +{5409, 113, 6145}, +{5345, 913, 6401}, +{5825, 753, 5921}, +{6225, 961, 5585}, +{6241, 481, 5361}, +{5569, 593, 6065}, +{6049, 225, 6273}, +{5713, 673, 6321}, +{5825, 721, 5793}, +{5969, 977, 5441}, +{5889, 881, 5841}, +{5857, 849, 6017}, +{5985, 497, 5809}, +{5729, 865, 5873}, +{5841, 1089, 5745}, +{5649, 657, 6241}, +{5617, 401, 6081}, +{5569, 497, 6033}, +{5617, 481, 5905}, +{5537, 513, 6337}, +{5745, 449, 5969}, +{5873, 641, 5713}, +{6001, 785, 5473}, +{6001, 1265, 5601}, +{5969, 1041, 5809}, +{5969, 753, 5601}, +{5921, 1297, 5505}, +{5841, 1441, 5713}, +{5937, 1409, 5905}, +{5873, 1297, 5857}, +{6065, 1361, 5537}, +{6081, 1041, 5473}, +{5777, 1121, 5825}, +{5809, 865, 6161}, +{5681, 865, 5953}, +{5761, 529, 5873}, +{5681, 1041, 6337}, +{5665, 705, 6241}, +{5745, 657, 5969}, +{6001, 929, 5457}, +{6001, 1153, 5457}, +{6033, 1521, 5569}, +{5985, 817, 5713}, +{6017, 1329, 5377}, +{6161, 1809, 5361}, +{6049, 1633, 5569}, +{6001, 1345, 5601}, +{5953, 1313, 5633}, +{6049, 1473, 5569}, +{6001, 1105, 5569}, +{5617, 833, 5793}, +{5889, 961, 5905}, +{5953, 881, 5633}, +{5889, 673, 5617}, +{5793, 753, 5809}, +{5809, 1073, 5969}, +{6177, 1137, 5425}, +{6209, 1009, 5361}, +{6049, 1025, 5473}, +{6081, 1297, 5617}, +{5889, 977, 5809}, +{6033, 1281, 5505}, +{5953, 1505, 5489}, +{6097, 1793, 5793}, +{6001, 1457, 5825}, +{6049, 1521, 5537}, +{5985, 1281, 5473}, +{5745, 1009, 5841}, +{5521, 945, 6417}, +{6049, 1441, 5633}, +{5921, 1185, 5425}, +{5809, 1265, 5633}, +{5633, 1329, 6337}, +{5697, 1265, 5985}, +{6097, 1105, 5537}, +{6081, 1441, 5233}, +{5921, 2161, 5425}, +{6049, 1537, 5857}, +{6033, 1521, 5601}, +{6113, 1537, 5217}, +{6097, 1985, 5233}, +{6049, 1809, 5585}, +{6257, 1425, 5425}, +{6033, 1377, 5377}, +{6225, 1553, 5297}, +{5921, 1057, 5649}, +{5681, 1393, 6097}, +{5825, 913, 5713}, +{5985, 1025, 5489}, +{5761, 625, 5889}, +{5617, 849, 6305}, +{5857, 593, 6161}, +{5937, 977, 5457}, +{5985, 1489, 5393}, +{6065, 1425, 5553}, +{5937, 1217, 5985}, +{5969, 977, 5665}, +{6081, 1665, 5329}, +{6113, 1537, 5489}, +{5841, 1537, 5921}, +{6129, 1537, 5617}, +{5985, 657, 5681}, +{5825, 657, 5745}, +{5665, 1089, 5857}, +{5889, 1137, 6001}, +{5713, 657, 6033}, +{5793, 929, 5809}, +{5681, 769, 5921}, +{5697, 1025, 6273}, +{5809, 1601, 5665}, +{6129, 913, 5457}, +{5921, 657, 5489}, +{5713, 1921, 5585}, +{5825, 1489, 5889}, +{5825, 1249, 5585}, +{5841, 1361, 5521}, +{5921, 1521, 5921}, +{5825, 1905, 5825}, +{5953, 769, 5713}, +{6049, 1217, 5489}, +{5857, 881, 5553}, +{5921, 1393, 5713}, +{5793, 1153, 6049}, +{5905, 881, 5601}, +{5825, 737, 5761}, +{5681, 1105, 6065}, +{5649, 833, 6273}, +{5729, 961, 6033}, +{5953, 753, 5521}, +{5985, 1057, 5553}, +{5729, 2177, 5569}, +{6305, 433, 6561}, +{6273, 1345, 5137}, +{6257, 1361, 5345}, +{5905, 1249, 5505}, +{6209, 1009, 5393}, +{6033, 1361, 5265}, +{6401, 369, 5697}, +{6769, 1217, 4529}, +{6801, 1089, 4561}, +{6433, 865, 4481}, +{6449, 369, 5265}, +{6257, 81, 5457}, +{6321, 497, 5377}, +{6305, 81, 5521}, +{6545, 177, 5153}, +{6577, 97, 5025}, +{6609, 513, 4817}, +{6721, 865, 4929}, +{6609, 705, 5121}, +{6353, 241, 5345}, +{6241, 465, 5345}, +{6369, 1217, 5249}, +{6321, 945, 5265}, +{6593, 497, 5281}, +{6529, 737, 5089}, +{6897, 369, 5201}, +{6417, 1121, 4561}, +{6833, 161, 4833}, +{6337, -79, 5425}, +{6545, 49, 5137}, +{6369, 305, 5137}, +{6369, 1, 5681}, +{5857, 897, 5345}, +{6225, 657, 5809}, +{6385, 1041, 5233}, +{6689, 1137, 5281}, +{6497, 1569, 4881}, +{6337, 2225, 4497}, +{6081, 1377, 5089}, +{6609, 1633, 4721}, +{6465, 2017, 4641}, +{6593, 2065, 5073}, +{6481, 1313, 5217}, +{6465, 1265, 5585}, +{6465, 1505, 5313}, +{6353, 1905, 5489}, +{6385, 1729, 5777}, +{6257, 2145, 5921}, +{5409, 1489, 4737}, +{5121, -463, 6465}, +{5505, 801, 6209}, +{5265, 1137, 6385}, +{5729, 577, 5969}, +{5873, 321, 5777}, +{5761, 1553, 5569}, +{5857, 1697, 5793}, +{5889, 1073, 6385}, +{5841, 1409, 5969}, +{6049, 1249, 5441}, +{6209, 929, 5201}, +{6017, 545, 5729}, +{6001, 1441, 5937}, +{6209, 1073, 5681}, +{6161, 1153, 5585}, +{5889, 881, 5489}, +{5729, 833, 5825}, +{5777, 673, 6193}, +{5585, 817, 5953}, +{5425, 369, 6193}, +{5585, 481, 6193}, +{5793, 737, 5969}, +{6209, 1105, 5345}, +{6209, 1185, 5249}, +{6113, 1745, 5457}, +{5873, 1889, 5889}, +{5825, 1313, 5985}, +{5777, 1329, 5729}, +{5841, 1425, 5617}, +{5777, 2225, 5713}, +{5905, 2385, 5793}, +{5937, 1345, 5777}, +{5729, 1409, 5681}, +{5745, 1233, 5761}, +{5537, 1441, 5921}, +{5473, 1537, 6017}, +{5553, 929, 5921}, +{5585, 849, 6017}, +{5585, 1057, 6017}, +{5473, 673, 6401}, +{5537, 881, 5985}, +{6145, 1121, 5569}, +{5953, 1793, 5521}, +{6001, 1537, 5809}, +{5889, 1457, 5777}, +{6017, 1377, 5617}, +{5905, 1905, 5489}, +{5953, 1793, 5601}, +{6049, 1489, 5569}, +{5969, 1569, 5809}, +{5905, 1137, 5633}, +{5713, 1313, 5809}, +{5569, 1649, 6081}, +{5793, 929, 5985}, +{5681, 769, 5857}, +{5681, 961, 5793}, +{5729, 1345, 6001}, +{5617, 561, 6225}, +{5601, 849, 6049}, +{5921, 1233, 5569}, +{5857, 1649, 5569}, +{6017, 1713, 5601}, +{5889, 769, 5889}, +{5777, 1121, 5729}, +{5937, 1761, 5553}, +{5889, 1473, 5633}, +{5857, 1361, 5985}, +{6033, 1617, 5713}, +{6257, 1601, 5521}, +{6225, 1185, 5249}, +{6161, 1105, 5153}, +{6017, 849, 5297}, +{5633, 1169, 5937}, +{6113, 1393, 5473}, +{6257, 401, 5441}, +{5937, 657, 5697}, +{5985, 993, 5777}, +{5969, 1441, 5601}, +{6241, 1073, 5473}, +{5857, 1729, 5489}, +{6017, 1633, 5649}, +{6065, 1681, 5681}, +{6113, 1457, 5281}, +{6193, 1745, 5153}, +{6209, 1825, 5409}, +{6113, 1729, 5585}, +{5937, 1697, 5665}, +{6033, 1105, 5841}, +{6033, 2001, 5537}, +{6145, 1665, 5249}, +{6209, 865, 5297}, +{6017, 1377, 5601}, +{5793, 769, 5889}, +{5697, 1025, 5889}, +{5601, 897, 6081}, +{5617, 1249, 6049}, +{6097, 833, 5697}, +{6193, 1105, 5409}, +{6001, 1313, 5553}, +{6033, 1617, 5521}, +{5985, 1745, 5617}, +{6001, 1409, 5761}, +{6033, 1537, 5441}, +{6129, 1729, 5313}, +{6017, 1665, 5313}, +{5905, 1617, 5953}, +{5825, 1457, 5937}, +{6097, 1585, 5553}, +{5969, 1153, 5665}, +{5857, 1441, 5633}, +{5889, 1169, 5761}, +{5889, 1217, 5873}, +{5889, 881, 5793}, +{5633, 1089, 5985}, +{5649, 961, 6033}, +{5617, 993, 6049}, +{5681, 849, 6065}, +{5745, 1057, 5937}, +{5921, 1185, 5745}, +{5825, 945, 5729}, +{5841, 1249, 5665}, +{5889, 1441, 5681}, +{5905, 1329, 5809}, +{5857, 1249, 5697}, +{5937, 1489, 5665}, +{5809, 1681, 5937}, +{5889, 1873, 5665}, +{5921, 1505, 5697}, +{6065, 1489, 5361}, +{6049, 1265, 5409}, +{6017, 1489, 5489}, +{5937, 1201, 5617}, +{5745, 1265, 5937}, +{5777, 1281, 5873}, +{5937, 1265, 5649}, +{5745, 945, 5969}, +{5777, 929, 5905}, +{5761, 945, 5905}, +{5777, 961, 5793}, +{5921, 561, 5777}, +{5857, 865, 5761}, +{5969, 1201, 5569}, +{5681, 1633, 5777}, +{5681, 1089, 6129}, +{5537, 1377, 6001}, +{5825, 1617, 5777}, +{5697, 1601, 5841}, +{5745, 1441, 5953}, +{5729, 1313, 5985}, +{5921, 1377, 5681}, +{5841, 1521, 5729}, +{5793, 929, 5969}, +{5585, 1601, 5937}, +{5761, 1281, 5921}, +{5697, 945, 5873}, +{5697, 881, 5921}, +{5713, 1073, 5841}, +{5585, 993, 5841}, +{5489, 961, 5985}, +{5889, 785, 6321}, +{5745, 1057, 6145}, +{6529, 1441, 5249}, +{6321, 561, 4401}, +{6497, 913, 5089}, +{6161, 513, 5553}, +{6449, 353, 5233}, +{6401, 417, 5121}, +{6273, 561, 5217}, +{6577, 273, 5249}, +{6465, -335, 5025}, +{6417, 97, 5041}, +{6497, -319, 5185}, +{6209, -559, 5345}, +{6001, -719, 5697}, +{5937, -1039, 6241}, +{5905, -895, 5745}, +{5985, -687, 5425}, +{5985, -1103, 5601}, +{6193, -911, 5393}, +{6257, -943, 5313}, +{6433, -351, 5233}, +{6129, 65, 4865}, +{6369, 49, 5937}, +{6305, -543, 5537}, +{6577, -383, 5345}, +{6785, 737, 5185}, +{6673, 289, 4593}, +{5969, 1313, 4817}, +{7969, 145, 4897}, +{6497, 1393, 5057}, +{6593, -591, 5169}, +{5921, -159, 5201}, +{6113, -367, 5761}, +{6129, 33, 5649}, +{6577, -447, 5361}, +{6177, 769, 5073}, +{6241, 209, 5761}, +{6209, -79, 6321}, +{6305, 209, 5713}, +{6577, 881, 4945}, +{6497, 1489, 4785}, +{6321, 657, 5313}, +{6241, 625, 5601}, +{6529, 929, 5377}, +{6449, 1489, 4977}, +{6193, 1585, 4961}, +{6273, 625, 5825}, +{6257, 1457, 5345}, +{6529, 785, 5249}, +{6289, 913, 4929}, +{6081, 385, 4897}, +{5809, -223, 6113}, +{5889, -271, 6049}, +{5761, -463, 5905}, +{5905, 33, 5793}, +{5921, 17, 5729}, +{5873, -111, 6049}, +{6081, -175, 5777}, +{6065, 65, 5697}, +{6193, 769, 5169}, +{6305, 865, 5121}, +{6337, 337, 5505}, +{6177, 417, 5697}, +{6241, 881, 5297}, +{6065, 1009, 5297}, +{6017, 545, 5745}, +{6193, 257, 5649}, +{6433, 641, 5361}, +{6401, 705, 5265}, +{6161, -399, 5473}, +{6033, 289, 5745}, +{6113, 257, 5553}, +{6161, -175, 5601}, +{6193, -335, 5569}, +{6113, 81, 5361}, +{6113, 465, 5393}, +{6001, 641, 5313}, +{6161, 2049, 6881}, +{6257, 1105, 5473}, +{6129, 1761, 5313}, +{6353, 2529, 5249}, +{6353, 2737, 5377}, +{6545, 2257, 4897}, +{6497, 2497, 5281}, +{6353, 2977, 4929}, +{6353, 2129, 3681}, +{6449, 2593, 4081}, +{6001, 1505, 5937}, +{6353, 1425, 5169}, +{6049, 1665, 5457}, +{5953, 1409, 5489}, +{6017, 977, 5617}, +{5617, 753, 5793}, +{5761, 897, 5713}, +{5825, 577, 5841}, +{5937, 753, 5649}, +{5793, 353, 5425}, +{6001, 225, 6049}, +{6353, 417, 5169}, +{6353, 577, 5521}, +{5921, 913, 5377}, +{6017, 1153, 5025}, +{6193, 1537, 6129}, +{5937, 1393, 5921}, +{5969, 1265, 5553}, +{6081, 1505, 5505}, +{6097, 1729, 5329}, +{6129, 1921, 5729}, +{5937, 1617, 5521}, +{6113, 1665, 5297}, +{6241, 1505, 5297}, +{6273, 1857, 5249}, +{5921, 1185, 5729}, +{5889, 1073, 5905}, +{6145, 1025, 5569}, +{6049, 961, 5457}, +{5889, 1089, 5665}, +{5745, 1057, 5921}, +{5889, 289, 5969}, +{6049, 929, 5585}, +{6129, 1105, 5425}, +{6049, 977, 5569}, +{5873, 1361, 5697}, +{6161, 1393, 5569}, +{6033, 1457, 5473}, +{6241, 1649, 5233}, +{6209, 2001, 5185}, +{6161, 1681, 5345}, +{6097, 1697, 5473}, +{6161, 1777, 5297}, +{6273, 1681, 5297}, +{6225, 1793, 5313}, +{6017, 1553, 5441}, +{5921, 1201, 5745}, +{5889, 1425, 5697}, +{6033, 1073, 5633}, +{5905, 1089, 5489}, +{5921, 897, 5681}, +{5745, 977, 6049}, +{5937, 1265, 5681}, +{6097, 865, 5473}, +{6081, 1217, 5441}, +{5873, 1281, 5713}, +{5889, 1697, 5729}, +{6129, 1585, 5553}, +{6097, 1489, 5425}, +{6097, 1457, 5409}, +{6049, 1633, 5473}, +{6033, 1697, 5569}, +{6129, 1505, 5441}, +{6129, 1537, 5473}, +{6177, 1761, 5345}, +{6193, 1585, 5361}, +{6145, 1393, 5441}, +{5841, 1473, 5697}, +{6065, 1233, 5585}, +{6129, 1073, 5425}, +{6001, 1073, 5553}, +{5969, 1185, 5649}, +{6049, 1089, 5697}, +{6129, 817, 5569}, +{6033, 1201, 5409}, +{6049, 993, 5553}, +{5969, 1361, 5553}, +{6017, 1313, 5633}, +{6225, 1409, 5313}, +{6209, 1217, 5297}, +{6193, 1457, 5329}, +{6193, 1633, 5345}, +{6033, 1505, 5665}, +{6129, 1537, 5441}, +{6145, 1553, 5409}, +{6161, 1473, 5457}, +{6161, 1281, 5553}, +{5969, 1361, 5617}, +{5985, 1281, 5617}, +{6033, 1249, 5553}, +{6001, 1041, 5585}, +{5969, 1137, 5681}, +{5889, 1089, 5825}, +{5921, 1185, 5761}, +{6113, 993, 5649}, +{6129, 1153, 5441}, +{6049, 1121, 5601}, +{6017, 1137, 5601}, +{6081, 1265, 5457}, +{6081, 1265, 5521}, +{6081, 1233, 5601}, +{5937, 1425, 5633}, +{6049, 1361, 5601}, +{6017, 1345, 5665}, +{5969, 1265, 5665}, +{6113, 1697, 5473}, +{6177, 1617, 5425}, +{6129, 1025, 5521}, +{5921, 1121, 5713}, +{5841, 1089, 5825}, +{6033, 1185, 5649}, +{5985, 1105, 5601}, +{5905, 1089, 5729}, +{5857, 737, 5873}, +{5857, 897, 5921}, +{5809, 849, 5809}, +{6129, 1073, 5505}, +{6001, 673, 5569}, +{6113, 1073, 5569}, +{6097, 1281, 5569}, +{6097, 1441, 5457}, +{6113, 1233, 5329}, +{5409, 1953, 5489}, +{6065, 1281, 5969}, +{5905, 1969, 5569}, +{6449, 1313, 4977}, +{6529, 1329, 4401}, +{6657, 945, 5041}, +{6273, 1121, 5473}, +{6369, 417, 5169}, +{6321, 385, 5345}, +{6289, 705, 5185}, +{6433, 417, 5329}, +{6161, 225, 5505}, +{6257, 417, 5121}, +{6657, 177, 4881}, +{6337, 241, 5393}, +{6369, 657, 5457}, +{6609, 849, 5089}, +{6577, 433, 5169}, +{6465, 913, 5169}, +{6641, 865, 4849}, +{6545, 1201, 4897}, +{6401, 945, 5265}, +{6449, 801, 5233}, +{6689, 929, 5025}, +{6625, 1041, 4945}, +{6577, 897, 4929}, +{6385, 417, 5201}, +{6289, 289, 5601}, +{6145, 241, 5521}, +{6193, 609, 5361}, +{6209, 353, 5537}, +{6385, 401, 5585}, +{6673, 609, 5265}, +{6273, 465, 5217}, +{6545, 513, 5105}, +{6369, 1185, 4977}, +{6465, 913, 5121}, +{6433, 753, 5249}, +{6305, 1137, 5265}, +{6321, 1313, 5249}, +{6289, 1313, 5441}, +{6321, 1057, 5393}, +{6257, 993, 5345}, +{6321, 1217, 5169}, +{6401, 817, 5201}, +{6465, 577, 5313}, +{6257, 481, 5537}, +{6401, 769, 5441}, +{6305, 513, 5249}, +{6001, 929, 5441}, +{5969, 849, 5825}, +{5953, 785, 6177}, +{6097, 609, 5777}, +{6097, 1281, 5425}, +{6081, 1489, 5617}, +{6145, 1345, 5553}, +{6289, 1185, 5073}, +{6225, 1313, 5169}, +{6433, 1409, 4961}, +{6113, 1521, 5537}, +{6225, 1265, 5681}, +{6161, 705, 5665}, +{6353, 1041, 5585}, +{5953, 1377, 5521}, +{6097, 1265, 5473}, +{6081, 1265, 5489}, +{5681, 881, 6193}, +{5857, 1521, 5953}, +{6209, 1457, 4977}, +{5969, 1537, 5617}, +{5889, 1313, 5793}, +{6049, 1553, 5937}, +{6065, 1425, 5745}, +{6001, 1681, 5521}, +{5537, 1937, 5777}, +{5889, 1937, 6273}, +{6289, 1329, 5489}, +{6257, 1201, 5057}, +{6241, 1425, 4721}, +{6209, 1937, 4929}, +{6049, 913, 5601}, +{5969, 1201, 5905}, +{6097, 1313, 5681}, +{6097, 1201, 5681}, +{5937, 1169, 5825}, +{5857, 1281, 5857}, +{6097, 1073, 5601}, +{6001, 1009, 5521}, +{5985, 1137, 5713}, +{6033, 1137, 5601}, +{5857, 1217, 5665}, +{5905, 1009, 5889}, +{5969, 1265, 5745}, +{5985, 1313, 5553}, +{6209, 1649, 5313}, +{6049, 1377, 5633}, +{6305, 1505, 5313}, +{6385, 1457, 5105}, +{6289, 1601, 5089}, +{6353, 1729, 5265}, +{6225, 1713, 5457}, +{6289, 1505, 5425}, +{6289, 1617, 5313}, +{6273, 1665, 5233}, +{6081, 1409, 5441}, +{6145, 1553, 5361}, +{5985, 977, 5665}, +{5953, 1169, 5809}, +{5825, 865, 5889}, +{5905, 1073, 5921}, +{5809, 945, 5921}, +{5777, 673, 5857}, +{5873, 897, 5745}, +{5921, 545, 5745}, +{5953, 865, 5761}, +{5985, 1041, 5713}, +{5921, 1025, 5873}, +{5969, 1025, 5745}, +{5969, 849, 5633}, +{5953, 1105, 5569}, +{5969, 1457, 5665}, +{5985, 1393, 5633}, +{6033, 1137, 5713}, +{6097, 961, 5697}, +{6209, 1025, 5329}, +{6113, 641, 5553}, +{6049, 1089, 5649}, +{6001, 753, 5729}, +{5953, 817, 5729}, +{5969, 721, 5777}, +{5825, 1073, 5809}, +{5841, 897, 5905}, +{5873, 1009, 5809}, +{6001, 801, 5713}, +{5937, 865, 5713}, +{5969, 1185, 5633}, +{5921, 1281, 5665}, +{5969, 1521, 5601}, +{6033, 1457, 5681}, +{6001, 1473, 5537}, +{6033, 1569, 5441}, +{5969, 1617, 5537}, +{5969, 1809, 5681}, +{6017, 1585, 5665}, +{6177, 1729, 5409}, +{6145, 1649, 5281}, +{6017, 1841, 5473}, +{5857, 1585, 5569}, +{5761, 1297, 5809}, +{5905, 1585, 5761}, +{5969, 1201, 5729}, +{5825, 1409, 5601}, +{5681, 1313, 5953}, +{5729, 1473, 6097}, +{5857, 1025, 5969}, +{5953, 1185, 5585}, +{5969, 1377, 5537}, +{5985, 1633, 5633}, +{5921, 1457, 5745}, +{5889, 1601, 5729}, +{5873, 1409, 5617}, +{5905, 1777, 5649}, +{5777, 1969, 5681}, +{5905, 1889, 5649}, +{6017, 1873, 5553}, +{5985, 1761, 5617}, +{6033, 1553, 5537}, +{5937, 1521, 5569}, +{5841, 1313, 5681}, +{5841, 1585, 5729}, +{5921, 1265, 5761}, +{5937, 1569, 5329}, +{5953, 1025, 5809}, +{5873, 1553, 5905}, +{5921, 945, 5953}, +{5841, 1249, 5713}, +{5729, 1889, 5521}, +{5857, 2337, 5569}, +{6193, 2129, 5393}, +{5825, 2497, 5473}, +{6113, 1985, 5361}, +{5921, 2097, 5473}, +{5953, 2209, 5537}, +{6193, 1953, 5361}, +{6065, 2113, 5377}, +{6001, 1953, 5441}, +{5905, 1857, 5553}, +{5793, 1873, 5665}, +{5761, 1345, 5729}, +{5777, 865, 5473}, +{5729, 1073, 5649}, +{5553, 1569, 6065}, +{5665, 1169, 6177}, +{5873, 1473, 5425}, +{5985, 1729, 5169}, +{6033, 1809, 5281}, +{5617, 1745, 6097}, +{5793, 1841, 5441}, +{5777, 2081, 5185}, +{5793, 1905, 5809}, +{5457, 1841, 5905}, +{5617, 1569, 6129}, +{5809, 1633, 5921}, +{5889, 1889, 5729}, +{5873, 1553, 5537}, +{5793, 1217, 5457}, +{5713, 1265, 6241}, +{5777, 1201, 5857}, +{5745, 1153, 5761}, +{5841, 1041, 5873}, +{6049, 1025, 5665}, +{6257, 945, 5665}, +{6065, 849, 5281}, +{6321, 1089, 5185}, +{6369, 1505, 5169}, +{6401, 977, 5425}, +{6097, 913, 5681}, +{6289, 1105, 5345}, +{6449, 1441, 5201}, +{6305, 1137, 5121}, +{6465, 1329, 5073}, +{6369, 897, 5393}, +{6497, 1073, 5249}, +{6433, 1121, 4929}, +{6241, 1121, 5281}, +{6193, 641, 5569}, +{6177, 433, 5553}, +{6113, 513, 5393}, +{6161, 705, 5457}, +{6273, 289, 5649}, +{6193, 337, 5665}, +{6401, 577, 5329}, +{6561, 385, 5217}, +{6305, 1121, 4929}, +{6065, 2193, 5425}, +{6769, -47, 5345}, +{6449, 1889, 5041}, +{6417, 1409, 5345}, +{6177, 1521, 5281}, +{6001, 1873, 5393}, +{6417, 1249, 5057}, +{6225, 945, 4929}, +{6241, 1041, 4945}, +{5969, 1601, 5329}, +{5665, 1889, 6081}, +{5649, 2417, 6609}, +{5745, 1361, 5585}, +{5985, 1441, 5473}, +{5953, 2289, 5537}, +{5985, 1393, 5377}, +{5921, 2081, 5441}, +{5905, 2241, 5601}, +{5985, 1921, 5489}, +{6097, 1969, 5249}, +{6081, 2161, 5169}, +{6097, 2065, 5329}, +{6097, 2241, 5585}, +{6097, 2241, 5393}, +{6065, 1809, 5409}, +{5969, 1633, 5377}, +{5937, 1745, 5537}, +{5953, 1985, 5601}, +{5921, 1793, 5553}, +{5889, 1729, 5569}, +{5793, 1809, 5937}, +{5841, 1793, 5873}, +{6129, 1665, 5505}, +{6241, 1361, 5361}, +{6049, 2081, 5105}, +{5937, 2273, 5249}, +{6033, 2161, 5633}, +{5921, 2017, 5905}, +{5889, 2033, 5713}, +{6001, 2097, 5217}, +{5825, 2337, 5553}, +{5953, 2129, 5633}, +{6017, 2065, 5409}, +{6017, 1777, 5457}, +{6065, 2273, 5297}, +{5889, 1873, 5537}, +{5809, 1825, 5713}, +{5745, 1425, 5841}, +{5777, 1777, 5745}, +{5889, 1265, 5585}, +{5809, 1681, 5777}, +{5873, 1553, 5777}, +{6033, 1505, 5665}, +{6065, 1393, 5489}, +{5953, 2017, 5329}, +{6129, 1553, 5553}, +{6065, 1185, 5521}, +{6049, 1297, 5489}, +{6017, 1585, 5377}, +{6033, 1889, 5329}, +{5953, 1921, 5537}, +{6113, 1681, 5473}, +{6177, 1825, 5297}, +{6113, 1697, 5329}, +{5985, 1505, 5425}, +{5937, 1457, 5649}, +{5857, 1425, 5921}, +{5825, 1185, 5681}, +{5809, 1377, 5745}, +{5713, 1393, 5873}, +{5745, 1217, 6049}, +{5825, 1281, 5777}, +{5937, 1169, 5649}, +{5905, 1185, 5585}, +{5873, 1345, 5665}, +{5857, 1377, 5713}, +{5873, 1633, 5873}, +{5889, 1473, 5745}, +{5841, 1249, 5601}, +{5873, 1729, 5617}, +{5793, 1761, 5633}, +{5777, 1441, 5969}, +{5873, 1681, 5713}, +{5985, 1665, 5505}, +{5969, 1601, 5617}, +{5873, 1537, 5617}, +{5857, 1297, 5841}, +{5761, 1313, 5969}, +{6017, 1377, 5409}, +{5953, 1265, 5473}, +{5889, 1329, 5537}, +{5873, 1265, 5809}, +{5953, 1169, 5697}, +{6049, 1249, 5489}, +{6113, 1361, 5441}, +{6065, 1601, 5441}, +{5873, 1585, 5553}, +{5809, 1617, 5761}, +{5841, 1857, 5665}, +{5873, 1793, 5489}, +{5969, 1809, 5505}, +{5857, 1873, 5633}, +{5969, 2225, 5409}, +{6017, 1617, 5537}, +{6049, 1697, 5521}, +{5953, 1505, 5553}, +{5905, 1761, 5489}, +{6001, 1601, 5825}, +{5905, 1393, 5553}, +{5921, 1441, 5505}, +{5777, 1265, 5633}, +{5681, 1681, 5889}, +{5985, 1521, 5617}, +{6065, 1169, 5441}, +{5969, 1425, 5473}, +{5841, 1521, 5649}, +{5777, 1857, 5809}, +{5793, 1745, 5953}, +{5825, 1745, 5553}, +{5841, 1841, 5553}, +{5889, 2017, 5569}, +{5793, 1873, 5681}, +{5937, 1889, 5729}, +{5921, 1985, 5505}, +{6017, 1921, 5441}, +{5905, 1649, 5681}, +{5905, 1585, 5697}, +{5937, 1761, 5569}, +{6097, 1409, 5265}, +{6017, 1377, 5441}, +{5905, 1377, 5649}, +{5793, 1665, 5921}, +{6001, 1521, 5649}, +{6065, 1473, 5361}, +{6033, 1313, 5521}, +{5873, 1777, 5697}, +{5841, 1649, 5857}, +{5761, 1569, 6001}, +{5841, 1793, 5409}, +{5777, 1729, 5537}, +{5809, 1713, 5713}, +{5713, 1905, 5777}, +{5761, 1681, 5969}, +{5889, 1937, 5569}, +{5857, 1713, 5553}, +{5777, 1521, 5761}, +{5745, 1457, 5857}, +{5745, 1777, 5745}, +{5825, 1393, 5777}, +{5825, 1377, 5777}, +{5825, 1345, 5761}, +{5745, 1681, 5841}, +{5697, 1361, 5841}, +{5761, 1377, 5905}, +{5937, 1409, 5633}, +{5873, 1617, 5601}, +{5745, 1857, 5521}, +{5793, 1793, 5601}, +{5793, 1969, 5889}, +{5857, 2049, 5489}, +{5889, 2161, 5377}, +{5873, 2385, 5409}, +{5873, 2193, 5585}, +{5793, 2001, 5681}, +{5985, 2401, 5297}, +{6001, 2289, 5377}, +{5873, 2289, 5409}, +{5857, 1729, 5617}, +{5825, 2017, 5601}, +{5889, 1761, 5569}, +{5841, 1713, 5521}, +{5793, 1601, 5601}, +{5825, 1873, 5793}, +{5841, 1521, 5857}, +{5921, 1441, 5633}, +{5905, 1793, 5601}, +{5809, 1745, 5713}, +{5809, 1793, 5713}, +{5905, 1761, 5745}, +{5921, 1745, 5473}, +{5713, 1745, 5425}, +{5793, 2129, 5585}, +{6689, 897, 6161}, +{6065, 2913, 5681}, +{6097, 1521, 5537}, +{6097, 1761, 5457}, +{6273, 1153, 5441}, +{6273, 1521, 5361}, +{6257, 1889, 5137}, +{6033, 1329, 5009}, +{6033, 209, 5729}, +{6113, 177, 5713}, +{5953, 609, 5761}, +{6129, 481, 5713}, +{5937, 481, 5665}, +{6129, 449, 5409}, +{6177, 369, 5457}, +{6177, 609, 5489}, +{6225, 305, 5569}, +{6097, 401, 5537}, +{6145, 305, 5649}, +{6081, 625, 5457}, +{6113, 705, 5457}, +{6081, 561, 5473}, +{6273, 609, 5633}, +{6433, 481, 5281}, +{6385, 529, 5217}, +{5873, 593, 5569}, +{6657, -1983, 5969}, +{5873, 1185, 5345}, +{6289, -607, 5681}, +{5489, 1441, 5313}, +{6033, -63, 5921}, +{6081, 1009, 5745}, +{5889, 1041, 6129}, +{6241, 817, 5345}, +{6145, 689, 5313}, +{6209, 1121, 5377}, +{6321, 1121, 5665}, +{6321, 1505, 5297}, +{6321, 1537, 5185}, +{6161, 2001, 4721}, +{6513, 2097, 5041}, +{6513, 1777, 5313}, +{6289, 1793, 5361}, +{5921, 2241, 4977}, +{6369, 2865, 4865}, +{5953, 3041, 5185}, +{6273, 3457, 4753}, +{6097, 3841, 4641}, +{6241, 3521, 4577}, +{6145, 2705, 4753}, +{6113, 2305, 4481}, +{5729, 2353, 4609}, +{5777, 3169, 7057}, +{6065, 2049, 4977}, +{6049, 1953, 5073}, +{5857, 2673, 5393}, +{5873, 2625, 5633}, +{5953, 2289, 5633}, +{5761, 2657, 5377}, +{5841, 2577, 5217}, +{5841, 2529, 5377}, +{5857, 2433, 5585}, +{5857, 2849, 5585}, +{5937, 2385, 5329}, +{5905, 2449, 5201}, +{6001, 2337, 5329}, +{5841, 2273, 5473}, +{5793, 2273, 5505}, +{5761, 2209, 5649}, +{5809, 2209, 5633}, +{5745, 2033, 5649}, +{5745, 2177, 5745}, +{5633, 2177, 5793}, +{5921, 2049, 5569}, +{5937, 1681, 5489}, +{5873, 1905, 5553}, +{5761, 2401, 5553}, +{5697, 2545, 5633}, +{5697, 2481, 5665}, +{5809, 2305, 5697}, +{5873, 2417, 5313}, +{5809, 2593, 5377}, +{5745, 2449, 5553}, +{5793, 2465, 5713}, +{5905, 2689, 5313}, +{5969, 2065, 5457}, +{5841, 2081, 5489}, +{5761, 1921, 5569}, +{5713, 2289, 5569}, +{5665, 2401, 5825}, +{5745, 1857, 5585}, +{5857, 1713, 5521}, +{5761, 1969, 5601}, +{5857, 2065, 5761}, +{5761, 1969, 5713}, +{6033, 1361, 5521}, +{5873, 2209, 5505}, +{5761, 2289, 5345}, +{5713, 2497, 5249}, +{5905, 2801, 5649}, +{6001, 2529, 5057}, +{6001, 2625, 5041}, +{6033, 2817, 5185}, +{5873, 2913, 5297}, +{5857, 2561, 5505}, +{5825, 2337, 5585}, +{5857, 2065, 5361}, +{5905, 2193, 5377}, +{5873, 1985, 5665}, +{5793, 1969, 5585}, +{5905, 1889, 5617}, +{5729, 1905, 5745}, +{5857, 1633, 5697}, +{5777, 1889, 5681}, +{5969, 2129, 5441}, +{6113, 1617, 5617}, +{6065, 1649, 5569}, +{5809, 2161, 5377}, +{5889, 2369, 5441}, +{5905, 1825, 5745}, +{6001, 2529, 5377}, +{6033, 2321, 5089}, +{6065, 2129, 5313}, +{5985, 2209, 5441}, +{6001, 2273, 5553}, +{6033, 1889, 5601}, +{5937, 1617, 5361}, +{5905, 1841, 5409}, +{5953, 1777, 5601}, +{6001, 1793, 5761}, +{5873, 1457, 5633}, +{5857, 1857, 5457}, +{5905, 1393, 5761}, +{5889, 1345, 5697}, +{5985, 1313, 5489}, +{6017, 1521, 5409}, +{5889, 2577, 5217}, +{5937, 2673, 5457}, +{5921, 2913, 5393}, +{5889, 2737, 5265}, +{6001, 2433, 5025}, +{6017, 2625, 5121}, +{5953, 2721, 5265}, +{6033, 2881, 5297}, +{6049, 2593, 5217}, +{6065, 2529, 5217}, +{5985, 2513, 5121}, +{5825, 2593, 5489}, +{5889, 2289, 5633}, +{5873, 2081, 5505}, +{5761, 1985, 5553}, +{5841, 2129, 5553}, +{5857, 2209, 5729}, +{5969, 1953, 5281}, +{5953, 2129, 5265}, +{5985, 2177, 5441}, +{5937, 2497, 5473}, +{6017, 2337, 5265}, +{6001, 2289, 5137}, +{5889, 2625, 5281}, +{5889, 2561, 5441}, +{5921, 2369, 5585}, +{6177, 2465, 5201}, +{5953, 2497, 5249}, +{5953, 2273, 5345}, +{6001, 2193, 5393}, +{5793, 2113, 5521}, +{5873, 1921, 5697}, +{5777, 1729, 5697}, +{5793, 2113, 5745}, +{5921, 1777, 5841}, +{5873, 2033, 5665}, +{5985, 1793, 5521}, +{5953, 1745, 5553}, +{5889, 2273, 5377}, +{5889, 2465, 5457}, +{6049, 2225, 5521}, +{5889, 2033, 5473}, +{5873, 2273, 5393}, +{5857, 2577, 5585}, +{5953, 2433, 5697}, +{6017, 2417, 5425}, +{6033, 2289, 5169}, +{5921, 2065, 5329}, +{5889, 1953, 5729}, +{5857, 2113, 5617}, +{6033, 1793, 5345}, +{5921, 2097, 5201}, +{5873, 1681, 5729}, +{5825, 2113, 5697}, +{5953, 1921, 5489}, +{5985, 1761, 5425}, +{6081, 1665, 5393}, +{6001, 2289, 5569}, +{6049, 2401, 5537}, +{6017, 2273, 5457}, +{5921, 1809, 5297}, +{5937, 2225, 5329}, +{5985, 2433, 5585}, +{5953, 2049, 5425}, +{6033, 2193, 5297}, +{5969, 2113, 5393}, +{5857, 1809, 5505}, +{5921, 1969, 5537}, +{5937, 2353, 5265}, +{5985, 2033, 5393}, +{5841, 2257, 5409}, +{5777, 2049, 5649}, +{5809, 1873, 5857}, +{5921, 1793, 5393}, +{5713, 2785, 5745}, +{6017, 1777, 5649}, +{5857, 2785, 5313}, +{6065, 2049, 5937}, +{6033, 2113, 5281}, +{6001, 1985, 5153}, +{5905, 2417, 5505}, +{5713, 2305, 5713}, +{5905, 2641, 5921}, +{6497, 1777, 4417}, +{6497, 673, 4625}, +{6721, 1057, 4785}, +}; +static const uint32_t duration_HRD[] = +{ +41, +39, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +40, +40, +80, +40, +40, +}; +static const uint32_t frame_HRD[] = +{ +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +151, +152, +153, +154, +155, +156, +157, +158, +159, +160, +161, +162, +163, +164, +165, +166, +167, +168, +169, +170, +171, +172, +173, +174, +175, +176, +177, +178, +179, +180, +181, +182, +183, +184, +185, +186, +187, +188, +189, +190, +191, +192, +193, +194, +195, +196, +197, +198, +199, +200, +201, +202, +203, +204, +205, +206, +207, +208, +209, +210, +211, +212, +213, +214, +215, +216, +217, +218, +219, +220, +221, +222, +223, +224, +225, +226, +227, +228, +229, +230, +231, +232, +233, +234, +235, +236, +237, +238, +239, +240, +241, +242, +243, +244, +245, +246, +247, +248, +249, +250, +251, +252, +253, +254, +255, +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +60, +61, +62, +63, +64, +65, +66, +67, +68, +69, +70, +71, +72, +73, +74, +75, +76, +77, +78, +79, +80, +81, +82, +83, +84, +85, +86, +87, +88, +89, +90, +91, +92, +93, +94, +95, +96, +97, +98, +99, +100, +101, +102, +103, +104, +105, +106, +107, +108, +109, +110, +111, +112, +113, +114, +115, +116, +117, +118, +119, +120, +121, +122, +123, +124, +125, +126, +127, +128, +129, +130, +131, +132, +133, +134, +135, +136, +137, +138, +139, +140, +141, +142, +143, +144, +145, +146, +147, +148, +149, +150, +}; + +static const uint8_t touch_HRD[] = +{ +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +1, +}; + +static const int32_t Expo_time[][NF_PPG_PER_CHANNEL*NF_PPG_CHANNEL] = +{ +{0, 256, 40}, +{0, 240, 40}, +{0, 224, 40}, +{0, 208, 40}, +{0, 208, 40}, +{0, 192, 40}, +{0, 184, 40}, +{0, 176, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +{0, 168, 40}, +}; + + + + +#endif diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/pxialg.h b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/pxialg.h new file mode 100644 index 000000000..bada56bbf --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/pxialg.h @@ -0,0 +1,698 @@ +#ifndef PXIALG_H__ +#define PXIALG_H__ +#include "stdint.h" +#include "pxivar.h" + +#define FW 1 + +#define FW_DEBUG 0 +#if ( FW == 0 ) +#undef FW_DEBUG +#define FW_DEBUG 0 +#endif + +//#define STRIIV + +#if FW == 1 +#define PXIALG_API +#else +#ifdef PXIALG_EXPORTS +#define PXIALG_API __declspec(dllexport) +#else +#define PXIALG_API __declspec(dllimport) +#endif +#endif +/* +typedef struct { + uint8_t frame_count; + uint32_t time; + uint8_t touch_flag; + uint32_t nf_ppg_channel; + uint32_t nf_ppg_per_channel; + int32_t *ppg_data; + uint32_t nf_mems; + int16_t *mems_data; +} pah8series_data_t; + +typedef enum { + FLAG_DATA_READY = 0, + FLAG_DATA_NOT_READY, + FLAG_DATA_LOSS, + FLAG_NO_TOUCH, + FLAG_DATA_ERROR, + FLAG_POOR_SIGNAL, + FLAG_FIFO_ERROR, + FLAG_TIMMING_ERROR, + FLAG_MEMS_ERROR, + FLAG_HR_UPDATE = 16, + FLAG_SG_UPDATE, +} PXI_STATUS_FLAG; + +typedef enum { + _quick_report_rms_gs_th = 0, + _hr_speed_mode, + _support_cal_motion_idx_enhancement_enh, + _rsv1, + _set_switch_mems_fft_max_energy_th, + _set_switch_mems_large_energy_num_th, + _set_switch_mn_fft_energy_lo_thr, + _set_switch_mn_fft_energy_hi_thr, + + _ppg_large_energy_num_th, + _max_hr_idx_th, + _min_hr_idx_th, + _ppg_fft_total_peak_num_th, + _mems_large_energy_num_th, + _mems_fft_max_energy_th, + _support_signal_grade_motion_detection_enh, + _support_signal_grade_check_signal_lelvel_enh, + _support_signal_grade_large_energy_num_enh, + _rsv2, + _rsv3, + _set_reg_shake_count_th0, +} PXI_PARAM_SET; + +typedef enum { + _rms_gs = 0, + _signal_level, + _cal_motion_idx, + _is_prediction_hr, + _get_switch_mems_fft_max_energy_th, + _get_switch_mems_large_energy_num_th, + _get_switch_mn_fft_energy_lo_thr, + _get_switch_mn_fft_energy_hi_thr, + + _hr_sample_count, + _ppg_large_energy_num, + _signal_grade_motion_frm, + _ppg_fft_max_energy_idx, + _ppg_fft_total_peak_num, + _mems_large_energy_num, + _mems_fft_max_energy, + _grade, + _signal_grade_hr_to_low_frm, + _flag_signal_grade_ready_go, + _motion_flag, + _get_reg_shake_count_th0, +} PXI_PARAM_GET; + +typedef enum { + MemsLargeEnergyNumTh = 0, + MemsFftMaxEnergyTh, + QuickReportRmsGsTh, + SupportSigGradeMotionDetection, + PpgLargeEnergyNumTh, + SupportSigGradeLargeEnergyNumEnh, + SupportSigGradeLargeEnergyNumTh, + SigGradeThr, + SupportSigGradeCheckSigLevel, + FlagCheckNotStableFirstHR, + MaxHrDefinition, + MinHrDefinition, +} PXI_PARAM2; +*/ + +#if FW == 1 +/** + * @brief When HRD and MEMS data are ready, call this function to do the algorithm processing + * + * @param[in] HRD_Data Pointer to the buffer where HRD data (13 Bytes) is stored. + * @param[in] MEMS_Data Pointer to the buffer where MEMS data (3*sizeof(float) Bytes) is stored. + * + * @return Return one of the PXI_STATUS_FLAG types. + */ +PXIALG_API int32_t PxiAlg_ProcessByTime(unsigned char *HRD_Data, float *MEMS_Data, float time); +PXIALG_API int32_t PxiAlg_Process(unsigned char *HRD_Data, float *MEMS_Data); + +/** + * @brief Call this function to get Heart Rate + * + * @param[out] hr Pointer to a float variable where heart rate is stored + * + * @return None + */ +PXIALG_API void PxiAlg_HrGet(float *hr); + + +PXIALG_API void PxiAlg_FlagInitialSignalNoiseGet(uint8_t *flag); +/** + * @brief Call this function to feed Algorithm raw data(19 Bytes), and get Signal Grade and Heart Rate + * + * @param[in] pixart_19_byte_data Pointer to a arrag where raw data is stored + * Format: 13 bytes PPG + G-sensor X_L[13] + X_H[14] + Y_L[15] + Y_H[16] + Z_L[17] + Z_H[18] + * @param[out] grade Pointer to a float variable where signal grade is stored. + * @param[out] heart_rate Pointer to a float variable where heart rate is stored + * + * @return status bit field, combinatoin of the list below + * 1 << FLAG_DATA_READY, + * 1 << FLAG_DATA_NOT_READY, + * 1 << FLAG_DATA_LOSS, + * 1 << FLAG_NO_TOUCH, + * 1 << FLAG_DATA_ERROR, + * 1 << FLAG_POOR_SIGNAL, + * 1 << FLAG_FIFO_ERROR, + * 1 << FLAG_TIMMING_ERROR, + * 1 << FLAG_MEMS_ERROR, + * 1 << FLAG_HR_UPDATE, + * 1 << FLAG_SG_UPDATE, + */ +PXIALG_API uint32_t PxiAlg_HRM(uint8_t *pixart_19_byte_data, float *grade, float * heart_rate); +#else +/** + * @brief When HRD, MEMS, and ECG data are ready, call this function to do the algorithm processing + * + * @param[in] HRD_Data Pointer to the buffer where HRD data (13 Bytes) is stored. + * @param[in] MEMS_Data Pointer to the buffer where MEMS data (12 Bytes) is stored. + * @param[in] ECG_Data Pointer to the buffer where ECG data (4 Bytes) is stored. + * + * @return Return one of the PXI_STATUS_FLAG types. + */ +PXIALG_API int32_t PxiAlg_Process(unsigned char *HRD_Data, float *MEMS_Data, float ECG_Data); + +/** + * @brief When HRD, MEMS, ECG data, and time interval are ready, call this function to do the algorithm processing + * + * @param[in] HRD_Data Pointer to the buffer where HRD data (13 Bytes) is stored. + * @param[in] MEMS_Data Pointer to the buffer where MEMS data (12 Bytes) is stored. + * @param[in] ECG_Data Pointer to the buffer where ECG data (4 Bytes) is stored. + * @param[in] time Time interval. + * + * @return Return one of the PXI_STATUS_FLAG types. + */ +PXIALG_API int32_t PxiAlg_ProcessByTime(unsigned char *HRD_Data, float *MEMS_Data, float ECG_Data, float time); + +/** + * @brief Call this function to get Heart Rate + * + * @param[out] hr Pointer to a float variable where heart rate is stored + * + * @return None + */ +PXIALG_API void PxiAlg_HrGet(float *hr); + +PXIALG_API void PxiAlg_FlagInitialSignalNoiseGet(uint8_t *flag); + +/** + * @brief Call this function to get output + * + * @param[out] output Pointer to a SHr_motion_plot variable where output information is stored + * + * @return None + */ +PXIALG_API int32_t PxiAlg_OutputGet(void *output); + +/** + * @brief Call this function to get a specific parameter + * + * @param[out] param Pointer to the start address of the variable of parameter list + * @param[in] offset Offset of the parameter variable + * @param[in] size Type size of the parameter + * + * @return None + */ +PXIALG_API void PxiAlg_ParamGet(uint8_t *param, int32_t offset, int32_t size); + +/** + * @brief Call this function to set a specific parameter + * + * @param[in] offset Offset of the parameter variable + * @param[in] size Type size of the parameter + * @param[in] param Pointer to the start address of the variable of parameter list + * + * @return None + */ +PXIALG_API void PxiAlg_ParamSet(int32_t offset, int32_t size, uint8_t *param); +#endif + +/** +* @brief When HRD, MEMS, and Expo data are ready, call this function to do the algorithm processing +* +* @param[in] HRD_Data Pointer to the buffer where HRD data (13 Bytes) is stored. +* @param[in] MEMS_Data Pointer to the buffer where MEMS data (12 Bytes) is stored. +* @param[in] expo Exposure Time. +* +* @return Return one of the PXI_STATUS_FLAG types. +*/ +PXIALG_API int32_t PxiAlg_Process_Expo(unsigned char *HRD_Data, float *MEMS_Data, int expo); + +/** + * @brief Call this function to determine the version of the algorithm + * + * + * @return Version of the algorithm + */ +PXIALG_API int32_t PxiAlg_Version(void); + +/** + * @brief Call this funtion to get Ready_Flag + * + * @return Return Ready_Flag + */ +PXIALG_API unsigned char PxiAlg_GetReadyFlag(void); + +/** + * @brief Call this funtion to get Motion_Flag + * + * @return Return Motion_Flag + */ +PXIALG_API unsigned char PxiAlg_GetMotionFlag(void); + + +/** +* @brief Call this function to get force flag +* +* @return force_flag +*/ +PXIALG_API unsigned char PxiAlg_GetForceFlag(void); + +/** + * @brief Call this funtion to get Timeout_Flag + * + * @return Return Timeout_Flag + */ +PXIALG_API unsigned char PxiAlg_GetTimeoutFlag(void); + +/** + * @brief Call this function to set PPG buffer pointer and size + * + * @param[in] ppg_buffer Pointer to a float buffer where the PPG data would be stored + * @param[in] size PPG buffer size + * + * @return None + */ +PXIALG_API void PxiAlg_SetPPGBuffer(float *ppg_buffer, int32_t size); + +/** + * @brief Call this function to set algorithm parameters + * + * @param[in] hr_param Pointer to a "HR_Param" sturcture where the parameters are stored. + * + * @return None + */ +PXIALG_API void PxiAlg_SetParam(void *hr_param); + +/** + * @brief Call this function to set data + * + * @param[in] data Pointer to an algorithm-dependent data + * + * @return None + */ +PXIALG_API void PxiAlg_SetData(void *data); + + +/** + * @brief Call this function to notify algorithm the Output Data Rate of PPG Sensor + * + * @param[in] odr The Output Data Rate of PPG Sensor. Only 10,20,40,160 and 200 ODR are supported. + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetODR(int32_t odr); + +/** + * @brief Call this function to notify algorithm the Timeout Length of PPG Sensor + * + * @param[in] t The Timeout Length of PPG Sensor. Unit: second. + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetTimeoutLength(int32_t t); + +/** + * @brief Call this function to notify algorithm the Quality Threshold of PPG Sensor + * + * @param[in] th The Quality Threshold of PPG Sensor. Range: 0.0 ~ 1.0 + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetQualityThreshold(float th); + +/** +* @brief Call this function to notify algorithm the HR smooth weight of PPG Sensor +* +* @param[in] w The weight. Range: 0.0 ~ 1.0 +* +* @return 1 for success. 0 for failure. +*/ +PXIALG_API uint8_t PxiAlg_SetHRSmoothWeight(float w); + +/** +* @brief Call this function to notify algorithm the length of process window of PPG Sensor +* +* @param[in] t The normal time window. +* @param[in] t_fast The fast time window. +* +* @return 1 for success. 0 for failure. +*/ +PXIALG_API uint8_t PxiAlg_SetProcWindow(float t, float t_fast); + +/** + * @brief Call this function to notify algorithm the number of PPG sample to skip + * + * @param[in] num The number + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetSkipSampleNum(int num); + + +/** + * @brief Call this function to notify algorithm the MEMS Scale of Motion Sensor + * + * @param[in] scale The MEMS Scale of Motion Sensor. 0: +-2G, 1: +-4G, 2: +-8G, and 3: +-16G + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetMemsScale(int scale); +PXIALG_API uint8_t PxiAlg_SetMemsScaleBase(int scale, int th); + + + + + +/** + * @brief Call this function to notify algorithm the time length to force hr to update + * + * @param[in] t The time length + * @param[in] ub The upper bound + * @param[in] lb The lower bound + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetForceOutput(int t, int ub, int lb); + + + +/** + * @brief Call this function to notify algorithm force hr to output + * + * @param[in] t The time length + * @param[in] ub The upper bound + * @param[in] lb The lower bound + * @param[in] link_flag To link with normal output + * @param[in] w Smoothing weight between force and normal + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetForceOutputLink(int t, int ub, int lb, int link_flag, float w); + + +/** + * @brief Call this function to notify algorithm normal hr to output + * + * @param[in] ub The upper bound + * @param[in] lb The lower bound + * @param[in] static_flag First normal output at static + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetNormalOutput(int ub, int lb, int static_flag); + + +/** + * @brief Call this function to notify algorithm the time to force hr to output + * + * @param[in] t The duration + * @param[in] bpm The amplitude + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetForceRipple(int t, int bpm); + + +/** + * @brief Call this function to notify algorithm the time to force hr to output + * + * @param[in] ch The ppg channel selection + * @param[in] flag The resample flag + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetPackage(int ch, int flag); + + +/** + * @brief Call this function to notify algorithm the time length to force hr to update + * + * @param[in] t The time length + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetForceUpdateTimeLength(int t); +/** + * @brief Call this function to notify algorithm the time to force hr to output + * + * @param[in] t The time length + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetForceOutputTime(int t); +/** + * @brief Call this function to notify algorithm the bound of hr + * + * @param[in] ub The upper bound + * @param[in] lb The lower bound + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetFullHRBound(int ub, int lb); +/** + * @brief Call this function to notify algorithm the bound of first hr + * + * @param[in] ub The upper bound + * @param[in] lb The lower bound + * @param[in] t The time length to keep this bound + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetFirstHRBound(int ub, int lb, int t); + + + +/** + * @brief Call this function to notify algorithm the MEMS Energy Threshold of Motion Sensor + * + * @param[in] lower The MEMS energy lower threshold + * @param[in] upper The MEMS energy upper threshold + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetMemsEnergyThrd(int lower, int upper); + +/** + * @brief Call this function to set PPG Signal Grade Threshold + * + * @param[in] threshold The PPG Signal Grade Threshold. Its value ranges from 0 to 100. + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetSigGradeThrd(float thrd); + +/** + * @brief Call this function to set parameters of PPG Signal Grade + * + * @param[in] frm_thrd The PPG Signal Grade Frame Threshold. + * @param[in] rep_count The PPG Signal Grade Repetitive Counter. + * + * @return 1 for success. 0 for failure. + */ +PXIALG_API uint8_t PxiAlg_SetSigGradeParam(int16_t frm_thrd, int16_t rep_count); + +/** + * @brief Call this function to enable or disable fast output mode + * + * @param[in] en The flag of fast output mode. + */ + +PXIALG_API void PxiAlg_EnableFastOutput(uint8_t en); + +/** + * @brief Call this function to enable or disable motion mode + * + * @param[in] en The flag of motion mode. + */ +PXIALG_API void PxiAlg_EnableMotionMode(uint8_t en); + +/** + * @brief Call this function to enable or disable auto mode + * + * @param[in] en The flag of auto mode. + */ +PXIALG_API void PxiAlg_EnableAutoMode(uint8_t en); + +/** + * @brief Call this function to enable or disable tracking mode after fast output + * + * @param[in] en The flag of tracking mode. + */ +PXIALG_API void PxiAlg_EnableTrackingAfterFastOut(uint8_t en); + +/** + * @brief Call this function to enable or disable mems0 signal grade mode + * + * @param[in] en 1 : enable. 0 : disable. + */ +PXIALG_API void PxiAlg_EnableMEMS0SigGrade(uint8_t en); + +//PXIALG_API void PxiAlg_EnableMEMS0SigGrade(uint8_t en, uint8_t idx); +//// idx = 0: PxiAlg_EnableFastOutput(uint8_t en); +//// idx = 1: PxiAlg_EnableMotionMode(uint8_t en); +//// idx = 2: PxiAlg_EnableAutoMode(uint8_t en); +//// idx = 3: PxiAlg_EnableTrackingAfterFastOut(uint8_t en); + +/** + * @brief Call this function to get PPG Signal Grade + * + * @param[out] grade Pointer to a float variable where signal grade is stored. + * + * @return Return 1 when Signal Grade is ready. Otherwise, return 0. + */ +PXIALG_API uint8_t PxiAlg_GetSigGrade(float *grade); + +/** + * @brief Call this function to get the alarm flag of fast output + * + * @param[out] flag The alarm flag of fast output + * + * @return Return 1 when the flag is set. Otherwise, return 0. + */ +PXIALG_API uint8_t PxiAlg_GetFastOutAlarmFlag(void); + +/** + * @brief Call this function to get the alarm flag of signal bad + * + * @param[out] flag The alarm flag of fast output + * + * @return Return 1 when the flag is set. Otherwise, return 0. + */ +PXIALG_API uint8_t PxiAlg_GetSignalBadAlarm(void); + +/** + * @brief Call this function to open algorithm + */ +#if FW == 1 +PXIALG_API uint8_t PxiAlg_Open_Mem(void *mem); +#else +PXIALG_API void PxiAlg_Open(void); +#endif + +/** + * @brief Call this function to close algorithm + */ +PXIALG_API void PxiAlg_Close(void); + +/** + * @brief Call this function to initialize 200Hz low-pass filter + */ +PXIALG_API void PxiAlg_LPF200Hz_Init(void); + +/** + * @brief Call this function to process 200Hz low-pass filter + */ +PXIALG_API float PxiAlg_LPF200Hz_Process(float data); + +/** + * @brief Call this function to get PPG Signal Level + * + * @param[out] grade Pointer to a float variable where signal level is stored. + * + * @return Return 1 when Signal Level is ready. Otherwise, return 0. + */ +#ifndef REDUCE_MORE_CODE_SIZE +PXIALG_API uint8_t PxiAlg_Get_Signal_Level(float *level); +#endif +/** + * @brief Call this function to enable/disable Check_Not_Stable_First_HR + * + * @param[in] 1 : enable, 0: disable + */ +PXIALG_API void PxiAlg_Check_Not_Stable_First_HR(uint8_t check); + +/** + * @brief Call this function to set Signal_Grade_Large_Energy_Num_Th_Lo + * + * @param[in] Threshold. + * + */ +PXIALG_API void PxiAlg_Set_Signal_Grade_Large_Energy_Num_Th_Lo(uint8_t th) ; + +/** + * @brief Call this function to Set SportMode + * + * @@param[in] en 0: disable 1: enable + * + * @return Return 1 when Set Signal Grade Large Energy Num Threshold is ready. Otherwise, return 0. + */ +PXIALG_API void PxiAlg_SetSportMode(uint8_t en); + +/** + * @brief Call this function to Set Signal Grade Large Energy Num Threshold + * + * @@param[in] th => threshold + * + * @return Return 1 when Set Signal Grade Large Energy Num Threshold is ready. Otherwise, return 0. + */ +PXIALG_API uint8_t PxiAlg_Set_Signal_Grade_Large_Energy_Num_Th(uint8_t th); + + +/** + * @brief Call this function to Set Algorithm Parameters + * + * @@param[in] index - index of parameters, param - parameter value + * + * @return Return 1 when Set algorithm parameter suceeessfully. Otherwise, return 0. + */ +PXIALG_API uint8_t PxiAlg_Set_Parameter(uint32_t index, float param); + +/** + * @brief Call this function to Get Algorithm Parameters + * + * @@param[in] index - index of parameters, *param - pointer to parameter value + * + * @return Return 1 when Set algorithm parameter suceeessfully. Otherwise, return 0. + */ +PXIALG_API uint8_t PxiAlg_Get_Parameter(uint32_t index, float *param); + +/** +* @brief Call this function to Set Algorithm Parameters (2nd Version) +* +* @@param[in] index - index of parameters, param - parameter value +* +* @return Return 1 when Set algorithm parameter suceeessfully. Otherwise, return 0. +*/ +PXIALG_API uint8_t PxiAlg_Set_Parameter2(uint32_t index, float param); + +/** +* @brief Call this function to Get Algorithm Parameters (2nd Version) +* +* @@param[in] index - index of parameters, *param - pointer to parameter value +* +* @return Return 1 when Set algorithm parameter suceeessfully. Otherwise, return 0. +*/ +PXIALG_API uint8_t PxiAlg_Get_Parameter2(uint32_t index, float *param); + + + +PXIALG_API uint8_t PxiAlg_Set_Cal_Flag_HR_Trust_Energy_Ratio(float fValue); +PXIALG_API uint8_t PxiAlg_Set_Cal_Flag_HR_Trust_Large_Energy_Num_Th(uint16_t fValue); +PXIALG_API uint8_t PxiAlg_Get_Cal_Flag_HR_Trust_Energy_Ratio(float *fValue); +PXIALG_API uint8_t PxiAlg_Get_Cal_Flag_HR_Trust_Large_Energy_Num_Th(uint16_t *fValue); + +PXIALG_API uint8_t PxiAlg_Get_Flag_HR_Trust(uint8_t *flag); + +#if (ANDROID_JNI==1) +PXIALG_API uint8_t PxiAlg_Get_ParameterName(uint32_t index, const char **param); +#endif + +PXIALG_API uint8_t PxiAlg_DecodeProcess(uint32_t data, int touch_flag, float time_in); +PXIALG_API uint8_t PxiAlg_Entrance_0(pah8series_data_t *pah8series_data); +PXIALG_API uint8_t PxiAlg_Entrance(pah8series_data_t *pah8series_data); +PXIALG_API uint8_t PxiAlg_EntranceD(pah8series_data_t *pah8series_data); +PXIALG_API uint32_t PxiAlg_Query_Mem_Size(void); +PXIALG_API uint8_t PxiAlg_GetHrUpdateFlag(void); + +PXIALG_API void PxiAlg_SetData_Seg(pah8series_data_t *pah8series_data); +PXIALG_API uint8_t PxiAlg_Process_Seg(uint8_t *is_finished); +PXIALG_API uint8_t PxiAlg_ProcessD_Seg(uint8_t *is_finished); +#endif /* PXIALG_H__ */ diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/pxivar.h b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/pxivar.h new file mode 100644 index 000000000..0f1dd761b --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/pxivar.h @@ -0,0 +1,96 @@ +#ifndef PXIVAR_H__ +#define PXIVAR_H__ + +#include "stdint.h" + +#ifndef pah8series_data_t +typedef struct { + uint8_t frame_count; + uint32_t time; + uint8_t touch_flag; + uint32_t nf_ppg_channel; + uint32_t nf_ppg_per_channel; + int32_t *ppg_data; + uint32_t nf_mems; + int16_t *mems_data; +} pah8series_data_t; +#endif + +typedef enum { + FLAG_DATA_READY = 0, + FLAG_DATA_NOT_READY, + FLAG_DATA_LOSS, + FLAG_NO_TOUCH, + FLAG_DATA_ERROR, + FLAG_POOR_SIGNAL, + FLAG_FIFO_ERROR, + FLAG_TIMMING_ERROR, + FLAG_MEMS_ERROR, + FLAG_HR_UPDATE = 16, + FLAG_SG_UPDATE, +} PXI_STATUS_FLAG; + +typedef enum { + _quick_report_rms_gs_th = 0, + _hr_speed_mode, + _support_cal_motion_idx_enhancement_enh, + _rsv1, + _set_switch_mems_fft_max_energy_th, + _set_switch_mems_large_energy_num_th, + _set_switch_mn_fft_energy_lo_thr, + _set_switch_mn_fft_energy_hi_thr, + + _ppg_large_energy_num_th, + _max_hr_idx_th, + _min_hr_idx_th, + _ppg_fft_total_peak_num_th, + _mems_large_energy_num_th, + _mems_fft_max_energy_th, + _support_signal_grade_motion_detection_enh, + _support_signal_grade_check_signal_lelvel_enh, + _support_signal_grade_large_energy_num_enh, + _rsv2, + _rsv3, + _set_reg_shake_count_th0, +} PXI_PARAM_SET; + +typedef enum { + _rms_gs = 0, + _signal_level, + _cal_motion_idx, + _is_prediction_hr, + _get_switch_mems_fft_max_energy_th, + _get_switch_mems_large_energy_num_th, + _get_switch_mn_fft_energy_lo_thr, + _get_switch_mn_fft_energy_hi_thr, + + _hr_sample_count, + _ppg_large_energy_num, + _signal_grade_motion_frm, + _ppg_fft_max_energy_idx, + _ppg_fft_total_peak_num, + _mems_large_energy_num, + _mems_fft_max_energy, + _grade, + _signal_grade_hr_to_low_frm, + _flag_signal_grade_ready_go, + _motion_flag, + _get_reg_shake_count_th0, +} PXI_PARAM_GET; + +typedef enum { + MemsLargeEnergyNumTh = 0, + MemsFftMaxEnergyTh, + QuickReportRmsGsTh, + SupportSigGradeMotionDetection, + PpgLargeEnergyNumTh, + SupportSigGradeLargeEnergyNumEnh, + SupportSigGradeLargeEnergyNumTh, + SigGradeThr, + SupportSigGradeCheckSigLevel, + FlagCheckNotStableFirstHR, + MaxHrDefinition, + MinHrDefinition, +} PXI_PARAM2; + +#endif /* PXIVAR_H__ */ diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/test_library_HRD.c b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/test_library_HRD.c new file mode 100644 index 000000000..0730dc245 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_hr/V303009/test_library_HRD.c @@ -0,0 +1,117 @@ + +#include "pah8009_testpattern_HRD.h" +// platform +#include +#include "pah800x_main.h" +#include "pah800x_bsp.h" +#include +#include "pxialg.h" +#include "pxivar.h" + +//#include "nrf_delay.h" +#define array_szie(arr) (sizeof(arr) / sizeof(arr[0])) + +void test_library_HRD(void) +{ + int i = 0; + void *hr_pBuffer = NULL; + static ppg_mems_data_t ppg_mems_data_alg; + + sRaw_Data_13Bytes hr_data; + + + // static Hr-V301009 + + PxiAlg_Close(); + int32_t version = PxiAlg_Version(); + DEBUG_PRINT("HR_Version = %d \r\n", version); + + + uint32_t Query_Mem_Size = PxiAlg_Query_Mem_Size(); + DEBUG_PRINT("HR_Mem_Size = %d \r\n", Query_Mem_Size); + + hr_pBuffer = malloc(Query_Mem_Size); + + + if(!PxiAlg_Open_Mem(hr_pBuffer)) + DEBUG_PRINT("PxiAlg_Open_Mem fail \n"); + + + PxiAlg_SetQualityThreshold(0.35f); + PxiAlg_SetHRSmoothWeight(0.9f); + PxiAlg_SetProcWindow(5.0f, 5.0f); + PxiAlg_SetTimeoutLength(30.0f); + PxiAlg_SetMemsScale(3); //MEMS 2/4/8/16G : 0/1/2/3 + PxiAlg_SetSkipSampleNum(10); + PxiAlg_SetMemsScaleBase(3, 0); //MEMS 2/4/8/16G : 0/1/2/3 + PxiAlg_SetForceOutputLink(10, 150, 40, 1, 0.9f); + PxiAlg_SetNormalOutput(200, 40, 0); + PxiAlg_SetForceRipple(3, 1); + //PxiAlg_SetForceOutput(30, 120, 45); + //PxiAlg_SetForceOutputTime(10); + PxiAlg_SetPackage(0, 1); + + + +//-----------------------------------------------// + + LOG_PRINT("ARRAY_SIZE = %d\n",array_szie(PAH8009_rawdata_HRD)); +//****************************************************************** + + float hr = 0.0f; + float hr_grader = 0.0f; + +//******************************************************************* + + //nrf_delay_ms(50); + + + for( i = 0 ; i 0 ? 0x80 : 0x00; + //LOG_PRINT("touch = %d ", hr_data.touch); + hr_data.rsv2 = 0; + + int exposure_time = Expo_time[i][1]; + //LOG_PRINT("exposure_time = %d \n",exposure_time); + + ppg_mems_data_alg.MEMS_Data[0]=PAH8009_mems_HRD[i][0]; + ppg_mems_data_alg.MEMS_Data[1]=PAH8009_mems_HRD[i][1]; + ppg_mems_data_alg.MEMS_Data[2]=PAH8009_mems_HRD[i][2]; + + int32_t ret = PxiAlg_Process_Expo((uint8_t*)&hr_data, ppg_mems_data_alg.MEMS_Data, exposure_time); + + //LOG_PRINT("ret_HR %d \n",ret); + + if(PxiAlg_GetHrUpdateFlag()) + { + PxiAlg_HrGet(&hr); + PxiAlg_GetSigGrade(&hr_grader); + } + + LOG_PRINT("ret %d , hr %f , hr_grade %f \n", ret, hr, hr_grader); + + } + + PxiAlg_Close(); + + return; +} + +void log_printf(char *s, float f) +{ + // printf("%s: %f\n", s, f); +} \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/libv703_0_1.a b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/libv703_0_1.a new file mode 100644 index 000000000..0cb0d3ba7 Binary files /dev/null and b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/libv703_0_1.a differ diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/pah8009_testpattern_SPO2.h b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/pah8009_testpattern_SPO2.h new file mode 100644 index 000000000..d8d9d4950 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/pah8009_testpattern_SPO2.h @@ -0,0 +1,257 @@ +#ifndef _PAH8009_TESTPATTERN_ +#define _PAH8009_TESTPATTERN_ + +#include +#define NF_PPG_CHANNEL 2 +#define NF_PPG_PER_CHANNEL 81 +static const int32_t PAH8009_rawdata_SPO2[][NF_PPG_PER_CHANNEL*NF_PPG_CHANNEL] = +{ +{1,44,1413227,1375343,1847643,1787527,1849059,1795619,1850643,1799035,1853773,1804053,1855985,1807487,1857211,1810045,1858155,1811489,1857549,1810013,1856203,1807653,1855885,1807985,1856225,1808433,1856443,1808915,1856873,1809501,1856415,1809469,1856153,1808027,1854979,1805393,1853881,1804191,1853475,1803313,1853703,1803495,1853817,1804027,1852163,1801415}, +{1,50,1849833,1797659,1848117,1794425,1846501,1792429,1846933,1794465,1848347,1797081,1847485,1795507,1845053,1791709,1845377,1792531,1845089,1792009,1844055,1790507,1844639,1792275,1845127,1792257,1844247,1791883,1845803,1795625,1848153,1799679,1848469,1799821,1847757,1799101,1847791,1798791,1847717,1799383,1847285,1799295,1846165,1798421,1846711,1799119,1846979,1800181,1847917,1802373,1850389,1806013}, +{1,54,1851247,1807949,1852643,1810447,1854655,1814097,1856243,1816695,1856223,1816223,1855313,1814589,1854833,1813203,1854871,1813909,1855589,1815461,1855909,1816625,1856441,1816653,1856433,1816745,1856403,1816085,1854765,1813617,1853649,1811729,1853635,1812979,1854253,1814335,1854801,1814861,1855735,1817119,1856677,1818893,1856001,1817823,1855067,1815591,1854373,1814907,1853907,1813719,1852421,1811229,1851319,1809519,1850537,1808687}, +{1,54,1850007,1808285,1850491,1808867,1851353,1810153,1850677,1808535,1849503,1806183,1847779,1803439,1845305,1798249,1842229,1794125,1841311,1792951,1840299,1790817,1839801,1790775,1839609,1791541,1840653,1792959,1840111,1792037,1838781,1789819,1838071,1788025,1837549,1786829,1837177,1786199,1834709,1782813,1835469,1783903,1837155,1788265,1838507,1791097,1839841,1792945,1841147,1795599,1842109,1797251,1842343,1798043,1843101,1799101}, +{1,52,1843105,1799891,1843259,1800647,1843283,1801331,1842971,1800695,1843171,1800911,1843061,1801429,1843091,1801291,1843385,1801803,1843243,1802025,1843955,1803115,1845053,1804645,1844847,1804419,1844275,1802959,1844563,1803241,1844051,1802191,1844389,1802653,1844789,1803795,1845123,1804267,1845465,1804429,1845769,1804835,1845421,1804775,1844911,1804409,1844629,1804201,1844617,1804613,1845049,1804889,1845049,1805099}, +{1,54,1845203,1805421,1844861,1805319,1845265,1805971,1845519,1806249,1845809,1806711,1845999,1807367,1846361,1807837,1846561,1808147,1847089,1809035,1847853,1810107,1848437,1811271,1848687,1811447,1848663,1811475,1848819,1811293,1848815,1811405,1847765,1810337,1847277,1809779,1847415,1809381,1846875,1808739,1846289,1808049,1846243,1807663,1846263,1807911,1845817,1807357,1845631,1807343,1845983,1807737,1846023,1807371,1845827,1807367}, +{1,52,1846061,1807943,1845723,1807769,1845883,1807671,1845831,1807777,1845765,1807449,1845733,1807487,1845631,1807823,1845133,1806927,1844505,1806271,1844083,1805967,1843839,1805569,1843705,1805473,1844097,1806027,1844243,1806141,1844395,1806617,1844113,1806423,1844341,1806709,1844363,1807205,1844527,1807439,1844603,1807187,1844567,1807015,1844563,1806931,1844247,1806691,1844457,1806229,1844533,1806451,1844537,1806307}, +{1,52,1844555,1806299,1843955,1806475,1843797,1805597,1843233,1805593,1843451,1805647,1843265,1805505,1843037,1805499,1843121,1805159,1843229,1805383,1843029,1804627,1843313,1805051,1843019,1805145,1843261,1804877,1842989,1804949,1842807,1804521,1843091,1805135,1843381,1805241,1843323,1805171,1843523,1805439,1843737,1805711,1843861,1806105,1843411,1806039,1842957,1805241,1842411,1804437,1842521,1804595,1842225,1804201}, +{1,54,1842265,1804225,1842225,1804141,1842091,1803731,1842001,1803837,1842331,1804307,1842349,1804483,1842811,1805057,1842709,1804691,1842997,1805397,1843061,1805025,1843003,1805237,1843179,1805291,1843309,1804907,1843287,1805309,1843237,1805263,1843353,1805513,1843121,1805413,1842015,1803891,1841531,1803513,1841903,1804169,1841713,1803343,1841855,1803643,1841597,1803495,1841721,1803983,1841979,1804191,1841961,1804663,1842237,1805463}, +{1,52,1842841,1805611,1843219,1805829,1843215,1806035,1843643,1806543,1843665,1807081,1844097,1807349,1844393,1807677,1844555,1808157,1844457,1808143,1845213,1809151,1844893,1808913,1844453,1808725,1844261,1808397,1844083,1808377,1844029,1807939,1843945,1807671,1843379,1807363,1843327,1806831,1843163,1806443,1842717,1806451,1842935,1806207,1842847,1806623,1843341,1806843,1843117,1806631,1842887,1806461,1843239,1806761}, +{1,52,1843491,1806813,1843455,1807039,1843207,1806913,1843179,1806881,1843535,1806961,1842847,1806401,1842167,1805047,1842027,1804743,1841633,1804475,1841295,1803827,1841263,1803435,1840961,1803563,1840957,1803337,1841055,1803563,1840755,1803551,1841335,1804649,1842085,1805085,1842247,1805269,1842033,1805263,1842063,1805325,1842263,1805527,1842563,1805681,1843101,1806203,1843291,1806545,1844207,1808087,1844433,1808143}, +{1,54,1844493,1808715,1843847,1808245,1844033,1809131,1844385,1809343,1844457,1808979,1844433,1808869,1844073,1808139,1843385,1807065,1843145,1806497,1843803,1807307,1843051,1806933,1844003,1809509,1845831,1812717,1847551,1816579,1851097,1823331,1860321,1839875,1866743,1849125,1865911,1843927,1860507,1835367,1859875,1834775,1858871,1833191,1857559,1830255,1854361,1824619,1852367,1821855,1851795,1820705,1850731,1818609,1850629,1818733}, +{1,52,1852007,1822665,1852347,1822961,1851195,1820025,1850279,1817891,1848753,1815595,1847853,1814407,1847935,1814333,1848401,1816057,1848725,1816107,1848753,1815591,1848549,1815471,1848717,1815887,1849229,1816815,1848961,1816479,1848807,1815707,1847681,1814379,1846801,1812689,1846111,1810819,1843763,1806849,1840543,1801615,1839751,1801757,1840755,1802973,1841277,1804533,1840179,1802529,1840005,1801457,1840333,1802113}, +{1,52,1839583,1800437,1838631,1799091,1838427,1799267,1839369,1800713,1839779,1801687,1840619,1804035,1841259,1804479,1841405,1804525,1841135,1804127,1841249,1804447,1840529,1804373,1840391,1804179,1839897,1803301,1839635,1802829,1839387,1802491,1839369,1802159,1839377,1802149,1839271,1801763,1839453,1802063,1839409,1802091,1839343,1802141,1839449,1802299,1839911,1802955,1840165,1803041,1840579,1803235,1840957,1803901}, +{1,54,1840957,1804053,1841015,1804355,1841415,1804557,1841627,1805273,1841847,1805861,1841179,1805361,1841343,1805159,1841357,1805579,1841353,1805249,1841153,1805343,1841231,1805547,1841491,1805587,1841633,1806263,1841685,1806429,1841651,1806705,1842211,1807541,1842779,1807939,1843069,1808897,1843483,1809417,1843837,1809717,1844225,1810343,1844371,1811299,1844701,1811483,1845013,1811833,1845563,1812531,1845239,1812135,1844749,1811935}, +{1,52,1844875,1812555,1844835,1812143,1844691,1811903,1844741,1811959,1844491,1811669,1844505,1811673,1844443,1811543,1844435,1811445,1844101,1811371,1844163,1811027,1844233,1811177,1843949,1811133,1844233,1811133,1844221,1811021,1844069,1810507,1844051,1810775,1844061,1810745,1844051,1810749,1843349,1810309,1842981,1809331,1842705,1809183,1842441,1808973,1842451,1808739,1842345,1808835,1842219,1808761,1842411,1808559}, +{1,54,1842157,1808645,1842139,1808919,1842389,1808895,1842463,1808749,1842335,1808767,1842407,1808839,1842527,1808295,1842543,1808405,1842563,1808735,1842229,1808049,1842567,1808585,1842535,1808383,1842411,1808495,1841747,1807763,1841427,1807067,1841277,1807089,1841295,1807213,1840813,1806619,1840951,1806783,1841151,1807095,1841019,1806927,1841053,1807181,1840885,1807043,1841227,1806959,1841073,1807035,1841063,1807181,1841215,1807417}, +{1,52,1841459,1807145,1841449,1807199,1841393,1807067,1841415,1806979,1841509,1807187,1841507,1807269,1841729,1807481,1840863,1806965,1840663,1806083,1840347,1805851,1840275,1805935,1840177,1805587,1839961,1805841,1840045,1805471,1839875,1805569,1840161,1805727,1840281,1805785,1840409,1805607,1840463,1806087,1840779,1806397,1840677,1806737,1841009,1806767,1841183,1807029,1841241,1807131,1841197,1807195,1841343,1807293}, +{1,52,1841673,1807403,1841477,1807223,1841063,1806543,1840397,1806369,1840027,1805805,1839885,1805675,1839769,1805283,1839823,1804973,1839867,1805033,1839169,1804963,1839217,1805009,1839599,1804875,1839439,1805443,1839685,1805367,1839583,1804599,1839377,1804201,1839027,1803559,1838803,1803089,1838555,1802459,1837971,1801073,1837439,1800159,1837599,1801079,1837897,1801331,1836701,1799857,1836455,1800321,1837069,1801853}, +{1,54,1837643,1802797,1837269,1801951,1836379,1801137,1836025,1799811,1835379,1799317,1835171,1798263,1834655,1798043,1834249,1797073,1833925,1796527,1833769,1796001,1833431,1795583,1833475,1795783,1833499,1795867,1832885,1794835,1832697,1794735,1832605,1794313,1832151,1793511,1832045,1793463,1831047,1792143,1830137,1791131,1829695,1790225,1829007,1789429,1829437,1789379,1828881,1789107,1828783,1789009,1829103,1789001,1828851,1789125}, +{1,52,1829207,1789139,1829051,1789453,1829331,1789623,1829469,1789449,1829407,1788433,1828309,1786533,1827885,1785401,1826885,1783253,1826359,1782583,1826343,1783151,1825813,1781565,1824831,1780531,1824051,1779917,1823559,1779967,1823461,1779837,1824221,1781705,1824447,1781357,1823893,1781117,1823901,1780941,1823883,1781123,1824131,1780957,1823839,1781045,1823811,1780333,1823719,1780059,1823785,1780587,1824243,1781293}, +{1,52,1824133,1781279,1824061,1781059,1823835,1780387,1823857,1779837,1823781,1780479,1823985,1780725,1823713,1780581,1822647,1779399,1822121,1779229,1822219,1779113,1821779,1778493,1822043,1779141,1822127,1779127,1822081,1779237,1822189,1779195,1822481,1779691,1822655,1779935,1823117,1780235,1823349,1780897,1823763,1780883,1823977,1781445,1823793,1780467,1823777,1780327,1823715,1780481,1823367,1779621,1823461,1779755}, +{1,52,1823465,1779557,1823283,1779347,1822891,1778737,1822153,1778157,1821487,1777481,1821353,1777227,1821121,1777199,1820645,1776801,1820579,1775975,1820005,1775847,1820139,1775845,1819555,1774539,1818991,1774099,1819245,1774247,1818719,1773383,1818675,1773563,1818791,1774507,1819827,1776039,1819635,1775619,1819863,1775813,1819399,1774935,1819159,1774599,1818537,1773767,1818973,1773683,1817563,1772195,1816719,1771193}, +{1,54,1816439,1770893,1816497,1770653,1816021,1770379,1815945,1769969,1816019,1769913,1815701,1769797,1815695,1769489,1815829,1769099,1814869,1769189,1815429,1769169,1815005,1768841,1815127,1768777,1814807,1768449,1815069,1768503,1814833,1768411,1814667,1768117,1814673,1767747,1814187,1767043,1814171,1766827,1813321,1765607,1812461,1764623,1811547,1763381,1811347,1762825,1811605,1763061,1811461,1763159,1811267,1763141,1811417,1763043}, +{1,52,1811207,1763505,1811399,1763381,1811279,1762695,1811127,1762769,1810949,1762285,1810439,1761947,1810625,1762151,1810679,1761753,1810119,1760941,1810021,1760303,1809585,1760031,1809807,1759923,1809531,1760353,1810315,1761195,1809123,1759887,1809127,1759245,1808331,1757739,1807961,1757407,1807691,1756865,1807641,1756431,1806881,1754813,1805857,1753145,1805035,1752749,1805217,1752675,1804987,1752327,1804667,1752295}, +{1,52,1804585,1751465,1803327,1749265,1803413,1749487,1803309,1749749,1803243,1749473,1803393,1750037,1803025,1749159,1802261,1747897,1801561,1747231,1800863,1746159,1799649,1745263,1799405,1744755,1798743,1743721,1798005,1742265,1798061,1742259,1797767,1741831,1796901,1740061,1796891,1740181,1796599,1739815,1798083,1743175,1799139,1743641,1798311,1742347,1797813,1740889,1797559,1740953,1799387,1743481,1798947,1742593}, +{1,54,1799303,1742917,1799445,1742663,1799517,1743083,1799889,1743079,1799733,1743379,1799933,1743517,1799961,1743591,1800597,1744391,1801647,1745711,1802941,1747685,1803389,1748443,1804265,1749357,1804725,1750605,1805401,1751169,1806089,1752397,1806809,1754191,1807241,1754333,1807415,1755207,1808975,1757327,1809331,1757363,1809041,1757489,1809379,1758127,1809705,1759277,1809865,1759227,1808869,1757333,1808459,1757331,1808091,1756473}, +{1,52,1807045,1755147,1807231,1755243,1806873,1755451,1806761,1754827,1806757,1754295,1806217,1753817,1806027,1753769,1806401,1754069,1806711,1754661,1806859,1755233,1806933,1755225,1807365,1755345,1807071,1755757,1807251,1755761,1807623,1756141,1807495,1756057,1807387,1755677,1807371,1755835,1807757,1756141,1807543,1755461,1806361,1754421,1805533,1753405,1805511,1753201,1805605,1753187,1805401,1752729,1805263,1752781}, +{1,52,1805613,1752315,1805137,1752665,1805399,1752813,1805449,1753159,1805729,1753197,1806223,1753723,1806507,1754129,1806973,1754699,1807193,1755253,1807833,1755965,1808139,1756455,1808989,1757391,1809501,1758191,1809683,1758837,1810497,1759453,1810839,1760163,1810781,1760455,1810839,1760599,1811329,1761517,1812057,1762755,1811983,1762155,1812405,1762877,1812733,1763441,1813155,1764143,1812799,1763593,1812693,1763099}, +{1,54,1812481,1762807,1812405,1762063,1812249,1761607,1812057,1761435,1812155,1761647,1811813,1761203,1811925,1761757,1811969,1761647,1811403,1761043,1811723,1761365,1810887,1760215,1810353,1759897,1809919,1759359,1809891,1759121,1809359,1758787,1809403,1758791,1808939,1757795,1808829,1757503,1808451,1756935,1808371,1756989,1808229,1756681,1807947,1755785,1807993,1756061,1807975,1755867,1807775,1755789,1807797,1755511,1807659,1754985}, +{1,52,1807571,1755303,1808317,1755933,1807913,1755669,1807827,1755669,1807589,1755723,1807089,1755683,1807089,1755355,1806965,1755235,1806689,1754925,1806067,1754607,1806019,1754393,1805933,1754103,1805657,1753807,1805565,1753949,1805707,1753847,1805747,1754023,1805729,1753903,1805827,1754413,1805801,1754563,1805921,1754255,1805897,1754011,1805921,1754429,1805871,1754121,1805919,1754323,1805671,1754277,1805263,1754413}, +{1,52,1805209,1754227,1805897,1755557,1806035,1755549,1806173,1755697,1806917,1756611,1806969,1757139,1806929,1757599,1807535,1758705,1807847,1759115,1807765,1758737,1807761,1759143,1808165,1759313,1807975,1758823,1807067,1757647,1807303,1758459,1807947,1759133,1807415,1758703,1807023,1758117,1805867,1757439,1805501,1756357,1805079,1756339,1804715,1755955,1804569,1756201,1804279,1755947,1804421,1756037,1804527,1756601}, +{1,52,1804421,1756603,1804003,1756661,1804229,1756589,1804137,1756763,1804239,1756745,1804127,1756897,1803851,1756615,1803973,1756601,1804061,1756971,1803985,1757065,1803905,1757175,1803039,1756335,1802317,1755469,1802149,1755613,1801841,1755233,1801673,1754699,1801405,1755127,1801317,1755405,1801865,1755553,1801775,1755783,1802007,1756199,1802047,1756413,1802665,1757401,1802757,1758035,1802861,1758265,1803333,1758617}, +{1,54,1803509,1759013,1803501,1758825,1803795,1759225,1803461,1759059,1802741,1758075,1801625,1757051,1801379,1756855,1801095,1756713,1801011,1756625,1800729,1756575,1800587,1757069,1800615,1757869,1800587,1757725,1801113,1758269,1801113,1758713,1800655,1757585,1799911,1756633,1799735,1756663,1800747,1757825,1800325,1756675,1799329,1755123,1799205,1755179,1799257,1755341,1798751,1755963,1798707,1756185,1798551,1755997,1797879,1755225}, +{1,52,1797367,1754219,1796909,1753631,1796335,1752809,1796371,1753193,1796439,1752919,1795339,1751653,1795025,1751049,1794957,1751515,1795433,1752569,1795659,1753511,1795905,1753413,1796083,1754171,1795839,1753729,1795621,1753535,1795993,1754393,1795527,1754129,1795243,1754023,1794505,1753095,1794037,1752227,1793841,1752365,1794041,1752597,1794273,1753441,1794505,1753691,1794229,1753579,1794331,1753715,1794029,1753835}, +{1,52,1794295,1753793,1793707,1753123,1793787,1753483,1793619,1753311,1793601,1753293,1793553,1753311,1794067,1753995,1794167,1754753,1794223,1754135,1794091,1754389,1793681,1753663,1792693,1752901,1792507,1753105,1792355,1753073,1792199,1753371,1792045,1752957,1792649,1753473,1792303,1753857,1792405,1753733,1792671,1753691,1792351,1753631,1793255,1754989,1794139,1756167,1794665,1757393,1795615,1759015,1797051,1760923}, +{1,54,1797991,1762359,1798559,1763421,1799031,1764405,1799703,1764909,1799057,1764355,1798547,1763805,1798737,1763389,1798591,1763057,1798417,1762189,1797965,1761883,1797911,1762243,1798551,1762849,1797751,1761471,1797311,1760659,1797417,1760673,1797075,1760535,1797289,1760857,1797417,1760483,1797421,1760539,1797065,1760297,1797083,1760017,1796897,1760843,1797111,1760641,1796375,1759817,1796065,1759407,1795299,1758599,1794891,1757997}, +{1,52,1795229,1758153,1794979,1758241,1794927,1758215,1794753,1758163,1794531,1757951,1794695,1758301,1794971,1758681,1794939,1758113,1794869,1757941,1794863,1758579,1794913,1758357,1795135,1758257,1795121,1758229,1795145,1758331,1795241,1758783,1795439,1758945,1795717,1758843,1795145,1758755,1794829,1758243,1794325,1757997,1794269,1757651,1793837,1757147,1793867,1756763,1793707,1756767,1793947,1756901,1793907,1757069}, +{1,52,1793863,1757511,1794237,1757447,1794113,1757077,1794527,1757489,1794525,1757479,1794553,1757143,1794273,1757065,1794167,1756233,1794219,1755963,1793971,1756111,1794189,1755799,1794015,1755489,1793939,1755603,1793237,1755003,1793173,1755039,1793027,1755271,1793255,1755335,1793263,1755113,1793111,1755211,1793295,1754985,1792939,1754713,1793013,1754815,1793161,1754861,1793095,1754365,1792969,1754167,1793191,1754639}, +{1,54,1793451,1754383,1793197,1754107,1793031,1753455,1793121,1753197,1792693,1752887,1792279,1751911,1792253,1752093,1792703,1752489,1792099,1752093,1791591,1751783,1791697,1752701,1792059,1752601,1792155,1752739,1792431,1752761,1792067,1752901,1792537,1753275,1792721,1753297,1792775,1753497,1793449,1753821,1793771,1754181,1794665,1754975,1795037,1755147,1795439,1756265,1796243,1757069,1796545,1757719,1797129,1757675,1797421,1757989}, +{1,52,1797827,1758691,1797973,1759365,1797889,1759835,1797707,1759929,1798089,1760553,1797719,1759745,1797963,1760145,1798387,1760733,1797475,1759877,1797719,1760201,1797945,1760113,1797449,1759531,1797545,1758953,1797247,1759083,1797243,1759055,1797479,1758935,1797465,1759611,1797809,1759615,1797825,1760007,1798013,1760127,1798061,1760455,1798125,1760327,1798311,1760599,1798243,1760345,1797265,1759101,1797247,1759037}, +{1,58,1797381,1759389,1797111,1758861,1797007,1758981,1796897,1758719,1796803,1758561,1796629,1758353,1796679,1758385,1796871,1758779,1796733,1758215,1796683,1758241,1796821,1758251,1796949,1758399,1797217,1757969,1797221,1758569,1797319,1758283,1797675,1758897,1797475,1758991,1797933,1759147,1797947,1759319,1797337,1758603,1797155,1758227,1797247,1758575,1797071,1758301,1796851,1758195,1797163,1758279,1796999,1758539,1797443,1758195,1797407,1758985,1797523,1759019}, +{1,54,1797665,1758957,1798177,1759151,1798279,1759715,1798257,1759849,1798347,1759957,1798085,1759513,1798725,1760179,1798381,1759415,1798631,1758657,1798133,1757821,1797741,1757073,1797115,1756099,1796243,1756261,1796673,1756537,1796193,1756149,1795713,1755589,1796811,1757377,1797029,1757761,1796433,1757651,1796611,1758049,1796941,1758911,1797003,1759107,1797399,1759213,1797483,1759619,1797973,1760635,1798445,1760547,1798707,1761071}, +{1,52,1799277,1761591,1799209,1762007,1799747,1762487,1800085,1763007,1800473,1763689,1800161,1763315,1799281,1762309,1799427,1762225,1799285,1762189,1798857,1761577,1798671,1760497,1798751,1760641,1798501,1760441,1798503,1759999,1798485,1759943,1798421,1760427,1798507,1759929,1798729,1760695,1798759,1760803,1799001,1760787,1798863,1760853,1799271,1761001,1799417,1761055,1799539,1761569,1799453,1761439,1799939,1761785}, +{1,52,1799521,1761459,1799089,1760973,1799063,1760833,1799165,1761269,1799197,1761375,1799115,1761385,1799119,1761357,1799431,1762063,1799201,1761749,1799539,1762119,1799779,1762307,1800183,1762571,1799943,1762585,1800245,1762687,1800507,1762937,1800815,1762705,1800153,1761703,1799965,1761459,1799775,1761463,1800245,1761255,1799463,1760381,1798795,1759877,1798223,1759481,1798399,1759619,1797981,1758723,1797529,1758127}, +{1,54,1797773,1758939,1797609,1759523,1797559,1758847,1797547,1759313,1797853,1759703,1797737,1759285,1797625,1759403,1797621,1759287,1797315,1758769,1797235,1758349,1797071,1758349,1797053,1757913,1797129,1758529,1797079,1758487,1796995,1757601,1796661,1758003,1795985,1757139,1795833,1756439,1795385,1756513,1795277,1756237,1794699,1755395,1794647,1754749,1794263,1754773,1794245,1754819,1794165,1754841,1794481,1755679,1794903,1755807}, +{1,52,1794625,1755947,1795273,1756347,1795101,1756915,1795403,1756917,1795127,1756865,1795403,1757271,1795659,1757553,1795611,1757319,1795523,1757197,1794793,1756527,1794047,1755617,1793775,1755553,1793823,1755307,1793357,1755129,1793289,1754855,1793255,1754727,1793405,1755159,1793295,1755351,1793335,1755091,1793449,1755155,1793713,1755899,1794673,1757867,1795135,1757937,1795539,1758279,1795975,1759213,1796069,1759687}, +{1,52,1796651,1759951,1796531,1759435,1796831,1759809,1796203,1759315,1796145,1759375,1795647,1758913,1796029,1759623,1796669,1760941,1796847,1761305,1796799,1761905,1797447,1762993,1797381,1763315,1797489,1763569,1798253,1764323,1798027,1764683,1798155,1764631,1798285,1765205,1798461,1764483,1798137,1764147,1798227,1764217,1798097,1763989,1799093,1766027,1799693,1766979,1799867,1767313,1799303,1765971,1798503,1765287}, +{1,54,1798307,1764545,1797951,1762859,1796985,1760899,1796723,1759923,1795953,1758823,1795443,1758565,1795571,1757899,1795531,1758375,1795553,1758657,1795931,1758991,1795749,1759015,1795917,1759203,1796105,1759485,1796149,1759805,1796439,1760077,1796647,1760847,1795843,1760169,1795723,1759507,1795759,1759849,1795887,1759327,1795799,1759411,1795665,1759475,1795647,1759827,1795957,1759475,1795777,1759623,1796025,1759873,1796037,1759975}, +{1,52,1796411,1760465,1796949,1761305,1797151,1761693,1797209,1761859,1797519,1762475,1798107,1763275,1798577,1764179,1798555,1763559,1797825,1762927,1797563,1762803,1797861,1763227,1797271,1762681,1797409,1762409,1797541,1762711,1797527,1762651,1797239,1762659,1797439,1762603,1797333,1762863,1797541,1762637,1797289,1762525,1797537,1762531,1797351,1762169,1797573,1761901,1797083,1761043,1797367,1761623,1797621,1761873}, +{1,52,1797069,1761279,1796973,1761463,1796817,1761251,1796341,1760013,1796203,1760165,1796109,1760417,1796381,1760849,1796693,1761665,1796749,1762427,1797123,1762151,1797207,1762723,1797189,1762507,1797507,1762963,1797247,1762963,1797439,1762715,1797345,1762151,1797163,1762137,1797283,1762127,1797269,1761891,1797275,1762087,1797221,1762317,1797551,1762243,1797199,1762437,1796967,1762469,1796577,1761907,1796891,1762031}, +{1,52,1796879,1762087,1796475,1761633,1796335,1761369,1796221,1761323,1796229,1760927,1796153,1761189,1796033,1761195,1796261,1761369,1796469,1761509,1796653,1761787,1796653,1762295,1796705,1762353,1797003,1762373,1797435,1762933,1796999,1762913,1797213,1762739,1797319,1762451,1797275,1762415,1797029,1762161,1796643,1761667,1796665,1761683,1796581,1761725,1796493,1761791,1796331,1761933,1796933,1762189,1796705,1761861}, +{1,54,1796393,1761875,1796577,1762031,1796785,1762059,1796927,1762581,1797395,1762817,1797349,1763037,1797311,1762709,1797705,1763311,1797773,1763181,1798243,1763395,1798337,1764331,1798319,1764243,1798777,1764225,1798547,1764299,1797991,1764139,1797627,1763685,1797763,1763559,1797817,1763385,1797261,1763007,1797181,1762803,1797279,1762903,1797123,1762785,1796995,1762405,1796875,1761985,1796715,1762127,1796755,1762299,1796795,1762247}, +{1,52,1796705,1761915,1796639,1761781,1796781,1762017,1796567,1761625,1796635,1761759,1796767,1761637,1796937,1761569,1796915,1761163,1796447,1761505,1795793,1760875,1795665,1760205,1795341,1759965,1795361,1759703,1795201,1759231,1795069,1759093,1794975,1758815,1794749,1758741,1794819,1758807,1794557,1758145,1794405,1758375,1794743,1758325,1794645,1757997,1794807,1758123,1794579,1758205,1794727,1758081,1794757,1757881}, +{1,52,1794385,1757605,1794561,1757691,1794659,1757157,1794645,1757035,1794735,1757133,1794549,1757525,1794019,1756869,1793285,1755965,1793183,1756265,1793175,1756043,1792965,1755397,1793139,1755405,1792573,1755299,1792889,1755007,1792437,1754819,1792645,1754827,1792471,1754855,1792623,1754449,1792529,1754653,1792695,1754523,1792885,1754707,1792867,1754815,1792827,1754847,1793089,1755175,1793173,1754949,1793333,1755165}, +{1,54,1793223,1754919,1793253,1755275,1793161,1754949,1793089,1754847,1792231,1754005,1792143,1753613,1791987,1753709,1791881,1753131,1791841,1753123,1791729,1753063,1791609,1753251,1791681,1752855,1791387,1752771,1791439,1752961,1791569,1752805,1791639,1752447,1791547,1752809,1792019,1752869,1791845,1753193,1792187,1753505,1792449,1753787,1792877,1754295,1792853,1754417,1793015,1754361,1793085,1754431,1793117,1754845,1793055,1754759}, +{1,52,1792707,1754499,1792507,1754283,1792915,1754739,1792681,1754707,1792783,1754495,1792445,1754611,1792783,1754883,1792657,1754647,1792635,1754231,1792965,1754795,1793209,1755035,1793481,1755817,1793771,1756199,1794081,1756745,1794263,1756981,1794367,1757439,1795033,1757721,1795113,1758629,1795901,1759047,1795817,1759439,1796159,1760469,1797013,1761309,1797127,1761781,1796853,1762017,1796891,1761851,1796785,1762085}, +{1,52,1796719,1761901,1797007,1762303,1797167,1762295,1796429,1761611,1796465,1761439,1796491,1761473,1796509,1761593,1796275,1761301,1796283,1761033,1796399,1761139,1795989,1760871,1796039,1760751,1796101,1761115,1796265,1761037,1796175,1761319,1796453,1761213,1796417,1761319,1796083,1761287,1795105,1759139,1794157,1757065,1793851,1756269,1793677,1756107,1793037,1754947,1792279,1754457,1792489,1755755,1792743,1756163}, +{1,54,1792657,1756201,1792783,1756523,1793001,1757021,1793215,1757845,1793271,1757961,1792601,1756879,1793499,1758159,1793027,1757799,1792929,1757563,1793259,1758237,1793343,1758329,1793467,1758671,1793659,1758523,1793223,1758423,1792769,1757645,1792245,1757271,1792151,1757807,1791901,1757467,1791333,1756099,1791435,1756375,1791097,1755941,1790999,1755859,1790493,1755525,1790839,1755977,1790609,1755849,1791075,1756593,1791239,1756499}, +}; +static const int16_t PAH8009_mems_SPO2[][3*NF_PPG_PER_CHANNEL] = +{ +{80, 155,370,2007,136,383,2012,170,393,2021,170,381,2016,150,376,2012,155,376,2010,163,383,2016,163,377,2015,156,367,2029,153,373,2014,161,402,1999,168,390,2012,151,385,2015,159,386,2015,167,390,2013,162,394,2014,161,391,2014,163,395,2014,166,394,2010,158,398,2010,159,396,2007,164,396,2007,162,397,2010,157,397,2008,160,403,2009,162,402,2008,162,400,2009,162,395,2009,161,396,2009,161,397,2013,161,394,2014,162,388,2011,159,386,2011,160,392,2012,159,391,2016,161,385,2015,162,386,2012,158,389,2016,161,392,2014,161,391,2011,159,394,2015,163,394,2011,161,393,2011,160,399,2010,162,402,2010,163,412,2014,159,428,1982,162,439,1993,173,352,2029,139,371,2020,162,419,2015,188,416,2011,164,412,2012,152,401,2004,165,402,1999,164,420,2002,157,443,1997,165,430,2007,166,388,2023,154,366,2016,156,396,2002,171,407,2010,162,408,2015,158,391,2010,161,386,2008,163,388,2012,163,363,2044,159,345,2022,151,404,2012,164,426,1988,169,409,2005,156,392,2018,158,382,2016,161,387,2013,157,408,2002,157,413,2008,162,400,2016,158,393,2012,158,392,2009,161,392,2010}, +{52, 162,411,2012,164,406,2008,164,407,2005,161,413,2006,165,412,2005,164,417,2005,169,407,2000,165,403,2010,160,409,2011,166,409,2008,161,412,2010,159,421,2016,165,417,2012,162,409,2008,166,391,2001,163,400,2005,164,411,2004,159,426,2013,160,420,2017,167,408,2004,170,402,2000,163,406,2003,161,410,2010,165,415,2010,161,415,2013,162,409,2010,165,395,2003,163,392,2003,168,398,2004,154,409,2017,157,409,2017,166,402,2016,161,400,2013,160,387,2006,157,391,2010,161,396,2012,164,395,2011,159,392,2012,159,392,2009,159,396,2013,160,399,2012,158,392,2009,159,391,2010,163,386,2007,161,384,2006,155,393,2014,165,387,2014,158,384,2015,162,342,2044,152,371,2009,164,419,1993,168,420,2003}, +{53, 158,390,2012,150,377,2025,160,377,2018,166,391,2011,164,403,2010,157,403,2009,157,398,2009,156,406,2013,161,402,2008,156,393,2012,152,393,2011,161,393,2012,164,393,2011,157,387,2010,160,397,2012,167,394,2010,151,396,2014,159,394,2013,161,395,2017,163,395,2011,159,390,2010,159,394,2013,164,393,2009,158,392,2013,159,393,2006,157,398,2012,163,404,2014,165,396,2013,165,388,2007,167,396,2004,161,400,2011,161,405,2015,167,399,2000,152,402,2041,180,407,2000,145,369,2002,159,417,2022,181,384,2001,143,413,2025,169,393,2004,159,412,2020,167,399,2006,160,399,2009,165,396,2003,161,410,2010,169,413,2006,168,412,2008,158,418,1996,163,441,1985,179,390,2022,155,380,2030,163,399,2005,175,415,2011}, +{52, 169,408,2005,161,400,2006,162,403,2009,171,408,2008,165,413,2009,166,417,2015,169,418,2012,172,406,2005,160,429,1989,167,441,1995,177,411,2006,158,409,2022,158,408,2010,173,400,2006,174,388,2003,161,392,2019,164,408,2011,166,419,2012,167,411,1997,161,417,2006,166,420,2009,163,395,2011,156,399,2000,165,410,2006,170,424,2015,166,420,2016,167,418,2011,167,417,2010,168,415,2006,163,423,1996,164,446,1991,175,396,2016,162,398,2019,161,429,2006,164,459,1984,170,422,2004,165,370,2017,157,368,2018,164,398,2000,167,404,2007,167,406,2008,159,402,2014,152,397,2013,159,388,2022,159,372,2026,151,408,2003,165,411,2000,159,399,2012,154,386,2010,153,393,2017,158,378,2014,157,383,2018}, +{52, 155,398,2007,160,397,2012,152,392,2014,159,379,2016,155,393,2018,153,407,2007,161,402,2010,153,391,2014,150,388,2011,154,391,2012,159,391,2010,154,394,2013,157,393,2011,154,390,2013,155,390,2013,155,391,2014,153,393,2015,156,381,2014,163,367,2031,147,382,2011,153,421,2002,169,415,2006,149,400,2016,154,399,2015,159,395,2008,152,392,2008,149,399,2009,161,404,2012,162,402,2012,158,395,2008,155,398,2008,157,403,2012,158,405,2011,156,401,2011,158,405,2009,158,401,2012,158,402,2011,159,399,2008,156,401,2011,158,402,2009,154,403,2009,155,402,2011,158,400,2010,158,402,2009,160,400,2010,154,399,2011,153,399,2009,156,400,2011,157,402,2013,153,399,2012,155,399,2011,158,399,2012}, +{53, 157,401,2011,157,398,2012,155,398,2011,154,396,2009,154,402,2011,159,400,2012,156,399,2012,159,398,2011,157,394,2008,155,399,2012,158,399,2011,155,398,2014,156,397,2011,156,398,2014,157,394,2009,155,395,2011,156,395,2012,156,393,2008,155,395,2014,157,398,2012,155,396,2013,154,397,2012,159,399,2014,158,392,2009,154,394,2011,157,395,2010,156,397,2015,158,400,2013,157,398,2012,156,397,2011,158,397,2009,160,395,2010,156,399,2011,158,402,2011,158,404,2012,157,401,2011,156,402,2012,157,404,2008,159,404,2010,158,403,2011,157,402,2012,157,404,2009,158,406,2010,160,405,2012,156,403,2011,156,401,2010,159,403,2008,159,404,2010,159,408,2010,158,408,2012,159,405,2010,157,397,2006,160,406,2012}, +{52, 160,407,2009,154,407,2013,160,403,2009,160,402,2008,159,405,2012,157,403,2010,156,404,2010,158,405,2010,157,407,2011,159,405,2009,158,402,2010,159,405,2010,160,406,2009,158,406,2012,156,408,2011,157,405,2008,159,405,2010,162,406,2007,156,404,2009,157,405,2008,159,405,2010,160,408,2010,157,405,2010,156,405,2008,161,402,2007,156,407,2014,159,405,2006,154,405,2013,158,410,2012,159,403,2009,156,405,2009,161,403,2006,157,405,2011,154,407,2012,157,404,2011,155,404,2013,158,402,2008,158,402,2013,157,403,2011,158,402,2009,157,402,2010,157,405,2011,157,406,2009,155,406,2011,156,406,2009,155,405,2011,159,404,2008,157,404,2007,157,407,2011,159,406,2008,156,407,2012,161,405,2007}, +{52, 157,406,2009,156,406,2011,159,408,2011,160,407,2007,158,408,2009,160,404,2011,158,405,2008,157,404,2008,158,407,2014,157,405,2011,156,408,2010,157,405,2007,158,407,2011,159,407,2009,156,405,2010,154,404,2007,158,407,2008,158,408,2009,158,405,2009,157,405,2007,158,405,2010,158,407,2007,159,407,2010,158,405,2009,155,406,2007,158,406,2008,157,409,2011,160,407,2006,156,406,2009,160,404,2005,154,405,2011,160,411,2012,157,407,2010,155,406,2011,158,402,2010,156,404,2006,161,408,2012,159,407,2006,154,406,2011,158,407,2011,159,405,2011,158,405,2010,156,404,2008,156,406,2010,157,408,2010,160,405,2009,153,403,2007,157,405,2008,157,408,2008,159,410,2011,159,405,2007,156,406,2007}, +{53, 157,405,2014,159,407,2006,156,411,2013,160,405,2004,159,407,2009,160,405,2006,153,406,2012,158,405,2005,156,409,2013,158,406,2007,157,404,2010,158,405,2009,159,408,2011,158,404,2010,156,402,2009,158,404,2010,158,406,2009,157,407,2012,157,405,2012,159,403,2008,159,404,2010,158,404,2010,157,407,2008,157,406,2012,157,405,2009,158,403,2009,157,407,2010,159,406,2011,159,406,2011,158,403,2008,157,406,2013,157,407,2011,155,409,2012,158,406,2008,156,406,2011,162,404,2006,159,403,2008,158,407,2010,158,408,2013,159,405,2011,155,408,2012,158,407,2010,157,407,2007,157,408,2010,158,405,2010,157,405,2008,159,407,2011,159,407,2012,156,405,2010,156,405,2008,157,406,2011,157,404,2009,156,405,2012}, +{52, 159,405,2010,159,400,2010,158,399,2009,155,404,2011,156,406,2013,155,405,2009,155,402,2012,160,401,2012,156,398,2009,158,402,2011,160,403,2009,157,403,2009,154,398,2013,154,405,2011,157,402,2009,155,402,2014,159,400,2010,155,397,2010,158,401,2011,158,404,2013,155,405,2012,156,400,2009,153,400,2011,158,399,2008,159,401,2012,155,400,2010,156,399,2008,159,404,2010,156,402,2012,153,399,2010,154,400,2010,158,402,2010,158,403,2011,160,401,2009,156,402,2014,157,404,2007,152,401,2012,157,403,2008,159,402,2011,158,405,2009,158,401,2010,158,403,2010,155,401,2008,156,404,2012,156,407,2012,156,405,2011,156,402,2010,158,402,2011,159,403,2009,155,400,2011,154,404,2012,159,405,2010}, +{52, 157,404,2012,157,404,2010,156,401,2009,155,402,2011,157,406,2012,161,403,2012,156,402,2012,156,402,2009,158,405,2013,157,404,2011,155,405,2012,157,403,2008,157,404,2011,159,404,2009,157,403,2008,157,405,2008,157,406,2012,156,405,2010,155,404,2009,156,403,2009,158,407,2008,157,406,2010,157,409,2010,158,403,2010,157,403,2008,157,403,2009,157,407,2012,160,402,2009,158,402,2010,158,400,2009,155,403,2008,156,405,2012,158,406,2011,159,403,2010,156,399,2012,157,400,2013,158,404,2007,156,403,2013,158,405,2011,155,399,2008,157,403,2013,160,403,2008,159,401,2014,160,403,2011,157,401,2011,161,405,2011,155,394,2007,151,401,2009,160,404,2010,158,404,2014,159,397,2008,158,400,2008}, +{53, 157,404,2011,157,401,2012,158,396,2010,156,397,2009,155,401,2010,158,404,2012,160,400,2012,158,397,2008,158,400,2010,156,404,2013,160,405,2009,156,401,2009,156,404,2011,158,401,2006,157,404,2007,161,405,2009,160,403,2008,159,408,2013,167,414,2010,168,405,2007,155,396,2006,154,394,2007,161,400,2008,163,399,2008,162,390,2008,155,392,2014,147,396,2024,159,365,2019,177,274,2086,159,354,2003,160,433,1978,145,472,1978,124,461,2001,145,446,2029,156,437,1987,152,444,1982,164,351,2016,134,333,2034,144,399,2014,177,420,2013,152,416,2013,143,414,2012,156,426,2011,159,453,1983,159,411,2010,146,366,2029,143,385,2013,162,417,2007,160,417,2005,151,410,1998,149,413,2024,171,416,2002,149,391,1996}, +{52, 147,423,2013,163,416,2007,143,434,2023,154,418,2010,152,423,2013,157,415,2004,157,415,1997,147,449,1979,160,416,2015,154,384,2029,144,410,2005,157,416,2006,157,414,2004,150,412,2007,157,416,2005,154,420,2007,152,421,2012,157,417,2010,156,413,2007,156,415,2007,156,413,2007,155,417,2010,156,409,2004,150,412,2010,154,417,2006,152,414,2012,154,417,2010,157,409,2006,156,411,2008,153,414,2011,154,418,2011,156,417,2009,156,420,2009,160,421,2007,148,433,2012,150,456,1968,156,466,1996,161,381,2024,147,358,2034,147,396,1999,165,401,2002,165,429,2017,167,409,2010,147,409,2014,158,413,2006,159,423,2016,160,415,2016,159,407,2010,161,402,2000,157,410,2007,162,420,2010,162,425,2008}, +{52, 162,427,2011,164,419,2006,153,423,1989,158,425,1990,170,379,2026,150,415,2006,165,422,2011,162,414,2010,156,409,2007,162,404,2006,162,412,2009,158,410,2011,155,409,2012,158,408,2011,162,405,2011,156,399,2007,155,401,2010,159,401,2009,160,402,2007,156,402,2012,157,402,2011,157,402,2011,159,405,2011,159,402,2011,158,404,2010,159,400,2010,157,404,2009,158,399,2009,159,403,2011,159,399,2007,154,404,2012,158,407,2011,160,405,2009,158,402,2010,157,404,2012,159,402,2008,162,406,2010,159,405,2010,158,405,2009,157,405,2011,157,404,2010,157,403,2012,160,404,2010,158,405,2011,157,407,2009,158,404,2012,158,404,2010,156,402,2009,156,406,2008,157,404,2010,160,403,2009,159,401,2009}, +{52, 158,403,2010,155,405,2012,159,400,2008,157,404,2012,157,402,2010,152,401,2012,158,403,2009,158,402,2011,156,403,2011,159,402,2011,157,402,2011,155,399,2009,156,401,2010,153,402,2012,155,403,2011,157,403,2009,155,401,2011,157,402,2010,156,398,2010,155,402,2011,156,403,2010,154,404,2014,155,400,2008,155,403,2011,157,401,2010,157,401,2012,156,398,2013,156,396,2009,155,400,2010,156,405,2011,151,401,2013,156,395,2010,158,393,2010,150,403,2021,161,399,2005,154,386,2008,153,410,2015,152,392,2012,153,395,2015,161,396,2011,156,394,2011,152,392,2011,154,399,2010,152,398,2011,152,396,2015,153,395,2015,153,395,2011,158,398,2012,158,396,2011,155,396,2016,155,395,2011,152,393,2010}, +{52, 151,397,2010,154,400,2013,155,398,2016,158,396,2012,157,393,2011,153,395,2014,155,399,2011,152,399,2009,151,396,2011,152,395,2013,156,395,2010,156,395,2011,156,396,2010,154,397,2013,155,396,2012,154,399,2012,153,398,2011,150,395,2013,155,396,2010,156,398,2012,157,398,2012,155,397,2014,154,397,2013,154,396,2013,152,397,2011,155,400,2013,154,401,2011,156,398,2014,157,395,2009,153,396,2011,154,399,2011,154,400,2009,154,397,2011,155,397,2010,153,396,2012,155,400,2013,157,400,2011,154,400,2013,156,395,2012,155,397,2011,155,397,2010,152,400,2013,154,402,2013,154,398,2012,155,398,2012,152,398,2012,153,401,2012,155,400,2011,154,398,2011,152,399,2012,154,399,2013,154,399,2012}, +{53, 154,399,2014,153,397,2011,155,398,2012,154,399,2013,156,399,2012,154,400,2012,154,399,2010,155,396,2012,155,398,2011,155,397,2009,155,399,2011,153,400,2012,154,401,2013,155,398,2010,153,398,2010,155,399,2011,155,400,2013,154,399,2012,155,399,2008,153,398,2010,156,401,2010,156,402,2010,154,398,2012,155,400,2011,157,400,2012,153,401,2014,156,400,2011,154,398,2012,157,399,2012,154,398,2011,153,398,2012,155,401,2011,153,402,2011,154,400,2015,155,396,2012,153,397,2009,155,399,2012,155,399,2011,154,398,2010,156,398,2010,154,397,2010,155,400,2014,157,401,2013,154,397,2010,153,398,2014,157,397,2012,153,397,2011,153,397,2012,155,400,2011,156,398,2012,155,395,2009,155,397,2012,155,401,2011}, +{52, 154,398,2011,154,398,2011,155,396,2011,154,397,2013,157,396,2011,156,400,2012,156,399,2012,154,397,2012,155,398,2012,155,398,2012,157,399,2011,154,398,2009,157,397,2010,156,399,2013,157,398,2011,152,400,2012,154,400,2011,157,398,2010,155,398,2011,155,399,2010,156,399,2012,158,401,2014,156,401,2011,152,398,2012,151,397,2013,156,398,2011,156,398,2011,153,398,2011,154,398,2012,154,399,2010,158,400,2015,156,397,2011,154,397,2012,153,399,2013,153,399,2015,157,398,2009,154,396,2013,154,397,2015,155,398,2013,154,397,2010,154,396,2012,156,398,2011,155,396,2010,155,395,2012,155,396,2012,157,395,2011,154,398,2014,153,395,2010,152,395,2012,154,398,2012,155,397,2012,155,396,2013}, +{52, 153,395,2012,155,395,2010,154,398,2014,159,399,2013,154,398,2012,154,397,2012,153,396,2010,156,396,2011,158,397,2013,157,398,2013,154,398,2012,153,399,2012,154,400,2013,154,397,2010,152,396,2015,154,399,2011,157,398,2013,158,400,2012,154,398,2013,152,397,2009,154,399,2013,153,400,2012,154,398,2014,153,397,2012,156,398,2013,156,398,2013,157,399,2012,154,400,2013,152,401,2016,156,403,2010,153,398,2012,154,397,2012,155,397,2009,155,402,2011,156,403,2011,154,398,2009,154,402,2009,157,406,2011,158,411,2014,157,404,2010,155,402,2007,157,400,2007,157,402,2010,158,403,2010,154,409,2015,159,407,2011,157,403,2012,156,397,2009,154,395,2008,158,395,2010,154,392,2005,152,399,2012}, +{53, 156,400,2012,153,398,2014,151,394,2011,149,391,2011,150,395,2013,156,396,2014,155,393,2012,154,389,2010,155,393,2014,157,395,2015,154,394,2011,151,395,2014,153,397,2012,154,394,2013,154,396,2014,152,395,2014,157,398,2013,157,397,2012,154,395,2012,152,400,2015,155,394,2011,155,392,2012,154,389,2010,152,396,2013,157,397,2013,153,395,2016,154,395,2013,157,390,2008,153,391,2014,155,393,2010,151,396,2016,157,397,2015,156,391,2015,152,391,2011,153,392,2014,157,393,2013,154,393,2014,155,393,2015,155,390,2010,156,392,2013,158,395,2014,156,392,2014,155,392,2012,154,393,2011,157,395,2012,156,395,2013,157,395,2012,155,390,2011,154,394,2012,159,393,2009,155,395,2015,155,393,2014,153,391,2014}, +{52, 155,394,2011,156,394,2011,155,393,2014,156,394,2010,151,395,2013,156,398,2013,156,393,2010,155,394,2012,156,397,2012,156,403,2015,157,397,2012,152,394,2011,156,395,2009,161,406,2010,165,409,2013,156,412,2012,155,402,2008,157,397,2004,156,407,2007,161,416,2012,155,414,2012,153,406,2007,156,402,2006,159,409,2008,163,406,2006,159,402,2010,158,407,2010,159,411,2015,158,404,2011,156,393,2011,153,396,2009,158,401,2011,162,409,2013,155,402,2013,151,398,2012,156,394,2009,157,395,2010,156,397,2013,157,397,2012,158,401,2012,159,398,2010,155,396,2013,157,396,2010,158,393,2012,157,402,2012,156,399,2010,154,401,2011,153,397,2009,157,396,2010,158,393,2009,155,399,2011,155,402,2015}, +{52, 158,404,2015,155,396,2014,154,395,2012,154,396,2013,158,403,2012,159,401,2011,156,398,2010,155,396,2011,155,393,2009,158,398,2010,156,400,2012,155,402,2013,156,397,2012,156,397,2015,156,396,2012,155,395,2010,158,396,2006,149,396,2017,166,397,2005,146,394,2013,166,403,2013,154,382,2013,156,396,2010,162,395,2011,156,402,2014,156,393,2014,154,391,2012,156,392,2012,160,396,2013,156,394,2014,158,390,2010,153,392,2013,155,394,2010,156,393,2013,155,392,2012,154,392,2011,156,396,2013,157,394,2011,157,392,2016,156,391,2010,152,393,2012,156,398,2012,159,401,2010,156,393,2012,157,394,2012,156,395,2011,157,401,2012,158,402,2012,156,402,2014,157,396,2008,156,396,2010,158,401,2010}, +{52, 159,404,2013,158,402,2011,158,399,2010,157,399,2010,159,401,2013,155,403,2014,155,401,2011,156,401,2009,160,401,2010,160,399,2010,156,397,2011,156,398,2009,157,401,2013,158,402,2014,155,399,2009,157,397,2010,160,401,2010,160,400,2012,156,400,2011,159,396,2011,156,399,2008,157,408,2013,158,406,2015,154,397,2011,156,390,2006,158,395,2007,160,403,2011,157,406,2015,157,401,2015,155,393,2008,155,392,2008,158,398,2011,158,396,2014,156,393,2012,154,395,2012,156,399,2015,154,396,2018,152,385,2019,150,382,2008,160,408,2004,165,408,2013,152,394,2013,150,395,2009,160,401,2011,156,404,2013,154,398,2013,157,395,2009,159,402,2012,156,402,2014,156,402,2011,159,398,2009,155,398,2012}, +{53, 155,400,2008,154,404,2014,158,404,2009,156,399,2012,157,400,2010,156,403,2009,155,402,2013,156,401,2014,158,397,2008,158,401,2012,156,404,2013,156,401,2007,157,399,2009,155,401,2010,157,401,2013,156,401,2012,155,399,2010,156,402,2009,159,403,2013,155,401,2012,157,398,2009,153,401,2010,155,400,2012,155,403,2016,156,397,2008,153,398,2008,157,399,2013,157,399,2013,157,403,2014,160,399,2010,156,399,2012,157,401,2013,155,400,2014,157,403,2013,158,399,2008,157,400,2009,156,402,2013,157,401,2013,156,404,2013,157,397,2007,157,402,2012,160,405,2011,159,405,2011,156,400,2011,158,399,2010,158,398,2007,156,401,2011,154,401,2012,157,402,2011,158,402,2013,159,392,2021,153,407,2010,161,394,2000}, +{52, 150,402,2014,161,398,2010,159,401,2013,158,402,2015,156,398,2015,158,396,2010,156,395,2011,157,400,2011,158,403,2014,156,400,2011,155,399,2011,155,396,2009,155,397,2010,156,399,2010,157,404,2014,157,404,2014,156,400,2011,155,402,2006,157,403,2011,157,402,2009,154,398,2005,155,399,2016,163,410,2011,155,397,2004,155,403,2013,158,394,2011,156,402,2013,164,405,2012,158,405,2016,149,396,2010,151,397,2010,160,400,2009,158,402,2009,151,398,2007,151,400,2009,158,403,2008,159,405,2012,158,402,2009,158,404,2008,160,409,2009,155,409,2011,152,408,2012,161,404,2005,166,401,2005,161,411,2009,163,408,2007,165,411,2008,160,407,2010,158,410,2011,157,404,2008,156,404,2011,160,405,2007}, +{52, 160,408,2012,160,414,2012,159,408,2010,158,403,2008,161,399,2001,159,402,2006,162,409,2009,156,410,2015,154,406,2011,166,399,2007,156,402,2011,159,404,2010,161,410,2011,156,404,2014,155,399,2009,161,397,2005,155,400,2009,157,404,2013,160,407,2011,160,403,2008,162,402,2010,154,400,2010,154,403,2011,161,403,2007,161,405,2010,157,407,2013,156,399,2006,160,401,2009,165,396,2005,154,409,2013,162,413,2013,160,408,2013,153,398,2008,158,396,2004,163,407,2010,167,412,2015,161,395,2009,152,390,2006,158,398,2009,165,416,2019,159,411,2018,149,397,2011,156,392,2006,163,401,2011,160,404,2013,157,392,2007,157,390,2004,158,393,2007,159,409,2015,167,420,2020,161,398,2010,151,392,2010}, +{53, 164,398,2005,161,405,2015,159,403,2012,157,397,2008,157,403,2009,161,405,2012,161,406,2015,159,401,2008,156,402,2008,161,406,2010,160,407,2009,158,408,2012,160,402,2008,159,407,2007,158,404,2007,161,407,2010,156,403,2009,156,409,2012,171,404,2009,154,411,2016,154,402,2007,160,405,2009,163,405,2009,159,403,2011,159,401,2009,160,408,2012,160,403,2008,155,403,2010,161,398,2008,159,400,2010,158,412,2013,164,412,2015,161,404,2011,161,394,2006,160,390,2004,157,399,2010,163,410,2016,161,409,2020,159,400,2012,159,393,2009,157,392,2009,162,394,2010,162,398,2011,160,394,2012,156,399,2018,161,403,2015,161,399,2014,154,397,2015,156,390,2012,165,386,2004,161,398,2013,157,404,2016,161,402,2013}, +{52, 157,394,2012,157,394,2008,165,393,2008,165,396,2010,160,403,2013,158,403,2014,158,403,2015,160,398,2011,158,394,2008,160,401,2013,164,400,2009,162,399,2011,157,397,2010,161,399,2009,160,405,2013,158,398,2009,156,401,2012,164,401,2009,164,401,2014,159,397,2011,158,397,2011,160,393,2010,159,396,2011,160,397,2012,158,395,2015,161,394,2011,161,393,2011,159,392,2012,158,391,2011,157,395,2015,161,398,2013,156,394,2013,158,396,2013,158,390,2010,159,394,2013,161,392,2010,155,395,2012,161,397,2012,160,398,2014,154,396,2013,153,392,2010,162,399,2012,166,396,2009,157,395,2014,159,394,2009,161,395,2010,159,404,2015,159,401,2014,157,394,2013,160,395,2010,162,397,2012,163,399,2012}, +{52, 158,396,2012,155,397,2012,159,395,2011,161,395,2013,161,396,2013,158,397,2014,157,398,2014,160,394,2013,160,393,2010,159,397,2013,157,394,2013,156,394,2014,159,393,2010,160,394,2011,158,393,2012,156,392,2011,155,394,2015,158,394,2011,156,393,2014,158,395,2013,159,392,2012,157,390,2011,157,394,2012,157,394,2013,157,393,2013,155,393,2012,156,395,2012,156,390,2012,159,390,2011,161,392,2012,161,393,2013,156,392,2010,155,391,2014,156,388,2013,154,388,2012,159,390,2012,158,394,2014,157,390,2013,157,393,2015,160,391,2013,157,392,2010,157,391,2012,157,393,2014,153,388,2012,157,390,2012,164,391,2013,161,397,2013,158,394,2014,155,394,2013,157,390,2012,161,392,2014,157,395,2013}, +{53, 157,397,2013,162,396,2010,163,396,2013,161,390,2006,159,394,2012,158,397,2011,155,400,2012,156,397,2011,164,398,2013,163,392,2009,157,390,2013,158,388,2009,160,400,2012,160,404,2015,153,398,2017,149,388,2010,158,391,2010,173,395,2009,168,395,2014,152,391,2015,148,392,2012,160,393,2011,159,397,2012,154,393,2013,155,394,2011,165,393,2009,165,393,2011,156,392,2013,156,393,2009,155,397,2015,162,399,2012,159,395,2014,159,391,2010,160,394,2010,162,398,2010,160,401,2013,157,392,2009,154,395,2013,160,399,2012,162,399,2012,160,399,2011,158,398,2013,160,394,2012,159,394,2010,156,399,2012,156,400,2012,160,396,2011,156,396,2009,157,398,2010,162,401,2017,165,398,2008,156,396,2013,159,398,2010}, +{52, 155,394,2014,156,398,2012,159,397,2012,159,402,2013,161,397,2014,160,394,2011,161,394,2010,157,394,2013,156,398,2014,156,397,2013,159,394,2010,159,394,2013,159,392,2012,158,393,2013,160,391,2015,157,393,2012,159,396,2011,158,393,2013,157,392,2013,159,390,2011,160,392,2010,157,395,2011,156,395,2012,158,393,2014,157,393,2014,161,388,2012,160,392,2012,157,393,2010,152,394,2013,155,391,2013,158,390,2014,158,392,2016,157,390,2014,158,387,2010,159,392,2012,161,393,2013,155,389,2013,155,390,2013,157,390,2012,158,391,2016,160,388,2013,153,387,2014,155,390,2013,157,388,2014,157,394,2015,159,391,2012,156,387,2013,161,389,2014,162,392,2015,159,391,2011,153,394,2011,153,392,2016}, +{52, 155,388,2014,160,384,2011,159,391,2013,162,389,2012,157,394,2018,157,388,2014,152,385,2009,159,384,2011,156,389,2016,155,388,2014,158,391,2015,163,385,2015,163,385,2010,159,382,2011,158,391,2015,156,391,2017,156,393,2018,161,390,2015,159,386,2014,157,384,2013,162,383,2011,162,388,2013,161,391,2013,158,391,2014,155,397,2015,158,395,2013,159,388,2011,159,383,2008,162,386,2011,161,387,2011,156,394,2015,155,395,2011,155,396,2016,159,391,2013,158,389,2012,160,387,2013,161,393,2014,161,390,2013,158,393,2014,159,388,2011,156,387,2012,156,393,2014,158,390,2014,159,388,2013,160,387,2011,160,390,2014,160,388,2014,158,388,2012,156,390,2014,158,392,2016,157,389,2014,158,386,2013}, +{53, 160,388,2012,161,388,2013,155,389,2015,155,387,2012,156,387,2011,156,389,2012,157,390,2016,157,385,2013,157,385,2013,163,387,2011,159,390,2016,158,389,2014,156,387,2013,158,387,2010,156,388,2016,158,387,2012,158,385,2015,161,386,2010,157,390,2015,158,387,2009,155,386,2014,159,391,2014,158,389,2013,157,387,2015,157,384,2014,157,385,2013,158,387,2014,157,388,2014,156,389,2014,159,386,2011,159,387,2012,159,389,2012,155,384,2013,154,390,2015,162,385,2008,152,386,2021,163,390,2011,154,385,2015,158,385,2013,157,387,2013,159,388,2017,158,383,2012,154,384,2015,158,384,2012,156,385,2014,159,386,2014,158,385,2017,158,386,2011,156,388,2013,159,392,2014,156,386,2014,158,387,2012,159,386,2009}, +{52, 158,390,2015,157,390,2015,155,387,2012,158,390,2013,161,388,2014,158,390,2016,161,391,2014,163,391,2011,161,389,2010,154,388,2011,153,389,2012,161,392,2015,163,389,2010,158,393,2016,160,389,2009,155,391,2013,160,389,2010,159,390,2013,156,383,2011,156,388,2015,160,385,2012,160,389,2017,163,380,2017,155,367,2027,151,390,2009,168,407,2001,161,395,2012,151,393,2016,160,395,2015,162,394,2014,157,391,2011,159,392,2009,163,390,2008,159,387,2011,158,392,2012,164,398,2012,161,406,2016,161,404,2019,160,396,2012,158,395,2007,157,387,2005,157,398,2010,165,402,2013,163,408,2013,156,395,2009,156,397,2009,159,397,2011,158,399,2013,161,401,2014,165,400,2010,159,398,2014,157,396,2010}, +{52, 154,398,2013,165,403,2010,166,402,2009,155,401,2014,159,403,2009,163,397,2008,163,399,2006,160,404,2011,156,409,2013,161,413,2015,165,401,2004,154,401,2011,165,409,2009,165,408,2012,155,400,2008,163,397,2003,162,406,2012,159,402,2009,154,399,2011,160,402,2008,162,403,2016,164,399,2013,161,395,2008,162,397,2011,162,407,2015,164,397,2011,156,390,2011,160,389,2008,160,396,2010,163,401,2013,163,400,2015,161,393,2010,161,390,2011,157,395,2013,158,399,2016,163,400,2016,162,393,2010,160,393,2011,163,392,2009,159,395,2012,160,396,2009,159,397,2011,160,395,2013,161,398,2013,159,393,2011,154,394,2012,160,397,2011,162,397,2011,157,394,2015,158,393,2011,159,394,2012,160,402,2011}, +{53, 159,397,2010,159,397,2013,161,396,2009,155,390,2010,162,397,2012,163,396,2011,157,393,2014,162,395,2011,158,395,2014,162,394,2013,158,394,2013,160,392,2008,160,390,2008,157,393,2012,159,393,2012,160,397,2014,161,398,2014,157,391,2011,157,388,2011,158,390,2012,159,396,2014,161,397,2015,161,391,2014,159,384,2010,157,391,2007,157,397,2015,162,395,2014,158,393,2013,154,390,2010,157,390,2013,161,388,2010,159,385,2013,159,390,2012,158,388,2012,158,388,2015,159,379,2022,154,382,2017,156,407,2000,170,400,2012,156,396,2018,159,390,2012,160,390,2011,156,390,2010,158,392,2011,161,390,2013,156,393,2016,157,387,2012,156,385,2011,158,388,2015,162,375,2024,153,378,2013,157,403,2002,163,402,2007}, +{52, 152,389,2014,153,386,2011,159,389,2015,162,384,2011,156,385,2019,158,386,2019,160,399,2014,162,391,2014,152,385,2012,156,390,2012,161,393,2014,160,393,2013,162,391,2010,160,396,2012,165,396,2010,158,401,2014,159,397,2009,160,388,2007,161,399,2012,165,393,2006,160,399,2014,159,403,2016,159,408,2014,168,405,2012,163,402,2013,157,395,2008,160,396,2005,161,404,2007,158,404,2008,158,408,2013,162,401,2008,155,404,2013,169,403,2005,165,406,2013,157,403,2013,158,399,2009,162,408,2013,164,406,2011,159,399,2009,157,399,2011,163,400,2006,159,405,2011,159,407,2012,157,404,2010,161,404,2011,163,402,2014,163,398,2008,160,399,2008,163,407,2010,159,409,2012,155,406,2010,152,396,2008}, +{52, 162,404,2010,171,404,2010,163,403,2011,157,402,2007,155,406,2010,156,406,2016,161,401,2007,161,402,2010,162,403,2012,162,403,2009,162,402,2005,158,401,2009,157,404,2009,159,404,2009,159,404,2014,168,404,2012,163,399,2008,159,398,2009,158,399,2009,160,404,2011,159,403,2011,158,408,2012,162,407,2012,162,403,2012,159,397,2008,160,401,2010,164,403,2010,161,401,2010,159,400,2011,158,403,2008,157,403,2011,161,404,2012,160,401,2011,161,400,2010,163,401,2011,162,403,2013,158,398,2007,157,402,2011,163,400,2010,160,398,2011,159,399,2011,165,403,2012,161,402,2010,155,400,2012,159,396,2009,160,400,2011,162,400,2012,159,401,2013,162,400,2009,160,399,2010,161,397,2013,162,399,2012}, +{53, 159,399,2010,160,402,2016,158,399,2010,161,396,2010,164,399,2010,159,398,2011,157,393,2012,162,397,2012,164,399,2010,158,402,2014,158,399,2012,161,397,2012,159,401,2012,167,399,2007,158,402,2015,157,401,2011,157,398,2009,162,401,2007,160,405,2012,162,402,2010,159,403,2013,161,402,2011,162,403,2010,161,398,2009,158,405,2011,160,406,2014,164,405,2007,158,396,2012,160,399,2009,161,400,2013,162,404,2011,160,401,2013,160,401,2009,154,400,2019,162,401,2012,160,393,2008,160,401,2009,161,399,2010,156,399,2010,160,401,2015,161,397,2010,158,398,2010,160,398,2010,162,398,2011,161,399,2010,159,400,2011,160,400,2012,158,400,2010,158,398,2013,158,397,2009,163,397,2010,163,401,2011,162,400,2010}, +{52, 157,400,2013,165,405,2014,162,402,2008,156,401,2012,164,400,2009,160,397,2009,158,401,2010,160,405,2011,158,406,2014,162,407,2013,164,399,2006,161,394,2006,160,396,2006,163,408,2013,159,406,2013,156,404,2012,161,401,2009,165,400,2012,161,393,2009,158,396,2010,162,400,2015,161,397,2012,155,398,2013,161,401,2012,160,396,2010,157,392,2012,160,395,2009,159,399,2012,159,399,2015,164,396,2013,160,397,2012,157,398,2011,159,400,2013,165,398,2008,159,393,2007,156,400,2012,160,402,2011,161,400,2012,163,397,2011,163,402,2008,161,403,2012,162,402,2013,159,400,2010,159,397,2007,161,398,2010,163,403,2014,163,403,2008,165,404,2012,168,406,2012,163,402,2010,157,401,2011,160,404,2011}, +{52, 161,403,2005,161,404,2012,167,403,2010,166,402,2009,161,402,2009,159,404,2010,163,398,2009,158,396,2010,156,408,2016,172,407,2012,169,406,2014,157,394,2011,160,392,2005,158,391,2008,157,401,2013,164,404,2014,165,402,2013,161,395,2009,160,394,2007,163,396,2009,160,402,2016,161,401,2011,160,402,2013,162,400,2012,161,397,2011,161,398,2009,165,400,2009,162,401,2012,164,403,2008,160,402,2010,160,401,2011,161,396,2008,163,398,2007,161,403,2015,166,400,2013,162,398,2011,160,398,2014,159,398,2012,161,394,2012,165,397,2011,162,398,2013,161,397,2013,160,396,2011,160,394,2009,163,395,2012,164,396,2014,162,398,2013,159,397,2012,161,398,2013,163,392,2010,160,392,2009,160,396,2011}, +{58, 165,399,2011,162,398,2012,162,398,2014,157,393,2012,158,396,2009,161,397,2011,162,395,2012,166,396,2011,161,395,2008,161,399,2014,164,396,2007,158,395,2012,158,397,2014,160,392,2010,161,396,2009,163,397,2014,162,398,2014,163,393,2010,161,394,2013,160,396,2010,160,395,2012,161,396,2011,164,394,2010,162,394,2017,161,398,2010,163,388,2009,163,405,2013,161,391,2011,157,396,2017,163,387,2006,161,399,2017,166,394,2009,158,394,2014,160,394,2011,159,393,2012,159,392,2012,161,396,2012,161,400,2013,164,395,2013,162,392,2012,160,388,2009,159,394,2012,161,397,2014,160,396,2013,159,395,2015,160,393,2012,160,392,2013,163,392,2011,161,393,2014,159,394,2013,159,397,2013,161,394,2014,162,393,2012,160,391,2010,160,395,2012,164,393,2010,160,391,2012,157,400,2018}, +{52, 164,389,2004,153,390,2017,165,391,2009,159,392,2012,164,396,2012,159,395,2017,165,392,2007,162,393,2009,160,398,2017,165,394,2010,160,390,2009,162,398,2012,161,399,2014,159,399,2011,161,400,2014,166,402,2010,163,401,2009,158,405,2011,162,403,2013,163,402,2007,161,410,2010,161,412,2010,162,406,2010,163,393,1999,162,407,2010,166,417,2011,159,406,2010,157,406,2010,167,410,2011,160,397,2009,158,390,2006,164,397,2005,164,407,2017,167,408,2016,162,395,2011,159,396,2006,160,395,2013,163,396,2014,161,391,2012,162,392,2009,163,393,2013,164,392,2011,162,393,2014,163,392,2011,157,389,2013,159,389,2013,161,387,2010,163,390,2011,162,394,2015,163,391,2014,163,387,2009,159,387,2013}, +{52, 158,392,2014,161,391,2013,159,390,2013,160,390,2010,161,387,2010,162,390,2010,158,391,2012,159,390,2010,156,388,2012,160,387,2012,160,393,2016,161,397,2016,161,387,2015,163,382,2006,160,386,2010,161,391,2014,162,394,2017,165,391,2014,162,392,2013,162,391,2011,160,394,2013,163,388,2009,161,389,2011,160,393,2011,160,397,2014,162,396,2010,159,396,2013,161,393,2010,163,395,2014,166,395,2007,157,393,2014,163,399,2014,163,395,2011,158,393,2010,162,396,2014,161,393,2012,162,395,2013,163,393,2010,161,396,2011,163,394,2011,159,395,2014,161,393,2013,161,392,2010,164,395,2012,163,397,2016,163,393,2012,159,395,2012,165,397,2012,165,396,2010,161,394,2010,160,396,2012,164,399,2015}, +{53, 164,395,2013,162,398,2011,161,396,2011,164,394,2012,165,396,2010,161,392,2008,162,396,2014,167,394,2012,163,397,2012,161,394,2013,163,398,2015,166,391,2010,161,391,2012,161,394,2010,162,398,2013,164,394,2011,163,394,2014,162,394,2014,160,392,2011,161,392,2012,165,393,2012,163,395,2013,164,397,2014,164,393,2011,161,392,2013,164,394,2012,162,397,2014,163,397,2013,163,395,2014,167,395,2010,165,400,2010,163,401,2013,162,401,2015,164,397,2009,161,400,2010,162,400,2013,169,400,2009,164,397,2009,161,402,2008,168,404,2010,166,406,2014,161,401,2011,161,401,2008,166,401,2008,168,404,2015,165,399,2009,159,403,2010,163,409,2008,165,408,2013,159,400,2010,161,394,2005,164,399,2007,164,406,2014}, +{52, 170,404,2011,162,405,2010,160,403,2013,160,404,2013,166,397,2011,165,396,2008,162,397,2008,160,404,2012,165,404,2014,164,398,2011,160,396,2009,162,398,2011,164,400,2013,165,402,2010,167,402,2011,158,403,2010,160,398,2007,165,400,2009,165,397,2009,163,403,2012,163,405,2015,161,400,2010,165,396,2008,166,401,2010,162,404,2015,168,408,2013,162,406,2014,162,394,2007,160,393,2009,164,399,2007,161,405,2014,162,408,2013,164,400,2009,161,398,2010,167,399,2009,163,402,2012,162,402,2014,165,403,2009,164,404,2011,162,404,2010,162,399,2010,164,400,2009,163,400,2007,163,404,2011,166,404,2011,163,405,2010,163,401,2008,163,400,2011,164,400,2010,162,400,2009,160,403,2012,161,404,2011}, +{52, 164,398,2008,161,397,2007,162,396,2009,165,399,2010,165,399,2012,159,396,2013,161,396,2009,162,399,2012,161,398,2011,161,395,2012,161,394,2013,164,395,2012,163,394,2011,161,399,2017,161,396,2012,159,396,2013,160,393,2012,164,396,2013,163,394,2010,162,397,2014,162,396,2012,166,395,2013,164,391,2011,158,394,2012,164,393,2014,163,393,2013,159,392,2010,163,396,2010,162,395,2017,164,392,2010,161,391,2012,160,390,2014,161,393,2010,162,394,2015,162,395,2014,164,392,2009,162,393,2015,162,394,2016,162,395,2010,162,396,2017,163,391,2013,161,385,2011,162,385,2007,159,391,2011,164,404,2018,165,398,2018,158,386,2012,156,385,2004,157,391,2013,161,394,2018,171,395,2010,159,386,2011}, +{53, 161,394,2011,164,394,2013,163,394,2015,164,389,2008,157,397,2011,166,392,2008,164,395,2015,166,391,2006,161,393,2012,166,400,2015,162,398,2012,165,394,2011,164,392,2011,166,392,2007,165,393,2012,167,397,2016,166,392,2014,163,391,2009,164,389,2013,163,391,2013,160,385,2012,164,389,2015,168,387,2012,163,386,2015,163,389,2016,164,385,2013,163,383,2014,163,381,2012,160,388,2017,164,386,2014,164,383,2018,164,379,2011,164,379,2012,161,388,2019,161,384,2014,160,384,2016,167,382,2012,164,380,2014,165,383,2016,162,382,2011,161,385,2018,169,379,2012,162,371,2008,158,378,2015,164,376,2017,166,360,2057,156,354,2005,162,425,1995,183,403,2007,150,390,2018,159,384,2015,172,392,2015,163,389,2012}, +{52, 160,390,2015,168,398,2016,172,398,2013,164,396,2011,162,395,2011,163,401,2009,166,406,2012,167,417,1996,169,412,2005,171,375,2020,158,393,2016,172,404,2010,165,403,2009,157,399,2010,163,400,2008,165,401,2011,165,401,2013,172,396,2011,169,402,2010,166,401,2013,164,400,2010,162,397,2010,163,399,2012,165,398,2012,167,400,2013,167,395,2010,167,397,2011,167,394,2010,163,393,2012,165,395,2014,167,398,2014,165,396,2014,163,395,2015,169,393,2012,167,392,2011,165,391,2012,164,394,2011,164,396,2013,166,398,2011,166,393,2011,163,395,2012,166,394,2011,166,396,2011,168,399,2015,167,398,2011,165,395,2010,164,395,2010,164,396,2010,165,396,2013,166,396,2013,167,394,2010,164,397,2014}, +{52, 166,392,2010,165,393,2010,165,395,2009,165,392,2010,163,393,2013,167,395,2012,167,391,2014,165,394,2013,167,387,2007,164,394,2017,169,389,2009,163,388,2015,164,389,2011,163,392,2016,166,393,2014,165,392,2014,166,392,2012,164,388,2013,165,389,2010,166,389,2013,166,391,2015,164,389,2010,165,392,2012,166,393,2013,165,392,2010,164,392,2013,166,391,2009,167,390,2010,163,392,2010,164,393,2015,165,395,2012,167,392,2010,166,393,2014,164,396,2014,166,391,2009,166,391,2011,164,391,2011,164,394,2013,165,394,2015,168,392,2008,165,389,2010,166,393,2010,167,395,2012,165,395,2015,167,394,2009,164,395,2012,164,397,2014,166,397,2011,166,391,2006,163,392,2007,165,398,2007,165,403,2014}, +{52, 165,401,2012,166,400,2009,164,396,2012,165,396,2009,166,394,2010,165,403,2013,168,402,2012,168,401,2013,165,394,2009,161,394,2008,162,399,2009,167,403,2013,168,400,2010,165,394,2009,162,396,2013,167,398,2012,165,391,2012,164,397,2010,163,397,2012,165,401,2011,161,391,2012,162,398,2013,167,396,2013,165,392,2011,163,388,2004,160,394,2013,163,398,2014,164,394,2013,164,391,2014,169,394,2008,164,395,2012,165,398,2015,166,395,2012,164,393,2009,164,390,2010,165,398,2012,166,400,2014,167,394,2011,165,391,2012,167,392,2008,163,395,2016,165,394,2011,165,397,2014,164,393,2011,162,393,2014,166,391,2010,163,395,2013,166,396,2011,166,393,2013,164,390,2012,160,390,2012,164,392,2011}, +{53, 166,393,2012,161,393,2014,163,395,2013,165,391,2011,162,390,2011,162,392,2011,162,393,2010,164,393,2014,163,396,2012,163,392,2011,163,392,2011,163,395,2011,165,393,2012,165,395,2012,160,394,2014,163,393,2010,164,390,2011,164,391,2011,163,393,2015,161,393,2012,164,389,2012,163,391,2012,163,390,2013,162,391,2013,162,388,2013,164,391,2012,164,390,2011,161,393,2013,163,390,2013,163,387,2014,165,390,2013,165,390,2013,163,391,2012,161,393,2015,161,390,2013,165,388,2012,164,391,2016,165,390,2009,159,393,2014,167,392,2012,164,390,2010,160,389,2012,163,392,2013,164,393,2013,166,390,2015,166,389,2011,162,389,2011,161,389,2013,164,390,2011,162,389,2013,162,390,2014,162,387,2013,164,388,2013}, +{52, 164,387,2016,161,389,2013,162,390,2012,165,391,2014,162,388,2011,161,388,2013,165,391,2014,165,385,2013,162,389,2012,164,392,2013,161,395,2014,167,392,2013,162,388,2012,159,387,2010,165,392,2013,167,395,2014,165,393,2016,165,389,2011,162,388,2011,164,390,2014,164,393,2011,167,394,2015,167,393,2014,164,388,2010,163,390,2012,165,392,2013,165,390,2014,160,390,2015,164,392,2013,167,394,2010,167,390,2011,163,388,2015,163,391,2012,164,392,2014,164,392,2014,166,393,2015,164,391,2015,163,390,2012,167,390,2014,162,392,2013,162,393,2014,164,392,2013,167,393,2012,163,390,2013,164,390,2010,164,392,2012,166,391,2014,164,391,2014,163,390,2013,165,389,2013,162,390,2014,164,391,2011}, +{52, 163,391,2014,165,392,2013,168,389,2012,164,390,2012,163,389,2014,164,391,2012,162,391,2013,164,391,2014,164,388,2013,166,388,2013,163,388,2014,161,389,2012,161,388,2012,163,391,2014,165,392,2015,163,389,2014,166,386,2012,166,389,2010,163,393,2013,164,393,2014,164,390,2012,163,389,2012,162,389,2011,164,391,2012,165,390,2014,166,391,2014,164,392,2011,163,392,2014,164,391,2010,161,390,2013,165,391,2011,167,391,2013,165,388,2011,163,389,2012,165,390,2010,164,391,2014,163,395,2014,163,390,2012,166,388,2013,165,391,2010,163,391,2014,165,391,2013,163,391,2012,164,392,2013,164,392,2013,163,391,2013,164,390,2013,163,390,2013,164,388,2016,162,388,2011,163,391,2015,162,392,2014}, +{53, 162,390,2013,165,389,2011,164,391,2012,163,392,2013,162,392,2012,162,391,2013,163,393,2013,165,390,2013,164,390,2012,162,391,2012,163,389,2011,164,390,2012,162,393,2015,163,394,2015,163,392,2015,166,386,2011,166,388,2013,161,389,2012,161,390,2013,164,394,2015,164,393,2015,163,387,2013,163,387,2011,163,390,2012,166,390,2012,164,388,2014,161,389,2013,162,391,2012,165,392,2016,165,392,2014,160,388,2014,163,388,2013,167,391,2014,163,390,2012,163,391,2012,162,392,2011,160,392,2014,164,390,2014,164,389,2014,163,389,2011,163,390,2014,165,391,2014,162,390,2011,160,390,2014,161,391,2014,163,386,2014,164,386,2014,164,389,2013,165,390,2014,163,390,2013,162,390,2015,162,390,2011,163,390,2017}, +{52, 164,389,2012,165,388,2012,165,391,2012,162,390,2013,164,390,2015,161,388,2012,160,392,2014,163,393,2013,166,388,2011,161,388,2011,163,387,2013,165,391,2015,163,392,2011,162,391,2014,160,390,2010,162,390,2011,164,393,2013,163,389,2014,163,389,2012,164,390,2012,166,392,2013,162,388,2014,160,389,2015,161,391,2015,164,390,2013,165,387,2011,162,389,2012,164,391,2013,167,389,2014,162,389,2011,162,390,2012,161,390,2013,163,391,2013,165,388,2013,165,390,2012,165,389,2012,162,390,2012,161,387,2012,162,392,2012,164,390,2013,160,388,2013,163,389,2011,168,390,2013,164,391,2014,162,389,2015,163,390,2012,161,389,2013,161,390,2014,164,388,2014,163,385,2012,165,391,2016,165,389,2013}, +{52, 162,391,2014,162,391,2013,162,388,2014,162,387,2013,164,388,2010,165,389,2012,165,391,2012,162,389,2012,161,389,2014,162,391,2013,162,390,2014,166,388,2014,163,387,2013,162,389,2013,164,391,2015,162,389,2013,162,389,2011,162,386,2011,160,389,2011,162,389,2013,167,396,2012,162,392,2016,163,392,2015,162,389,2014,164,391,2013,165,388,2013,161,390,2013,161,390,2012,163,395,2014,166,390,2013,165,389,2012,161,390,2010,162,392,2014,164,387,2013,161,390,2013,165,390,2013,163,392,2013,164,392,2013,166,392,2010,163,386,2012,161,388,2012,161,385,2011,160,392,2011,165,389,2011,162,388,2015,163,384,2013,164,385,2015,165,386,2012,165,386,2011,159,387,2015,161,387,2013,160,387,2013}, +{53, 165,384,2013,164,386,2014,163,381,2013,163,384,2012,165,387,2014,161,393,2017,163,391,2016,162,389,2013,165,386,2011,166,386,2010,162,387,2011,164,390,2012,164,392,2016,161,389,2013,164,391,2014,166,392,2011,163,388,2012,162,388,2013,164,390,2011,163,389,2013,164,392,2012,162,392,2014,162,392,2013,164,387,2010,162,389,2013,165,391,2014,166,391,2012,163,392,2012,160,388,2013,160,388,2009,165,389,2013,166,389,2015,165,390,2012,163,388,2016,162,390,2013,162,392,2015,162,399,2017,162,398,2014,164,395,2012,164,393,2007,165,399,2012,167,398,2008,163,398,2007,158,399,2010,164,412,2010,167,409,2010,158,398,2009,161,395,2004,167,396,2006,166,403,2008,164,404,2014,162,406,2017,166,397,2007}, +{53, 167,395,2010,167,393,2010,161,389,2012,162,393,2013,166,393,2016,165,388,2013,162,386,2014,165,395,2014,166,394,2017,164,387,2014,165,379,2012,163,381,2007,160,388,2013,164,394,2018,164,388,2016,163,383,2013,165,380,2013,164,383,2010,164,388,2012,160,390,2014,161,386,2012,160,384,2012,159,386,2013,164,382,2014,164,384,2015,164,383,2015,162,385,2015,163,386,2015,161,382,2012,160,382,2016,160,381,2009,160,381,2013,163,384,2017,167,386,2017,167,386,2016,160,385,2019,159,376,2012,159,378,2011,162,384,2013,164,387,2014,162,382,2016,163,381,2015,165,383,2013,164,383,2016,162,379,2013,158,385,2014,159,385,2014,163,384,2016,165,379,2014,162,378,2013,164,383,2014,163,384,2015,158,383,2017}, +}; +static const uint32_t duration_SPO2[] = +{ +1013, +1048, +1062, +1059, +1037, +1062, +1065, +1038, +1058, +1060, +1040, +1058, +1060, +1039, +1060, +1060, +1036, +1061, +1061, +1040, +1059, +1062, +1035, +1060, +1062, +1034, +1062, +1059, +1060, +1038, +1060, +1061, +1036, +1060, +1061, +1037, +1062, +1063, +1037, +1059, +1060, +1145, +1059, +1063, +1036, +1062, +1062, +1037, +1059, +1061, +1035, +1060, +1061, +1048, +1047, +1064, +1048, +1049, +1063, +}; + +static const uint8_t frame_SPO2[] = +{ +1, +2, +3, +4, +5, +6, +7, +8, +9, +10, +11, +12, +13, +14, +15, +16, +17, +18, +19, +20, +21, +22, +23, +24, +25, +26, +27, +28, +29, +30, +31, +32, +33, +34, +35, +36, +37, +38, +39, +40, +41, +42, +43, +44, +45, +46, +47, +48, +49, +50, +51, +52, +53, +54, +55, +56, +57, +58, +59, +}; + +#endif diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/pxialg_spo2.h b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/pxialg_spo2.h new file mode 100644 index 000000000..fdda92655 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/pxialg_spo2.h @@ -0,0 +1,152 @@ +#ifndef __PXIALG_SPO2_H__ +#define __PXIALG_SPO2_H__ + + +#include + + +#if defined(WIN32) && !defined(PXIALG_STATIC_LIB) +# ifdef PXIALG_EXPORTS +# define PXIALG_API __declspec(dllexport) +# else +# define PXIALG_API __declspec(dllimport) +# endif +#else +# define PXIALG_API +#endif // WIN32 + +#pragma pack(1) +typedef struct SpO2_mems { + int16_t data[3]; +} SpO2_mems_t; + +typedef struct SpO2_info { + float IR_DC; + float R_DC; + float G_DC; + float IR_AC; + float R_AC; + float G_AC; + float R_IR_Ratio; + float R_G_Ratio; + float G_IR_Ratio; + float Noise; + float SpO2_ref; + float PI; + float PVI; + float RMS; + float MEMS; + float Output[5]; + float xyz_mean[3]; +} SpO2_info_t; +#pragma pack() + +typedef enum { + SPO2_MSG_SUCCESS = 0, + SPO2_MSG_ALG_NOT_OPEN, + SPO2_MSG_ALG_REOPEN, + SPO2_MSG_ALG_NOT_SUPPORT, + SPO2_MSG_INVALID_ARGUMENT, + SPO2_MSG_MOVING_SPO2_READY = 0x100, + SPO2_MSG_MOVING_SPO2_NOT_READY, + SPO2_MSG_MOVING_SPO2_STOP, +}spo2_msg_code_t; + + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + + +PXIALG_API uint32_t SpO2_OpenSize(void); +PXIALG_API int SpO2_Open(void *mem); +PXIALG_API int SpO2_Close(void); +PXIALG_API int SpO2_GetSpO2(float *spo2); +PXIALG_API int SpO2_GetReadyFlag(uint8_t *ready_flag); +PXIALG_API int SpO2_GetPeriodicity(float *periodicity); +PXIALG_API int SpO2_Version(void); +PXIALG_API int SpO2_Process(int touch_flag, int total_channel, int *input, int samples_per_ch, float time_in); +PXIALG_API int SpO2_ProcessD(int touch_flag, int total_channel, int *input, int samples_per_ch, float time_in); +PXIALG_API int SpO2_GetFilteredData(int touch_flag, int total_channel, int expo_R, int expo_IR, int DAC_R, int DAC_IR, float **filter_R, float **filter_IR, int *FilteredDataLength); + +//parameters +PXIALG_API int SpO2_SetIIRFilterRatio(float IIRFilterRatio); //0 ~ 0.5. bigger value more smooth. +PXIALG_API int SpO2_SetMotionDetectionLevel(float level); +PXIALG_API int SpO2_SetInputModelScale(float scale); +PXIALG_API int SpO2_SetInputCorrelationTh(float th); +PXIALG_API int SpO2_SetInputRatioLow(float ratio); +PXIALG_API int SpO2_SetInputCoefLow0(float coef); +PXIALG_API int SpO2_SetInputCoefLow1(float coef); +PXIALG_API int SpO2_SetInputCoefLow2(float coef); +PXIALG_API int SpO2_SetInputCoefLow3(float coef); +PXIALG_API int SpO2_SetInputCoefMid0(float coef); +PXIALG_API int SpO2_SetInputCoefMid1(float coef); +PXIALG_API int SpO2_SetInputCoefMid2(float coef); +PXIALG_API int SpO2_SetInputCoefMid3(float coef); +PXIALG_API int SpO2_SetInputCoefHigh0(float coef); +PXIALG_API int SpO2_SetInputCoefHigh1(float coef); +PXIALG_API int SpO2_SetInputCoefHigh2(float coef); +PXIALG_API int SpO2_SetInputCoefHigh3(float coef); +PXIALG_API int SpO2_SetInputRatioHighBound(float bound); +PXIALG_API int SpO2_SetInputRatioLowBound(float bound); +PXIALG_API int SpO2_SetInputFlagCheckHr(int value); +PXIALG_API int SpO2_SetOutputHighBound(float value); +PXIALG_API int SpO2_SetOutputLowBound(float value); +PXIALG_API int SpO2_Set_Init_Low_SpO2_Constrain(int value); +PXIALG_API int SpO2_Set_Init_Low_SpO2_Th(float value); + +PXIALG_API int SpO2_Set_Init_Low_SpO2_Check_Sec(int value); + +PXIALG_API int SpO2_Set_Motion_Rms_Th(float value); +PXIALG_API int SpO2_Set_Motion_Rms_Th2(float value); + +PXIALG_API int SpO2_Set_Correlation_Th2_Count(int value); +PXIALG_API int SpO2_Set_Input_Correlation_Th2(float value); + +PXIALG_API int SpO2_Set_Flag_Hold_Breathe_Mode(char value); + +PXIALG_API int SpO2_Set_Keep_Init_SpO2_Bound(float value); +PXIALG_API int SpO2_Set_Keep_Init_SpO2_Count_Th(int value); +PXIALG_API int SpO2_Set_SpO2_Bias_Value(float value); +PXIALG_API int SpO2_Set_SpO2_Outlier_Smooth_Coef(float value); +PXIALG_API int SpO2_Set_SpO2_Decrease_Coef(float value); + +PXIALG_API int SpO2_Set_Motion_MEMS_Th(float value); + +PXIALG_API int SpO2_Set_T1(float value); +PXIALG_API int SpO2_Set_T2(float value); +PXIALG_API int SpO2_Set_T3(float value); +PXIALG_API int SpO2_Set_T4(float value); +PXIALG_API int SpO2_Set_T5(float value); +PXIALG_API int SpO2_Set_Spo2_Force_Output_Second(int value); + +PXIALG_API int Spo2_Set_SpO2_First_Smooth_Th(float value); +PXIALG_API int Spo2_Set_SpO2_First_Smooth_Sec(int value); +PXIALG_API int Spo2_Set_SpO2_Correlation_Smooth_Th(float value); + +//set HR +PXIALG_API int SpO2_SetHrValue(int value); + +//get SPO2_Info +PXIALG_API int SpO2_GetInfo(SpO2_info_t *info); + +PXIALG_API int SpO2_SetMems(SpO2_mems_t *mems, int samples); + +PXIALG_API int SpO2_Set_Update_Sec(int spo2_update_sec); + +PXIALG_API int SpO2_SetMemsRmsThr(float mems_rms_thr); +PXIALG_API int SpO2_CalAvgSpO2(float mySpO2, float trust_flag, float mems_rms, float *result); //called every one second +PXIALG_API int SpO2_SetSkipDataLen(int len); +PXIALG_API int SpO2_SetChMapping(int8_t *alg_ch, int8_t ch_nr); + +PXIALG_API int Spo2_Set_Force_Output_Value(float value); +PXIALG_API int Spo2_Set_Force_Output_Value2(float value); + +PXIALG_API int SpO2_Set_Signal_Periodicity_Th(float value); + +#ifdef __cplusplus +} +#endif // __cplusplus + + +#endif diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/test_library_SPO2.c b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/test_library_SPO2.c new file mode 100644 index 000000000..2f76e5259 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_spo2/V703/test_library_SPO2.c @@ -0,0 +1,432 @@ +// algorithm +#include "pxialg_spo2.h" +// HR algorithm +#include "pxialg.h" +// testpattern +#include "pah8009_testpattern_SPO2.h" +// platform +#include + +#include "pah800x_main.h" +//#include "system_clock.h" +//#include "i2c.h" +//#include "gpio_ctrl.h" +//#include "pah_comm.h" +#include +#include "nrf_delay.h" +#define array_szie(arr) (sizeof(arr) / sizeof(arr[0])) + +#define SAMPLES_PER_CHANNEL 25 +#define TOTAL_CHANNEL 3 + +//#define Open_Rest_Flow + +static SpO2_mems_t mems_data_raw[150]; //add item + +typedef struct +{ + void *pBuffer; + void *hr_pBuffer; +} pxialg_spo2_state; + +//#define parameter_printf(...) NRF_LOG_RAW_INFO(__VA_ARGS__) + +extern void spo2_log_printf(char s, float f); +//static void spo2_log_printf(char s, float f) +//{ +// parameter_printf("%s= "LOG_FLOAT_MARKER" \n",s, LOG_FLOAT(f)); + +//} + + + + +static void bubblesort(float *input,int count) +{ + int i,j; + float sort_temp; + for(i=0;i=25) ) + { + alg_count = alg_count -25; + if (ReadyFlag > 0) + { + LOG_PRINT("myHR = "LOG_FLOAT_MARKER" ",LOG_FLOAT(myHR)); + //nrf_delay_ms(10); + LOG_PRINT(",grade = "LOG_FLOAT_MARKER" ",LOG_FLOAT(hr_grader)); + //nrf_delay_ms(10); + LOG_PRINT(",spo2 = "LOG_FLOAT_MARKER" ",LOG_FLOAT(mySpO2)); + //nrf_delay_ms(10); + LOG_PRINT(",correlation = "LOG_FLOAT_MARKER" ",LOG_FLOAT(correlation)); + //nrf_delay_ms(10); + LOG_PRINT(",trust_flag = "LOG_FLOAT_MARKER" ",LOG_FLOAT(trust_flag)); + //nrf_delay_ms(10); + LOG_PRINT(", SignalPeriodicity = "LOG_FLOAT_MARKER" ",LOG_FLOAT(SignalPeriodicity)); + //nrf_delay_ms(10); + LOG_PRINT(",MEMS_RMS = "LOG_FLOAT_MARKER" ",LOG_FLOAT(MEMS_RMS)); + //nrf_delay_ms(10); + LOG_PRINT(",reason = %d \n",no_value_reason); + } + else + { + LOG_PRINT("myHR = "LOG_FLOAT_MARKER" ",LOG_FLOAT(myHR)); + //nrf_delay_ms(10); + LOG_PRINT(",grade = "LOG_FLOAT_MARKER" ",LOG_FLOAT(hr_grader)); + //nrf_delay_ms(10); + LOG_PRINT(",spo2 = "LOG_FLOAT_MARKER" ",LOG_FLOAT(mySpO2)); + //nrf_delay_ms(10); + LOG_PRINT(",correlation = "LOG_FLOAT_MARKER" ",LOG_FLOAT(correlation)); + //nrf_delay_ms(10); + LOG_PRINT(",trust_flag = "LOG_FLOAT_MARKER" ",LOG_FLOAT(trust_flag)); + //nrf_delay_ms(10); + LOG_PRINT(", SignalPeriodicity = "LOG_FLOAT_MARKER" ",LOG_FLOAT(SignalPeriodicity)); + //nrf_delay_ms(10); + LOG_PRINT(",MEMS_RMS = "LOG_FLOAT_MARKER" ",LOG_FLOAT(MEMS_RMS)); + //nrf_delay_ms(10); + LOG_PRINT(",reason = %d \n",no_value_reason); + + } + +// float new_spo2=mySpO2; + + + #if defined(Optimize_SPO2_flow) + //time_accu=time_accu+time; + LOG_PRINT("time_accu = %d\n",time_accu); + if(time_accu>=31000) + { + spo2_array[count]=mySpO2; + count=count+1; + + LOG_PRINT("Over_30_sec_Stop_measurement\n"); + LOG_PRINT("This_meausrement_suggest_spo2_value is"); + + bubblesort(spo2_array,count); + + if(count % 2 == 0) + { + //LOG_PRINT(" "LOG_FLOAT_MARKER" \n", LOG_FLOAT(spo2_array[count/2])); + LOG_PRINT(" "LOG_FLOAT_MARKER" \n",LOG_FLOAT((spo2_array[(int)(count/2)] + spo2_array[(int)(count/2) - 1]) / 2.0f)); + } + else + { + LOG_PRINT(" "LOG_FLOAT_MARKER"\n", LOG_FLOAT(spo2_array[(int)(count/2)]*1.0f)); + } + count=0; + nrf_delay_ms(50); + //add sensor stop here + SpO2_Close(); + PxiAlg_Close(); + free(pBuffer); + free(_spo2_state.hr_pBuffer); + //NRF_LOG_FLUSH(); + return; + + } + else + { + if(mySpO2>0) + { + spo2_array[count]=mySpO2; + count=count+1; + } + + } + #endif + } + else + { + + switch (ret_value) + { + case SPO2_MSG_ALG_NOT_OPEN: + LOG_PRINT("Algorithm is not initialized. \n"); + break; + + case SPO2_MSG_ALG_REOPEN: + LOG_PRINT("Algorithm is re initialized. \n"); + break; + + case SPO2_MSG_ALG_NOT_SUPPORT: + LOG_PRINT("Algorithm is not support. \n"); + break; + case SPO2_MSG_SUCCESS: + //LOG_PRINT("Algorithm is SUCCESS. \n"); + break; + default: + LOG_PRINT("Algorithm unhandle error = %d \n", ret_value); + break; + } + } + + + + nrf_delay_ms(40); + } + + LOG_PRINT("Out of memory. \n"); + nrf_delay_ms(10); + SpO2_Close(); + PxiAlg_Close(); + free(pBuffer); + free(_spo2_state.hr_pBuffer); + return; +} diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_stress/V6033/pxialg_hrv.h b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_stress/V6033/pxialg_hrv.h new file mode 100644 index 000000000..0e2a0079a --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/algorithm/pah_stress/V6033/pxialg_hrv.h @@ -0,0 +1,72 @@ +#ifndef _PXIALG_HRV_ +#define _PXIALG_HRV_ +#include "stdint.h" + +typedef struct +{ + void *pBuffer; + float collect_duration; + uint8_t has_got_sdnn; +} hrv_state_s; + + + +#if defined(WIN32) && !defined(PXIALG_STATIC_LIB) +# ifdef PXIALG_EXPORTS +# define PXIALG_API __declspec(dllexport) +# else +# define PXIALG_API __declspec(dllimport) +# endif +#else +# define PXIALG_API +#endif // WIN32 + + +#ifdef __cplusplus +extern "C" +{ +#endif + PXIALG_API int HRVReset(void); + PXIALG_API int HRVGetMemorySize(int enable_lhr, int test_seconds, int sampling_rate); + PXIALG_API int HRVOpen(void *p_buffer); + PXIALG_API int HRVProcess(int data_ready, float data); + PXIALG_API int HRVProcessD(int data_ready, uint32_t data); + PXIALG_API int HRVClose(void); + + PXIALG_API int HRVGetVersion(void); + PXIALG_API float HRVGetSDNN(void); + PXIALG_API int HRVGetSDNNLevel(int m_iAge, float dSDNN); + PXIALG_API float HRVGetLHRatio(float *nlf, float *nhf); + PXIALG_API float HRVGetRMSSD(void); + PXIALG_API int HRVGetSleepQuality(int age); + PXIALG_API int HRVGetOnlineRRIReportFlag(void); + PXIALG_API float HRVGetOnlineRRI(void); + PXIALG_API int HRVGetRawRRINum(void); + PXIALG_API float * HRVGetRawRRIBuf(void); + PXIALG_API float HRVGetNoiseRate(void); + PXIALG_API float HRVGetRRIStability(void); + PXIALG_API float HRVGetRRIQuality(void); + PXIALG_API int HRVGetReadyFlag(void); + PXIALG_API int HRVGetMotionFlag(void); + PXIALG_API int HRVGetAnomalyFlag(void); + PXIALG_API int HRVGetHRAvg(void); + + PXIALG_API void HRVSetSkipCounterTh(int SkipCounterTh); + PXIALG_API void HRVSetFreqOffset(float FreqOffset); + PXIALG_API void HRVSetDiffTime(float DiffTime, int SampleNum); + PXIALG_API void HRVSetPeakProcessReadyCounterTh(int PeakProcessReady3Counter_Th0, + int PeakProcessReady3Counter_Th1, + int PeakProcessReady3Counter_Th2, + int PeakProcessReady3Counter_Th3, + int m_PeakProcessReady3Counter_HeartRate_Th1, + int m_PeakProcessReady3Counter_HeartRate_Th2, + int m_PeakProcessReady3Counter_HeartRate_Th3); + + PXIALG_API float HRVGetStress(int grade); + +#ifdef __cplusplus +} +#endif + +#endif /* _PXIALG_HRV_ */ + diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah8009_factory_reg.h b/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah8009_factory_reg.h new file mode 100644 index 000000000..af20cbf7a --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah8009_factory_reg.h @@ -0,0 +1,94 @@ +#ifndef __pah8009_factory_reg_h__ +#define __pah8009_factory_reg_h__ + +// pah +#include "pah800x_factory_test.h" + + +static const uint8_t PAH_800x_REG_DEVICE_INIT_FACTORY[][2] = { +// { 0xEE,0x07 }, //SW RESET + { 0xE8,0x00 },//Close suspend + { 0xD1,0xD0 },//{R_GPIO_0_IEB, R_GPIO_1_IEB, R_GPIO_0_OEB, R_GPIO_1_OEB, R_GPIO_0_PULLL_EnH, R_GPIO_1_PULLL_EnH, R_GPIO_0_PULLH_EnH, R_GPIO_1_PULLH_EnH}; + { 0xD2,0x00 },//R_GPIO_0_Open_Drain_EnH(0xD2[5]), 1(0x20):GPIO default open-drain mode, 0(0x00):GPIO debug mode + { 0xD3,0x20 },//GPIO debug select +// { 0xD6,0x30 },//{Dummy, R_I2C_SLEW, R_I2C_DRV[1:0], Dummy[3:0]} +// { 0xD5,0x44 },//IO-level(I2C), 44:3.3V, 00:1.8V +// { 0xB2,0x25 }, + { 0x55,0x24 },//Soft Reset:04 Hard Reset:24 + { 0x52,0x12 },//VDDAY=1.63V +// { 0xA6,0xF7 },//Cmd_vdday_pwrsv_sel_EnH=0 + { 0xAE,0x3F },//R_LPO_Cali_mode=1 +}; + +static const uint8_t PAH_800x_REG_BRIGHTNESS_TEST_FACTORY[][2] = { + { 0x03,0x40 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x06 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x08,0x00 },//A period + { 0x09,0x08 },//A period + { 0x0A,0x00 },//B period + { 0x0B,0x08 },//B period + { 0x0C,0x00 },//C period + { 0x0D,0x08 },//C period + { 0x0E,0x01 },//RDB_FrameNum_A[6:0] + { 0x0F,0x01 },//RDB_FrameNum_B[6:0] + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x77 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x14,0x52 },//{RDB_ChA_congain_sel[1:0], Dummy[0], R_LEDDAC_code0[4:0]} + { 0x15,0x44 },//{RDB_ChB_congain_sel[1:0], Dummy[0], R_LEDDAC_code1[4:0]} + { 0x16,0x44 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x17,0x00 },//RDB_expo_A[7:0] + { 0x18,0x01 },//RDB_expo_A[15:8] + { 0x19,0x00 },//RDB_expo_B[7:0] + { 0x1A,0x01 },//RDB_expo_B[15:8] + { 0x1B,0x00 },//RDB_expo_C[7:0] + { 0x1C,0x01 },//RDB_expo_C[15:8] + { 0x1D,0x2F },//{R_ChA_LED_EnH[2:0], R_ChA_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1E,0x4F },//{R_ChB_LED_EnH[2:0], R_ChB_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0xF7 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x2A },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0xEB,0x80 },//update_flag +// { 0x20,0xF7 },//Clear INT +}; + +static const uint8_t PAH_800x_REG_LEAK_LIGHT_TEST_FACTORY[][2] = { + { 0x03,0x40 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x06 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x08,0x00 },//A period + { 0x09,0x08 },//A period + { 0x0A,0x00 },//B period + { 0x0B,0x08 },//B period + { 0x0C,0x00 },//C period + { 0x0D,0x08 },//C period + { 0x0E,0x01 },//RDB_FrameNum_A[6:0] + { 0x0F,0x01 },//RDB_FrameNum_B[6:0] + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x77 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x14,0x12 },//{RDB_ChA_congain_sel[1:0], Dummy[0], R_LEDDAC_code0[4:0]} + { 0x15,0x0A },//{RDB_ChB_congain_sel[1:0], Dummy[0], R_LEDDAC_code1[4:0]} + { 0x16,0x8A },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x17,0x00 },//RDB_expo_A[7:0] + { 0x18,0x02 },//RDB_expo_A[15:8] + { 0x19,0x00 },//RDB_expo_B[7:0] + { 0x1A,0x02 },//RDB_expo_B[15:8] + { 0x1B,0x20 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1D,0x2F },//{R_ChA_LED_EnH[2:0], R_ChA_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1E,0x4F },//{R_ChB_LED_EnH[2:0], R_ChB_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0xF7 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x2A },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0xEB,0x80 },//update_flag +// { 0x20,0xF7 },//Clear INT +}; + + +//============================================================================ +// Public function +//============================================================================ +void factory_test_mode(factory_test_type test_type, bool expo_adjust_en, uint16_t expo_a, uint16_t expo_b, uint16_t expo_c); + + +#endif // header guard diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah800x_factory_test.c b/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah800x_factory_test.c new file mode 100644 index 000000000..d4cd39c3c --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah800x_factory_test.c @@ -0,0 +1,556 @@ +// pah +#include "pah800x_factory_test.h" +#include "pah8009_factory_reg.h" + +static uint16_t factory_test_ch[3] = {0}; + +//============================================================================ +// Static Global Variable +//============================================================================ +static pah_800x_test_t _factory_state; +static pah_verify_config_t g_config_table[test_type_num] = +{ + //factory_tesst_num=0 + { + .ch_spec[0] = + { + .verify_enabled = BRIGHTNESS_GLODEN_CHA_ENABLE, + .min_enabled = BRIGHTNESS_GLODEN_CHA_MIN_ENABLE, .max_enabled = BRIGHTNESS_GLODEN_CHA_MAX_ENABLE, + .min = BRIGHTNESS_GLODEN_CHA_MIN, .max = BRIGHTNESS_GLODEN_CHA_MAX + }, + .ch_spec[1] = + { + .verify_enabled = BRIGHTNESS_GLODEN_CHB_ENABLE, + .min_enabled = BRIGHTNESS_GLODEN_CHB_MIN_ENABLE, .max_enabled = BRIGHTNESS_GLODEN_CHB_MAX_ENABLE, + .min = BRIGHTNESS_GLODEN_CHB_MIN, .max = BRIGHTNESS_GLODEN_CHB_MAX + }, + .ch_spec[2] = + { + .verify_enabled = BRIGHTNESS_GLODEN_CHC_ENABLE, + .min_enabled = BRIGHTNESS_GLODEN_CHC_MIN_ENABLE, .max_enabled = BRIGHTNESS_GLODEN_CHC_MAX_ENABLE, + .min = BRIGHTNESS_GLODEN_CHC_MIN, .max = BRIGHTNESS_GLODEN_CHC_MAX + }, + .test_regs = + { + .init_reg_arr = + { + .reg_arr = (pah_reg*)PAH_800x_REG_DEVICE_INIT_FACTORY, + .reg_arr_len = PAH_ARRAY_SIZE(PAH_800x_REG_DEVICE_INIT_FACTORY) + }, + .test_reg_arr = + { + .reg_arr = (pah_reg*)PAH_800x_REG_BRIGHTNESS_TEST_FACTORY, + .reg_arr_len = PAH_ARRAY_SIZE(PAH_800x_REG_BRIGHTNESS_TEST_FACTORY) + } + } + }, + + //factory_tesst_num=1 + { + .ch_spec[0] = + { + .verify_enabled = BRIGHTNESS_TARGET_CHA_ENABLE, + .min_enabled = BRIGHTNESS_TARGET_CHA_MIN_ENABLE, .max_enabled = BRIGHTNESS_TARGET_CHA_MAX_ENABLE, + .min = BRIGHTNESS_TARGET_CHA_MIN, .max = BRIGHTNESS_TARGET_CHA_MAX + }, + .ch_spec[1] = + { + .verify_enabled = BRIGHTNESS_TARGET_CHB_ENABLE, + .min_enabled = BRIGHTNESS_TARGET_CHB_MIN_ENABLE, .max_enabled = BRIGHTNESS_TARGET_CHB_MAX_ENABLE, + .min = BRIGHTNESS_TARGET_CHB_MIN, .max = BRIGHTNESS_TARGET_CHB_MAX + }, + .ch_spec[2] = + { + .verify_enabled = BRIGHTNESS_TARGET_CHC_ENABLE, + .min_enabled = BRIGHTNESS_TARGET_CHC_MIN_ENABLE, .max_enabled = BRIGHTNESS_TARGET_CHC_MAX_ENABLE, + .min = BRIGHTNESS_TARGET_CHC_MIN, .max = BRIGHTNESS_TARGET_CHC_MAX + }, + .test_regs = + { + .init_reg_arr = + { + .reg_arr = (pah_reg*)PAH_800x_REG_DEVICE_INIT_FACTORY, + .reg_arr_len = PAH_ARRAY_SIZE(PAH_800x_REG_DEVICE_INIT_FACTORY) + }, + .test_reg_arr = + { + .reg_arr = (pah_reg*)PAH_800x_REG_BRIGHTNESS_TEST_FACTORY, + .reg_arr_len = PAH_ARRAY_SIZE(PAH_800x_REG_BRIGHTNESS_TEST_FACTORY) + } + } + }, + + //factory_tesst_num=2 + { + .ch_spec[0] = + { + .verify_enabled = LEAK_LIGHT_TARGET_CHA_ENABLE, + .min_enabled = LEAK_LIGHT_TARGET_CHA_MIN_ENABLE, .max_enabled = LEAK_LIGHT_TARGET_CHA_MAX_ENABLE, + .min = LEAK_LIGHT_TARGET_CHA_MIN, .max = LEAK_LIGHT_TARGET_CHA_MAX + }, + .ch_spec[1] = + { + .verify_enabled = LEAK_LIGHT_TARGET_CHB_ENABLE, + .min_enabled = LEAK_LIGHT_TARGET_CHB_MIN_ENABLE, .max_enabled = LEAK_LIGHT_TARGET_CHB_MAX_ENABLE, + .min = LEAK_LIGHT_TARGET_CHB_MIN, .max = LEAK_LIGHT_TARGET_CHB_MAX + }, + .ch_spec[2] = + { + .verify_enabled = LEAK_LIGHT_TARGET_CHC_ENABLE, + .min_enabled = LEAK_LIGHT_TARGET_CHC_MIN_ENABLE, .max_enabled = LEAK_LIGHT_TARGET_CHC_MAX_ENABLE, + .min = LEAK_LIGHT_TARGET_CHC_MIN, .max = LEAK_LIGHT_TARGET_CHC_MAX + }, + .test_regs = + { + .init_reg_arr = + { + .reg_arr = (pah_reg*)PAH_800x_REG_DEVICE_INIT_FACTORY, + .reg_arr_len = PAH_ARRAY_SIZE(PAH_800x_REG_DEVICE_INIT_FACTORY) + }, + .test_reg_arr = + { + .reg_arr = (pah_reg*)PAH_800x_REG_LEAK_LIGHT_TEST_FACTORY, + .reg_arr_len = PAH_ARRAY_SIZE(PAH_800x_REG_LEAK_LIGHT_TEST_FACTORY) + } + } + }, + + //factory_tesst_num=3 + { + .test_regs = + { + .init_reg_arr = + { + .reg_arr = (pah_reg*)PAH_800x_REG_DEVICE_INIT_FACTORY, + .reg_arr_len = PAH_ARRAY_SIZE(PAH_800x_REG_DEVICE_INIT_FACTORY) + }, + .test_reg_arr = + { + .reg_arr = (pah_reg*)PAH_800x_REG_LEAK_LIGHT_TEST_FACTORY, + .reg_arr_len = PAH_ARRAY_SIZE(PAH_800x_REG_LEAK_LIGHT_TEST_FACTORY) + } + } + } + +}; + +//============================================================================ +// Private function +//============================================================================ +static void pah_sensor_factory_mode_init(factory_test_type test_type, bool expo_adjust_en, uint16_t expo_a, uint16_t expo_b, uint16_t expo_c); +static void pah_sensor_factory_mode_start(void); +static void pah_sensor_factory_mode_stop(void); +static void pah_sensor_factory_mode_task(void); +static void pah_sensor_factory_mode_verify_result(void); + +static pah_ret _pah_800x_hal_comm_write(uint8_t addr, const uint8_t *data, size_t write_size); +static pah_ret _pah_800x_hal_comm_read(uint8_t addr, uint8_t *data, size_t read_size); +static pah_ret _comm_write(uint8_t addr, uint8_t data); + +static pah_ret _pah_800x_hal_write_reg_arr(const pah_reg_arr *reg_arr); +static pah_ret _pah_800x_hal_write_reg_array(const uint8_t reg_array[][2], size_t length); +static pah_ret _pah_800x_hal_write_suspend_state(bool suspend); +static pah_ret _pah_800x_hal_write_interrupt_clear(void); +static pah_ret _pah_800x_hal_write_ch_exposure(uint16_t expo_a, uint16_t expo_b, uint16_t expo_c, uint8_t ch_num); +static pah_ret _pah_800x_hal_tg_toggle(bool enable); +static pah_ret _pah_800x_hal_update_flag(void); + +static pah_ret _pah_800x_hal_read_product_id(uint16_t *product_id); +static pah_ret _pah_800x_hal_read_ppg_interrupt(uint8_t *ppg_interrupt); +static pah_ret _pah_800x_hal_read_ppg_overflow(uint8_t *ppg_overflow, uint8_t *overflow_num); +static pah_ret _pah_800x_hal_read_ppg_adc(uint16_t *ppg_adc, uint8_t ch_num); +static pah_ret _pah_800x_hal_check_enable_channel(pah_800x_test_t *factory_state, const pah_reg_arr *reg_arr); + + +//============================================================================ +// Public function +//============================================================================ +void factory_test_mode(factory_test_type test_type, bool expo_adjust_en, uint16_t expo_a, uint16_t expo_b, uint16_t expo_c) +{ + LOG_PRINT("test_type=%d\n{\n factory_test_brightness_golden_sample=0\n " \ + "factory_test_brightness_target_sample=1\n factory_test_leak_light_target_sample=2\n " \ + "factory_test_power_noise=3\n factory_test_INT_high=4\n factory_test_INT_low=5\n}\n", test_type); + + pah_sensor_factory_mode_init(test_type, expo_adjust_en, expo_a, expo_b, expo_c); + + pah_sensor_factory_mode_start(); + + pah_delay_ms(25); + + if (test_type < factory_test_power_noise) + { + pah_sensor_factory_mode_task(); + pah_sensor_factory_mode_verify_result(); + pah_sensor_factory_mode_stop(); + } + else + { + return; + } + + pah_delay_ms(500); + + return; + +} + + +//============================================================================ +// Private function +//============================================================================ +static void pah_sensor_factory_mode_init(factory_test_type test_type, bool expo_adjust_en, uint16_t expo_a, uint16_t expo_b, uint16_t expo_c) +{ + DEBUG_PRINT("%s(%d)\n", __func__, test_type); + + memset(&_factory_state, 0, sizeof(_factory_state)); + + uint16_t product_id = 0; + _pah_800x_hal_read_product_id(&product_id); + DEBUG_PRINT("product_id = 0x%04X\n", product_id); + if (product_id != PAH_800x_PRODUCT_ID) + { + DEBUG_PRINT("Failed to verify product_id\n"); + } +/**/ + for (int ch_index=0; ch_index<3; ch_index++) + { + _factory_state.verify_config.ch_spec[ch_index] = g_config_table[test_type].ch_spec[ch_index]; + } + + _factory_state.verify_config.test_regs = g_config_table[test_type].test_regs; + _pah_800x_hal_write_reg_arr(&_factory_state.verify_config.test_regs.init_reg_arr); + _pah_800x_hal_write_reg_arr(&_factory_state.verify_config.test_regs.test_reg_arr); + _pah_800x_hal_check_enable_channel(&_factory_state, &_factory_state.verify_config.test_regs.test_reg_arr); +/**/ + if (expo_adjust_en) + { + for(uint8_t ch_num=0; ch_num 0); + if (has_ppg_interrupt > 0) + { + for (uint8_t ch_num=0; ch_num < PAH_800x_MAX_CH_NUM; ch_num++) + { + if (_factory_state.test_ch_enabled[ch_num]) + { + _pah_800x_hal_read_ppg_adc(&_factory_state.test_result.adc[ch_num], ch_num); + } + } + } + + //clear_interrupt(state, has_ppg_interrupt, state->ppg_result.has_overflow); + +} + +static void pah_sensor_factory_mode_verify_result(void) +{ + DEBUG_PRINT("%s\n", __func__); + LOG_PRINT("=============== Verify_Result ===============\n" \ + "{\n result=1 : pass\n result=0 : fail\n}\n"); + + for (int i=0; i _factory_state.verify_config.ch_spec[i].max) + { + _factory_state.verify_result.ch_result[i].is_passed = false; + } + else + { + _factory_state.verify_result.ch_result[i].is_passed = true; + } + printf("ch[%d] : (min, value, max)=(%d, %d, %d), result=%d \n",\ + i, _factory_state.verify_config.ch_spec[i].min, \ + _factory_state.test_result.adc[i], \ + _factory_state.verify_config.ch_spec[i].max, \ + _factory_state.verify_result.ch_result[i].is_passed); + } + else if (_factory_state.verify_config.ch_spec[i].verify_enabled + && _factory_state.verify_config.ch_spec[i].min_enabled) + { + if (_factory_state.test_result.adc[i] < _factory_state.verify_config.ch_spec[i].min) + { + _factory_state.verify_result.ch_result[i].is_passed = false; + } + else + { + _factory_state.verify_result.ch_result[i].is_passed = true; + } + printf("ch[%d] : (min, value)=(%d, %d), result=%d \n",\ + i, _factory_state.verify_config.ch_spec[i].min, \ + _factory_state.test_result.adc[i], \ + _factory_state.verify_result.ch_result[i].is_passed); + } + else if (_factory_state.verify_config.ch_spec[i].verify_enabled + && _factory_state.verify_config.ch_spec[i].max_enabled) + { + if (_factory_state.test_result.adc[i] > _factory_state.verify_config.ch_spec[i].max) + { + _factory_state.verify_result.ch_result[i].is_passed = false; + } + else + { + _factory_state.verify_result.ch_result[i].is_passed = true; + } + + factory_test_ch[i] = _factory_state.test_result.adc[i]; + + printf("ch[%d] : (value, max)=(%d, %d), result=%d \n",\ + i, _factory_state.test_result.adc[i], \ + _factory_state.verify_config.ch_spec[i].max, \ + _factory_state.verify_result.ch_result[i].is_passed); + } + } +} + + +//============================================================================ +// Private function (HAL) +//============================================================================ +static pah_ret _pah_800x_hal_comm_write(uint8_t addr, const uint8_t *data, size_t write_size) +{ + //return plat->comm.write(&plat->comm, addr, data, write_size); + //return plat->comm.write(addr, data, write_size); + return pah_comm_i2c_write(addr, data, write_size); +} + +static pah_ret _pah_800x_hal_comm_read(uint8_t addr, uint8_t *data, size_t read_size) +{ + + //return plat->comm.read(&plat->comm, addr, data, read_size); + return pah_comm_i2c_read(addr, data, read_size); +} + +static pah_ret _comm_write(uint8_t addr, uint8_t data) +{ + //return pah_800x_hal_comm_write( addr, &data, 1); + return _pah_800x_hal_comm_write(addr, &data, 1); +} +#define _comm_read(addr, data) _pah_800x_hal_comm_read(addr, data, 1) +#define _comm_burst_read(addr, data, read_size) _pah_800x_hal_comm_read(addr, data, read_size) + + +static pah_ret _pah_800x_hal_write_reg_arr(const pah_reg_arr *reg_arr) +{ + return _pah_800x_hal_write_reg_array(reg_arr->reg_arr, reg_arr->reg_arr_len); +} + +static pah_ret _pah_800x_hal_write_reg_array(const uint8_t reg_array[][2], size_t length) +{ + size_t i = 0; + uint8_t reg_value = 0; + for (i = 0; i < length; ++i) + { + //for trim bit + if(reg_array[i][0] == 0x14) + { + _comm_read(0x14, ®_value); + reg_value = (reg_value & 0x1F) | (reg_array[i][1] & 0xE0); + _comm_write(reg_array[i][0], reg_value); + } + else + _comm_write(reg_array[i][0], reg_array[i][1]); + } + return PAH_RET_SUCCESS; +} + +static pah_ret _pah_800x_hal_write_suspend_state(bool suspend) +{ + uint8_t data = 0; + DEBUG_PRINT("%s(%d)\n", __func__, suspend); + if (suspend) + { + _comm_read(PAH_800x_ADDR_E8, &data); + PAH_SET_BIT(data, PAH_800x_ADDR_E8_CMD_SUSPEND_MODE_BIT); + _comm_write(PAH_800x_ADDR_E8, data); + } + else + { + _comm_read(PAH_800x_ADDR_E8, &data); + PAH_CLEAR_BIT(data, PAH_800x_ADDR_E8_CMD_SUSPEND_MODE_BIT); + _comm_write(PAH_800x_ADDR_E8, data); + + } + DEBUG_PRINT("%s(%d) end\n", __func__, suspend); + + return PAH_RET_SUCCESS; +} + +static pah_ret _pah_800x_hal_write_interrupt_clear(void) +{ + uint8_t data = 0; + // DR interrupt + _comm_read(PAH_800x_ADDR_20, &data); + //PAH_CLEAR_BIT(data, PAH_800x_ADDR_20_BIT_DR_FLAG); + _comm_write(PAH_800x_ADDR_20, (data|0x04)); //SD-revise-20191205 + return PAH_RET_SUCCESS; +} + +static pah_ret _pah_800x_hal_write_ch_exposure(uint16_t expo_a, uint16_t expo_b, uint16_t expo_c, uint8_t ch_num) +{ + //uint8_t data = 0; + DEBUG_PRINT("%s(%d, %d, %d, %d)\n", __func__, expo_a, expo_b, expo_c, ch_num); + + uint8_t a_exposure_low = PAH_UINT16_LOW(expo_a); + uint8_t a_exposure_high = PAH_UINT16_HIGH(expo_a); + uint8_t b_exposure_low = PAH_UINT16_LOW(expo_b); + uint8_t b_exposure_high = PAH_UINT16_HIGH(expo_b); + uint8_t c_exposure_low = PAH_UINT16_LOW(expo_c); + uint8_t c_exposure_high = PAH_UINT16_HIGH(expo_c); + + if(ch_num == PAH_800x_CH_NUM_A) + { + _comm_write(PAH_800x_ADDR_17, a_exposure_low); + _comm_write(PAH_800x_ADDR_18, a_exposure_high); + } + else if(ch_num == PAH_800x_CH_NUM_B) + { + _comm_write(PAH_800x_ADDR_19, b_exposure_low); + _comm_write(PAH_800x_ADDR_1A, b_exposure_high); + } + else if(ch_num == PAH_800x_CH_NUM_C) + { + _comm_write(PAH_800x_ADDR_1B, c_exposure_low); + _comm_write(PAH_800x_ADDR_1C, c_exposure_high); + } + + return PAH_RET_SUCCESS; +} + +static pah_ret _pah_800x_hal_tg_toggle(bool enable) +{ + uint8_t data = 0; + DEBUG_PRINT("%s(%d)\n", __func__, enable); + _comm_read( PAH_800x_ADDR_07_TG, &data); + if(enable) + PAH_SET_BIT(data, PAH_800x_ADDR_07_TG_BIT_EN); + else + PAH_CLEAR_BIT(data, PAH_800x_ADDR_07_TG_BIT_EN); + _comm_write(PAH_800x_ADDR_07_TG, data); + + return PAH_RET_SUCCESS; +} + +static pah_ret _pah_800x_hal_update_flag(void) +{ + _comm_write(PAH_800x_ADDR_EB, PAH_800x_ADDR_E8_UPDATE_FLAG); + + return PAH_RET_SUCCESS; +} + +static pah_ret _pah_800x_hal_read_product_id(uint16_t *product_id) +{ + return _comm_burst_read(PAH_800x_ADDR_00_PRODUCT_ID, (uint8_t *)product_id,2); +} + +static pah_ret _pah_800x_hal_read_ppg_interrupt(uint8_t *ppg_interrupt) +{ + uint8_t data = 0; + _comm_read(PAH_800x_ADDR_20, &data); + if (ppg_interrupt) + *ppg_interrupt = PAH_CHECK_BIT(data, PAH_800x_ADDR_20_BIT_DR_FLAG); + + return PAH_RET_SUCCESS; +} + +static pah_ret _pah_800x_hal_read_ppg_overflow(uint8_t *ppg_overflow, uint8_t *overflow_num) +{ + uint8_t data = 0; + _comm_read( PAH_800x_ADDR_20, &data); + if (ppg_overflow) + { + *ppg_overflow = PAH_CHECK_BIT(data, PAH_800x_ADDR_20_BIT_OVERFLOW_FLAG); + *overflow_num = (data&0x70)>>4; + } + return PAH_RET_SUCCESS; +} + +static pah_ret _pah_800x_hal_read_ppg_adc(uint16_t *ppg_adc, uint8_t ch_num) +{ + uint16_t data = 0; + + if(ch_num == PAH_800x_CH_NUM_A) + _comm_burst_read(PAH_800x_ADDR_2E, (uint8_t*)&data, 2); + else if(ch_num == PAH_800x_CH_NUM_B) + _comm_burst_read(PAH_800x_ADDR_39, (uint8_t*)&data, 2); + else if(ch_num == PAH_800x_CH_NUM_C) + _comm_burst_read(PAH_800x_ADDR_44, (uint8_t*)&data, 2); + + //*ppg_adc = data >> 2; + *ppg_adc = data >> 2; + + return PAH_RET_SUCCESS; +} + +static pah_ret _pah_800x_hal_check_enable_channel(pah_800x_test_t *factory_state, const pah_reg_arr *reg_arr) +{ + for(int i=0;ireg_arr_len;i++) + { + if(reg_arr->reg_arr[i][0] == PAH_800x_ADDR_11_EnCh) + { + uint8_t data = reg_arr->reg_arr[i][1]; + factory_state->test_ch_enabled[0] = PAH_CHECK_BIT(data, 0); // CH A + factory_state->test_ch_enabled[1] = PAH_CHECK_BIT(data, 1); // CH B + factory_state->test_ch_enabled[2] = PAH_CHECK_BIT(data, 2); // CH C + } + } + + return PAH_RET_SUCCESS; +} + + +void pah8009_get_leaklight_data(uint16_t *ch0,uint16_t *ch1,uint16_t *ch2) +{ + *ch0 = factory_test_ch[0]; + *ch1 = factory_test_ch[1]; + *ch2 = factory_test_ch[2]; + + factory_test_ch[0] = 0; + factory_test_ch[1] = 0; + factory_test_ch[2] = 0; +} diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah800x_factory_test.h b/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah800x_factory_test.h new file mode 100644 index 000000000..7519958b8 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/factory/pah800x_factory_test.h @@ -0,0 +1,160 @@ +#ifndef __pah800x_factory_test_h__ +#define __pah800x_factory_test_h__ + +// pah +//#include "pah_800x.h" +#include "pah_unit.h" +#include "pah_800x_config.h" + + +//============================================================================ +// Definition +//============================================================================ + +/*---------Brightness Test Golden Option---------*/ +#define BRIGHTNESS_GLODEN_CHA_ENABLE true +#define BRIGHTNESS_GLODEN_CHA_MIN_ENABLE true +#define BRIGHTNESS_GLODEN_CHA_MAX_ENABLE true +#define BRIGHTNESS_GLODEN_CHA_MIN 7600 +#define BRIGHTNESS_GLODEN_CHA_MAX 8400 +#define BRIGHTNESS_GLODEN_CHB_ENABLE true +#define BRIGHTNESS_GLODEN_CHB_MIN_ENABLE true +#define BRIGHTNESS_GLODEN_CHB_MAX_ENABLE true +#define BRIGHTNESS_GLODEN_CHB_MIN 7600 +#define BRIGHTNESS_GLODEN_CHB_MAX 8400 +#define BRIGHTNESS_GLODEN_CHC_ENABLE true +#define BRIGHTNESS_GLODEN_CHC_MIN_ENABLE true +#define BRIGHTNESS_GLODEN_CHC_MAX_ENABLE true +#define BRIGHTNESS_GLODEN_CHC_MIN 7600 +#define BRIGHTNESS_GLODEN_CHC_MAX 8400 + +/*---------Brightness Test Target Option---------*/ +#define BRIGHTNESS_TARGET_CHA_ENABLE true +#define BRIGHTNESS_TARGET_CHA_MIN_ENABLE true +#define BRIGHTNESS_TARGET_CHA_MAX_ENABLE true +#define BRIGHTNESS_TARGET_CHA_MIN 2400 +#define BRIGHTNESS_TARGET_CHA_MAX 15200 +#define BRIGHTNESS_TARGET_CHB_ENABLE true +#define BRIGHTNESS_TARGET_CHB_MIN_ENABLE true +#define BRIGHTNESS_TARGET_CHB_MAX_ENABLE true +#define BRIGHTNESS_TARGET_CHB_MIN 2400 +#define BRIGHTNESS_TARGET_CHB_MAX 15200 +#define BRIGHTNESS_TARGET_CHC_ENABLE true +#define BRIGHTNESS_TARGET_CHC_MIN_ENABLE true +#define BRIGHTNESS_TARGET_CHC_MAX_ENABLE true +#define BRIGHTNESS_TARGET_CHC_MIN 4000 +#define BRIGHTNESS_TARGET_CHC_MAX 12000 + +/*---------Brightness Test Target Option---------*/ +#define LEAK_LIGHT_TARGET_CHA_ENABLE true +#define LEAK_LIGHT_TARGET_CHA_MIN_ENABLE false +#define LEAK_LIGHT_TARGET_CHA_MAX_ENABLE true +#define LEAK_LIGHT_TARGET_CHA_MIN 0 +#define LEAK_LIGHT_TARGET_CHA_MAX 160 +#define LEAK_LIGHT_TARGET_CHB_ENABLE true +#define LEAK_LIGHT_TARGET_CHB_MIN_ENABLE false +#define LEAK_LIGHT_TARGET_CHB_MAX_ENABLE true +#define LEAK_LIGHT_TARGET_CHB_MIN 0 +#define LEAK_LIGHT_TARGET_CHB_MAX 160 +#define LEAK_LIGHT_TARGET_CHC_ENABLE true +#define LEAK_LIGHT_TARGET_CHC_MIN_ENABLE false +#define LEAK_LIGHT_TARGET_CHC_MAX_ENABLE true +#define LEAK_LIGHT_TARGET_CHC_MIN 0 +#define LEAK_LIGHT_TARGET_CHC_MAX 160 + + +//============================================================================ +// Type Definition +//============================================================================ +typedef enum +{ + factory_test_brightness_golden_sample, + factory_test_brightness_target_sample, + factory_test_leak_light_target_sample, + factory_test_power_noise, + factory_test_INT_high, + factory_test_INT_low, + test_type_num, + +} factory_test_type; + +typedef struct +{ + bool verify_enabled; + + bool min_enabled; + bool max_enabled; + + uint16_t min; + uint16_t max; + +} pah_ch_verify_spec_t; + +typedef struct +{ + pah_reg_arr init_reg_arr; + pah_reg_arr test_reg_arr; + +} pah_verify_reg_t; + +typedef struct +{ + pah_ch_verify_spec_t ch_spec[PAH_800x_MAX_CH_NUM]; + + pah_verify_reg_t test_regs; + +} pah_verify_config_t; + +typedef struct +{ + bool has_data; + + // Avaiable only if has_data is true + bool has_overflow; + + uint8_t overflow_num; + + // Avaiable only if has_data is true + uint16_t exposure_time[PAH_800x_MAX_CH_NUM]; + uint16_t adc[PAH_800x_MAX_CH_NUM]; + +} pah_test_result_t; + +typedef struct +{ + uint16_t adc; + + bool is_passed; + +} pah_ch_verify_result_t; + +typedef struct +{ + pah_ch_verify_result_t ch_result[PAH_800x_MAX_CH_NUM]; + +} pah_verify_result_t; + +typedef struct +{ + // Config + //pah_plat plat; + pah_verify_config_t verify_config; + + bool test_ch_enabled[PAH_800x_MAX_CH_NUM]; + + // PPG state + pah_test_result_t test_result; + + // verify + pah_verify_result_t verify_result; + +} pah_800x_test_t; + + +//============================================================================ +// Public function +//============================================================================ +void factory_test_mode(factory_test_type test_type, bool expo_adjust_en, uint16_t expo_a, uint16_t expo_b, uint16_t expo_c); +void pah8009_get_leaklight_data(uint16_t *ch0,uint16_t *ch1,uint16_t *ch2); + +#endif // header guard diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_bsp.c b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_bsp.c new file mode 100644 index 000000000..b7c25d5bd --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_bsp.c @@ -0,0 +1,95 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2025-05-27 11:09:04 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-28 16:43:06 + * @FilePath: /sdk615/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_bsp.c + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +// pah +#include "pah800x_bsp.h" +#include "custom_utils.h" +#include "systick.h" + +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_hal.h" +#endif + +//============================================================================ +// Definition +//============================================================================ +#define PAH800xx_I2C_SLAVE_ID 0x40 +#define I2C_PPG_PORT_ID 1 +#define PAH800xx_I2C_BUS I2C_BUS_2 + +//============================================================================ +// Public function +//============================================================================ +void pah_delay_ms(uint32_t ms) +{ + // pxi_nrf_delay_ms(ms); + LOS_Mdelay(ms); +} + +uint64_t pah_get_tick_count(void) +{ + // return pxi_nrf_get_tick_count(); + uint64_t cnt = uapi_systick_get_ms(); + // printf("cnt : %llu\n",cnt); + return cnt; +} + +pah_ret pah_comm_i2c_write(uint8_t addr, const uint8_t *data, size_t write_size) +{ + //DEBUG_PRINT("W A:0x%02x,D:0x%02x\n",addr,*data); + // pxi_nrf_i2c_write(addr, data, write_size); + custom_i2c_write_reg(PAH800xx_I2C_SLAVE_ID, addr, 1, data, write_size, PAH800xx_I2C_BUS); + + return PAH_RET_SUCCESS; +} + +pah_ret pah_comm_i2c_read(uint8_t addr, uint8_t *data, size_t read_size) +{ + // pxi_nrf_i2c_read(addr, data, read_size); + custom_i2c_read_regs(PAH800xx_I2C_SLAVE_ID, addr, 1 , data, read_size, PAH800xx_I2C_BUS); + //DEBUG_PRINT("R A:0x%02x,D:0x%02x\n",addr,*data); + return PAH_RET_SUCCESS; +} + +void pah_print( + int32_t fileline, + const char *funcname, + const char *filename, + const char *format, ...) +{ + UNUSED_VAR(fileline); + UNUSED_VAR(funcname); + UNUSED_VAR(filename); + + char dest[256]; + va_list argptr; + int char_num = 0; + + if (!format) + return; + + va_start(argptr, format); + char_num = vsprintf(dest, format, argptr); + va_end(argptr); + + //uart_printf("%s", dest); + + //dest[char_num] = '\n'; + // pxi_nrf_uart_transmit((uint8_t*)dest, (uint16_t)(char_num + 1)); +} + +void ReadGSensor(float *x, float *y, float *z) +{ +#ifdef SUPPORT_CYWEE_SERVICE + gsenson_t data = {0}; + cywee_get_gsensor_data(1,&data); + *x = data.x; + *y = data.y; + *z = data.z; +#endif +} diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_bsp.h b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_bsp.h new file mode 100644 index 000000000..cae483f3b --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_bsp.h @@ -0,0 +1,46 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2025-05-27 11:09:04 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-05-27 11:32:50 + * @FilePath: /sdk615/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_bsp.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +#ifndef __pah_800x_bsp_h__ +#define __pah_800x_bsp_h__ + +// c +#include +#include +#include +#include + +// pah +#include "pah_unit.h" +#include "pah_800x_config.h" + + +//============================================================================ +// Public function +//============================================================================ +#ifdef __cplusplus +extern "C" { +#endif + +void pah_delay_ms(uint32_t ms); +uint64_t pah_get_tick_count(void); +pah_ret pah_comm_i2c_write(uint8_t addr, const uint8_t *data, size_t write_size); +pah_ret pah_comm_i2c_read(uint8_t addr, uint8_t *data, size_t read_size); +void pah_print( + int32_t fileline, + const char *funcname, + const char *filename, + const char *format, ...); + +void ReadGSensor(float *x, float *y, float *z); + +#ifdef __cplusplus +} +#endif + +#endif // header guard diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c new file mode 100644 index 000000000..d03000b3a --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.c @@ -0,0 +1,1865 @@ +// pah +#include "pah800x_main.h" +//#include "pah_8009_reg_arr_default.h" +#include "pxialg_spo2.h" +#include "pxialg_hrv.h" +#include "pxivar.h" +#include "pah_8009_reg_arr_default_20220623.h" +#include "pah800x_factory_test.h" +#include "cmsis_os2.h" + +#ifdef SUPPORT_PPG_SERVICE +#include "ppg_service.h" +#include "ppg_hal.h" +#endif +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_service.h" +#endif +#include "custom_runtime.h" +#ifdef SUPPORT_PPG_BLE_SERVICE +#include "ppgBleService.h" +#endif +//============================================================================ +// Static Global Variable +//============================================================================ +static main_state _main; +static ppg_mems_data_t ppg_mems_data_buf[FIFO_SIZE] ; +static int _read_index = 0 ; +static int _write_index = 0 ; + +// hr algotirhm +static float hr = 0.0f; +static float hr_grader =0.0f; +static ppg_mems_data_t ppg_mems_data_alg; + +// spo2 algorithm +void *pBuffer = NULL; +void *hr_pBuffer = NULL; +static float myHR = 0.0f; +static float mySpO2 = 0.0f; +static float correlation = 0.0f; +static float trust_flag = 0.0f; +static float MEMS_RMS = 0.0f; +uint8_t mySPO2_ReadyFlag = 0 ; +static uint8_t no_value_reason = 0 ; +static float SignalPeriodicity=0.0f ; + +static int time_accu = 0 ; +static int count =0; +static float spo2_array[31]={0.0f}; + +static uint32_t data_buf_count_spo2_alg=0; + +static SpO2_info_t _spo2_detect_item; +pah8series_data_t pxialg_data_spo2; +static SpO2_mems_t mems_data_raw[150]; +#ifdef PPG_MEMS_Synchronize +//int16_t mems_int_data_in[90] ={0}; +int16_t mems_int_data_out[90]={0}; +int time_temp=0; +static uint8_t ppg_data_num=0; +uint8_t mems_data_polling_ready = 0 ; +#endif + +// Stress Algorithm +static hrv_state_s _hrv_state; +void *stress_pBuffer = NULL; +#define HRV_ENABLE_LHR 1 +#define HRV_SAMPLING_RATE 20 +#define HRV_COLLECTION_SECONDS 180 +static uint32_t duration_total = 0; +uint8_t SDNN_ReadyFlag = 0; +uint8_t Get_Stress = 0; +static float Stress = 0.0f; +static uint8_t HRAvg = 0; +static float SQ_Stress = 0.0f; +static uint8_t AnomalyFlag = 0; +uint8_t Stress_ReadyFlag = 0; +uint8_t Weak_Flag = 0; + +static int32_t factory_data = 0; +static uint8_t work_mode = 0; +static uint8_t wear_status = 0; + +static osTimerId_t g_pah8009_timer = NULL; + +static uint8_t time_cnt = 0; + +static int history_wear_status = -1; + + +#if POLLING_MODE +static int time_out = 40; +#endif + +static uint8_t hrs_num = 0; +static int32_t sum_hrs = 0; +static int8_t hrs_data[7] = {0}; +static uint8_t left = 0; +static uint8_t right = -1; +static uint8_t avg_hrs = 0; + +static uint8_t timeout = 0; + +//============================================================================ +// Private function +//============================================================================ +static bool sensor_basic_verification(void); +static void process(uint64_t timestamp); +static void ppg_sensor_enable(void); +static void ppg_sensor_disable(void); +static void touch_sensor_enable(void); +static void touch_sensor_disable(void); + +static void report_touch_data(uint64_t timestamp, const int8_t *touch_flag); +static void report_ppg_data(const ppg_mems_data_t *ppg_mems_data_alg); +static void report_hr_data(const ppg_mems_data_t *ppg_mems_data_alg, int32_t ret, float hr, float hr_grader); +static void report_spo2_data(const ppg_mems_data_t *ppg_mems_data_alg, int32_t ret, float myHR, float mySpO2, float correlation, float trust_flag, float MEMS_RMS, int data_buf_count_spo2_alg, uint8_t no_value_reason, float SignalPeriodicity, int time_accu ); +static void report_stress_data(const ppg_mems_data_t *ppg_mems_data_alg, uint8_t Stress_ReadyFlag, uint32_t measuretime, float collect_time); + +static void error_handle(void); + + +static void pah8009_unwearstatus_update(void) +{ + uint8_t data = 0; + printf("uapi_dev_runtime_get_train_status() : %d\n",uapi_dev_runtime_get_train_status()); + if(uapi_dev_runtime_get_train_status()) + { +#ifdef SUPPORT_CYWEE_SERVICE + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_HRS_CHANGE,&data); +#endif + } + else + { +// #ifdef SUPPORT_PPG_SERVICE +// ppg_msg_callback_t func = ppg_get_send_msg_callback_func(); +// if(func != NULL) +// { +// //为了主界面脱腕灵敏;需要增加未佩戴 +// func(PPG_MSG_TYPE_HRS_UPDATE, &data, 1); +// func(PPG_MSG_TYPE_WEARSTAT_UPDATE, &data,1); +// func(PPG_MSG_TYPE_WEARSTAT_UPDATE,&data,1); +// func(PPG_MSG_TYPE_WEARSTAT_UPDATE,&data,1); +// } +// #endif + } + +} + +static void pah8009_wearstatus_update(int wear_status) +{ + if(history_wear_status != wear_status) + { + history_wear_status = wear_status; +#ifdef SUPPORT_CYWEE_SERVICE + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_WEAR_STATUS_CHANGE,(uint8_t *)&history_wear_status); +#endif + // if(wear_status != 1) + // { + // pah8009_unwearstatus_update(); + // } + } + +} + +static void bubblesort(float *input,int count) +{ + int i,j; + float sort_temp; + for(i=0;i= FIFO_SIZE) + tmp = 0 ; + if(tmp == _read_index) + return false; + ppg_mems_data_buf[tmp] = *data ; + _write_index = tmp ; + return true; +} + +bool pah_pop(ppg_mems_data_t *data) +{ + int tmp ; + if(isFIFOEmpty()) + return false; + tmp = _read_index + 1; + if(tmp >= FIFO_SIZE) + tmp = 0 ; + _read_index = tmp ; + *data = ppg_mems_data_buf[_read_index] ; + + return true; +} + + +//============================================================================ +// Public function +//============================================================================ +void pah_sensor_init(reg_config_type type) +{ + memset(&_main, 0, sizeof(_main)); + + pah_800x_reg_setting reg_setting; + memset(®_setting, 0, sizeof(reg_setting)); + + if (!sensor_basic_verification()) + { + // error_handle(); + LOG_PRINT("sensor_basic_verification failed\n"); + return; + } + + + // pah_800x + pah_800x_config pah_800x_config; + pah_800x_get_default_config(&pah_800x_config); + LOG_PRINT("PPG_SETTING_VESION = %d \n" ,PPG_SETTING_VERSION); + +#if (ENABLE_AE==0) + pah_800x_config.enable_ppg_convergence[0] = false; + pah_800x_config.enable_ppg_convergence[1] = false; + pah_800x_config.enable_ppg_convergence[2] = false; +#endif + +#if (ENABLE_AE_RECONVERGENCE==0) + pah_800x_config.enable_ppg_reconvergence_if_out_of_bounds[0] = false; + pah_800x_config.enable_ppg_reconvergence_if_out_of_bounds[1] = false; + pah_800x_config.enable_ppg_reconvergence_if_out_of_bounds[2] = false; +#endif + + if (type == pc_4mm_2g_ir_hrd) + { +#if (PC_4MM_2G_IR_HRD==1) + PAH_REG_ARR_SETUP(reg_setting.startup_init, PAH8009_REG_DEVICE_INIT); + PAH_REG_ARR_SETUP(reg_setting.ppg_enable, PAH8009_REG_PC_4MM_2G_IR_PPG); + PAH_REG_ARR_SETUP(reg_setting.touch_enable, PAH8009_REG_PC_4MM_2G_IR_TOUCH); +#endif + } + else if (type == diw_4mm_g_ir_hrd) + { +#if (DIW_4MM_G_IR_HRD==1) + PAH_REG_ARR_SETUP(reg_setting.startup_init, PAH8009_REG_DEVICE_INIT); + PAH_REG_ARR_SETUP(reg_setting.ppg_enable, PAH8009_REG_DIW_4MM_G_IR_PPG); + PAH_REG_ARR_SETUP(reg_setting.touch_enable, PAH8009_REG_DIW_4MM_G_IR_TOUCH); +#endif + } + else if (type == diw_4mm_ir_r_ir_spo2) + { +#if (DIW_4MM_IR_R_IR_SPO2==1) + for(int ch=0;ch 2) + { + min_hrs = hrs_data[0]; + max_hrs = hrs_data[0]; + for (int i = 0;i < hrs_num; i++) + { + if (hrs_data[i] < min_hrs) + min_hrs = hrs_data[i]; + if (hrs_data[i] > max_hrs) + max_hrs = hrs_data[i]; + } + avg_hrs = (sum_hrs - max_hrs - min_hrs) / (hrs_num - 2); + printf("max_hrs[%d],min_hrs[%d],avg_hrs[%d]\n",max_hrs,min_hrs,avg_hrs); + } +} + +void hr_alg_task(void) +{ + if(Check_alg_enable()) + { + if(Check_alg_enable()==MSG_ALG_ENABLE) + { + hr_algorithm_enable(); + }else if(Check_alg_enable()==MSG_ALG_DISABLE) + { + hr_algorithm_disable(); + } + Clear_alg_enable(); + } + + if(!isFIFOEmpty()) + { + if(pah_pop(&ppg_mems_data_alg)) //Get data from FIFO + { + if(_main.hr_is_enabled) + { + ppg_mems_data_alg.ppg_data.has_overflow = 0; + ppg_mems_data_alg.ppg_data.overflow_num = 0; + + + + // 13Bytes format to hr lib; + sRaw_Data_13Bytes hr_data; + + memset(&hr_data, 0, sizeof(hr_data)); + hr_data.loss = (uint8_t)ppg_mems_data_alg.ppg_data.overflow_num + 1; + hr_data.rawData = ppg_mems_data_alg.ppg_data.data[1]; + hr_data.non_zero1 = 1; + hr_data.non_zero2 = 2; + hr_data.non_zero3 = 3; + hr_data.frame_count = ppg_mems_data_alg.ppg_frame_count; + hr_data.time = ppg_mems_data_alg.duration; + hr_data.rsv = 0; + hr_data.touch = (ppg_mems_data_alg.touch_flag > 0 ? 0x80 : 0x00); + hr_data.rsv2 = 0; + + int32_t ret = PxiAlg_Process_Expo((uint8_t*)&hr_data, ppg_mems_data_alg.MEMS_Data, ppg_mems_data_alg.ppg_data.exposure_time[1]); + + + if(PxiAlg_GetHrUpdateFlag()) + { + PxiAlg_HrGet(&hr); + PxiAlg_GetSigGrade(&hr_grader); + } + if(ppg_mems_data_alg.touch_flag==0) + { + hr = 0 ; + hr_grader = 0; + } + + // if(hr > 0) + // printf("hr:%f\n",hr); +#ifdef SUPPORT_PPG_SERVICE + time_cnt++; + + if(time_cnt >= 15) + { + // ppg_msg_callback_t func = ppg_get_send_msg_callback_func(); + + uint8_t data = (uint8_t)hr; + + if(data > 30 && data < 220) + get_avg_hrs(data); + + // printf("func(PPG_MSG_TYPE_HRS_UPDATE, &avg_hrs, 1); :%d\n",avg_hrs); + // func(PPG_MSG_TYPE_HRS_UPDATE, &avg_hrs, 1); + + // data = cywee_wear_status; + // func(PPG_MSG_TYPE_WEARSTAT_UPDATE, &data, 1); + time_cnt = 0; + +#ifdef SUPPORT_PPG_BLE_SERVICE + if(uapi_dev_runtime_get_hrs_ble_status()) + { + ble_ppgtest_server_send_input_report(&avg_hrs,1); + } +#endif + } + + + + +#endif + report_hr_data(&ppg_mems_data_alg, ret, hr, hr_grader); + + + } + else + { + report_ppg_data(&ppg_mems_data_alg); + } + } + } +} + +// HRD- ALG- Task2 +void hr_alg_task2(uint8_t ppg_num) +{ +#ifdef PPG_MEMS_Synchronize + if(Check_alg_enable()) + { + if(Check_alg_enable()==MSG_ALG_ENABLE) + { + hr_algorithm_enable(); + }else if(Check_alg_enable()==MSG_ALG_DISABLE) + { + hr_algorithm_disable(); + } + Clear_alg_enable(); + } + + if(!isFIFOEmpty()) + { + for (int i=0; i 0 ? 0x80 : 0x00); + hr_data.rsv2 = 0; + + int32_t ret = PxiAlg_Process_Expo((uint8_t*)&hr_data, ppg_mems_data_alg.MEMS_Data, ppg_mems_data_alg.ppg_data.exposure_time[1]); + + + if(PxiAlg_GetHrUpdateFlag()) + { + PxiAlg_HrGet(&hr); + PxiAlg_GetSigGrade(&hr_grader); + } + + report_hr_data(&ppg_mems_data_alg, ret, hr, hr_grader); + + } + else + { + report_ppg_data(&ppg_mems_data_alg); + } + } + } + } +#endif +} + + + +// SPO2 +void spo2_algorithm_enable(void) +{ + if (_main.spo2_is_enabled) + { + return; + } + + + int version = SpO2_Version(); + DEBUG_PRINT("PxiAlg_Version() = %d\n", version); + + uint32_t buffer_size = SpO2_OpenSize(); + DEBUG_PRINT("SpO2_Open buffer_size = %d \n", buffer_size); + + pBuffer = malloc(buffer_size); + + if (SpO2_Open(pBuffer) != SPO2_MSG_SUCCESS) + { + DEBUG_PRINT("SpO2_Open() failed. \n"); + free(pBuffer); + return; + } + int8_t alg_ch[2] = {0, 1}; + + SpO2_SetChMapping(alg_ch, 2); + SpO2_SetInputRatioHighBound(94.0f); + SpO2_SetInputRatioLowBound(87.0f); + SpO2_SetInputModelScale(0.50f); + + SpO2_SetInputCoefHigh0(-36877.85546875f); + SpO2_SetInputCoefHigh1(1135.91394042969f); + SpO2_SetInputCoefHigh2(-11.6429319381714f); + SpO2_SetInputCoefHigh3(0.0398150011897087f); + + SpO2_SetInputCoefMid0(-1430.70520019531f); + SpO2_SetInputCoefMid1(50.1599006652832f); + SpO2_SetInputCoefMid2(-0.567422986030579f); + SpO2_SetInputCoefMid3(0.00219199992716312f); + + SpO2_SetInputCoefLow0(-8.19796657562256f); + SpO2_SetInputCoefLow1(1.74200701713562f); + SpO2_SetInputCoefLow2(-0.0173850003629923f); + SpO2_SetInputCoefLow3(0.000105999999505002f); + + SpO2_SetIIRFilterRatio(0.5f); + SpO2_SetInputCorrelationTh(0.850000078678131f); + SpO2_SetInputRatioLow(0.05f); + + SpO2_SetInputFlagCheckHr(1); + SpO2_SetMotionDetectionLevel(2.0f); + SpO2_Set_Update_Sec(1); + + SpO2_Set_Init_Low_SpO2_Constrain(0.0); + SpO2_SetOutputHighBound(100.0f); + SpO2_SetOutputLowBound(60.0f); + SpO2_Set_Keep_Init_SpO2_Bound(95.0f); + SpO2_Set_Keep_Init_SpO2_Count_Th(18.0f); + SpO2_Set_SpO2_Bias_Value(0.5f); + SpO2_Set_SpO2_Outlier_Smooth_Coef(5.5f); + SpO2_Set_SpO2_Decrease_Coef(0.5f); + SpO2_SetSkipDataLen(25); + + SpO2_Set_Flag_Hold_Breathe_Mode(0); + SpO2_Set_Input_Correlation_Th2(0.85000f); + SpO2_Set_Correlation_Th2_Count(30.0f); + SpO2_Set_Init_Low_SpO2_Th(94.5f); + SpO2_Set_Motion_Rms_Th(3000.0f); + SpO2_Set_Motion_Rms_Th2(1500.0f); + SpO2_Set_Motion_MEMS_Th(0.0f); + SpO2_Set_T1(0.85f); + SpO2_Set_Spo2_Force_Output_Second(15.0f); + + Spo2_Set_Force_Output_Value(97.50f); // Good Signal Force SpO2 + Spo2_Set_Force_Output_Value2(95.00f); // Bad Signal Force SpO2 + + SpO2_Set_Init_Low_SpO2_Check_Sec(20); + Spo2_Set_SpO2_First_Smooth_Th(95.0f); + Spo2_Set_SpO2_First_Smooth_Sec(15); + Spo2_Set_SpO2_Correlation_Smooth_Th(0.85f); + SpO2_Set_Signal_Periodicity_Th(0.50f); + + // static Hr-V301009 + PxiAlg_Close(); + version = PxiAlg_Version(); + DEBUG_PRINT("HR_Version = %d \r\n", version); + + + uint32_t Query_Mem_Size = PxiAlg_Query_Mem_Size(); + DEBUG_PRINT("HR_Mem_Size = %d \r\n", Query_Mem_Size); + + hr_pBuffer = malloc(Query_Mem_Size); + + + if(!PxiAlg_Open_Mem(hr_pBuffer)) + DEBUG_PRINT("PxiAlg_Open_Mem fail \n"); + + + PxiAlg_SetQualityThreshold(0.35f); + PxiAlg_SetHRSmoothWeight(0.9f); + PxiAlg_SetProcWindow(5.0f, 5.0f); + PxiAlg_SetTimeoutLength(30.0f); + PxiAlg_SetMemsScale(1); //MEMS 2/4/8/16G : 0/1/2/3 + PxiAlg_SetSkipSampleNum(10); + PxiAlg_SetMemsScaleBase(1, 0); //MEMS 2/4/8/16G : 0/1/2/3 + PxiAlg_SetForceOutputLink(15, 90, 60, 1, 0.9f); + PxiAlg_SetNormalOutput(200, 40, 1); + PxiAlg_SetForceRipple(3, 1); + PxiAlg_SetPackage(0, 1); + + myHR = 0.0f; + mySpO2 = 0.0f; + correlation = 0.0f; + trust_flag = 0.0f; + MEMS_RMS = 0.0f; + mySPO2_ReadyFlag = 0; + hr_grader = 0.0f; + data_buf_count_spo2_alg=0; + no_value_reason = 0 ; + SignalPeriodicity=0.0f ; + time_accu = 0 ; + count = 0 ; + memset(spo2_array, 0, sizeof(*spo2_array)); + _main.spo2_is_enabled = true; +} + +void spo2_algorithm_disable(void) +{ + if (!_main.spo2_is_enabled) + return; + PxiAlg_Close(); + SpO2_Close(); + free(pBuffer); + free(hr_pBuffer); + myHR = 0.0f; + mySpO2 = 0.0f; + correlation = 0.0f; + trust_flag = 0.0f; + MEMS_RMS = 0.0f; + mySPO2_ReadyFlag = 0; + hr_grader = 0.0f; + data_buf_count_spo2_alg=0; + + no_value_reason = 0 ; + SignalPeriodicity=0.0f ; + time_accu = 0 ; + + + _main.spo2_is_enabled = false; +} + +void spo2_alg_task(void) +{ + if(Check_alg_enable()) + { + if(Check_alg_enable()==MSG_ALG_ENABLE) + { + spo2_algorithm_enable(); + }else if(Check_alg_enable()==MSG_ALG_DISABLE) + { + spo2_algorithm_disable(); + } + Clear_alg_enable(); + } + + if(!isFIFOEmpty()) + { + if(pah_pop(&ppg_mems_data_alg)) //Get data from FIFO + { + if(_main.spo2_is_enabled) + { + // 13Bytes format to hr lib; + + int32_t RAW_DATA[2] ; + sRaw_Data_13Bytes hr_data; + + memset(&hr_data, 0, sizeof(hr_data)); + hr_data.loss = (uint8_t)ppg_mems_data_alg.ppg_data.overflow_num + 1; + hr_data.rawData = ppg_mems_data_alg.ppg_data.data[0]; + hr_data.non_zero1 = 1; + hr_data.non_zero2 = 2; + hr_data.non_zero3 = 3; + hr_data.frame_count = ppg_mems_data_alg.ppg_frame_count; + hr_data.time = ppg_mems_data_alg.duration; + hr_data.rsv = 0; + hr_data.touch = (ppg_mems_data_alg.touch_flag > 0 ? 0x80 : 0x00); + hr_data.rsv2 = 0; + + + int32_t ret = PxiAlg_Process_Expo((uint8_t*)&hr_data, ppg_mems_data_alg.MEMS_Data, ppg_mems_data_alg.ppg_data.exposure_time[0]); + + + + + if(PxiAlg_GetHrUpdateFlag()) + { + PxiAlg_HrGet(&myHR); + PxiAlg_GetSigGrade(&hr_grader); + } + + + int32_t spo2_raw_1=ppg_mems_data_alg.ppg_data.data[0]; + int32_t spo2_raw_2=ppg_mems_data_alg.ppg_data.data[1]; + + RAW_DATA[0]=spo2_raw_1; + RAW_DATA[1]=spo2_raw_2; + + mems_data_raw[0].data[0]=ppg_mems_data_alg.MEMS_Data[0]; + mems_data_raw[0].data[1]=ppg_mems_data_alg.MEMS_Data[1] ; + mems_data_raw[0].data[2]=ppg_mems_data_alg.MEMS_Data[2]; + + // SPO2 fill data on pah8series structure + pxialg_data_spo2.touch_flag = ppg_mems_data_alg.touch_flag ; + pxialg_data_spo2.time = ppg_mems_data_alg.duration ;; + pxialg_data_spo2.ppg_data = (int32_t*)RAW_DATA; + pxialg_data_spo2.nf_ppg_channel = 2; + pxialg_data_spo2.nf_ppg_per_channel = 1; + pxialg_data_spo2.frame_count = ppg_mems_data_alg.ppg_frame_count ; + pxialg_data_spo2.nf_mems = 1; + pxialg_data_spo2.mems_data = (int16_t*)mems_data_raw; + + + + // DEBUG_PRINT("data_buf_count_spo2_alg = %d \r\n", data_buf_count_spo2_alg); + + + SpO2_SetHrValue(myHR); + SpO2_SetMems(mems_data_raw, 1); + //int ret_value = SpO2_Process(ppg_mems_data_alg.touch_flag , 2, pxialg_data_spo2.ppg_data, 1); + int ret_value = SpO2_Process(ppg_mems_data_alg.touch_flag , 2, pxialg_data_spo2.ppg_data, 1,pxialg_data_spo2.time ); + + SpO2_GetSpO2(&mySpO2); + + // if(mySpO2 > 0) + // printf("SpO2 : %f\n",mySpO2); +#ifdef SUPPORT_PPG_SERVICE + time_cnt++; + + // ppg_msg_callback_t func = ppg_get_send_msg_callback_func(); + + // if(func != NULL && time_cnt >= 25) + // { + // uint8_t data = (uint8_t)mySpO2; + // func(PPG_MSG_TYPE_SPO2_UPDATE, &data, 1); + // time_cnt = 0; + // } +#endif + + SpO2_GetReadyFlag(&mySPO2_ReadyFlag); + SpO2_GetInfo(&_spo2_detect_item); + correlation =_spo2_detect_item.Noise; + trust_flag =_spo2_detect_item.Output[3]; + no_value_reason=_spo2_detect_item.Output[4]; + SpO2_GetPeriodicity(&SignalPeriodicity); + MEMS_RMS =_spo2_detect_item.RMS; + + + data_buf_count_spo2_alg++; + + #if defined(Optimize_SPO2_flow) + time_accu=time_accu+pxialg_data_spo2.time; + #endif + + if( (ret_value == 0 ) && (data_buf_count_spo2_alg>=25) ) + { + + #if defined(Optimize_SPO2_flow) + //time_accu=time_accu+pxialg_data->time; + DEBUG_PRINT("SPO2 Test Time = %d ,count =%d\n",time_accu,count); + if(time_accu>=60000) + { + spo2_array[count]=mySpO2; + count=count+1; + + LOG_PRINT("Over_30_sec_Stop_measurement\n"); + LOG_PRINT("This_meausrement_suggest_spo2_value is"); + + bubblesort(spo2_array,count); + + if(count % 2 == 0) + { + //log_printf(" "LOG_FLOAT_MARKER" \n", LOG_FLOAT(spo2_array[count/2])); + LOG_PRINT(" "LOG_FLOAT_MARKER" \n",LOG_FLOAT((spo2_array[(int)(count/2)] + spo2_array[(int)(count/2) - 1]) / 2.0f)); + } + else + { + LOG_PRINT(" "LOG_FLOAT_MARKER" \n", LOG_FLOAT(spo2_array[(int)(count/2)]*1.0f)); + } + + //log_pah8series_no_touch(); + spo2_algorithm_disable(); + pah_sensor_stop(); + count=0; + //add sensor stop here + } + else + { + if(mySpO2>0) + { + spo2_array[count]=mySpO2; + count=count+1; + } + } + #endif + //report_spo2_data(&ppg_mems_data_alg, ret, mySpO2, myHR, correlation, trust_flag, MEMS_RMS,data_buf_count_spo2_alg, Opt_SpO2, drop_flag, ascend_flag, mems_fla); + report_spo2_data(&ppg_mems_data_alg, ret, mySpO2, myHR, correlation, trust_flag, MEMS_RMS,data_buf_count_spo2_alg, no_value_reason, SignalPeriodicity, time_accu); + data_buf_count_spo2_alg = data_buf_count_spo2_alg -25; + } + else + { + //report_spo2_data(&ppg_mems_data_alg, ret, mySpO2, myHR, correlation, trust_flag, MEMS_RMS,data_buf_count_spo2_alg, Opt_SpO2, drop_flag, ascend_flag, mems_flag); + report_spo2_data(&ppg_mems_data_alg, ret, mySpO2, myHR, correlation, trust_flag, MEMS_RMS,data_buf_count_spo2_alg, no_value_reason, SignalPeriodicity, time_accu); + + switch (ret_value) + { + case SPO2_MSG_ALG_NOT_OPEN: + DEBUG_PRINT("Algorithm is not initialized. \n"); + break; + + case SPO2_MSG_ALG_REOPEN: + DEBUG_PRINT("Algorithm is re initialized. \n"); + break; + + case SPO2_MSG_ALG_NOT_SUPPORT: + DEBUG_PRINT("Algorithm is not support. \n"); + break; + + default: + // DEBUG_PRINT("Algorithm unhandle error = %d \n", ret_value); + break; + } + //return 1 ; + } + } + else + { + report_ppg_data(&ppg_mems_data_alg); + } + } + } +} + + + +// SPO2- ALG- Task2 +void spo2_alg_task2(uint8_t ppg_num) +{ +#ifdef PPG_MEMS_Synchronize + if(Check_alg_enable()) + { + if(Check_alg_enable()==MSG_ALG_ENABLE) + { + spo2_algorithm_enable(); + }else if(Check_alg_enable()==MSG_ALG_DISABLE) + { + spo2_algorithm_disable(); + } + Clear_alg_enable(); + } + + if(!isFIFOEmpty()) + { + for (int k=0; k 0 ? 0x80 : 0x00); + hr_data.rsv2 = 0; + + + int32_t ret = PxiAlg_Process_Expo((uint8_t*)&hr_data, ppg_mems_data_alg.MEMS_Data, ppg_mems_data_alg.ppg_data.exposure_time[0]); + + + + + if(PxiAlg_GetHrUpdateFlag()) + { + PxiAlg_HrGet(&myHR); + PxiAlg_GetSigGrade(&hr_grader); + } + + + int32_t spo2_raw_1=ppg_mems_data_alg.ppg_data.data[0]; + int32_t spo2_raw_2=ppg_mems_data_alg.ppg_data.data[1]; + + RAW_DATA[0]=spo2_raw_1; + RAW_DATA[1]=spo2_raw_2; + + mems_data_raw[0].data[0]=ppg_mems_data_alg.MEMS_Data[0]; + mems_data_raw[0].data[1]=ppg_mems_data_alg.MEMS_Data[1] ; + mems_data_raw[0].data[2]=ppg_mems_data_alg.MEMS_Data[2]; + + // SPO2 fill data on pah8series structure + pxialg_data_spo2.touch_flag = ppg_mems_data_alg.touch_flag ; + pxialg_data_spo2.time = ppg_mems_data_alg.duration ;; + pxialg_data_spo2.ppg_data = (int32_t*)RAW_DATA; + pxialg_data_spo2.nf_ppg_channel = 2; + pxialg_data_spo2.nf_ppg_per_channel = 1; + pxialg_data_spo2.frame_count = ppg_mems_data_alg.ppg_frame_count ; + pxialg_data_spo2.nf_mems = 1; + pxialg_data_spo2.mems_data = (int16_t*)mems_data_raw; + + + + //DEBUG_PRINT("data_buf_count_spo2_alg = %d \r\n", data_buf_count_spo2_alg); + + + SpO2_SetHrValue(myHR); + SpO2_SetMems(mems_data_raw, 1); + //int ret_value = SpO2_Process(ppg_mems_data_alg.touch_flag , 2, pxialg_data_spo2.ppg_data, 1); + int ret_value = SpO2_Process(ppg_mems_data_alg.touch_flag , 2, pxialg_data_spo2.ppg_data, 1,pxialg_data_spo2.time ); + + SpO2_GetSpO2(&mySpO2); + SpO2_GetReadyFlag(&mySPO2_ReadyFlag); + SpO2_GetInfo(&_spo2_detect_item); + correlation =_spo2_detect_item.Noise; + trust_flag =_spo2_detect_item.Output[3]; + no_value_reason=_spo2_detect_item.Output[4]; + SpO2_GetPeriodicity(&SignalPeriodicity); + MEMS_RMS =_spo2_detect_item.RMS; + + + data_buf_count_spo2_alg++; + + #if defined(Optimize_SPO2_flow) + time_accu=time_accu+pxialg_data_spo2.time; + #endif + + if( (ret_value == 0 ) && (data_buf_count_spo2_alg>=25) ) + { + + #if defined(Optimize_SPO2_flow) + //time_accu=time_accu+pxialg_data->time; + DEBUG_PRINT("SPO2 Test Time = %d ,count =%d\n",time_accu,count); + if(time_accu>=31000) + { + spo2_array[count]=mySpO2; + count=count+1; + + LOG_PRINT("Over_30_sec_Stop_measurement\n"); + LOG_PRINT("This_meausrement_suggest_spo2_value is"); + + bubblesort(spo2_array,count); + + if(count % 2 == 0) + { + //log_printf(" "LOG_FLOAT_MARKER" \n", LOG_FLOAT(spo2_array[count/2])); + LOG_PRINT(" "LOG_FLOAT_MARKER" \n",LOG_FLOAT((spo2_array[(int)(count/2)] + spo2_array[(int)(count/2) - 1]) / 2.0f)); + } + else + { + LOG_PRINT(" "LOG_FLOAT_MARKER" \n", LOG_FLOAT(spo2_array[(int)(count/2)]*1.0f)); + } + + //log_pah8series_no_touch(); + spo2_algorithm_disable(); + pah_sensor_stop(); + count=0; + //add sensor stop here + } + else + { + if(mySpO2>0) + { + spo2_array[count]=mySpO2; + count=count+1; + } + } + #endif + //report_spo2_data(&ppg_mems_data_alg, ret, mySpO2, myHR, correlation, trust_flag, MEMS_RMS,data_buf_count_spo2_alg, Opt_SpO2, drop_flag, ascend_flag, mems_fla); + report_spo2_data(&ppg_mems_data_alg, ret, mySpO2, myHR, correlation, trust_flag, MEMS_RMS,data_buf_count_spo2_alg, no_value_reason, SignalPeriodicity, time_accu); + data_buf_count_spo2_alg = data_buf_count_spo2_alg -25; + } + else + { + //report_spo2_data(&ppg_mems_data_alg, ret, mySpO2, myHR, correlation, trust_flag, MEMS_RMS,data_buf_count_spo2_alg, Opt_SpO2, drop_flag, ascend_flag, mems_flag); + report_spo2_data(&ppg_mems_data_alg, ret, mySpO2, myHR, correlation, trust_flag, MEMS_RMS,data_buf_count_spo2_alg, no_value_reason, SignalPeriodicity, time_accu); + + switch (ret_value) + { + case SPO2_MSG_ALG_NOT_OPEN: + DEBUG_PRINT("Algorithm is not initialized. \n"); + break; + + case SPO2_MSG_ALG_REOPEN: + DEBUG_PRINT("Algorithm is re initialized. \n"); + break; + + case SPO2_MSG_ALG_NOT_SUPPORT: + DEBUG_PRINT("Algorithm is not support. \n"); + break; + + default: + DEBUG_PRINT("Algorithm unhandle error = %d \n", ret_value); + break; + } + //return 1 ; + } + } + else + { + report_ppg_data(&ppg_mems_data_alg); + } + } + } + } +#endif +} + + + +// Stress +void stress_algorithm_enable(void) +{ + int buffer_size = 0; + if (_main.stress_is_enable) + { + return; + } + + LOG_PRINT("HRVGetVersion() = %d \n", HRVGetVersion()); + buffer_size = HRVGetMemorySize(HRV_ENABLE_LHR, HRV_COLLECTION_SECONDS, HRV_SAMPLING_RATE); + LOG_PRINT("HRVGetMemorySize(), open_size = %d \n", buffer_size); + + if (!buffer_size) + { + LOG_PRINT("HRVGetMemorySize(), failed to get memory size \n"); + return ; + } + + stress_pBuffer = (uint8_t*)malloc(buffer_size); + if (!stress_pBuffer) + { + LOG_PRINT("Out of memory \n"); + return ; + } + + if (!HRVOpen(stress_pBuffer)) + { + LOG_PRINT("HRVOpen() failed. \n"); + return ; + } + duration_total=0; + _hrv_state.collect_duration = 0; + + _main.stress_is_enable = true; +} + +void stress_algorithm_disable(void) +{ + if (!_main.stress_is_enable) + return; + HRVClose(); + free(stress_pBuffer); + + duration_total = 0; + SDNN_ReadyFlag = 0; + Get_Stress = 0; + Stress = 0.0f; + HRAvg = 0; + SQ_Stress = 0.0f; + AnomalyFlag = 0; + Stress_ReadyFlag = 0; + Weak_Flag = 0; + _main.stress_is_enable = false; +} + +void stress_alg_task(int grade) +{ + if(Check_alg_enable()) + { + if(Check_alg_enable()==MSG_ALG_ENABLE) + { + stress_algorithm_enable(); + }else if(Check_alg_enable()==MSG_ALG_DISABLE) + { + stress_algorithm_disable(); + } + Clear_alg_enable(); + } + + if(!isFIFOEmpty()) + { + if(pah_pop(&ppg_mems_data_alg)) //Get data from FIFO + { + if(_main.stress_is_enable) + { + uint32_t raw_data = ppg_mems_data_alg.ppg_data.data[1]; + uint8_t frame_count = ppg_mems_data_alg.ppg_frame_count; + uint8_t timeInterval = ppg_mems_data_alg.duration; + uint8_t touch_flag = ppg_mems_data_alg.touch_flag; + + // If using Interrupt mode call this API + HRVSetDiffTime(timeInterval,1); + + HRVProcess(touch_flag, raw_data); + + duration_total+=timeInterval; + + + if(Stress_ReadyFlag==0) + { + Stress_ReadyFlag=HRVGetReadyFlag(); + } + + if((duration_total>25000)&& Stress_ReadyFlag==0) + { + LOG_PRINT("PPG Raw data is too Weak\r\n"); + LOG_PRINT("TEST Stop\r\n"); + stress_algorithm_disable(); + Weak_Flag=1; + return ; + } + + if(Stress_ReadyFlag == 1 || HRVGetReadyFlag()) + { + Stress_ReadyFlag=1; + _hrv_state.collect_duration += timeInterval; + + if(_hrv_state.collect_duration > (HRV_COLLECTION_SECONDS * 1000)) + { + //int grade=100; + HRAvg = HRVGetHRAvg(); + Stress= HRVGetStress(grade); + SQ_Stress=HRVGetRRIQuality(); + AnomalyFlag= HRVGetAnomalyFlag(); + LOG_PRINT("HRAvg = %d Stress = %f HRV_Quality = %f AnomalyFlag= %d \n", HRAvg ,Stress,SQ_Stress,AnomalyFlag); + + if(SQ_Stress>0.4f) + { + LOG_PRINT("HRV_Quality Good\n"); + } + else + { + LOG_PRINT("HRV_Quality Weak\n"); + } + + + if(Stress >=80 && Stress<=100) + { + LOG_PRINT("Stress_Level High\n"); + } + else if(Stress >=60 && Stress<80) + { + LOG_PRINT("Stress_Level Medium\n"); + } + else if(Stress >=30 && Stress<60) + { + LOG_PRINT("Stress_Level Normal\n"); + } + else + { + LOG_PRINT("Stress_Level Relaxed\n"); + } + + stress_algorithm_disable(); + _hrv_state.has_got_sdnn = 1; + Get_Stress=1; + return ; + } + } + report_stress_data(&ppg_mems_data_alg,Stress_ReadyFlag, duration_total, _hrv_state.collect_duration ); + } + else + { + report_ppg_data(&ppg_mems_data_alg); + LOG_PRINT("Stress_Level Normal\n"); + } + } + } +} + + + + +//============================================================================ +// Private function +//============================================================================ +static bool sensor_basic_verification(void) +{ + uint16_t product_id = 0; + pah_800x_get_product_id(&product_id); + if (product_id != PAH_800x_PRODUCT_ID) + { + pah_800x_power_toggle(&_main.pah_800x, true); + pah_800x_get_product_id( &product_id); + } + + DEBUG_PRINT("product_id = 0x%04X\n", product_id); + if (product_id != PAH_800x_PRODUCT_ID) + { + DEBUG_PRINT("Failed to verify product_id\n"); + return false; + } + + return true; +} + +static void process(uint64_t timestamp) +{ + float mems_data[3] = { 0.0f, 0.0f, 0.0f }; + + // Task + pah_ret ret = pah_800x_task(&_main.pah_800x); + if (PAH_FAILED(ret)) + { + DEBUG_PRINT("pah_800x_task() failed, ret = %d\n", ret); + return; + } + + int8_t touch_flag = -1; + pah_800x_get_touch_flag(&_main.pah_800x, &touch_flag); + + // PRINT("touch_flag : %d\n",touch_flag); + + pah8009_wearstatus_update(touch_flag); + + if (_main.ppg_is_enabled) + { + pah_800x_ppg_data ppg_data; + pah_800x_ppg_get_data(&_main.pah_800x, &ppg_data); + + if (ppg_data.has_data) + { + // LOG_PRINT("ppg data %d %d %d %d %d %d %d %d\n",ppg_data.has_data,ppg_data.overflow_num,ppg_data.data[0],ppg_data.data[1],ppg_data.data[2], + // ppg_data.exposure_time[0],ppg_data.exposure_time[1],ppg_data.exposure_time[2]); + // LOG_PRINT("ppg data %d %d %d %d %d %d\n",ppg_data.frame_period[0],ppg_data.frame_period[1],ppg_data.frame_period[2] + // ,ppg_data.adc[0],ppg_data.adc[1],ppg_data.adc[2]); + + // PRINT("ppg data : %d %d %d\n",ppg_data.data[0],ppg_data.data[1],ppg_data.data[2]); + + factory_data = ppg_data.data[0]; + + uint64_t duration = timestamp - _main.ppg_prev_report_timestamp; + + if (!_main.ppg_has_prev_report_timestamp) + { + _main.ppg_has_prev_report_timestamp = true; + duration = 50; + } + _main.ppg_prev_report_timestamp = timestamp; + + if (duration > UINT8_MAX) + { + DEBUG_PRINT("duration > UINT8_MAX !!!\n"); + return; + } + + ppg_mems_data_t ppg_mems_data; + + /***********************G sensor explanation start***********************************/ + //If no G sensor, please set ppg_mems_data.MEMS_Data[3] = {0}; + //Please set G sensor default range = ±2G. + //If G sensor output data format is not 16bit, please change to 16bit format. + //For example: G sensor is 12bit + //ReadGSensor(&mems_data[0],&mems_data[1],&mems_data[2]) + //MEMS_SensorX() absolute data must be largest when let hand down at static state. + //MEMS_SensorZ() absolute data must be largest when let hand horizontal on the table at static state. + /***********************G sensor explanation end***********************************/ + + ReadGSensor(&mems_data[0],&mems_data[1],&mems_data[2]); + + ppg_mems_data.MEMS_Data[0] = mems_data[0] * 2048 / 10;//ReadGSensorX(); + ppg_mems_data.MEMS_Data[1] = mems_data[1] * 2048 / 10;//ReadGSensorY(); + ppg_mems_data.MEMS_Data[2] = mems_data[2] * 2048 / 10;//ReadGSensorZ(); + // printf("x:%f y:%f z:%f\n",ppg_mems_data.MEMS_Data[0],ppg_mems_data.MEMS_Data[1],ppg_mems_data.MEMS_Data[2]); + ppg_mems_data.duration = duration; + + ppg_mems_data.ppg_data = ppg_data ; + ppg_mems_data.touch_flag = touch_flag ; + ppg_mems_data.ppg_frame_count = _main.ppg_frame_count; //SD-revise-20200320 + + pah_push(&ppg_mems_data); + +#ifdef PPG_MEMS_Synchronize + time_temp+=duration; + mems_data_polling_ready=0; + if(time_temp>=Time_Interval) + { + mems_data_polling_ready=1; + time_temp =0; + } + ppg_data_num++; +#endif + ++_main.ppg_frame_count; + + //report_ppg_data(&ppg_mems_data); + + } + } + + if (_main.is_Auto_mode || _main.touch_is_enabled)//SD-reivse-20191205 + { + if ( _main.touch_last_is_touched != touch_flag) + { + _main.touch_last_is_touched = touch_flag; + + report_touch_data(timestamp, &touch_flag); + + bool is_touched = (touch_flag >= 1); + + if (_main.is_Auto_mode && is_touched)//SD-revise-20191205 + { + //touch_sensor_disable(); + ppg_sensor_enable(); + _main.alg_is_enabled = MSG_ALG_ENABLE; + } + else if (_main.is_Auto_mode && !is_touched) + { + // pah8009_unwearstatus_update(); + ppg_sensor_disable(); + pah_800x_update_touch_setting(&_main.pah_800x); + //touch_sensor_enable(); + _main.alg_is_enabled = MSG_ALG_DISABLE; + } + } + } +} + +static void ppg_sensor_enable(void) +{ + if (_main.ppg_is_enabled) + return; + + pah_800x_ppg_toggle(&_main.pah_800x, true); + + _main.debug_print_header = true; + _main.ppg_has_prev_report_timestamp = false; + _main.ppg_prev_report_timestamp = pah_get_tick_count(); + _main.ppg_frame_count = 0; + + _main.ppg_is_enabled = true; + + _read_index = 0 ; + _write_index = 0 ; +#ifdef PPG_MEMS_Synchronize + ppg_data_num = 0 ; +#endif + //LOG_PRINT("ppg_sensor_enable\n"); +} + +static void ppg_sensor_disable(void) +{ + if (!_main.ppg_is_enabled) + return; + + pah_800x_ppg_toggle(&_main.pah_800x, false); + + _main.ppg_is_enabled = false; +} + +static void touch_sensor_enable(void) +{ + if (_main.touch_is_enabled) + return; + + pah_800x_touch_toggle(&_main.pah_800x, true); + + _main.touch_last_is_touched = 0;//default no touch => touch mode + + _main.touch_is_enabled = true; +} + +static void touch_sensor_disable(void) +{ + if (!_main.touch_is_enabled) + return; + + pah_800x_touch_toggle(&_main.pah_800x, false); + + _main.touch_is_enabled = false; +} + +static void report_touch_data(uint64_t timestamp, const int8_t *touch_flag) +{ + LOG_PRINT("TOUCH: time = { %llu }, touch_flag = { %d } \n", timestamp, *touch_flag ); +} + +static void report_ppg_data(const ppg_mems_data_t *ppg_mems_data_alg) +{ + if (_main.debug_print_header == true) + { + LOG_PRINT("Frame, Time, Touch_Flag, Data_Ready, Overflow_Flag, Overflow_Num, ppg0, ppg1, ppg2, Expo_A, Expo_B, Expo_C, MEMS_X, MEMS_Y, MEMS_Z\n"); + _main.debug_print_header = false; + } + + LOG_PRINT("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", + ppg_mems_data_alg->ppg_frame_count, ppg_mems_data_alg->duration, ppg_mems_data_alg->touch_flag, + ppg_mems_data_alg->ppg_data.has_data, ppg_mems_data_alg->ppg_data.has_overflow, ppg_mems_data_alg->ppg_data.overflow_num, + ppg_mems_data_alg->ppg_data.data[0], ppg_mems_data_alg->ppg_data.data[1], ppg_mems_data_alg->ppg_data.data[2], + ppg_mems_data_alg->ppg_data.exposure_time[0], ppg_mems_data_alg->ppg_data.exposure_time[1], ppg_mems_data_alg->ppg_data.exposure_time[2], + (int)(ppg_mems_data_alg->MEMS_Data[0]), (int)(ppg_mems_data_alg->MEMS_Data[1]), (int)(ppg_mems_data_alg->MEMS_Data[2])); +} + +static void report_hr_data(const ppg_mems_data_t *ppg_mems_data_alg, int32_t ret, float hr, float hr_grader) +{ + if (_main.debug_print_header == true) + { + LOG_PRINT("Frame, Time, Touch_Flag, Data_Ready, Overflow_Flag, Overflow_Num, PPG0, PPG1, PPG2, Expo_A, Expo_B, Expo_C, MEMS_X, MEMS_Y, MEMS_Z, ret, hr, hr_grade\n"); + + _main.debug_print_header = false; + } + + LOG_PRINT("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f\n", + ppg_mems_data_alg->ppg_frame_count, ppg_mems_data_alg->duration, ppg_mems_data_alg->touch_flag, + ppg_mems_data_alg->ppg_data.has_data, ppg_mems_data_alg->ppg_data.has_overflow, ppg_mems_data_alg->ppg_data.overflow_num, + ppg_mems_data_alg->ppg_data.data[0], ppg_mems_data_alg->ppg_data.data[1], ppg_mems_data_alg->ppg_data.data[2], + ppg_mems_data_alg->ppg_data.exposure_time[0], ppg_mems_data_alg->ppg_data.exposure_time[1], ppg_mems_data_alg->ppg_data.exposure_time[2], + (int)(ppg_mems_data_alg->MEMS_Data[0]), (int)(ppg_mems_data_alg->MEMS_Data[1]), (int)(ppg_mems_data_alg->MEMS_Data[2]), ret, hr, hr_grader); + +} + +//static void report_spo2_data(const ppg_mems_data_t *ppg_mems_data_alg, int32_t ret, float mySpO2, float myHR, float correlation, float trust_flag, float MEMS_RMS, int data_buf_count_spo2_alg, , float Opt_SpO2, int drop_flag, int ascend_flag, int mems_flag) +static void report_spo2_data(const ppg_mems_data_t *ppg_mems_data_alg, int32_t ret, float myHR, float mySpO2, float correlation, float trust_flag, float MEMS_RMS, int data_buf_count_spo2_alg, uint8_t no_value_reason, float SignalPeriodicity, int time_accu ) +{ + if (_main.debug_print_header == true) + { + + LOG_PRINT("Frame, Time, Touch_Flag, Data_Ready, Overflow_Flag, Overflow_Num, PPG0, PPG1, PPG2, Expo_A, Expo_B, Expo_C, MEMS_X, MEMS_Y, MEMS_Z, ret, spo2, myHR, hr_grader, correlation, MEMS_RMS, trust, no_value_reason, SignalPeriodicity, time_accu \n"); + _main.debug_print_header = false; + } + + if(data_buf_count_spo2_alg>=25) + { + LOG_PRINT("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %f, %f, %f, %f, %f, %f, %d, %f, %d\n", + ppg_mems_data_alg->ppg_frame_count, ppg_mems_data_alg->duration, ppg_mems_data_alg->touch_flag, + ppg_mems_data_alg->ppg_data.has_data, ppg_mems_data_alg->ppg_data.has_overflow, ppg_mems_data_alg->ppg_data.overflow_num, + ppg_mems_data_alg->ppg_data.data[0], ppg_mems_data_alg->ppg_data.data[1], ppg_mems_data_alg->ppg_data.data[2], + ppg_mems_data_alg->ppg_data.exposure_time[0], ppg_mems_data_alg->ppg_data.exposure_time[1], ppg_mems_data_alg->ppg_data.exposure_time[2], + (int)(ppg_mems_data_alg->MEMS_Data[0]), (int)(ppg_mems_data_alg->MEMS_Data[1]), (int)(ppg_mems_data_alg->MEMS_Data[2]), ret, mySpO2,myHR,hr_grader,correlation, MEMS_RMS,trust_flag,no_value_reason,SignalPeriodicity, time_accu); + } + else + { + LOG_PRINT("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d\n", + ppg_mems_data_alg->ppg_frame_count, ppg_mems_data_alg->duration, ppg_mems_data_alg->touch_flag, + ppg_mems_data_alg->ppg_data.has_data, ppg_mems_data_alg->ppg_data.has_overflow, ppg_mems_data_alg->ppg_data.overflow_num, + ppg_mems_data_alg->ppg_data.data[0], ppg_mems_data_alg->ppg_data.data[1], ppg_mems_data_alg->ppg_data.data[2], + ppg_mems_data_alg->ppg_data.exposure_time[0], ppg_mems_data_alg->ppg_data.exposure_time[1], ppg_mems_data_alg->ppg_data.exposure_time[2], + (int)(ppg_mems_data_alg->MEMS_Data[0]), (int)(ppg_mems_data_alg->MEMS_Data[1]), (int)(ppg_mems_data_alg->MEMS_Data[2]), ret); + + + } +} + + +static void report_stress_data(const ppg_mems_data_t *ppg_mems_data_alg, uint8_t Stress_ReadyFlag, uint32_t measuretime, float collect_time) +{ + if (_main.debug_print_header == true) + { + LOG_PRINT("Frame, Time, Touch_Flag, Data_Ready, Overflow_Flag, Overflow_Num, PPG0, PPG1, PPG2, Expo_A, Expo_B, Expo_C, MEMS_X, MEMS_Y, MEMS_Z, Stress_Ready, measure_time, collect_time\n"); + + _main.debug_print_header = false; + } + + LOG_PRINT("%d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %d, %f\n", + ppg_mems_data_alg->ppg_frame_count, ppg_mems_data_alg->duration, ppg_mems_data_alg->touch_flag, + ppg_mems_data_alg->ppg_data.has_data, ppg_mems_data_alg->ppg_data.has_overflow, ppg_mems_data_alg->ppg_data.overflow_num, + ppg_mems_data_alg->ppg_data.data[0], ppg_mems_data_alg->ppg_data.data[1], ppg_mems_data_alg->ppg_data.data[2], + ppg_mems_data_alg->ppg_data.exposure_time[0], ppg_mems_data_alg->ppg_data.exposure_time[1], ppg_mems_data_alg->ppg_data.exposure_time[2], + (int)(ppg_mems_data_alg->MEMS_Data[0]), (int)(ppg_mems_data_alg->MEMS_Data[1]), (int)(ppg_mems_data_alg->MEMS_Data[2]), Stress_ReadyFlag,duration_total, _hrv_state.collect_duration ); + +} +#ifdef PPG_MEMS_Synchronize +uint8_t get_ppg_data_num(void) +{ + return ppg_data_num; +} +void clear_ppg_data_num(void) +{ + ppg_data_num = 0; +} + +void mems_interpolation(int16_t *mems_int_data_in,uint8_t mems_num,uint8_t ppg_num) +{ + + // Customer Define MEMS-input X, Y, Z + // Put data in mems_int_data_in ,and mems_count + // Then call the PXI_MEMS_interp to do interpolation + + PXI_MEMS_interp(mems_int_data_in, mems_num, mems_int_data_out, ppg_num); + +} +#endif + +static void error_handle(void) +{ + while (true) + { + } +} + + + +uint16_t pah8009_get_chip_id(void) +{ + uint16_t product_id = 0; + pah_800x_get_product_id(&product_id); + return product_id; +} + +int32_t pah8009_get_factory_data(void) +{ + int32_t data = factory_data; + factory_data = 0; + return data; +} + +void pah8009_int_handler(void) +{ + timeout = 1; + ppg_interrupt_handle(); + ppg_sensor_task_interrupt(); + + if(work_mode == 1) + { + // PRINT("hr_alg_task \n"); + hr_alg_task(); + } + else if(work_mode == 2) + { + // PRINT("spo2_alg_task \n"); + spo2_alg_task(); + } + +} + +void pah8009_timer_handler(void) +{ + ppg_sensor_task_polling(); + + if(work_mode == 1) + { + // PRINT("hr_alg_task \n"); + hr_alg_task(); + } + else if(work_mode == 2) + { + // PRINT("spo2_alg_task \n"); + spo2_alg_task(); + } + +} + +static void pah8009_timer_callback(void) +{ + // printf("pah8009_timer_callback \n"); +#ifdef SUPPORT_PPG_SERVICE + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_HRS_TIMER_CALLBACK); +#endif +} + +static void pah8009_timer_init(void) +{ + if(g_pah8009_timer == NULL) + g_pah8009_timer = osTimerNew((osTimerFunc_t)pah8009_timer_callback, osTimerPeriodic, NULL, NULL); +} + +void pah8009_check_int(void) +{ +#if INTERRUPT_MODE + if(work_mode != 1) + { + // printf("work_mode != 1\n"); + return; + } + + if(!timeout) + { + // printf("pah8009_check_int \n"); + pah8009_int_handler(); + } + else + { + timeout = 0; + } +#endif +} + +void pah8009_reset(void) +{ + pah_sensor_stop(); + pah_sensor_init(diw_4mm_g_ir_hrd); + ppg_only_sensor_start(); +} + +void pah8009_control(char *mode,uint8_t enable) +{ + // printf("mode : %s ,enable : %d\n",mode,enable); + if(!enable) + { +#if POLLING_MODE + if(g_pah8009_timer != NULL) + osTimerStop(g_pah8009_timer); +#endif + pah_sensor_stop(); + work_mode = 0; + if(uapi_dev_runtime_get_sleep_monitoring_status() && uapi_dev_runtime_get_hrs_passivity_flag()) + { + pah8009_wearstatus_update(history_wear_status); + uapi_dev_runtime_set_hrs_passivity(0); + } + } + else + { +#if POLLING_MODE + pah8009_timer_init(); +#endif + + time_cnt = 0; + + if (strcmp(mode, "hrs") == 0) { + pah_sensor_init(diw_4mm_g_ir_hrd); + // auto_mode_sensor_start(); + work_mode = 1; + // touch_only_sensor_start(); + ppg_only_sensor_start(); +#if POLLING_MODE + time_out = 30; +#endif + } else if (strcmp(mode, "hrv") == 0) { + // md = HRV_MODE; + } else if (strcmp(mode, "spo2") == 0) { + // md = SPO2_MODE; + pah_sensor_init(diw_4mm_ir_r_ir_spo2); + ppg_only_sensor_start(); + work_mode = 2; +#if POLLING_MODE + time_out = 30; +#endif + } else if (strcmp(mode, "leaklight") == 0) { + // md = FT_LEAK_LIGHT_MODE; + factory_test_mode(factory_test_leak_light_target_sample, 0, 0, 0, 0); + // extern void test_library_HRD(void); + // test_library_HRD(); + } else if (strcmp(mode, "wear") == 0) { + pah_sensor_init(diw_4mm_g_ir_hrd); + touch_only_sensor_start(); +#if POLLING_MODE + time_out = 5000; +#endif + } +#if POLLING_MODE + if(g_pah8009_timer != NULL) + osTimerStart(g_pah8009_timer,time_out); +#endif + } +} + +uint8_t pah8009_get_hrs(void) +{ + return avg_hrs; +} + +uint8_t pah8009_get_spo2(void) +{ + return (uint8_t)mySpO2; +} + +uint8_t pah8009_get_wear_status(void) +{ + return history_wear_status; +} \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.h b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.h new file mode 100644 index 000000000..19cb4bce8 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah800x_main.h @@ -0,0 +1,197 @@ +#ifndef __pah_800x_main_h__ +#define __pah_800x_main_h__ + +// pah +#include "pah_800x.h" +#include "pah_unit.h" +#include "pah_800x_config.h" + + + +//static hr algotirhm +#include "pxialg.h" + +// spo2 algorithm +#include "pxialg_spo2.h" + +// Stress algorithm +#include "pxialg_hrv.h" +#ifdef PPG_MEMS_Synchronize +//MEMS-INT +#include "pxi_interp.h" +#endif +//============================================================================ +// Functions +//============================================================================ +#ifdef __cplusplus +extern "C" { +#endif + + +//============================================================================ +// Definition +//============================================================================ +#ifdef PPG_MEMS_Synchronize +#define FIFO_SIZE 50 //FIFO Size is dependent on the CPU performance +#else +#define FIFO_SIZE 8 //FIFO Size is dependent on the CPU performance +#endif + +//============================================================================ +// Type Definition +//============================================================================ +#pragma pack(1) +typedef struct raw_data_13bytes_t +{ + uint8_t loss; + uint32_t rawData; + uint8_t non_zero1; + uint8_t non_zero2; + uint8_t non_zero3; + uint8_t frame_count; + uint8_t time; + uint8_t rsv; + uint8_t touch; + uint8_t rsv2; +} sRaw_Data_13Bytes; + +typedef enum { + MSG_ALG_NOCHANGE = 0, + MSG_ALG_ENABLE, + MSG_ALG_DISABLE, +} alg_msg_code_t; +#pragma pack() + +typedef enum +{ + pc_4mm_2g_ir_hrd, // PC 4.25mm for HRD wear + diw_4mm_g_ir_hrd, // DI+WALL 4.25mm for HRD hrs + diw_4mm_ir_r_ir_spo2, // DI+WALL 4.25mm for SPO2 spo2 + pc_22mm_2g_ir_hrd, // PC 2.2mm for HRD + di_18mm_g_g_hrd, // DI 1.8mm for HRD + +} reg_config_type; + +typedef struct { + + volatile bool has_interrupt; + volatile uint64_t interrupt_timestamp; + + // pah + pah_800x pah_800x; + + bool is_Auto_mode; + // ppg + bool ppg_is_enabled; + //bool ppg_only_is_enabled; + bool ppg_has_prev_report_timestamp; + uint64_t ppg_prev_report_timestamp; + uint8_t ppg_frame_count; + + // touch + bool touch_is_enabled; + //bool touch_only_is_enabled; + int touch_last_is_touched; + + // alg + uint8_t alg_is_enabled; + bool hr_is_enabled; + bool spo2_is_enabled; + bool stress_is_enable; + // debug + bool debug_print_header; + uint8_t debug_frame_count; + +} main_state; + +typedef struct { + float MEMS_Data[3] ; + pah_800x_ppg_data ppg_data; + uint8_t touch_flag; + uint8_t duration; + uint8_t ppg_frame_count; + //pah_800x_touch_data touch_data; +} ppg_mems_data_t; + + + + + +//============================================================================ +// Public function +//============================================================================ +void pah_sensor_init(reg_config_type type); +void touch_only_sensor_start(void); +void ppg_only_sensor_start(void); +void auto_mode_sensor_start(void); +void pah_sensor_stop(void); +void ppg_interrupt_handle(void); +void ppg_sensor_task_interrupt(void); +void ppg_sensor_task_polling(void); + + +bool isFIFOEmpty(void); +bool pah_push(ppg_mems_data_t *data); +bool pah_pop(ppg_mems_data_t *data); + + +uint8_t Check_alg_enable(void); +void Clear_alg_enable(void); + +//HRD +void hr_algorithm_enable(void); +void hr_algorithm_disable(void); +void hr_alg_task(void); +void hr_alg_task2(uint8_t ppg_num); + +//SPO2 +void spo2_algorithm_enable(void); +void spo2_algorithm_disable(void); +void spo2_alg_task(void); +void spo2_alg_task2(uint8_t ppg_num); + +//Stress +void stress_algorithm_enable(void); +void stress_algorithm_disable(void); +//void stress_alg_task(void); +void stress_alg_task(int grade); + +uint16_t pah8009_get_chip_id(void); +void pah8009_control(char *mode,uint8_t enable); +int32_t pah8009_get_factory_data(void); +void pah8009_int_handler(void); +void pah8009_check_int(void); + +uint8_t pah8009_get_hrs(void); +uint8_t pah8009_get_spo2(void); +uint8_t pah8009_get_wear_status(void); + +/** + * @brief Macro to be used in a formatted string to a pass float number to the log. + * + * Macro should be used in formatted string instead of the %f specifier together with + * @ref LOG_FLOAT macro. + * Example: LOG_INFO("My float number" LOG_FLOAT_MARKER "\r\n", LOG_FLOAT(f))) + */ +#define LOG_FLOAT_MARKER "%c%d.%05d" + +/** + * @brief Macro for dissecting a float number into two numbers (integer and residuum). + */ +#define LOG_FLOAT(val) ((val >= 0.0f)?32:45),(int32_t)((val >= 0.0f)?val:val*-1) , (int32_t)(((val > 0) ? (val) - (int32_t)(val): (int32_t)(val) - (val))*100000) + + + +#ifdef PPG_MEMS_Synchronize +//MEMS Interpolation +//void mems_interpolation(uint8_t ppg_num); +void mems_interpolation(int16_t *mems_int_data_in,uint8_t mems_count,uint8_t ppg_num); +uint8_t get_ppg_data_num(void); +void clear_ppg_data_num(void); +#endif + +#ifdef __cplusplus +} +#endif + +#endif // header guard diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_8009_reg_arr_default_20220623.h b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_8009_reg_arr_default_20220623.h new file mode 100644 index 000000000..a05c1c17f --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_8009_reg_arr_default_20220623.h @@ -0,0 +1,491 @@ +#ifndef __pah_8009_reg_arr_default_h__ +#define __pah_8009_reg_arr_default_h__ + +// c +#include + +//pah +#include "pah_800x_config.h" + + +static const uint8_t PAH8009_REG_DEVICE_INIT[][2] = { +// { 0xEE,0x07 }, //SW RESET + { 0xD1,0xD0 },//{R_GPIO_0_IEB, R_GPIO_1_IEB, R_GPIO_0_OEB, R_GPIO_1_OEB, R_GPIO_0_PULLL_EnH, R_GPIO_1_PULLL_EnH, R_GPIO_0_PULLH_EnH, R_GPIO_1_PULLH_EnH}; + { 0xD2,0x00+R_GPIO_SLEW+R_GPIO_0_OD_EnH },//R_GPIO_0_Open_Drain_EnH(0xD2[5]), 1(0x20):GPIO default open-drain mode, 0(0x00):GPIO debug mode + { 0xD3,0x20 },//GPIO debug select + { 0xD6,0x00+R_I2C_SLEW },//{Dummy, R_I2C_SLEW, Dummy[5:0]} +#if (INT_OD_EXTERNAL_PULLH) + { 0xD1,0xD0 },//{R_GPIO_0_IEB, R_GPIO_1_IEB, R_GPIO_0_OEB, R_GPIO_1_OEB, R_GPIO_0_PULLL_EnH, R_GPIO_1_PULLL_EnH, R_GPIO_0_PULLH_EnH, R_GPIO_1_PULLH_EnH}; + { 0xD2,0x20+R_GPIO_SLEW },//R_GPIO_0_Open_Drain_EnH(0xD2[5]), 1(0x20):GPIO default open-drain mode, 0(0x00):GPIO debug mode + { 0xD3,0x00 },//GPIO debug select + { 0xD6,0x00+R_I2C_SLEW },//{Dummy, R_I2C_SLEW, Dummy[5:0]} +#endif +#if (INT_OD_INTERNAL_PULLH) + { 0xD1,0xD2 },//{R_GPIO_0_IEB, R_GPIO_1_IEB, R_GPIO_0_OEB, R_GPIO_1_OEB, R_GPIO_0_PULLL_EnH, R_GPIO_1_PULLL_EnH, R_GPIO_0_PULLH_EnH, R_GPIO_1_PULLH_EnH}; + { 0xD2,0x20+R_GPIO_SLEW },//R_GPIO_0_Open_Drain_EnH(0xD2[5]), 1(0x20):GPIO default open-drain mode, 0(0x00):GPIO debug mode + { 0xD3,0x00 },//GPIO debug select + { 0xD6,0x00+R_I2C_SLEW },//{Dummy, R_I2C_SLEW, Dummy[5:0]} +#endif +#if (INT_PUP_WITHOUT_PULLH) + { 0xD1,0xD0 },//{R_GPIO_0_IEB, R_GPIO_1_IEB, R_GPIO_0_OEB, R_GPIO_1_OEB, R_GPIO_0_PULLL_EnH, R_GPIO_1_PULLL_EnH, R_GPIO_0_PULLH_EnH, R_GPIO_1_PULLH_EnH}; + { 0xD2,0x00+R_GPIO_SLEW },//R_GPIO_0_Open_Drain_EnH(0xD2[5]), 1(0x20):GPIO default open-drain mode, 0(0x00):GPIO debug mode + { 0xD3,0x00 },//GPIO debug select + { 0xD6,0x00+R_I2C_SLEW },//{Dummy, R_I2C_SLEW, Dummy[5:0]} +#endif +// { 0xD6,0x30 },//{Dummy, R_I2C_SLEW, R_I2C_DRV[1:0], Dummy[3:0]} +// { 0xD5,0x44 },//IO-level(I2C), 44:3.3V, 00:1.8V +// { 0xB2,0x25 }, + { 0x55,0x24 },//Soft Reset:04 Hard Reset:24 + { 0x52,0x12 },//VDDAY=1.63V +// { 0xA6,0xF7 },//Cmd_vdday_pwrsv_sel_EnH=0 + { 0xAE,0x3F },//R_LPO_Cali_mode=1 + { 0x20,0x05 },//Clear INT +}; +#ifndef LED_SUPPLIER_NEW +#ifdef DI_WALL_4mm +#define PPG_SETTING_VERSION 0x01 +#endif +#if (DIW_4MM_G_IR_HRD==1) +static const uint8_t PAH8009_REG_DIW_4MM_G_IR_PPG[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x40 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x06 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x08,0xE8 },//A period + { 0x09,0x03 },//A period + { 0x0A,0x00 },//B period + { 0x0B,0x08 },//B period + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x0E,0x04 },//RDB_FrameNum_A[6:0] + { 0x0F,0x08 },//RDB_FrameNum_B[6:0] + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x76 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x14,0x12 },//{RDB_ChA_congain_sel[1:0], Dummy[0], R_LEDDAC_code0[4:0]} + { 0x15,0x04 },//{RDB_ChB_congain_sel[1:0], Dummy[0], R_LEDDAC_code1[4:0]} + { 0x16,0x92 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x17,0x58 },//RDB_expo_A[7:0] + { 0x18,0x02 },//RDB_expo_A[15:8] + { 0x19,0x00 },//RDB_expo_B[7:0] + { 0x1A,0x01 },//RDB_expo_B[15:8] + { 0x1B,0x20 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1D,0x1F },//{R_ChA_LED_EnH[2:0], R_ChA_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1E,0x2F },//{R_ChB_LED_EnH[2:0], R_ChB_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0xF7 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] +// #ifdef TOUCH_DETECT_TRH_1 +// { 0x4C,0x20 },//R_TouchDetection_Th_Low[7:0] +// { 0x4D,0x03 },//R_TouchDetection_Th_Low[13:8] //1800 ir阈值 +// #else +// { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] //1280 ir阈值 +// { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] +// #endif + { 0xEB,0x80 },//update_flag +}; + +static const uint8_t PAH8009_REG_DIW_4MM_G_IR_TOUCH[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x40 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x06 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x44 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x16,0x92 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x1B,0x20 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0x04 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; +#endif +#if (DIW_4MM_IR_R_IR_SPO2==1) +static const uint8_t PAH8009_REG_DIW_4MM_IR_R_IR_PPG[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x00 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x05 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x08,0x00 },//A period + { 0x09,0x01 },//A period + { 0x0A,0x00 },//B period + { 0x0B,0x01 },//B period + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x0E,0x40 },//RDB_FrameNum_A[6:0] + { 0x0F,0x40 },//RDB_FrameNum_B[6:0] + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x77 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x14,0x52 },//{RDB_ChA_congain_sel[1:0], Dummy[0], R_LEDDAC_code0[4:0]} + { 0x15,0x44 },//{RDB_ChB_congain_sel[1:0], Dummy[0], R_LEDDAC_code1[4:0]} + { 0x16,0x84 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x17,0x40 },//RDB_expo_A[7:0] + { 0x18,0x00 },//RDB_expo_A[15:8] + { 0x19,0x40 },//RDB_expo_B[7:0] + { 0x1A,0x00 },//RDB_expo_B[15:8] + { 0x1B,0x20 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1D,0x1F },//{R_ChA_LED_EnH[2:0], R_ChA_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1E,0x4F },//{R_ChB_LED_EnH[2:0], R_ChB_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0xF7 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; + + +static const uint8_t PAH8009_REG_DIW_4MM_IR_R_IR_TOUCH[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x00 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x05 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x44 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x16,0x92 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x1B,0x20 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0x04 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; + +#endif + +#if (PC_4MM_2G_IR_HRD==1) +#ifdef PC_4mm +#define PPG_SETTING_VERSION 0x11 +#endif +static const uint8_t PAH8009_REG_PC_4MM_2G_IR_PPG[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x40 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x06 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x08,0xE8 },//A period + { 0x09,0x03 },//A period + { 0x0A,0x00 },//B period + { 0x0B,0x08 },//B period + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x0E,0x04 },//RDB_FrameNum_A[6:0] + { 0x0F,0x08 },//RDB_FrameNum_B[6:0] + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x76 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x14,0x12 },//{RDB_ChA_congain_sel[1:0], Dummy[0], R_LEDDAC_code0[4:0]} + { 0x15,0x44 },//{RDB_ChB_congain_sel[1:0], Dummy[0], R_LEDDAC_code1[4:0]} + { 0x16,0xC4 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x17,0x58 },//RDB_expo_A[7:0] + { 0x18,0x02 },//RDB_expo_A[15:8] + { 0x19,0x00 },//RDB_expo_B[7:0] + { 0x1A,0x01 },//RDB_expo_B[15:8] + { 0x1B,0x28 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1D,0x1F },//{R_ChA_LED_EnH[2:0], R_ChA_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1E,0x6F },//{R_ChB_LED_EnH[2:0], R_ChB_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0xF7 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; + +static const uint8_t PAH8009_REG_PC_4MM_2G_IR_TOUCH[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x40 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x06 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x44 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x16,0xD2 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x1B,0x28 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0x04 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; +#endif + + +#else +#ifdef DI_WALL_4mm +#define PPG_SETTING_VERSION 0x21 +#endif +#if (DIW_4MM_G_IR_HRD==1) +static const uint8_t PAH8009_REG_DIW_4MM_G_IR_PPG[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x40 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x06 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x08,0xE8 },//A period + { 0x09,0x03 },//A period + { 0x0A,0x00 },//B period + { 0x0B,0x08 },//B period + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x0E,0x04 },//RDB_FrameNum_A[6:0] + { 0x0F,0x08 },//RDB_FrameNum_B[6:0] + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x76 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x14,0x12 },//{RDB_ChA_congain_sel[1:0], Dummy[0], R_LEDDAC_code0[4:0]} + { 0x15,0x04 },//{RDB_ChB_congain_sel[1:0], Dummy[0], R_LEDDAC_code1[4:0]} + { 0x16,0x12 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x17,0x58 },//RDB_expo_A[7:0] + { 0x18,0x02 },//RDB_expo_A[15:8] + { 0x19,0x00 },//RDB_expo_B[7:0] + { 0x1A,0x01 },//RDB_expo_B[15:8] + { 0x1B,0x20 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1D,0x1F },//{R_ChA_LED_EnH[2:0], R_ChA_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1E,0x2F },//{R_ChB_LED_EnH[2:0], R_ChB_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0xF7 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; + +static const uint8_t PAH8009_REG_DIW_4MM_G_IR_TOUCH[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x40 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x06 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x44 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x16,0x12 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x1B,0x20 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0x04 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; +#endif + +#if (DIW_4MM_IR_R_IR_SPO2==1) +static const uint8_t PAH8009_REG_DIW_4MM_IR_R_IR_PPG[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x00 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x05 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x08,0x00 },//A period + { 0x09,0x01 },//A period + { 0x0A,0x00 },//B period + { 0x0B,0x01 },//B period + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x0E,0x40 },//RDB_FrameNum_A[6:0] + { 0x0F,0x40 },//RDB_FrameNum_B[6:0] + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x77 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x14,0x12 },//{RDB_ChA_congain_sel[1:0], Dummy[0], R_LEDDAC_code0[4:0]} + { 0x15,0x04 },//{RDB_ChB_congain_sel[1:0], Dummy[0], R_LEDDAC_code1[4:0]} + { 0x16,0x04 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x17,0x40 },//RDB_expo_A[7:0] + { 0x18,0x00 },//RDB_expo_A[15:8] + { 0x19,0x40 },//RDB_expo_B[7:0] + { 0x1A,0x00 },//RDB_expo_B[15:8] + { 0x1B,0x20 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1D,0x1F },//{R_ChA_LED_EnH[2:0], R_ChA_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1E,0x4F },//{R_ChB_LED_EnH[2:0], R_ChB_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0xF7 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; + +static const uint8_t PAH8009_REG_DIW_4MM_IR_R_IR_TOUCH[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x00 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x05 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x44 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x16,0x12 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x1B,0x20 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0x04 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; +#endif + +//China LED + +#if (PC_4MM_2G_IR_HRD==1) +#ifdef PC_4mm +#define PPG_SETTING_VERSION 0x31 +#endif +static const uint8_t PAH8009_REG_PC_4MM_2G_IR_PPG[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x40 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x06 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x08,0xE8 },//A period + { 0x09,0x03 },//A period + { 0x0A,0x00 },//B period + { 0x0B,0x08 },//B period + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x0E,0x04 },//RDB_FrameNum_A[6:0] + { 0x0F,0x08 },//RDB_FrameNum_B[6:0] + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x76 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x14,0x12 },//{RDB_ChA_congain_sel[1:0], Dummy[0], R_LEDDAC_code0[4:0]} + { 0x15,0x44 },//{RDB_ChB_congain_sel[1:0], Dummy[0], R_LEDDAC_code1[4:0]} + { 0x16,0x04 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x17,0x58 },//RDB_expo_A[7:0] + { 0x18,0x02 },//RDB_expo_A[15:8] + { 0x19,0x00 },//RDB_expo_B[7:0] + { 0x1A,0x01 },//RDB_expo_B[15:8] + { 0x1B,0x28 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1D,0x1F },//{R_ChA_LED_EnH[2:0], R_ChA_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1E,0x6F },//{R_ChB_LED_EnH[2:0], R_ChB_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0xF7 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; + +static const uint8_t PAH8009_REG_PC_4MM_2G_IR_TOUCH[][2] = { + //{ 0xEE,0x07 }, + { 0x03,0x40 },//Golden report period[7:0] (1T=31.25us) + { 0x04,0x06 },//Golden report period[15:8] + { 0x05,0x00 },//Golden report period[19:16] + { 0x12,0x01 },//ChC_report_divider[7:0] + { 0x13,0x00 },//ChC_report_divider[9:8] + { 0x0C,0x00 },//C period + { 0x0D,0x01 },//C period + { 0x10,0x01 },//RDB_FrameNum_C[6:0] + { 0x11,0x44 },//{R_OnOff_mode_C_EnH, R_OnOff_mode_B_EnH, R_OnOff_mode_A_EnH, R_ChC_EnH, R_ChB_EnH, R_ChA_EnH} + { 0x16,0x12 },//{RDB_ChC_congain_sel[1:0], Dummy[0], R_LEDDAC_code2[4:0]} + { 0x1B,0x28 },//RDB_expo_C[7:0] + { 0x1C,0x00 },//RDB_expo_C[15:8] + { 0x1F,0x1F },//{R_ChC_LED_EnH[2:0], R_ChC_Pixel_EnH[3:0]}, [3]:pixel3, [2]:pixel2, [1]:pixel1, [0]:pixel0, enable high + { 0x22,0x04 },//RDB_Int_En[7:0], [2]:touch flag [1]:overflow [0]:data ready + { 0x26,0x20 },//{R_ADCdata_C_Sel[1:0], R_ADCdata_B_Sel[1:0], R_ADCdata_A_Sel[1:0]}, 0:on, 1:off(需開On-Off), 2:on-off(需開On-Off) + { 0x49,0x11 },//RDB_Touch_EnH + { 0x4A,0x00 },//R_TouchDetection_Th_Hi[7:0] + { 0x4B,0x07 },//R_TouchDetection_Th_Hi[13:8] + { 0x4C,0x00 },//R_TouchDetection_Th_Low[7:0] + { 0x4D,0x05 },//R_TouchDetection_Th_Low[13:8] + { 0x4E,0x00 },//R_TouchDetection_Count_Th[4:0] + { 0x4F,0x00 },//R_NoTouchDetection_Count_Th[4:0] + { 0xEB,0x80 },//update_flag +}; +#endif + +#endif + +#endif // header guard diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_800x.c b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_800x.c new file mode 100644 index 000000000..da77ddbdc --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_800x.c @@ -0,0 +1,833 @@ +// pah +#include "pah_800x.h" + + +//============================================================================ +// Private function +//============================================================================ +static bool sensor_has_enabled(pah_800x *state); + +static pah_ret ppg_convergence_toggle(pah_800x *state, bool enable, uint8_t ch_num); + +static pah_ret ppg_reset_exposure(pah_800x *state, uint8_t ch_num); + +//static pah_ret touch_process(pah_800x *state, uint8_t *touch_flag); +static pah_ret ppg_process(pah_800x *state, pah_800x_ppg_data *ppg_result); +static pah_ret clear_interrupt(pah_800x *state, bool has_ppg_interrupt, bool has_overflow); + +static pah_ret ppg_converging(pah_800x *state, uint32_t ppg_value, uint8_t ch_num); +static uint16_t select_new_ppg_exposure(pah_800x *state, uint16_t old_ppg_exposure, uint16_t ppg_value, uint8_t ch_num); + +static bool is_touched(pah_800x *state); +static bool is_not_touched(pah_800x *state); + +static bool ppg_value_is_out_of_outer_bounds(pah_800x *state, uint32_t ppg_data, uint8_t ch_num); +static bool ppg_value_is_out_of_inner_bounds(pah_800x *state, uint16_t ppg_data, uint8_t ch_num); + +static pah_ret pah_800x_sw_reset(pah_800x *state); +///////////////////////////////////////////////////////////////////////////////////////////// + +//// comm + +static pah_ret pah_800x_hal_comm_write(uint8_t addr, const uint8_t *data, size_t write_size); +static pah_ret pah_800x_hal_comm_read(uint8_t addr, uint8_t *data, size_t read_size); + + +//// write +static pah_ret pah_800x_hal_write_reg_arr(const pah_reg_arr *reg_arr); +static pah_ret pah_800x_hal_write_reg_array(const uint8_t reg_array[][2], size_t length); +static pah_ret pah_800x_hal_write_suspend_state(bool suspend); +static pah_ret pah_800x_hal_write_interrupt_clear(void); +static pah_ret pah_800x_hal_write_interrupt_clear_v2(bool int_status_DR_FLAG_b); +static pah_ret pah_800x_hal_write_ppg_overflow_clear(void); +static pah_ret pah_800x_hal_write_exposure(uint16_t exposure, uint8_t ch_num); +static pah_ret pah_800x_hal_tg_toggle(bool enable); +static pah_ret pah_800x_hal_update_flag(void); +static pah_ret pah_800x_hal_write_sw_reset(void); +static pah_ret pah_800x_hal_reset_gpio_state(void); +//// read +static pah_ret pah_800x_hal_read_product_id(uint16_t *product_id); +static pah_ret pah_800x_hal_read_ppg_interrupt(uint8_t *ppg_interrupt); +static pah_ret pah_800x_hal_read_ppg_sync(uint32_t *ppg_data, uint8_t ch_num); +static pah_ret pah_800x_hal_read_ppg_overflow(uint8_t *ppg_overflow, uint8_t *overflow_num); +static pah_ret pah_800x_hal_read_ppg_exposure(uint16_t *als_exposure, uint8_t ch_num); +static pah_ret pah_800x_hal_touch_get_touch_flag(int8_t *touch_flag); +static pah_ret pah_800x_hal_touch_get_touch_info(int8_t *touch_flag,uint16_t *touch_value); + + +static pah_ret pah_800x_hal_check_enable_channel(pah_800x *state, const pah_reg_arr *reg_arr); +static pah_ret comm_write(uint8_t addr, uint8_t data); +static pah_ret pah_800x_hal_read_ppg_adc(uint16_t *ppg_adc, uint8_t ch_num); +static pah_ret pah_800x_hal_read_ppg_frame_period(uint16_t *ppg_frame_period, uint8_t ch_num); + + +//============================================================================ +// Public function +//============================================================================ +uint16_t pah_800x_get_i2c_default_slave_addr(void) +{ + return PAH_800x_DEFAULT_I2C_SLAVE_ID_1; +} + +void pah_800x_get_default_config(pah_800x_config *config) +{ + memset(config, 0, sizeof(*config)); + + config->enable_ppg_convergence[0] = PAH_800x_DEFAULT_ENABLE_PPG_CONVERGENCE; + config->enable_ppg_convergence[1] = PAH_800x_DEFAULT_ENABLE_PPG_CONVERGENCE; + config->enable_ppg_convergence[2] = false; + + config->enable_ppg_reconvergence_if_out_of_bounds[0] = PAH_800x_DEFAULT_ENABLE_PPG_RECONVERGENCE_IF_OUT_OF_BOUNDS; + config->enable_ppg_reconvergence_if_out_of_bounds[1] = PAH_800x_DEFAULT_ENABLE_PPG_RECONVERGENCE_IF_OUT_OF_BOUNDS; + config->enable_ppg_reconvergence_if_out_of_bounds[2] = false; + + for(int ch=0;chppg_convergence[ch].t_weight_normal_mode = PAH_800x_DEFAULT_PPG_CONVERGENCE_T_WEIGHT_NORMAL_MODE; + config->ppg_convergence[ch].t_weight_fast_mode = PAH_800x_DEFAULT_PPG_CONVERGENCE_T_WEIGHT_FAST_MODE; + config->ppg_convergence[ch].t_min = PAH_800x_DEFAULT_PPG_CONVERGENCE_T_MIN; + config->ppg_convergence[ch].t_max = PAH_800x_DEFAULT_PPG_CONVERGENCE_T_MAX; + config->ppg_convergence[ch].raw_outer_high_bound = PAH_800x_DEFAULT_PPG_CONVERGENCE_RAW_OUTER_HIGH_BOUND; + config->ppg_convergence[ch].raw_inner_high_target = PAH_800x_DEFAULT_PPG_CONVERGENCE_RAW_INNER_HIGH_TARGET; + config->ppg_convergence[ch].raw_inner_low_target = PAH_800x_DEFAULT_PPG_CONVERGENCE_RAW_INNER_LOW_TARGET; + config->ppg_convergence[ch].raw_outer_low_bound = PAH_800x_DEFAULT_PPG_CONVERGENCE_RAW_OUTER_LOW_BOUND; + config->ppg_convergence[ch].convergence_count = PAH_800x_DEFAULT_PPG_CONVERGENCE_COUNT; + config->ppg_initial_exposure[ch] = PAH_800x_DEFAULT_PPG_INITIAL_EXPOSURE; + } + +} + +pah_ret pah_800x_get_product_id(uint16_t *product_id) +{ + return pah_800x_hal_read_product_id(product_id); +} + +pah_ret pah_800x_init(pah_800x *state, const pah_800x_config *config) +{ + memset(state, 0, sizeof(*state)); + + // state->plat = *plat; + state->config = *config; + for(int ch=0;chenable_ppg_convergence[ch]); + if (config->enable_ppg_convergence[ch]) + { + DEBUG_PRINT("(t_weight_normal_mode, t_weight_fast_mode) = (%d, %d)\n", + config->ppg_convergence[ch].t_weight_normal_mode, + config->ppg_convergence[ch].t_weight_fast_mode); + DEBUG_PRINT("(t_min, t_max) = (%d, %d)\n", + config->ppg_convergence[ch].t_min, + config->ppg_convergence[ch].t_max); + DEBUG_PRINT("(raw_outer_high_bound, raw_inner_high_target) = (%d, %d)\n", + config->ppg_convergence[ch].raw_outer_high_bound, + config->ppg_convergence[ch].raw_inner_high_target); + DEBUG_PRINT("(raw_inner_low_target, raw_outer_low_bound) = (%d, %d)\n", + config->ppg_convergence[ch].raw_inner_low_target, + config->ppg_convergence[ch].raw_outer_low_bound); + } + } + + return PAH_RET_SUCCESS; +} + +pah_ret pah_800x_deinit(pah_800x *state) +{ + pah_800x_ppg_toggle(state, false); + pah_800x_touch_toggle(state, false); + pah_800x_power_toggle(state, false); + return PAH_RET_SUCCESS; +} + +pah_ret pah_800x_device_init(pah_800x *state, const pah_800x_reg_setting *reg_setting) +{ + DEBUG_PRINT("%s\n", __func__); + + //uint16_t *product_id; + uint16_t product_id; + state->reg_setting = *reg_setting; + + pah_800x_hal_write_suspend_state(false); + pah_800x_hal_write_sw_reset(); + pah_delay_ms(2); + pah_800x_power_toggle(state, true); + + // read id, delay for reg bank reset + //pah_800x_hal_read_product_id(product_id); + pah_800x_hal_read_product_id(&product_id); + pah_800x_hal_write_reg_arr(&state->reg_setting.startup_init); + + return PAH_RET_SUCCESS; +} + +pah_ret pah_800x_power_toggle(pah_800x *state, bool enable) +{ + DEBUG_PRINT("%s(%d, %d)\n", __func__, state->is_powered, enable); + + + if (enable) + { + if (state->is_powered == enable) + { + return PAH_RET_SUCCESS; + } + pah_800x_hal_write_suspend_state(false); + } + else + { + state->ppg_state.is_enabled = false; + state->touch_state.is_enabled = false; + + pah_800x_hal_write_suspend_state(false); + //pah_800x_hal_write_sw_reset(); + pah_delay_ms(2); + pah_800x_hal_write_suspend_state(true); + pah_800x_hal_reset_gpio_state(); + } + + state->is_powered = enable; + state->touch_state.touch_flag = TOUCH_TRALSE_VALUE; + + return PAH_RET_SUCCESS; +} + +pah_ret pah_800x_verify_product_id(pah_800x *state, uint16_t *product_id) +{ + return pah_800x_hal_read_product_id(product_id); +} + +pah_ret pah_800x_ppg_toggle(pah_800x *state, bool enable) +{ + DEBUG_PRINT("%s(%d, %d)\n", __func__, state->ppg_state.is_enabled, enable); + if (state->ppg_state.is_enabled == enable) + return PAH_RET_SUCCESS; + //pah_800x_hal_write_als_toggle( enable); + if (enable) + { + //load ppg setting + //comm_write(0xEB,0x80); +// for(uint8_t ch_num=0;ch_num < PAH_800x_MAX_CH_NUM;ch_num++) +// { +// ppg_reset_exposure(state,ch_num); +// pah_800x_hal_update_flag(); +// } + + pah_800x_hal_write_reg_arr(&state->reg_setting.ppg_enable); + + pah_800x_hal_check_enable_channel(state, &state->reg_setting.ppg_enable); + //DEBUG_PRINT("ch enable %d %d %d \n",state->ppg_state.ppg_ch_enabled[0],state->ppg_state.ppg_ch_enabled[1],state->ppg_state.ppg_ch_enabled[2]); + pah_800x_hal_update_flag(); + + pah_800x_hal_write_interrupt_clear(); + if(!state->touch_state.is_enabled) + pah_800x_hal_tg_toggle(true); + } + else + { + if(!state->touch_state.is_enabled) + pah_800x_hal_tg_toggle(false); + } + + + for(uint8_t ch_num=0;ch_num < PAH_800x_MAX_CH_NUM;ch_num++) + { + state->ppg_state.is_converging[ch_num] = enable; + state->ppg_state.cur_converging_count[ch_num] = 0; + } + + state->ppg_state.is_enabled = enable; + return PAH_RET_SUCCESS; +} + +pah_ret pah_800x_ppg_get_data(pah_800x *state, pah_800x_ppg_data *ppg_data) +{ + *ppg_data = state->ppg_result; + return PAH_RET_SUCCESS; +} + +pah_ret pah_800x_update_touch_setting(pah_800x *state) +{ + pah_800x_hal_write_reg_arr(&state->reg_setting.touch_enable); + pah_800x_hal_update_flag(); + + return PAH_RET_SUCCESS; +} + +pah_ret pah_800x_touch_toggle(pah_800x *state, bool enable) +{ + DEBUG_PRINT("%s(%d, %d)\n", __func__, state->touch_state.is_enabled, enable); + if (state->touch_state.is_enabled == enable) + return PAH_RET_SUCCESS; + + if (enable) + { + //load touch setting + pah_800x_hal_write_reg_arr(&state->reg_setting.touch_enable); + pah_800x_hal_update_flag(); + pah_800x_hal_tg_toggle(true); + } + else + pah_800x_hal_tg_toggle(false); + state->touch_state.is_enabled = enable; + + return PAH_RET_SUCCESS; +} + +pah_ret pah_800x_get_touch_flag(pah_800x *state, int8_t *touch_flag) +{ + *touch_flag = state->touch_flag; + return PAH_RET_SUCCESS; +} +pah_ret pah_800x_get_touch_value(pah_800x *state, uint16_t *touch_value) +{ + *touch_value = state->touch_value; + return PAH_RET_SUCCESS; +} + + +pah_ret pah_800x_task(pah_800x *state) +{ + uint8_t ppg_interrupt = 0; + bool has_ppg_interrupt = false; + memset(&state->ppg_result, 0, sizeof(state->ppg_result)); + state->touch_flag = -1; + //memset(&state->touch_result, 0, sizeof(state->touch_result)); + + //touch_process(state, &state->touch_flag); + pah_800x_hal_touch_get_touch_flag( &state->touch_flag); + //pah_800x_hal_touch_get_touch_info( &state->touch_flag,&state->touch_value); + + pah_800x_hal_read_ppg_interrupt(&ppg_interrupt); + + has_ppg_interrupt = (ppg_interrupt > 0); + //DEBUG_PRINT("%s(%d)(%d)\n", __func__, ppg_interrupt,state->touch_flag); + if (has_ppg_interrupt > 0) + { + ppg_process(state, &state->ppg_result); + } + + clear_interrupt(state, has_ppg_interrupt, state->ppg_result.has_overflow); + + return PAH_RET_SUCCESS; +} + + +//============================================================================ +// Private function +//============================================================================ +static bool sensor_has_enabled(pah_800x *state) +{ + return state->ppg_state.is_enabled + || state->touch_state.is_enabled; +} + +static pah_ret ppg_convergence_toggle(pah_800x *state, bool enable, uint8_t ch_num) +{ + //DEBUG_PRINT("%s(%d, %d, %d)\n", __func__, state->config.enable_ppg_convergence[ch_num], enable, ch_num); + + if (ch_num >= PAH_800x_MAX_CH_NUM) + return PAH_RET_INVALID_ARGUMENT; + + if (!state->config.enable_ppg_convergence[ch_num]) + return PAH_RET_SUCCESS; + + if (enable && state->ppg_state.cur_converging_count[ch_num] < state->config.ppg_convergence[ch_num].convergence_count) + { + state->ppg_state.cur_converging_count[ch_num]++; + return PAH_RET_SUCCESS; + } + else + { + state->ppg_state.cur_converging_count[ch_num] = 0; + } + state->ppg_state.is_converging[ch_num] = enable; + + return PAH_RET_SUCCESS; +} + +static pah_ret ppg_reset_exposure(pah_800x *state, uint8_t ch_num) +{ + //DEBUG_PRINT("%s(%d)\n", __func__, state->config.ppg_initial_exposure[ch_num]); + if (!state->config.enable_ppg_convergence[ch_num]) + return PAH_RET_SUCCESS; + + return pah_800x_hal_write_exposure( state->config.ppg_initial_exposure[ch_num],ch_num); +} +/*static pah_ret touch_process(pah_800x *state, uint8_t *touch_flag) +{ + + pah_800x_touch_get_touch_flag( touch_flag); + + return PAH_RET_SUCCESS; +}*/ + + +static pah_ret ppg_process(pah_800x *state, pah_800x_ppg_data *ppg_result) +{ + uint32_t ppg_value[PAH_800x_MAX_CH_NUM] = {0}; + uint8_t ppg_overflow = 0; + uint8_t overflow_num = 0; + uint16_t ppg_exposure = 0; + uint16_t ppg_adc = 0; + uint16_t ppg_frame_period = 0; + if (!state->ppg_state.is_enabled) + return PAH_RET_SUCCESS; + + for(uint8_t ch_num=0; ch_num < PAH_800x_MAX_CH_NUM; ch_num++) + { + if(state->ppg_state.ppg_ch_enabled[ch_num]) + { + pah_800x_hal_read_ppg_sync(&ppg_value[ch_num], ch_num); + pah_800x_hal_read_ppg_exposure(&ppg_exposure, ch_num); + pah_800x_hal_read_ppg_frame_period(&ppg_frame_period,ch_num); + pah_800x_hal_read_ppg_adc(&ppg_adc,ch_num); + ppg_converging(state, ppg_adc, ch_num);//SD-revise-20191205 + + ppg_result->data[ch_num] = ppg_value[ch_num]; + ppg_result->exposure_time[ch_num] = ppg_exposure; + ppg_result->frame_period[ch_num] = ppg_frame_period; + ppg_result->adc[ch_num] = ppg_adc; + } + } + pah_800x_hal_read_ppg_overflow(&ppg_overflow,&overflow_num); + ppg_result->has_data = true; + ppg_result->has_overflow = (ppg_overflow > 0); + ppg_result->overflow_num = overflow_num; + + return PAH_RET_SUCCESS; +} + +static pah_ret clear_interrupt(pah_800x *state, bool has_ppg_interrupt, bool has_overflow) +{ + + //pah_800x_hal_write_interrupt_clear(); + pah_800x_hal_write_interrupt_clear_v2(has_ppg_interrupt); + return PAH_RET_SUCCESS; +} + +static pah_ret ppg_converging(pah_800x *state, uint32_t ppg_adc, uint8_t ch_num) +{ + if (ch_num >= PAH_800x_MAX_CH_NUM) + return PAH_RET_INVALID_ARGUMENT; + + if (!state->config.enable_ppg_convergence[ch_num]) + return PAH_RET_SUCCESS; + + if (state->config.enable_ppg_reconvergence_if_out_of_bounds[ch_num] + && !state->ppg_state.is_converging[ch_num] + && is_touched(state) + && ppg_value_is_out_of_outer_bounds(state, ppg_adc, ch_num)) + { + ppg_convergence_toggle(state, true, ch_num); + } + else + { + state->ppg_state.cur_converging_count[ch_num] = 0; + } + + if (!state->ppg_state.is_converging[ch_num]) + return PAH_RET_SUCCESS; + + if (ppg_value_is_out_of_inner_bounds(state, ppg_adc, ch_num)) + { + uint16_t ppg_exposure = 0; + uint16_t new_ppg_exposure = 0; + + pah_800x_hal_read_ppg_exposure(&ppg_exposure, ch_num); + //DEBUG_PRINT("ppg converging[%d] exposure time %d ppg_value %d \n",ch_num, ppg_exposure,ppg_value); + new_ppg_exposure = select_new_ppg_exposure(state, ppg_exposure, ppg_adc, ch_num); + if(new_ppg_exposure==ppg_exposure) + { + return PAH_RET_SUCCESS; + } + + if (new_ppg_exposure > state->config.ppg_convergence[ch_num].t_max) + { + new_ppg_exposure = state->config.ppg_convergence[ch_num].t_max; + ppg_convergence_toggle(state, false, ch_num); + + DEBUG_PRINT("ppg converging complete: (exposure, t_max) = (%d)\n", new_ppg_exposure, state->config.ppg_convergence[ch_num].t_max); + } + else if (new_ppg_exposure < state->config.ppg_convergence[ch_num].t_min) + { + new_ppg_exposure = state->config.ppg_convergence[ch_num].t_min; + ppg_convergence_toggle(state, false, ch_num); + + DEBUG_PRINT("ppg converging complete: (exposure, t_min) = (%d)\n", new_ppg_exposure, state->config.ppg_convergence[ch_num].t_min); + } + + pah_800x_hal_write_exposure(new_ppg_exposure, ch_num); + pah_800x_hal_update_flag(); + + } + else + { + ppg_convergence_toggle(state, false, ch_num); + + DEBUG_PRINT("ppg converging complete: (low_target, als_lux_sync, high_target) = (%d, %d, %d)\n", + state->config.ppg_convergence[ch_num].raw_inner_low_target, ppg_adc, + state->config.ppg_convergence[ch_num].raw_inner_high_target); + } + + return PAH_RET_SUCCESS; +} + +static uint16_t select_new_ppg_exposure(pah_800x *state, uint16_t old_ppg_exposure, uint16_t ppg_value, uint8_t ch_num) +{ + int32_t new_ppg_exposure = (int32_t)old_ppg_exposure; + + if (ppg_value < state->config.ppg_convergence[ch_num].raw_outer_low_bound) + new_ppg_exposure += state->config.ppg_convergence[ch_num].t_weight_fast_mode; + else if (ppg_value < state->config.ppg_convergence[ch_num].raw_inner_low_target) + new_ppg_exposure += state->config.ppg_convergence[ch_num].t_weight_normal_mode; + else if (ppg_value > state->config.ppg_convergence[ch_num].raw_outer_high_bound) + { + if(new_ppg_exposure==state->config.ppg_convergence[ch_num].t_min) + { + return new_ppg_exposure; + } + new_ppg_exposure -= state->config.ppg_convergence[ch_num].t_weight_fast_mode; + + }else if (ppg_value > state->config.ppg_convergence[ch_num].raw_inner_high_target) + new_ppg_exposure -= state->config.ppg_convergence[ch_num].t_weight_normal_mode; + + return new_ppg_exposure; +} + +static bool is_touched(pah_800x *state) +{ + return state->touch_flag == 1; +} + +static bool is_not_touched(pah_800x *state) +{ + return state->touch_flag == 0; +} + +static bool ppg_value_is_out_of_outer_bounds(pah_800x *state, uint32_t ppg_data, uint8_t ch_num) +{ + return (ppg_data < state->config.ppg_convergence[ch_num].raw_outer_low_bound) + || (ppg_data > state->config.ppg_convergence[ch_num].raw_outer_high_bound); +} + +static bool ppg_value_is_out_of_inner_bounds(pah_800x *state, uint16_t ppg_data, uint8_t ch_num) +{ + return (ppg_data < state->config.ppg_convergence[ch_num].raw_inner_low_target) + || (ppg_data > state->config.ppg_convergence[ch_num].raw_inner_high_target); +} + +static pah_ret pah_800x_sw_reset(pah_800x *state) +{ + //set sw reset should not in suspend mode + if (state->is_powered == false) + return PAH_RET_FAILED; + + return pah_800x_hal_write_sw_reset(); +} +//////////////////////////////////////////////////////////////////////////////////////////// + + + +//=========================================================================== +// Private function +//=========================================================================== +static pah_ret pah_800x_hal_comm_write(uint8_t addr, const uint8_t *data, size_t write_size) +{ + //return plat->comm.write(&plat->comm, addr, data, write_size); + //return plat->comm.write(addr, data, write_size); + return pah_comm_i2c_write(addr, data, write_size); +} + +static pah_ret pah_800x_hal_comm_read(uint8_t addr, uint8_t *data, size_t read_size) +{ + + //return plat->comm.read(&plat->comm, addr, data, read_size); + return pah_comm_i2c_read(addr, data, read_size); +} + +static pah_ret comm_write(uint8_t addr, uint8_t data) +{ + //return pah_800x_hal_comm_write( addr, &data, 1); + return pah_800x_hal_comm_write(addr, &data, 1); +} +#define comm_read(addr, data) pah_800x_hal_comm_read(addr, data, 1) +#define comm_burst_read(addr, data, read_size) pah_800x_hal_comm_read(addr, data, read_size) + + +//=========================================================================== +// Private function (HAL) +//=========================================================================== +static pah_ret pah_800x_hal_write_reg_arr(const pah_reg_arr *reg_arr) +{ + return pah_800x_hal_write_reg_array(reg_arr->reg_arr, reg_arr->reg_arr_len); +} + +static pah_ret pah_800x_hal_write_reg_array(const uint8_t reg_array[][2], size_t length) +{ + size_t i = 0; + uint8_t reg_value = 0; + for (i = 0; i < length; ++i) + { + //for trim bit + if (reg_array[i][0] == 0x14) + { + comm_read(0x14, ®_value); + reg_value = (reg_value & 0x1F) | (reg_array[i][1] & 0xE0); + comm_write(reg_array[i][0], reg_value); + } + else + comm_write(reg_array[i][0], reg_array[i][1]); + } + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_write_suspend_state(bool suspend) +{ + uint8_t data = 0; + DEBUG_PRINT("%s(%d)\n", __func__, suspend); + if (suspend) + { + pah_800x_hal_write_interrupt_clear(); + comm_read(PAH_800x_ADDR_E8, &data); + PAH_SET_BIT(data, PAH_800x_ADDR_E8_CMD_SUSPEND_MODE_BIT); + comm_write(PAH_800x_ADDR_E8, data); + } + else + { + comm_read(PAH_800x_ADDR_E8, &data); + PAH_CLEAR_BIT(data, PAH_800x_ADDR_E8_CMD_SUSPEND_MODE_BIT); + comm_write(PAH_800x_ADDR_E8, data); + + } + DEBUG_PRINT("%s(%d) end\n", __func__, suspend); + + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_write_interrupt_clear(void) +{ + uint8_t data = 0; + // DR interrupt + comm_read(PAH_800x_ADDR_20, &data); + //PAH_CLEAR_BIT(data, PAH_800x_ADDR_20_BIT_DR_FLAG); + comm_write(PAH_800x_ADDR_20, (data|0x04)); //SD-revise-20191205 + return PAH_RET_SUCCESS; +} +static pah_ret pah_800x_hal_write_interrupt_clear_v2(bool int_status_DR_FLAG_b) +{ + uint8_t data = 0; + bool int_status_DR_FLAG = 0; + // DR interrupt + comm_read(PAH_800x_ADDR_20, &data); + int_status_DR_FLAG = PAH_CHECK_BIT(data, PAH_800x_ADDR_20_BIT_DR_FLAG) ; + + if(int_status_DR_FLAG_b==int_status_DR_FLAG) + { + comm_write(PAH_800x_ADDR_20, (data|0x04)); //SD-revise-20191205 + }else if((int_status_DR_FLAG_b)==0 &&(int_status_DR_FLAG==1)) + { + comm_write(PAH_800x_ADDR_20, ((data|0x04)&0xFE)); //SD-revise-20191205 + } + return PAH_RET_SUCCESS; +} + + +static pah_ret pah_800x_hal_write_ppg_overflow_clear(void) +{ + uint8_t data = 0; + // Clear ppg_overflow flag + comm_read(PAH_800x_ADDR_20, &data); + PAH_SET_BIT(data, PAH_800x_ADDR_20_BIT_OVERFLOW_FLAG); + comm_write( PAH_800x_ADDR_20, data); + // Recover + PAH_CLEAR_BIT(data, PAH_800x_ADDR_20_BIT_OVERFLOW_FLAG); + comm_write(PAH_800x_ADDR_20, data); + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_write_exposure(uint16_t exposure, uint8_t ch_num) +{ + //uint8_t data = 0; + uint8_t exposure_low = PAH_UINT16_LOW(exposure); + uint8_t exposure_high = PAH_UINT16_HIGH(exposure); + + if(ch_num == PAH_800x_CH_NUM_A) + { + comm_write(PAH_800x_ADDR_17, exposure_low); + comm_write(PAH_800x_ADDR_18, exposure_high); + } + else if(ch_num == PAH_800x_CH_NUM_B) + { + comm_write(PAH_800x_ADDR_19, exposure_low); + comm_write(PAH_800x_ADDR_1A, exposure_high); + } + else if(ch_num == PAH_800x_CH_NUM_C) + { + comm_write(PAH_800x_ADDR_1B, exposure_low); + comm_write(PAH_800x_ADDR_1C, exposure_high); + } + + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_read_product_id(uint16_t *product_id) +{ + return comm_burst_read(PAH_800x_ADDR_00_PRODUCT_ID, (uint8_t *)product_id,2); +} + +static pah_ret pah_800x_hal_read_ppg_interrupt(uint8_t *ppg_interrupt) +{ + uint8_t data = 0; + comm_read(PAH_800x_ADDR_20, &data); + if (ppg_interrupt) + *ppg_interrupt = PAH_CHECK_BIT(data, PAH_800x_ADDR_20_BIT_DR_FLAG); + + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_read_ppg_sync(uint32_t *ppg_data, uint8_t ch_num) +{ + if(ch_num == PAH_800x_CH_NUM_A) + comm_burst_read(PAH_800x_ADDR_27_RAWDATA_A_SYNC, (uint8_t*)ppg_data, 3); + else if(ch_num == PAH_800x_CH_NUM_B) + comm_burst_read(PAH_800x_ADDR_32_RAWDATA_B_SYNC, (uint8_t*)ppg_data, 3); + else if(ch_num == PAH_800x_CH_NUM_C) + comm_burst_read(PAH_800x_ADDR_3D_RAWDATA_C_SYNC, (uint8_t*)ppg_data, 3); + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_read_ppg_overflow(uint8_t *ppg_overflow, uint8_t *overflow_num) +{ + uint8_t data = 0; + comm_read( PAH_800x_ADDR_20, &data); + if (ppg_overflow) + { + *ppg_overflow = PAH_CHECK_BIT(data, PAH_800x_ADDR_20_BIT_OVERFLOW_FLAG); + *overflow_num = (data&0x70)>>4; + } + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_read_ppg_exposure(uint16_t *ppg_exposure, uint8_t ch_num) +{ + if(ch_num == PAH_800x_CH_NUM_A) + comm_burst_read(PAH_800x_ADDR_2A, (uint8_t*)ppg_exposure, 2); + else if(ch_num == PAH_800x_CH_NUM_B) + comm_burst_read(PAH_800x_ADDR_35, (uint8_t*)ppg_exposure, 2); + else if(ch_num == PAH_800x_CH_NUM_C) + comm_burst_read(PAH_800x_ADDR_40, (uint8_t*)ppg_exposure, 2); + + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_read_ppg_frame_period( uint16_t *ppg_frame_period, uint8_t ch_num) +{ + if(ch_num == PAH_800x_CH_NUM_A) + comm_burst_read(PAH_800x_ADDR_2C, (uint8_t*)ppg_frame_period, 2); + else if(ch_num == PAH_800x_CH_NUM_B) + comm_burst_read(PAH_800x_ADDR_37, (uint8_t*)ppg_frame_period, 2); + else if(ch_num == PAH_800x_CH_NUM_C) + comm_burst_read(PAH_800x_ADDR_42, (uint8_t*)ppg_frame_period, 2); + + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_read_ppg_adc(uint16_t *ppg_adc, uint8_t ch_num) +{ + uint16_t data = 0; + + if(ch_num == PAH_800x_CH_NUM_A) + comm_burst_read(PAH_800x_ADDR_2E, (uint8_t*)&data, 2); + else if(ch_num == PAH_800x_CH_NUM_B) + comm_burst_read(PAH_800x_ADDR_39, (uint8_t*)&data, 2); + else if(ch_num == PAH_800x_CH_NUM_C) + comm_burst_read(PAH_800x_ADDR_44, (uint8_t*)&data, 2); + + //*ppg_adc = data >> 2; + *ppg_adc = data >> 2; + + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_touch_get_touch_flag(int8_t *touch_flag) +{ + uint8_t data = 0; + uint16_t data1 = 0; +// comm_read(PAH_800x_ADDR_20, &data); + comm_burst_read(PAH_800x_ADDR_44, (uint8_t*)&data1, 2); + comm_read(PAH_800x_ADDR_20, &data); + // printf("data : %d, data1 : %d\n",data,data1); + if (touch_flag) + *touch_flag = PAH_CHECK_BIT(data, PAH_800x_ADDR_20_BIT_TOUCH_FLAG); + + return PAH_RET_SUCCESS; +} +static pah_ret pah_800x_hal_touch_get_touch_info(int8_t *touch_flag,uint16_t *touch_value) +{ + uint8_t data = 0; + uint16_t data1 = 0; +// comm_read(PAH_800x_ADDR_20, &data); + comm_burst_read(PAH_800x_ADDR_44, (uint8_t*)&data1, 2); + *touch_value =data1>>2; + comm_read(PAH_800x_ADDR_20, &data); + if (touch_flag) + *touch_flag = PAH_CHECK_BIT(data, PAH_800x_ADDR_20_BIT_TOUCH_FLAG); + + + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_tg_toggle(bool enable) +{ + uint8_t data = 0; + comm_read( PAH_800x_ADDR_07_TG, &data); + if(enable) + PAH_SET_BIT(data, PAH_800x_ADDR_07_TG_BIT_EN); + else + PAH_CLEAR_BIT(data, PAH_800x_ADDR_07_TG_BIT_EN); + comm_write(PAH_800x_ADDR_07_TG, data); + + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_update_flag(void) +{ + comm_write(PAH_800x_ADDR_EB, PAH_800x_ADDR_E8_UPDATE_FLAG); + + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_write_sw_reset(void) +{ + comm_write(PAH_800x_ADDR_EE, PAH_800x_ADDR_EE_SW_RESET); + + return PAH_RET_SUCCESS; +} + +static pah_ret pah_800x_hal_check_enable_channel(pah_800x *state, const pah_reg_arr *reg_arr) +{ + for(int i=0;ireg_arr_len;i++) + { + if(reg_arr->reg_arr[i][0] == PAH_800x_ADDR_11_EnCh) + { + uint8_t data = reg_arr->reg_arr[i][1]; + state->ppg_state.ppg_ch_enabled[0] = PAH_CHECK_BIT(data, 0); // CH A + state->ppg_state.ppg_ch_enabled[1] = PAH_CHECK_BIT(data, 1); // CH B + state->ppg_state.ppg_ch_enabled[2] = PAH_CHECK_BIT(data, 2); // CH C + } + } + + return PAH_RET_SUCCESS; +} + + +static pah_ret pah_800x_hal_reset_gpio_state(void) +{ + uint8_t data = 0; + + comm_read(PAH_800x_ADDR_D2, &data); + PAH_SET_BIT(data, PAH_800x_ADDR_D2_OD_EnH); + comm_write(PAH_800x_ADDR_D2, data); + + return PAH_RET_SUCCESS; +} diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_800x.h b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_800x.h new file mode 100644 index 000000000..2500dc690 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_800x.h @@ -0,0 +1,158 @@ +#ifndef __pah_800x_h__ +#define __pah_800x_h__ + +// pah +#include "pah_unit.h" +#include "pah_800x_config.h" + + +//============================================================================ +// Definition +//============================================================================ +#define TOUCH_TRALSE_VALUE (-1) + + +//============================================================================ +// Type Definition +//============================================================================ +typedef struct +{ + uint16_t t_weight_normal_mode; + uint16_t t_weight_fast_mode; + uint16_t t_min; + uint16_t t_max; + + uint16_t raw_outer_high_bound; + uint16_t raw_inner_high_target; + uint16_t raw_inner_low_target; + uint16_t raw_outer_low_bound; + + uint16_t convergence_count; +} pah_800x_ppg_convergence; + +typedef struct +{ + uint16_t ppg_initial_exposure[PAH_800x_MAX_CH_NUM]; + + bool enable_ppg_convergence[PAH_800x_MAX_CH_NUM]; + pah_800x_ppg_convergence ppg_convergence[PAH_800x_MAX_CH_NUM]; + bool enable_ppg_reconvergence_if_out_of_bounds[PAH_800x_MAX_CH_NUM]; + +} pah_800x_config; + +typedef struct +{ + bool is_enabled; + + bool is_converging[PAH_800x_MAX_CH_NUM]; + + bool ppg_ch_enabled[PAH_800x_MAX_CH_NUM]; + uint16_t cur_converging_count[PAH_800x_MAX_CH_NUM]; +} pah_800x_ppg_state; + +typedef struct +{ + bool has_data; + uint32_t data[PAH_800x_MAX_CH_NUM]; + + + // Avaiable only if has_data is true + bool has_overflow; + + uint8_t overflow_num; + + // Avaiable only if has_data is true + uint16_t exposure_time[PAH_800x_MAX_CH_NUM]; + uint16_t adc[PAH_800x_MAX_CH_NUM]; + uint16_t frame_period[PAH_800x_MAX_CH_NUM]; + +} pah_800x_ppg_data; + +typedef struct +{ + bool is_enabled; + + int8_t touch_flag; + +} pah_800x_touch_state; + +typedef struct +{ + pah_reg_arr startup_init; + pah_reg_arr ppg_enable; + pah_reg_arr touch_enable; + +} pah_800x_reg_setting; + +typedef struct +{ + // Config + //pah_plat plat; + pah_800x_config config; + + // Power state + bool is_powered; + + // PPG state + pah_800x_ppg_state ppg_state; + pah_800x_ppg_data ppg_result; + + // TOUCH state + pah_800x_touch_state touch_state; + int8_t touch_flag; + uint16_t touch_value; + // Other + pah_800x_reg_setting reg_setting; + +} pah_800x; + + +//============================================================================ +// Public function +//============================================================================ +#ifdef __cplusplus +extern "C" { +#endif + + +// Info +uint16_t pah_800x_get_i2c_default_slave_addr(void); +void pah_800x_get_default_config(pah_800x_config *config); +pah_ret pah_800x_get_product_id( uint16_t *product_id); + +// Init +pah_ret pah_800x_init(pah_800x *state, const pah_800x_config *config); +pah_ret pah_800x_deinit(pah_800x *state); + +// Device init +pah_ret pah_800x_device_init(pah_800x *state, const pah_800x_reg_setting *reg_setting); + +// Config +//pah_ret pah_800x_set_ppg_convergence(pah_800x *state,uint8_t ch_num, const pah_800x_ppg_convergence *ppg_convergence); + +// Power +pah_ret pah_800x_power_toggle(pah_800x *state, bool enable); + +// Basic verification +pah_ret pah_800x_verify_product_id(pah_800x *state, uint16_t *product_id); + +// PPG +pah_ret pah_800x_ppg_toggle(pah_800x *state, bool enable); +pah_ret pah_800x_ppg_get_data(pah_800x *state, pah_800x_ppg_data *ppg_data); + +// TOUCH +pah_ret pah_800x_touch_toggle(pah_800x *state, bool enable); +pah_ret pah_800x_get_touch_flag(pah_800x *state, int8_t *touch_flag); +pah_ret pah_800x_get_touch_value(pah_800x *state, uint16_t *touch_value); +pah_ret pah_800x_update_touch_setting(pah_800x *state); + +// Task +pah_ret pah_800x_task(pah_800x *state); + + + +#ifdef __cplusplus +} +#endif + +#endif // header guard diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_800x_config.h b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_800x_config.h new file mode 100644 index 000000000..b484f21c2 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_800x_config.h @@ -0,0 +1,166 @@ +#ifndef __pah_800x_config_h__ +#define __pah_800x_config_h__ + +// pah +#include "pah800x_bsp.h" +#include "debug_print.h" +#include "cywee_hal.h" + +/* + * Select LED Supplier + * If Use new Supplier LED , Need to define LED_SUPPLIER_NEW +*/ +#define LED_SUPPLIER_NEW + + +/* + * Select Cover Type +*/ +#define DI_WALL_4mm +//#define PC_4mm + +/* + * Select HW and ALG configuration + * PC_4MM_2G_IR_HRD : Printing Cover with 4mm 2 Green and 1 IR LED for HRD algorithm use (PAH8009ES) + * DIW_4MM_G_IR_HRD : DI+Wall Cover with 4mm 1 Green and 1 IR LED for HRD algorithm use (PAH8009ES) + * DIW_4MM_IR_R_IR_SPO2 : DI+Wall Cover with 4mm 1 IR LED and 1 RED for SpO2 algorithm use (PAH8009ES) + * This definition will enable the PPG register setting corresponding to different HW and ALG configuration + */ + +#define PC_4MM_2G_IR_HRD 1 +#define DIW_4MM_G_IR_HRD 1 +#define DIW_4MM_IR_R_IR_SPO2 1 + +//#endif + +//============================================================================ +// Debug Option +//============================================================================ +#define ENABLE_AE 1 +#define ENABLE_AE_RECONVERGENCE 1 + + +#define PAH_800x_ENABLE_DEBUG_PRINT +#define PAH_800x_ENABLE_LOG_PRINT + + +#ifdef PAH_800x_ENABLE_LOG_PRINT +#define LOG_PRINT(fmt, ...) \ + do { \ + CWM_OS_dbgPrintf(fmt"PAH:", ##__VA_ARGS__); \ + } while (0) +#else +#define LOG_PRINT(...) do {} while (0) +#endif + +#ifdef PAH_800x_ENABLE_DEBUG_PRINT +#define DEBUG_PRINT(fmt, ...) \ + do { \ + CWM_OS_dbgPrintf(fmt"PAH:", ##__VA_ARGS__); \ + } while (0) +#else +#define DEBUG_PRINT(...) do {} while (0) +#endif + +/* + * Select Interrupt or Polling Mode + * This definition will enable the corresponding demo functionin main.c + * If select INT mode, then slect following INT configuration type + */ +#define INTERRUPT_MODE 0 +#define POLLING_MODE 1 +#define Test_pattern_mode 0 + +/* + * Select INT HW configuration type + * INT_OD_EXTERNAL_PULLH : INT open-drain type with external pull-high resistor + * INT_OD_INTERNAL_PULLH : INT open-drain type with internal pull-high resistor + * INT_PUP_WITHOUT_PULLH : INT push-pull type without any pull-high resistor + * If user select POLLING_MODE, all define need to set 0 + * This definition will enable the GPIO register setting corresponding to different INT HW configuration + */ +#define INT_OD_EXTERNAL_PULLH 1 +#define INT_OD_INTERNAL_PULLH 0 +#define INT_PUP_WITHOUT_PULLH 0 + + +/* +* Configure VBUS Type + * Define VBUS_18V=1, compatible with VBUS=1.8V or 3.3V (default) + * Define VBUS_18V=0, only support VBUS=3.3V + * If user want to define VBUS_18V=0, or VBUS not 1.8V/3.3V, please contact with PixArt for evaluation + */ +#define VBUS_18V 1 +#if (VBUS_18V) + #define R_GPIO_0_OD_EnH (0x20) + #define R_GPIO_SLEW (0x01) + #define R_I2C_SLEW (0x40) + #define R_SCL_Sel (0x00) + #define R_SDA_Sel (0x00) +#else + #define R_GPIO_0_OD_EnH (0x20) + #define R_GPIO_SLEW 0 + #define R_I2C_SLEW 0 + #define R_SCL_Sel (0x40) + #define R_SDA_Sel (0x04) +#endif + +#define Time_Interval 400 +/* +If Customer platform use G-Sensor with FIFO,they can refer this flow to run pxi alg to get alg output +*/ +//#define PPG_MEMS_Synchronize +#define Optimize_SPO2_flow + +//****** Demo 800X mode Select ******// +//============HRD-INT================// +//#define touch_only_hrd_en +//#define ppg_only_hrd_en +#define auto_hrd_en + +//============HRD-Polling================// +//#define touch_only_polling_hrd_en +//#define ppg_only_polling_hrd_en +//#define auto_polling_hrd_en + + +//============SPO2-INT================// +//#define touch_only_spo2_en +//#define ppg_only_spo2_en +//#define auto_spo2_en + +//============SPO2-Polling================// +//#define touch_only_polling_spo2_en +//#define ppg_only_polling_spo2_en +//#define auto_polling_spo2_en + + +//============Stress-INT================// +//#define touch_only_stress_en +//#define ppg_only_stress_en +//#define auto_stress_en + +//============Stress-Polling================// +//#define touch_only_polling_stress_en +//#define ppg_only_polling_stress_en +//#define auto_polling_stress_en + +//=========== Test_pattern======== // +//#define hrd_testpattern_en +//#define spo2_testpattern_en + +//=========== Factory _Test=========// +//#define factory_test_en + + +//============HRD-INT====PC Cover============// +//#define touch_only_hrd_en_pc +//#define ppg_only_hrd_en_pc +//#define auto_hrd_en_pc + +//============HRD-Polling======PC Cover==========// +//#define touch_only_polling_hrd_en_pc +//#define ppg_only_polling_hrd_en_pc +//#define auto_polling_hrd_en_pc + +#endif // header guard diff --git a/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_unit.h b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_unit.h new file mode 100644 index 000000000..64a1a7e67 --- /dev/null +++ b/code/sdk/zhihui/drivers/ppg/pah8009/sensor/pah_unit.h @@ -0,0 +1,340 @@ +#ifndef __pah_unit_h__ +#define __pah_unit_h__ + +// c +#include +#include +#include +#include +#include +#include + + +//============================================================================ +// Default +//============================================================================ +#define PAH_800x_DEFAULT_PPG_INITIAL_EXPOSURE (400) + +#define PAH_800x_DEFAULT_ENABLE_PPG_CONVERGENCE true + + +#define PAH_800x_DEFAULT_PPG_CONVERGENCE_COUNT (0) +#define PAH_800x_DEFAULT_PPG_CONVERGENCE_T_WEIGHT_NORMAL_MODE (8) +#define PAH_800x_DEFAULT_PPG_CONVERGENCE_T_WEIGHT_FAST_MODE (16) +#define PAH_800x_DEFAULT_PPG_CONVERGENCE_T_MIN (10) +#define PAH_800x_DEFAULT_PPG_CONVERGENCE_T_MAX (1792) +#define PAH_800x_DEFAULT_PPG_CONVERGENCE_RAW_OUTER_HIGH_BOUND (12288) +#define PAH_800x_DEFAULT_PPG_CONVERGENCE_RAW_INNER_HIGH_TARGET (10240) +#define PAH_800x_DEFAULT_PPG_CONVERGENCE_RAW_INNER_LOW_TARGET (8192) +#define PAH_800x_DEFAULT_PPG_CONVERGENCE_RAW_OUTER_LOW_BOUND (6144) + +#define PAH_800x_DEFAULT_ENABLE_PPG_RECONVERGENCE_IF_OUT_OF_BOUNDS true + + +//============================================================================ +// Definition +//============================================================================ + +// I2C 7-bit ID +#define PAH_800x_DEFAULT_I2C_SLAVE_ID_1 (0x40) +#define PAH_800x_DEFAULT_I2C_SLAVE_ID_2 (0x10) + +#define PAH_800x_PRODUCT_ID (0x8008) + + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @file pah_ret.h + * + * Copyright (c) 2016-2018 PixArt Imaging Inc. + * All Rights Reserved. + * Confidential and Proprietary - PixArt Imaging Inc. + **/ + +typedef enum { + + PAH_RET_SUCCESS = 0, // Success + + PAH_RET_PENDING, + + PAH_RET_FAILED, // Unknown error, generally there exists bug in this driver + + PAH_RET_PLAT_FAILED, // Platform API failed + PAH_RET_VERIFY_FAILED, // Verify device failed + + PAH_RET_NOT_IMPLEMENTED, // This API is not supported or is not implemented + + PAH_RET_INVALID_ARGUMENT, // Invalid argument to API + PAH_RET_INVALID_OPERATION, // This operation is not available at this time + + PAH_RET_FIFO_CKS_FAILED, // Failed to compare check sum with fifo data + PAH_RET_FIFO_OVERFLOW, // Fifo in device is overflow + + PAH_RET_ASYNC_PENDING, + +} pah_ret; + +typedef enum { + PAH_800x_CH_NUM_A = 0, + PAH_800x_CH_NUM_B, + PAH_800x_CH_NUM_C, + PAH_800x_MAX_CH_NUM, +} pah_800x_ch_num; + +#define PAH_SUCCEEDED(ret) (ret == PAH_RET_SUCCESS) +#define PAH_FAILED(ret) (!PAH_SUCCEEDED(ret)) + + +#define PAH_CHECK_RET(ret) \ + if (PAH_FAILED(ret)) { \ + return ret; \ + } + +#define PAH_CHECK_NULL(p) \ + if (!p) { \ + return PAH_RET_INVALID_ARGUMENT; \ + } + + + +/** + * @file pah_plat.h + * + * Copyright (c) 2016-2018 PixArt Imaging Inc. + * All Rights Reserved. + * Confidential and Proprietary - PixArt Imaging Inc. + **/ + + + + +//============================================================================ +// Definition +//============================================================================ + +//============================================================================ +// Macro +//============================================================================ +#ifndef __FILENAME__ +# define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) +#endif + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + + +/** + * @file pah_util.h + * + * Copyright (c) 2016-2018 PixArt Imaging Inc. + * All Rights Reserved. + * Confidential and Proprietary - PixArt Imaging Inc. + **/ + + + +#define PAH_ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) + +#define PAH_SET_BIT(var,pos) do { ((var) |= (1 << (pos))); } while(0) +#define PAH_CLEAR_BIT(var,pos) do { ((var) &= ~(1 << (pos))); } while(0) +#define PAH_CHECK_BIT(var,pos) (((var) >> (pos)) & 1) + +// +// PAH_SET_BITSLICE +// +// ex1: +// // var = 0x00 : 00000000 +// // pos = 2 : ^ +// // mask = 0x3C : 00111100 +// // value = 0x0D : 1101 +// // ret = 0x34 : 00110100 +// uint8_t data = 0x00; +// uint8_t ret = PAH_SET_BITSLICE(data, 2, 0x3C, 0x0D); +// +// ex2: +// // var = 0x6D : 01101101 +// // pos = 6 : ^ +// // mask = 0xC0 : 11000000 +// // value = 0x02 : 10 +// // ret = 0xAD : 10101101 +// uint8_t data = 0x6D; +// uint8_t ret = PAH_SET_BITSLICE(data, 6, 0xC0, 0x02); +// +#define PAH_SET_BITSLICE(var, pos, mask, value) \ + ((var & ~mask) | ((value << pos) & mask)) + +// +// PAH_GET_BITSLICE +// +// ex1: +// // var = 0x5D : 01011101 +// // pos = 2 : ^ +// // mask = 0x3C : 00111100 +// // ret = 0x07 : 0111 +// uint8_t ret = PAH_GET_BITSLICE(0x5D, 2, 0x3C); +// +// ex2: +// // var = 0xA6 : 10100110 +// // pos = 5 : ^ +// // mask = 0xE0 : 11100000 +// // ret = 0x05 : 101 +// uint8_t ret = PAH_GET_BITSLICE(0xA6, 5, 0xE0); +// +#define PAH_GET_BITSLICE(var, pos, mask) \ + ((var & mask) >> pos) + +#define PAH_UINT64_HIGH(var) ((uint32_t)(var >> 32)) +#define PAH_UINT64_LOW(var) ((uint32_t)(var & UINT32_MAX)) + +#define PAH_UINT16_HIGH(var) ((uint8_t)(var >> 8)) +#define PAH_UINT16_LOW(var) ((uint8_t)(var & UINT8_MAX)) + +#define PAH_UNUSED_VAR(var) (void)(var) +#define UNUSED_VAR(var) (void)(var) + +#ifndef __FILENAME__ +# define __FILENAME__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__) +#endif + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/** + * @file pah_reg.h + * + * Copyright (c) 2016-2018 PixArt Imaging Inc. + * All Rights Reserved. + * Confidential and Proprietary - PixArt Imaging Inc. + **/ + + + + +//============================================================================ +// Definition +//============================================================================ +typedef const uint8_t (pah_reg)[2]; + + +typedef struct { + + pah_reg *reg_arr; + uint32_t reg_arr_len; + +} pah_reg_arr; + + +#define PAH_REG_ARR_SETUP(pah_reg_arr, reg_array) \ + do { \ + pah_reg_arr.reg_arr = (pah_reg*)reg_array; \ + pah_reg_arr.reg_arr_len = PAH_ARRAY_SIZE(reg_array); \ + } while(0) + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +//============================================================================ +// Register address +//============================================================================ + +/*#define PAH_800x_ADDR_00_PRODUCT_ID (0x00) +#define PAH_800x_ADDR_03 (0x03) +#define PAH_800x_ADDR_03_BIT_R_PS_EN (0) +#define PAH_800x_ADDR_03_BIT_R_ALS_EN (1) +#define PAH_800x_ADDR_03_BIT_SW_SUSPEND (5) + +#define PAH_800x_ADDR_04 (0x04) +#define PAH_800x_ADDR_04_BIT_ALS_OVERFLOW_ECO (7) + +#define PAH_800x_ADDR_09 (0x09) +#define PAH_800x_ADDR_09_BIT_ALS_INTERRUPT (2) +#define PAH_800x_ADDR_09_BIT_PS_INTERRUPT (5) +#define PAH_800x_ADDR_09_BIT_PS_APPROACH (6) + +#define PAH_800x_ADDR_10_PS_ONOFF_SYNC (0x10) + +#define PAH_800x_ADDR_11 (0x11) +#define PAH_800x_ADDR_11_BIT_R_LED_CONTROL_OUT_EN (4) +#define PAH_800x_ADDR_11_BIT_R_PS_INTERRUPT_EN (7) + +#define PAH_800x_ADDR_0E_ALS_LUX_SYNC (0x0E) + +#define PAH_800x_ADDR_34 (0x34) +#define PAH_800x_ADDR_34_BIT_R_EXPOSURE_ALS_F0 (0) + +#define PAH_800x_ADDR_35 (0x35) +#define PAH_800x_ADDR_35_BIT_R_EXPOSURE_ALS_F0 (0) + +#define PAH_800x_ADDR_38 (0x38) +#define PAH_800x_ADDR_38_BIT_0_LOCK_EXPOTIME (0) +#define PAH_800x_ADDR_38_BIT_1_CLEAR_ALS_OVERFLOW_ECO (1) + +#define PAH_800x_ADDR_EC (0xEC) +#define PAH_800x_ADDR_EC_BIT_7_R_CLK_MANUAL (7)*/ + +#define PAH_800x_ADDR_00_PRODUCT_ID (0x00) + +#define PAH_800x_ADDR_07_TG (0X07) +#define PAH_800x_ADDR_07_TG_BIT_EN (0) + +#define PAH_800x_ADDR_20 (0x20) +#define PAH_800x_ADDR_20_BIT_DR_FLAG (0) +#define PAH_800x_ADDR_20_BIT_OVERFLOW_FLAG (1) +#define PAH_800x_ADDR_20_BIT_TOUCH_FLAG (2) + +//expo A Sync +#define PAH_800x_ADDR_2A (0x2A) +#define PAH_800x_ADDR_2B (0x2B) + +#define PAH_800x_ADDR_35 (0x35) +#define PAH_800x_ADDR_36 (0x36) + +#define PAH_800x_ADDR_40 (0x40) +#define PAH_800x_ADDR_41 (0x41) + +#define PAH_800x_ADDR_11_EnCh (0x11) + +//expo A write +#define PAH_800x_ADDR_17 (0x17) +#define PAH_800x_ADDR_18 (0x18) + +#define PAH_800x_ADDR_19 (0x19) +#define PAH_800x_ADDR_1A (0x1A) + +#define PAH_800x_ADDR_1B (0x1B) +#define PAH_800x_ADDR_1C (0x1C) + +//frame period + +#define PAH_800x_ADDR_2C (0x2C) +#define PAH_800x_ADDR_2D (0x2D) + +#define PAH_800x_ADDR_37 (0x37) +#define PAH_800x_ADDR_38 (0x38) + +#define PAH_800x_ADDR_42 (0x42) +#define PAH_800x_ADDR_43 (0x43) + +//adc + +#define PAH_800x_ADDR_2E (0x2E) +#define PAH_800x_ADDR_2F (0x2F) + +#define PAH_800x_ADDR_39 (0x39) +#define PAH_800x_ADDR_3A (0x3A) + +#define PAH_800x_ADDR_44 (0x44) +#define PAH_800x_ADDR_45 (0x45) + +#define PAH_800x_ADDR_27_RAWDATA_A_SYNC (0x27) +#define PAH_800x_ADDR_32_RAWDATA_B_SYNC (0x32) +#define PAH_800x_ADDR_3D_RAWDATA_C_SYNC (0x3D) + +#define PAH_800x_ADDR_E8 (0xE8) +#define PAH_800x_ADDR_E8_CMD_SUSPEND_MODE_BIT (0) + +#define PAH_800x_ADDR_EB (0xEB) +#define PAH_800x_ADDR_E8_UPDATE_FLAG (0x80) + +#define PAH_800x_ADDR_EE (0xEE) +#define PAH_800x_ADDR_EE_SW_RESET (0x1F)//(0x07) +#define PAH_800x_ADDR_D2 (0xD2) +#define PAH_800x_ADDR_D2_OD_EnH (5) + +#endif // header guard diff --git a/code/sdk/zhihui/drivers/ppg/service/ppg_service.cpp b/code/sdk/zhihui/drivers/ppg/service/ppg_service.cpp index ac40a9654..6cdc1dc75 100644 --- a/code/sdk/zhihui/drivers/ppg/service/ppg_service.cpp +++ b/code/sdk/zhihui/drivers/ppg/service/ppg_service.cpp @@ -41,15 +41,14 @@ extern "C" { #include "cmsis_os2.h" #include "ppg_service.h" #include "los_printf.h" - #include "thread_init.h" #include "custom_utils.h" #include "custom_save_runtime.h" #include "ppg_hal.h" -// #ifdef PPG_HX3695 -// #include "hx3695.h" -// #endif +#ifdef PPG_HX3695 +#include "hx3695.h" +#endif #if defined(PPG_VC9202) #include "vc9202_hal.h" @@ -58,8 +57,7 @@ extern "C" { #include "vc921x_hal.h" #include "vc921x_user_app.h" #elif defined(PPG_GH3X2X) -#include "gh3x2x_hal.h" -#include "gh3x2x_afe_drv.h" +// #include "gh_demo.h" #else #endif @@ -67,10 +65,6 @@ static bool g_ppg_service_initialled = false; uint8_t card_databuf[64] = {0}; uint8_t light_databuf[64] = {0}; - -osTimerId_t g_ppg_service_timer = NULL; - - /*** * 其他cmd在Header里定义,对外开放 */ @@ -95,151 +89,92 @@ void set_keep_in_wear_det_mode(uint8_t mod) keep_in_wear_det_mod = mod; } -#ifdef PPG_HX3695 -//漏光测试 -errcode_t update_leaklight_event_notify(uint8_t *data) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "send lightdata to ui %s",data); - //CustomEventPublish(TOPIC_EVENT_LEAKLIGHT_UPDATA,(uint8_t*)data,strlen((char*)data)); - return 0; -} -errcode_t update_leaklight_event_sendmsg_toUI(uint8_t *data) -{ - /**通过UI事件发送Notify*/ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_leaklight_event_notify, data)); - return ERRCODE_SUCC; -} - - -//灰卡测试 -errcode_t update_graycard_event_notify(uint8_t *data) -{ - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "send carddata to ui %s",data); - //CustomEventPublish(TOPIC_EVENT_GRAYCARD_UPDATA,(uint8_t*)data,strlen((char*)data)); - return 0; -} -errcode_t update_graycard_event_sendmsg_toUI(uint8_t *data) -{ - /**通过UI事件发送Notify*/ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_graycard_event_notify, data)); - return ERRCODE_SUCC; -} - - -//血氧 -errcode_t update_spo2_event_notify(uint8_t spo2) -{ - //CustomEventPublish(TOPIC_EVENT_SPO2_UPDATE,(uint8_t*)&spo2,sizeof(spo2)); - return 0; -} -errcode_t update_spo2_event_sendmsg_toUI(uint8_t spo2) -{ - /**通过UI事件发送Notify*/ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_spo2_event_notify, spo2)); - return ERRCODE_SUCC; -} - -//心率 -errcode_t update_hrs_event_notify(uint8_t hrs) -{ - //CustomEventPublish(TOPIC_EVENT_HEARTRATE_UPDATA,(uint8_t*)&hrs,sizeof(hrs)); - return 0; -} -errcode_t update_hrs_event_sendmsg_toUI(uint8_t hrs) -{ - /**通过UI事件发送Notify*/ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_hrs_event_notify, hrs)); - return ERRCODE_SUCC; -} - +// //血氧 +// errcode_t update_spo2_event_notify(uint8_t spo2) +// { +// CustomEventPublish(TOPIC_EVENT_SPO2_UPDATE,(uint8_t*)&spo2,sizeof(spo2)); +// return 0; +// } +// errcode_t update_spo2_event_sendmsg_toUI(uint8_t spo2) +// { +// /**通过UI事件发送Notify*/ +// GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_spo2_event_notify, spo2)); +// return ERRCODE_SUCC; +// } -//穿戴状态 -errcode_t update_wearstatus_event_notify(int32_t wearstatus) -{ - //CustomEventPublish(TOPIC_EVENT_WEARSTATE_UPDATE,(uint8_t*)&wearstatus,sizeof(wearstatus)); - return 0; -} -errcode_t update_wearstatus_event_sendmsg_toUI(int32_t wearstatus) -{ - /**通过UI事件发送Notify*/ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_wearstatus_event_notify, wearstatus)); - return ERRCODE_SUCC; -} +// //心率 +// errcode_t update_hrs_event_notify(uint8_t hrs) +// { +// CustomEventPublish(TOPIC_EVENT_HEARTRATE_UPDATA,(uint8_t*)&hrs,sizeof(hrs)); +// return 0; +// } +// errcode_t update_hrs_event_sendmsg_toUI(uint8_t hrs) +// { +// /**通过UI事件发送Notify*/ +// GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_hrs_event_notify, hrs)); +// return ERRCODE_SUCC; +// } -//静息心率 -errcode_t update_static_hrs_event_notify(int32_t hrs) -{ - //CustomEventPublish(TOPIC_EVENT_STATIC_HEARTRATE_UPDATA,(uint8_t*)&hrs,sizeof(hrs)); - return 0; -} -errcode_t update_static_hrs_event_sendmsg_toUI(int32_t hrs) -{ - /**通过UI事件发送Notify*/ - GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_static_hrs_event_notify, hrs)); - return ERRCODE_SUCC; -} +// //穿戴状态 +// errcode_t update_wearstatus_event_notify(int32_t wearstatus) +// { +// CustomEventPublish(TOPIC_EVENT_WEARSTATE_UPDATE,(uint8_t*)&wearstatus,sizeof(wearstatus)); +// return 0; +// } +// errcode_t update_wearstatus_event_sendmsg_toUI(int32_t wearstatus) +// { +// /**通过UI事件发送Notify*/ +// GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_wearstatus_event_notify, wearstatus)); +// return ERRCODE_SUCC; +// } -void hx3695_msg_callback(uint8_t msg_type, uint8_t *msg_data, int32_t msg_datalen) -{ -#if 0 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "hx3695_msg_callback"); - FT_CUSTOM_RESULTS_t sensor_data; // 使用更通用的名称 sensor_data -#if 1 - if (msg_datalen < sizeof(FT_CUSTOM_RESULTS_t)) { - // 数据长度不足以填充整个结构体 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Invalid data length for SPO2 update"); - //return; - } -#endif - memcpy(&sensor_data, msg_data, sizeof(FT_CUSTOM_RESULTS_t)); - switch(msg_type) - { - case HX3695_MSG_TYPE_HRS_UPDATE: - //每秒心率 - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_HRS_UPDATE = %d", sensor_data.lastesthrs); - update_hrs_event_sendmsg_toUI(sensor_data.lastesthrs); - break; - case HX3695_MSG_TYPE_HRV_UPDATE: - break; - case HX3695_MSG_TYPE_SPO2_UPDATE: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_SPO2_UPDATE = %d", sensor_data.lastestspo2); - update_spo2_event_sendmsg_toUI(sensor_data.lastestspo2); - break; - case HX3695_MSG_TYPE_LEAKLIGHT_UPDATE: - memset_s(light_databuf,64,0,64); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "LEAKLIGHT_UPDATE"); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_leak_green_UPDATE = %d", sensor_data.leak_green); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_leak_red_UPDATE = %d", sensor_data.leak_red); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_leak_ir_UPDATE = %d", sensor_data.leak_ir); - sprintf((char *)light_databuf,"%d,%d,%d",sensor_data.leak_green,sensor_data.leak_red,sensor_data.leak_ir); - update_leaklight_event_sendmsg_toUI(light_databuf); - break; - case HX3695_MSG_TYPE_GRAYCARD_UPDATE: - memset_s(card_databuf,64,0,64); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "GRAYCARD_UPDATE"); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_card_green_UPDATE = %d", sensor_data.card_green); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_card_red_UPDATE = %d", sensor_data.card_red); - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_card_ir_UPDATE = %d", sensor_data.card_ir); - sprintf((char *)card_databuf,"%d,%d,%d",sensor_data.card_green,sensor_data.card_red,sensor_data.card_ir); - update_graycard_event_sendmsg_toUI(card_databuf); - break; - case HX3695_MSG_TYPE_WEARSTAT_UPDATE: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_WEARSTATUS_UPDATE = %d", sensor_data.wearstatus); - update_wearstatus_event_sendmsg_toUI(sensor_data.wearstatus); - break; - case HX3695_MSG_TYPE_STATIC_HRS_UPDATE: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_STATIC_HRS_UPDATE = %d", sensor_data.lastesthrs); - update_static_hrs_event_sendmsg_toUI(sensor_data.lastesthrs); - break; - default: - WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Unknown sensor message type"); - break; - } -#endif -} +// //静息心率 +// errcode_t update_static_hrs_event_notify(int32_t hrs) +// { +// CustomEventPublish(TOPIC_EVENT_STATIC_HEARTRATE_UPDATA,(uint8_t*)&hrs,sizeof(hrs)); +// return 0; +// } +// errcode_t update_static_hrs_event_sendmsg_toUI(int32_t hrs) +// { +// /**通过UI事件发送Notify*/ +// GraphicService::GetInstance()->PostGraphicEvent(std::bind(update_static_hrs_event_notify, hrs)); +// return ERRCODE_SUCC; +// } -#endif +// void ppg_msg_callback(uint8_t msg_type, uint8_t *msg_data, int32_t msg_datalen) +// { +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "ppg_msg_callback"); + +// if(msg_datalen > 1 || msg_data == NULL) +// return; + +// switch(msg_type) +// { +// case PPG_MSG_TYPE_HRS_UPDATE: +// //每秒心率 +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_HRS_UPDATE = %d", *msg_data); +// update_hrs_event_sendmsg_toUI(*msg_data); +// break; +// case PPG_MSG_TYPE_HRV_UPDATE: +// break; +// case PPG_MSG_TYPE_SPO2_UPDATE: +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_SPO2_UPDATE = %d", *msg_data); +// update_spo2_event_sendmsg_toUI(*msg_data); +// break; +// case PPG_MSG_TYPE_WEARSTAT_UPDATE: +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_WEARSTATUS_UPDATE = %d", *msg_data); +// update_wearstatus_event_sendmsg_toUI(*msg_data); +// break; +// case PPG_MSG_TYPE_STATIC_HRS_UPDATE: +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "HX3695_MSG_TYPE_STATIC_HRS_UPDATE = %d", *msg_data); +// update_static_hrs_event_sendmsg_toUI(*msg_data); +// break; +// default: +// WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "Unknown sensor message type"); +// break; +// } +// } void uapi_ppg_service_deinit(void) { @@ -249,17 +184,21 @@ void uapi_ppg_service_deinit(void) errcode_t send_ppg_cmd_msg(int cmd) { errcode_t ret; - if (ppg_sensor_exist == false) + if (ppg_sensor_exist == false) { + // uapi_save_runtime_log(RUNTIME_LOG_HEART_EXIST_ERROR); return OSAL_FAILURE; + } + + // PRINT("cmd : 0x%x\n",cmd); - // printf("send_ppg_cmd_msg cmd : 0x%x\n",cmd); - PPG_CMD_TYPE_T mail = 0; mail = cmd; ret = osal_msg_queue_write_copy(g_app_queue, (void *)&mail, sizeof(PPG_CMD_TYPE_T), 0); if (ret != OSAL_SUCCESS) { - PRINT_ERR("Error ppg Check MSG 0x%02X send failed! err=0x%x! \r\n",cmd, ret); + PRINT_ERR("Error ppg Check MSG 0x%02X send failed! err=0x%x! \r\n", cmd, + ret); + // uapi_save_runtime_log(RUNTIME_LOG_HEART_MSG_ERROR); } return ret; } @@ -279,11 +218,9 @@ static void ppg_service_check_task(void *arg) } if((wear_mode_state == 1) && (mail > 0x10) && mail != PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST) { - // uapi_save_runtime_log(RUNTIME_LOG_WEAR_MIN_STOP); + uapi_save_runtime_log(RUNTIME_LOG_WEAR_MIN_STOP); wear_mode_state = 0; -#ifdef PPG_HX3695 ppg_send_cmd_to_driver("wear",0); -#endif ppg_service_running_stat = false; } char* cmd = "hrs"; @@ -292,6 +229,7 @@ static void ppg_service_check_task(void *arg) // #ifdef PPG_HX3695 // heart_rate_meas_timeout_handler(NULL); // #endif + // ppg_hrs_timer_handler(); ppg_timer_handler(HRS_TIMER_MODE); continue; }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_AGC_TIMER_CALLBACK){ @@ -304,11 +242,12 @@ static void ppg_service_check_task(void *arg) // #ifdef PPG_HX3695 // wear_mode_timeout_handler(NULL); // #endif + // ppg_wear_timer_handler(); ppg_timer_handler(WEAR_TIMER_MODE); continue; }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_TEST){ //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_GET_ACC,NULL); - // uapi_save_runtime_log(RUNTIME_LOG_HEART_DRIVER_MEASURE); + uapi_save_runtime_log(RUNTIME_LOG_HEART_DRIVER_MEASURE); cmd = "hrs"; enable = 1; // uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); @@ -330,8 +269,8 @@ static void ppg_service_check_task(void *arg) cmd = "graycard"; enable = 1; }else if (mail == PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST){ - if (keep_in_wear_det_mod == 0) continue;; - // uapi_save_runtime_log(RUNTIME_LOG_WEAR_MIN_START); + if (keep_in_wear_det_mod == 0) continue; + uapi_save_runtime_log(RUNTIME_LOG_WEAR_MIN_START); cmd = "wear"; enable = 1; wear_mode_state = 1; @@ -347,7 +286,7 @@ static void ppg_service_check_task(void *arg) enable = 0; wear_mode_state = 0; }else if (mail == PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST){ - // uapi_save_runtime_log(RUNTIME_LOG_HEART_DRIVER_MEASURE_END); + uapi_save_runtime_log(RUNTIME_LOG_HEART_DRIVER_MEASURE_END); cmd = "hrs"; enable = 0; // uint8_t cnt = pm_veto_get_id_cnt(PM_ID_HEART); @@ -360,30 +299,21 @@ static void ppg_service_check_task(void *arg) cmd = "spo2"; enable = 0; } - else if (mail == PPG_SERVICE_CMD_TYPE_OPEN_HRS_BLE) - { -#ifdef PPG_HX3695 - // hx3695_set_hrs_ble_swtich(1); -#endif - continue ; - } - else if (mail == PPG_SERVICE_CMD_TYPE_CLOSE_HRS_BLE) - { -#ifdef PPG_HX3695 - // hx3695_set_hrs_ble_swtich(0); -#endif - continue ; - }else if (mail == PPG_SERVICE_CMD_TYPE_INT_HANDLER){ -#ifdef PPG_VC9202 - vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,0); -#elif defined PPG_VC921X - cmd = "int"; - enable = 1; - ppg_send_cmd_to_vc921x_driver(cmd,enable); -#elif defined PPG_GH3X2X - hal_gh3x2x_afe_int_handler_call_back(); - GH3X2X_AFE_ChipPro(); -#endif + else if (mail == PPG_SERVICE_CMD_TYPE_INT_HANDLER){ +// #ifdef PPG_VC9202 +// vc9202_usr_interrupt_handler(SPORT_TYPE_NORMAL,0); +// #elif defined PPG_VC921X +// cmd = "int"; +// enable = 1; +// ppg_send_cmd_to_vc921x_driver(cmd,enable); +// #elif defined PPG_GH3X2X +// hal_gh3x2x_afe_int_handler_call_back(); +// GH3X2X_AFE_ChipPro(); +// #elif defined PPG_PAH8009 +// hal_gh3x2x_afe_int_handler_call_back(); +// GH3X2X_AFE_ChipPro(); +// #endif + ppg_int_handler(); continue; } else if (mail == PPG_SERVICE_CMD_TYPE_FPC_TEST){ @@ -408,36 +338,23 @@ static void ppg_service_check_task(void *arg) continue ; } -#ifdef PPG_HX3695 ppg_send_cmd_to_driver(cmd,enable); -#elif defined (PPG_VC9202) - ppg_send_cmd_to_vc9202_driver(cmd,enable); -#elif defined(PPG_VC921X) - ppg_send_cmd_to_vc921x_driver(cmd,enable); -#elif defined(PPG_GH3X2X) - ppg_send_cmd_to_gh3x2x_driver(cmd,enable); -#endif if(enable == 1) ppg_service_running_stat = true; else ppg_service_running_stat = false; - if((strcmp(cmd, "wear") != 0) && (enable == 0)) { if (keep_in_wear_det_mod == 1) { uapi_save_runtime_log(RUNTIME_LOG_WEAR_MIN_START); -#ifdef PPG_HX3695 ppg_send_cmd_to_driver("wear",1); -#endif wear_mode_state = 1; ppg_service_running_stat = true; } } - } - } void create_ppg_queue(void) { @@ -452,7 +369,7 @@ errcode_t uapi_ppg_service_init(void) if (ppg_get_chip_id() != PPG_CHIP_ID) { - LOS_Mdelay(50); + LOS_Mdelay(10); if (ppg_get_chip_id() != PPG_CHIP_ID) { @@ -461,12 +378,19 @@ errcode_t uapi_ppg_service_init(void) } } + // ppg_register_msg_callback(ppg_msg_callback);//注册驱动回调 + // ppg_send_cmd_to_driver("wear",0); + ppg_sensor_exist = true; app_task_definition_t taskcfg={0}; taskcfg.create_queue_handle = create_ppg_queue; taskcfg.attr.name="ppg_service"; +// #ifdef BOARD_FD230 taskcfg.attr.priority = osPriorityBelowNormal4; +// #else +// taskcfg.attr.priority = osPriorityAboveNormal5; +// #endif taskcfg.attr.stack_size = PPG_SERVICE_TASK_SIZE; taskcfg.func = ppg_service_check_task; taskcfg.use_mem = USE_EXTEND_MEM; @@ -478,17 +402,14 @@ errcode_t uapi_ppg_service_init(void) return ERRCODE_FAIL; } - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST); - // g_ppg_service_timer = osTimerNew((osTimerFunc_t)ppg_int_callback, osTimerPeriodic, NULL, NULL); - return ERRCODE_SUCC; } void ppg_int_callback(pin_t pin, uintptr_t param) { uapi_gpio_clear_interrupt(pin); - uint32_t tm; - uapi_get_timestampe_ms(&tm); + // uint32_t tm; + // uapi_get_timestampe_ms(&tm); // PRINT("ppg_int_callback %d 0x%X tm : %d \n",pin,param,tm); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_INT_HANDLER); } @@ -502,6 +423,7 @@ void ppg_int_callback(pin_t pin, uintptr_t param) // DEBUG_PRINTF("ppg_service_service suspend!\r\n"); // } + #ifdef __cplusplus #if __cplusplus } diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/CMakeLists.txt b/code/sdk/zhihui/drivers/ppg/vc9202/CMakeLists.txt deleted file mode 100644 index 0bf14bb6e..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/CMakeLists.txt +++ /dev/null @@ -1,63 +0,0 @@ -#=============================================================================== -# @brief cmake file -# Copyright (c) @CompanyNameMagicTag 2022-2023. All rights reserved. -#=============================================================================== -set(COMPONENT_NAME "ppg_sensor_vc9202") - -if("PPG_VC9202" IN_LIST DEFINES) -set(SOURCES ${SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/src/vc9202_driver_testmode.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vc9202_driver.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vc9202_user_debug.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vc9202_user.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vc9202_hal.c -) -set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/inc - -) - -else() -set(SOURCES ${SOURCES} - # ${CMAKE_CURRENT_SOURCE_DIR}/ztw523_touch/ztw523_ctrl.c -) -set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR} -) -endif() - - -set(PRIVATE_HEADER -) - -set(PRIVATE_DEFINES -) - -set(PUBLIC_DEFINES -) - -# use this when you want to add ccflags like -include xxx -set(COMPONENT_PUBLIC_CCFLAGS -) - -set(COMPONENT_CCFLAGS -) - -set(WHOLE_LINK - true -) - -set(MAIN_COMPONENT - false -) - -if("PPG_VC9202" IN_LIST DEFINES) - find_library(LIB_PATH_VC9202_1 lib/lib_BIO_v151_int_miniSDK_log_02.a ${CMAKE_CURRENT_SOURCE_DIR}) - find_library(LIB_PATH_VC9202_2 lib/lib_hr_v640ed04_miniSDK_NA_01.a ${CMAKE_CURRENT_SOURCE_DIR}) - find_library(LIB_PATH_VC9202_3 lib/lib_Sp_Int_HaiSi_01.a ${CMAKE_CURRENT_SOURCE_DIR}) - find_library(LIB_PATH_VC9202_4 lib/lib_spo2_9202A4_limit_HaiSi_NA_01.a ${CMAKE_CURRENT_SOURCE_DIR}) - - target_link_libraries(${TARGET_NAME} PRIVATE -Wl,--whole-archive ${LIB_PATH_VC9202_1} ${LIB_PATH_VC9202_2} ${LIB_PATH_VC9202_3} ${LIB_PATH_VC9202_4} PRIVATE -Wl,--whole-archive) -endif() -build_component() - diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/inc/BIODetect_V15_1.h b/code/sdk/zhihui/drivers/ppg/vc9202/inc/BIODetect_V15_1.h deleted file mode 100644 index d03b0b1dd..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/inc/BIODetect_V15_1.h +++ /dev/null @@ -1,16 +0,0 @@ - - -#ifndef BIODETECT -#define BIODETECT - -#include -#include -#include - -void f_BIOInit(int32_t gapDeltaBIO, int32_t gapDeltaPS); - -uint8_t f_BIOdetect(int32_t inputBIO, int32_t inputPS, int32_t PSth); - -char* bioVersion(void); - -#endif /* BIODETECT */ \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/inc/algo.h b/code/sdk/zhihui/drivers/ppg/vc9202/inc/algo.h deleted file mode 100644 index a370e99ff..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/inc/algo.h +++ /dev/null @@ -1,70 +0,0 @@ - -#ifndef APP_ALGO_ALGO_H -#define APP_ALGO_ALGO_H - -#include -#include - -typedef enum -{ - SPORT_TYPE_NORMAL =0x00, // 日常 - SPORT_TYPE_RUNNING =0x01, // 跑步 - SPORT_TYPE_RIDE_BIKE =0X02, // 骑行 - SPORT_TYPE_JUMP_ROPE =0X03, // 跳绳 - SPORT_TYPE_SWIMMING =0X04, // 游泳 - SPORT_TYPE_BADMINTON =0X05, // 羽毛球 - SPORT_TYPE_TABLE_TENNIS=0X06, // 乒乓球 - SPORT_TYPE_TENNIS =0X07, // 网球 - SPORT_TYPE_CLIMBING =0X08, // 爬山 - SPORT_TYPE_WALKING =0X09, // 椭圆机 - SPORT_TYPE_BASKETBALL =0X0A, // 篮球 - SPORT_TYPE_FOOTBALL =0X0B, // 足球 - SPORT_TYPE_BASEBALL =0X0C, // 棒球 - SPORT_TYPE_VOLLEYBALL =0X0D, // 排球 - SPORT_TYPE_CRICKET = 0X0E, // 板球 - SPORT_TYPE_RUGBY = 0X0F, // 橄榄球 - SPORT_TYPE_HOCKEY =0X10, // 曲棍球 - SPORT_TYPE_DANCE = 0X11, // 跳舞 - SPORT_TYPE_SPINNING = 0X12, // 动感单车 - SPORT_TYPE_YOGA = 0X13, // 瑜伽 - SPORT_TYPE_SIT_UP =0X14, // 仰卧起坐 - SPORT_TYPE_TREADMILL =0X15, // 跑步机 - SPORT_TYPE_GYMNASTICS =0X16, // 体操 - SPORT_TYPE_BOATING = 0X17, // 划船 - SPORT_TYPE_JUMPING_JACK = 0X18, // 开合跳 - SPORT_TYPE_FREE_TRAINING = 0X19,// 自由训练 - SPORT_TYPE_PERIODIC_MONITORING = 0X1A,// 定时监测模式 -} AlgoSportMode; -//未出现在上表中的运动形式均先以跑步输入 - - -typedef struct -{ - int32_t x; - int32_t y; - int32_t z; -}AlgoAxesData_t; - -typedef struct -{ - int32_t hrData; - int32_t reliability; -}AlgoOutputData_t; - -typedef struct -{ - AlgoAxesData_t axes; - int32_t ppgSample; - int32_t envSample; -}AlgoInputData_t; - -void Algo_Init(void); -void Algo_Input(AlgoInputData_t *pInputData,int32_t gaptime,AlgoSportMode sportMode,int16_t surfaceRecogMode,int16_t opticalAidMode); -void Algo_Output(AlgoOutputData_t *pOutputData); - - - -#endif /* APP_ALGO_ALGO_H_ */ - - - diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/inc/spo2Algo.h b/code/sdk/zhihui/drivers/ppg/vc9202/inc/spo2Algo.h deleted file mode 100644 index 351643ae3..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/inc/spo2Algo.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __SPO2ALGO_H__ -#define __SPO2ALGO_H__ - -#include - -void spo2AlgoInit(void); -int32_t spo2Algo(int32_t r_ppg, int32_t ir_ppg, int32_t mode); - -void spo2_algo_content_init(void); - -char * -version_info_spo2(void); - -#endif diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc30x91x92x_common.h b/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc30x91x92x_common.h deleted file mode 100644 index 36badd54a..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc30x91x92x_common.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * @Author: penglei 1624952103@qq.com - * @Date: 2024-12-07 16:04:22 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-12-09 10:32:42 - * @FilePath: /sdk615/code/sdk/drivers/peripheral/ppg/vc9202/vc30x91x92x_common.h - * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE - */ -/********************************************************************************************************* - * Copyright(c) 2022, vcare Corporation. All rights reserved. - ********************************************************************************************************** - * @file vc30x91x92x_common.h - * @brief configuration file for vc30x,vc91x,vc92x. - * @details - * @author - * @date - * @version - *********************************************************************************************************/ -#ifndef __VC30x91x92x_COMMON_H__ -#define __VC30x91x92x_COMMON_H__ - -#include "algo.h" -#include "spo2Algo.h" -#include "vcSportMotionIntAlgo.h" - -#ifndef SUB -#define SUB(a, b) ((a) - (b)) -#endif -#ifndef ABS -#define ABS(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) -#endif - -#define FUNC_DISABLE (0) -#define FUNC_ENABLE (!FUNC_DISABLE) -#define WEAR_IS_DROP (0) -#define WEAR_IS_HOLD (1) - -typedef enum -{ - WEAR_STA_NONE = 0, - WEAR_STA_HOLD = 1, - WEAR_STA_DROP = 2, -}WearStatusTypeDef; - -typedef enum -{ - WORK_MODE_NONE = 0, - WORK_MODE_HR = 1, - WORK_MODE_SPO2 = 2, - WORK_MODE_HRV = 3, /* 100hz������ʹ��BIO������Ҫ��֤�ܹ��õ���ʱ��Ӧ��������Ȼ���ܻᵼ�¶��жϣ����������� */ - WORK_MODE_STRESS = 4, - WORK_MODE_WEAR = 5, - WORK_MODE_FACTORY = 6, - WORK_MODE_TEMPERATURE = 7, - WORK_MODE_FPC_TEST = 8, -}WorkModeTypeDef; - -typedef struct -{ - unsigned short sampling_gap_time; - WorkModeTypeDef work_mode; -}InitParamTypeDef; - -typedef struct -{ - unsigned char led_cur[3]; - unsigned char pd_res[3]; - unsigned char env_val[3]; - unsigned char pre_val[2]; - unsigned char ps_val; - unsigned char aenv_val[3]; - unsigned char apdbias_val[4]; - unsigned int pdbias; - unsigned char apre_val[2]; - unsigned char aps_val; - unsigned int ppg_data[128]; - unsigned short int bio_val_i; - unsigned short int bio_val_o; - signed short int temp_val_i; - signed short int temp_val_o; -}SamplingDataTypeDef; - -extern unsigned char usr_iic_write_bytes(unsigned char reg_addr, unsigned char *pBuffer, unsigned char buf_size); -extern unsigned char usr_iic_read_bytes(unsigned char reg_addr, unsigned char *pBuffer, unsigned char buf_size); -extern unsigned int usr_get_clock_ticks(void); - -#endif diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_common.h b/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_common.h deleted file mode 100644 index 64d5ff998..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_common.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * @Author: penglei 1624952103@qq.com - * @Date: 2024-12-07 16:04:22 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-12-10 18:40:24 - * @FilePath: /sdk615/code/sdk/drivers/peripheral/ppg/vc9202/inc/vc9202_common.h - * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE - */ -/********************************************************************************************************* - * Copyright(c) 2022, vcare Corporation. All rights reserved. - ********************************************************************************************************** - * @file vc9202_common.h - * @brief configuration file for the hardware driver layer - * @details - * @author - * @date - * @version - *********************************************************************************************************/ -#ifndef __VC9202_COMMON_H__ -#define __VC9202_COMMON_H__ - -#include "vc30x91x92x_common.h" - -#define VC9202_CFG_DRV_BY_TIMER (FUNC_DISABLE) -/* VC_COMMON_VC9202_CFG_SAMPLE_RATE: default 25hz */ -#define VC9202_CFG_SAMPLE_RATE (25) -/*VC_COMMON_CFG_GPIO_TIME: 0-50us, 1-100us, 2-200us, 3-400us */ -#define VC9202_CFG_INTERRUPT_TIME (3) -/* 0:rising edge 1:descending edge */ -#define VC9202_CFG_INTERRUPT_MODE (0) - -#define VC9202_CFG_CLK_CHECK_FREQUENCY (32000) //counter 32K -#define VC9202_CFG_CLK_CHECK_MAX (0xFFFFFF) //24bits counter -#define VC9202_CFG_CLK_CHECK_GAPTIME (10) //seconds -#define VC9202_CFG_CLK_CHECK_DEVIATION (3) - -/**************************************************************************** - * Configuration wear parameters - ***************************************************************************/ -#define VC9202_CFG_WEAR_DETECTION (FUNC_ENABLE) // FUNC_DISABLE FUNC_ENABLE -#define VC9202_CFG_WEAR_DEFAULT_STATUS (WEAR_IS_HOLD) //1 is default wear,0 is default not wear WEAR_IS_HOLD WEAR_IS_DROP -#define VC9202_CFG_WEAR_BIO_EN (FUNC_ENABLE) -#define VC9202_CFG_WEAR_ALG_EN (FUNC_DISABLE) //开启心率摘下功能,必须开启满足(ATC|BIO)为真 -#define VC9202_CFG_WEAR_ACT_EN (FUNC_DISABLE) -#define VC9202_CFG_WEAR_THRESHOLD_EN (FUNC_ENABLE) //绝对阈值宏开关 -#define VC9202_CFG_WEAR_HOLD_CNT (1) -#define VC9202_CFG_WEAR_DROP_CNT (3) - -/* sensor serial default wear param */ -#define VC9202_CFG_WEAR_PARAM_PS (128) -#define VC9202_CFG_WEAR_PARAM_PSIN (100) -#define VC9202_CFG_WEAR_PARAM_ENVMAX (128) //8*16 -#define VC9202_CFG_WEAR_PARAM_ENVMIN (64) //4*16 -#define VC9202_CFG_WEAR_PARAM_BIOIN (40) - -#define VC9202_CFG_PS_SLOT_CUR (0x3A) /* 0x5A */ -#define VC9202_CFG_PS_SLOT_RES (0x47) - -/* board cap halve,电容减半,需要提高一倍采样率的配置 */ -#define VC9202_CFG_IS_HALVE_CAP 0 - -/* VC9202 function */ -extern unsigned char vc9202_drv_reg_init(InitParamTypeDef *pInit_Param); -extern unsigned char vc9202_drv_get_chip_id(void); -extern void vc9202_drv_start_sampling(void); -extern void vc9202_drv_stop_sampling(void); -extern void vc9202_drv_soft_reset(void); -extern unsigned char vc9202_drv_channel_switch(unsigned char num_channel, unsigned char enable_flag); -extern unsigned char vc9202_drv_get_int_reason(void); -extern void vc9202_drv_set_algo_wear_status(WearStatusTypeDef status); -extern void vc9202_drv_set_gsensor_actuating_quantity(unsigned int axis_diff); -extern WearStatusTypeDef vc9202_drv_get_wear_status(void); -extern unsigned char vc9202_drv_get_sampling_data(SamplingDataTypeDef *pSamplingData, unsigned char *psize); -/* electrostatic patch */ -extern void vc9202_drv_electrostatic_death( void ); - -#endif diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_driver.h b/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_driver.h deleted file mode 100644 index 047534aaa..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_driver.h +++ /dev/null @@ -1,184 +0,0 @@ -/********************************************************************************************************* - * Copyright(c) 2022, vcare Corporation. All rights reserved. - ********************************************************************************************************* - * @file vc9202_driver.h - * @brief vc9202 driver layer interface implementation. - * @details - * @author - * @date - * @version - *********************************************************************************************************/ - -#ifndef __VC9202_DRIVER_H__ -#define __VC9202_DRIVER_H__ - -#include "vc9202_common.h" - -#define VC9202_STATUS_CONFLICT (1<<4) -#define VC9202_STATUS_INSAMPLE (1<<3) -#define VC9202_STATUS_OVERLOAD2 (1<<2) -#define VC9202_STATUS_OVERLOAD1 (1<<1) -#define VC9202_STATUS_OVERLOAD0 (1<<0) - -#define VC9202_EVENT_TEMP_MARK (1<<6) //128 -#define VC9202_EVENT_BIO_MARK (1<<5) //64 -#define VC9202_EVENT_PS_MARK (1<<4) //32 -#define VC9202_EVENT_OV_MARK (1<<3) //8 -#define VC9202_EVENT_FIFO_MARK (1<<2) //4 -#define VC9202_EVENT_ENV_MARK (1<<1) //2 -#define VC9202_EVENT_PPG_MARK (1<<0) //1 - -#define VC9202_MAX_RES_LEVEL 17 //21 9202offset只有0-2,3和2一样、所以表中只有17个等效 -#define VC9202_MAX_CUR_LEVEL 0x6F - -#define VC9202_ENV_MAX_TH 8*16 - -/* adjust marco */ -#define VC9202_PPG_TH_CELL 10 // Causes of PPG interruption PPG_TH = 300 -#define VC9202_ADJUST_INCREASE 22 // 1.4 << 4 = 22.4//1.4f -#define VC9202_ADJUST_DECREASE 11 // 0.7 << 4 = 11.2//0.7f -#define VC9202_ADJUST_STEP_MAX 32 -#define VC9202_ADJUST_STEP_MIN 1 -#define VC9202_SLOTCHNU 3 - -/* bio算法运算结果宏定义 */ -#define VC9202_BIO_STA_NONE 0 -#define VC9202_BIO_STA_DROP 1 -#define VC9202_BIO_STA_HOLD 2 - -/**************************************************************************** - * driver ret enum - ***************************************************************************/ -typedef enum -{ - RET_OK = 0, - RET_STATUS_ERR = (1<<0), - RET_OVERLOAD_ERR = (1<<1), - RET_ENV_ERR = (1<<2), - RET_PPG_ERR = (1<<3), - RET_OSC_ERR = (1<<4), - RET_FIFO_ERR = (1<<5), -}VC9202DrvRetTypeDef; - -/**************************************************************************** - * clock calibration_struct - ***************************************************************************/ -typedef struct -{ - unsigned int last_clk_count; - unsigned int osc_gap_cnt; - unsigned char count_index; - unsigned int osc_count[6]; - unsigned int clk_count[6]; - unsigned int last_clk_check; /* 2023.06.05,check running gaptime */ -}VC9202OscClkTypeDef; - -/**************************************************************************** - * WearStatus_struct - ***************************************************************************/ -typedef struct -{ - unsigned char wear_ps; - unsigned char wear_env; - short int wear_bio; - unsigned char wear_hold_cnt; - unsigned char wear_drop_cnt; - WearStatusTypeDef wear_status; - WearStatusTypeDef last_status; -}VC9202WearInfoTypeDef; - -typedef enum -{ - WEAR_NO_CHANGE = 0, - DROP_TO_HOLD = 1, - HOLD_TO_DROP = 2, -}VC9202WearChangeTypeDef; - -/**************************************************************************** - * ADJUST_struct - ***************************************************************************/ -typedef struct -{ - unsigned char res; - unsigned char offset; - unsigned char low; -}VC9202ResTableTypeDef; - -typedef struct -{ - unsigned char res_val; - unsigned char low_res; - unsigned char offset; - unsigned char offset3; -}VC9202ResLevelTypeDef; - -typedef enum -{ - AGC_DIR_NULL = 0, - AGC_DIR_UP = 1, - AGC_DIR_DOWN = 2, -}VC9202AgcDirTypeDef; - -typedef struct -{ - VC9202AgcDirTypeDef dir; - VC9202AgcDirTypeDef last_dir; - unsigned char current_step; -}VC9202AgcInfoTypeDef; - -typedef struct -{ - unsigned char max_current; - unsigned char max_res_level; - unsigned char record_env; - unsigned char slot_env; - unsigned char current; - unsigned char res_level; - VC9202AgcInfoTypeDef info; -}VC9202AdjustSlotTypeDef; - -/**************************************************************************** - * Dev_struct - ***************************************************************************/ -typedef struct -{ - unsigned short fifo_time; - unsigned char work_frequency; - unsigned char enable_bio; - WorkModeTypeDef work_mode; - - unsigned char work_status; - unsigned int int_event; - - WearStatusTypeDef wear_status; - unsigned char osc_clk_status; - unsigned char enfifo_div; - unsigned char enslot[2]; - unsigned char slot_number; - unsigned char read_fifo_address; - -}VC9202DrvInfoTypeDef; - -/**************************************************************************** - * test_struct - ***************************************************************************/ -typedef struct -{ - unsigned char wait_cnt; - unsigned char step1_ret; // step1_ret/step2_ret/step3_ret:0-wait test,1-pass,2-failed - unsigned char icid; - unsigned char reason; - unsigned char leak_pre_value; - unsigned char max_current; - signed short temperature; - unsigned int frequency; - - unsigned char step2_ret; - unsigned char ps_value; - unsigned short biovalue_max; - unsigned short biovalue_now[2]; - unsigned short biovalue_gap[2]; -} VC9202TestInfoTypeDef; - - -#endif diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_hal.h b/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_hal.h deleted file mode 100644 index 5f7850520..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_hal.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * @Author: penglei 1624952103@qq.com - * @Date: 2024-06-07 11:18:26 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-12-27 16:08:10 - * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.h - * @Description: - * - * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. - */ -#ifndef VC_9202_H__ -#define VC_9202_H__ -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#include "stdint.h" - -typedef uint32_t PPG_CMD_TYPE_T ; - -#ifdef PPG_HX3695 - -#include "tyhx_hrs_custom.h" - - - -typedef enum{ - HX3695_MSG_TYPE_HRS_UPDATE, - HX3695_MSG_TYPE_HRV_UPDATE, - HX3695_MSG_TYPE_SPO2_UPDATE, - HX3695_MSG_TYPE_LEAKLIGHT_UPDATE, - HX3695_MSG_TYPE_GRAYCARD_UPDATE, - HX3695_MSG_TYPE_WEARSTAT_UPDATE, - HX3695_MSG_TYPE_STATIC_HRS_UPDATE, -} hx3695_msg_type_t; - - -typedef void (*hx3695_msg_callback_t)(uint8_t msg_type, uint8_t *msg_data, int32_t msg_datalen); -uint32_t hx3695_register_msg_callback(hx3695_msg_callback_t func); -hx3695_msg_callback_t hx3695_get_send_msg_callback_func(void); - -#endif - -void ppg_send_cmd_to_vc9202_driver(char* mode, uint8_t enable); - -uint32_t tyhx_poweron(void); -uint32_t tyhx_poweroff(void); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_user.h b/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_user.h deleted file mode 100644 index 213da80be..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vc9202_user.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * @Author: penglei 1624952103@qq.com - * @Date: 2024-12-07 16:04:22 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-01-07 16:00:59 - * @FilePath: /sdk615/code/sdk/drivers/peripheral/ppg/vc9202/inc/vc9202_user.h - * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE - */ -/********************************************************************************************************* - * Copyright(c) 2022, vcare Corporation. All rights reserved. - ********************************************************************************************************** - * @file vc9202_user.h - * @brief functional Module Layer - * @details The functional interface is implemented by calling the driver.contain init_func,irq_handler - * @author - * @date - * @version - *********************************************************************************************************/ - -#ifndef __VC9202_USER_H__ -#define __VC9202_USER_H__ - -#include "vc9202_common.h" - -/* gsensor struct */ -typedef struct -{ - unsigned char sampling_rate; /* 25hz,50hz */ - unsigned char sensing_range; /* ±4G, ±8G, ±16G*/ - unsigned char effective_bits; /* 11(12)bit, 15(16)bit */ - - int gsensor_x_axis[40]; - int gsensor_y_axis[40]; - int gsensor_z_axis[40]; -}GsensorTypeDef; - - -typedef struct -{ - short int hr_rate; - unsigned char spo2_val; - unsigned char hrv_results; - unsigned char stress_results; - signed short int temperature_value; -}AlgoCalcResultsTypeDef; - -void vc9202_usr_init( InitParamTypeDef *pInitParam ); -void vc9202_usr_get_chip_id( unsigned char *pchip_id, unsigned char *pvers_id ); -void vc9202_usr_start_sampling(void); -void vc9202_usr_stop_sampling(void); -void vc9202_usr_soft_reset(void); -unsigned char vc9202_usr_channel_switch(unsigned char num_channel, unsigned char enable_flag); -unsigned char vc9202_usr_get_int_reason(void); -unsigned char vc9202_usr_get_wear_status(void); -void vc9202_usr_interrupt_handler( AlgoSportMode hr_alg_mode, unsigned char spo2_alg_mode ); - -uint32_t vc9202_get_hr_ppg_data(void); -void vc9202_get_spo2_ppg_data(uint32_t *ir_data,uint32_t *red_data); -void vc9202_get_leaklight_data(uint32_t *led_cur,uint32_t *apre_val,uint32_t *aps_val); -void vc9202_get_graycard_data(uint32_t *apre_val,uint32_t *aps_val); - -#endif - diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vcSportMotionIntAlgo.h b/code/sdk/zhihui/drivers/ppg/vc9202/inc/vcSportMotionIntAlgo.h deleted file mode 100644 index b137a7f06..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/inc/vcSportMotionIntAlgo.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __VCSPORTMOTIONALGOH__ -#define __VCSPORTMOTIONALGOH__ - -#include -#include -#include - - -void vcSportMotionAlgoInit(void); -int32_t vcSportMotionCalculate(int32_t x, int32_t y, int32_t z); -char* version_info_SportMotion(void); - -#endif diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/lib/.WeDrive b/code/sdk/zhihui/drivers/ppg/vc9202/lib/.WeDrive deleted file mode 100644 index c285ea891..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/lib/.WeDrive +++ /dev/null @@ -1 +0,0 @@ -C:\Users\zwj\Documents\WXWork\1688852039096625\WeDrive\维客昕微\技术支持组和应用方案开发组公共文件\1.心率IC\1.心率+血氧资料\2.驱动文件\VCHR9202\drv_9202_sensor_v218\algo \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_BIO_V151_MiniSdk_NA_01.a b/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_BIO_V151_MiniSdk_NA_01.a deleted file mode 100644 index cee79a175..000000000 Binary files a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_BIO_V151_MiniSdk_NA_01.a and /dev/null differ diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_BIO_v151_int_miniSDK_log_01.a b/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_BIO_v151_int_miniSDK_log_01.a deleted file mode 100644 index de6f1fb76..000000000 Binary files a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_BIO_v151_int_miniSDK_log_01.a and /dev/null differ diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_BIO_v151_int_miniSDK_log_02.a b/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_BIO_v151_int_miniSDK_log_02.a deleted file mode 100644 index 051247082..000000000 Binary files a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_BIO_v151_int_miniSDK_log_02.a and /dev/null differ diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_Sp_Int_HaiSi_01.a b/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_Sp_Int_HaiSi_01.a deleted file mode 100644 index 0d572721f..000000000 Binary files a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_Sp_Int_HaiSi_01.a and /dev/null differ diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_hr_v640ed04_miniSDK_NA_01.a b/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_hr_v640ed04_miniSDK_NA_01.a deleted file mode 100644 index b19f240ef..000000000 Binary files a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_hr_v640ed04_miniSDK_NA_01.a and /dev/null differ diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_spo2_9202A4_limit_HaiSi_NA_01.a b/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_spo2_9202A4_limit_HaiSi_NA_01.a deleted file mode 100644 index c98d6dd3f..000000000 Binary files a/code/sdk/zhihui/drivers/ppg/vc9202/lib/lib_spo2_9202A4_limit_HaiSi_NA_01.a and /dev/null differ diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_driver.c b/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_driver.c deleted file mode 100644 index 9c8fce5f8..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_driver.c +++ /dev/null @@ -1,1621 +0,0 @@ -/********************************************************************************************************* - * Copyright(c) 2022, vcare Corporation. All rights reserved. - ********************************************************************************************************** - * @file vc9202_driver.c - * @brief vc9202 driver layer interface implementation. - * @details - * @author - * @date - * @version - *********************************************************************************************************/ -#include "vc9202_common.h" -#include "vc9202_driver.h" -#include "BIODetect_V15_1.h" - -/* static wear status declaration */ -static int bio_result = VC9202_BIO_STA_NONE; -static WearStatusTypeDef alg_wear_status = WEAR_STA_HOLD; -static unsigned int gsnesor_axis_diff = 0; -static VC9202WearInfoTypeDef dev9202_wear = {0}; -/* static adjust data declaration */ -static VC9202AdjustSlotTypeDef dev9202_adjust[3] = {0}; -static unsigned char ppg_mark[128 / 2] = {0}; -/* static device data declaration */ -static VC9202DrvInfoTypeDef dev9202_info = {0}; -/* static oscclk data declaration */ -static VC9202OscClkTypeDef dev9202_clk = {0}; - -static int Bio_Max_Value = 0; -static int Bio_Max_Diff_Value = 0; -static int Bio_Min_Diff_Value = 0; -static int Bio_Old_Value = 0; -static uint8_t Bio_cnt = 0; -static uint8_t Bio_HOLD_cnt = 0; -static uint8_t BIO_HOLD_DROP_FLAG = 2; -/* global test infomation declaration */ -extern VC9202TestInfoTypeDef vc9202_test_info; -extern void vc9202_test_handler(SamplingDataTypeDef *pResult, VC9202TestInfoTypeDef *ptest_info); -extern void vc9202_test_init(VC9202TestInfoTypeDef *ptest_info); -/* res-level tab */ -const static VC9202ResTableTypeDef res_table[22] = { - /* level: 0 */ {0, 0, 1}, - /* level: 1 */ {1, 0, 1}, - /* level: 2 */ {2, 0, 1}, - /* level: 3 */ {3, 0, 1}, - /* level: 4 */ {4, 0, 1}, - /* level: 5 */ {5, 0, 1}, - /* level: 6 */ {0, 0, 0}, - /* level: 7 */ {1, 0, 0}, - /* level: 8 */ {2, 0, 0}, - /* level: 9 */ {3, 0, 0}, - /* level:10 */ {4, 0, 0}, - /* level:11 */ {5, 0, 0}, - /* level:12 */ {6, 0, 0}, - /* level:13 */ {7, 0, 0}, - /* level:14 */ {6, 1, 0}, /* +2 */ - /* level:15 */ {7, 1, 0}, - /* level:16 */ {6, 2, 0}, /* +4 */ - /* level:17 */ {7, 2, 0}, - /* level:18 */ {6, 3, 0}, /* +6 */ - /* level:19 */ {7, 3, 0}, - /* level:20 */ {6, 4, 0}, /* +8 */ - /* level:21 */ {7, 4, 0}, -}; // 21-5 = 16 - -void vc9202_drv_set_gsensor_actuating_quantity(unsigned int axis_diff) -{ - gsnesor_axis_diff = axis_diff; -} - -void vc9202_drv_set_algo_wear_status(WearStatusTypeDef status) -{ - alg_wear_status = status; -} - -/******************************************************************************************************** - * 时钟校准部分 - ********************************************************************************************************/ -static void vc9202_drv_clear_clk(void) -{ - dev9202_clk.osc_gap_cnt = 0; - dev9202_clk.count_index = 0; - dev9202_clk.last_clk_count = 0; - dev9202_info.osc_clk_status = 0; - - dev9202_clk.last_clk_check = 0; -} -/** - * @brief 时钟校验,与原来的VC9201系列一致 - * @param 无 - * @retval - 0 校验正常通过 - 1 vc9202计数当次就溢出 - 2 mcu tick或vc9202后两次中断的时候有计数溢出 - 3 频率计算没有通过 - */ -static unsigned char vc9202_drv_calibration_osc_clk(void) -{ - unsigned char count_vaild = 1; - unsigned char i = 0; - unsigned char osc_buf[4] = {0}; - unsigned int osc_tick[2] = {0}; - unsigned int clock_tick[2] = {0}; - unsigned short int calc_div[2] = {0}; - unsigned short int mean_div = 0; - unsigned char reg_div1[2] = {0}; - /* 判断是否需要校准时钟,如不需则直接返回 */ - unsigned int sec_gap_cnt = VC9202_CFG_CLK_CHECK_GAPTIME * 1000 / dev9202_info.fifo_time; - if (dev9202_info.osc_clk_status && dev9202_clk.osc_gap_cnt++ <= sec_gap_cnt) - { - return 0; - } - /* 获取时钟计数 */ - clock_tick[0] = usr_get_clock_ticks(); - usr_iic_read_bytes(0x07, osc_buf, 4); - clock_tick[1] = usr_get_clock_ticks(); - osc_tick[0] = (osc_buf[0] << 8) + osc_buf[1]; - osc_tick[1] = (osc_buf[2] << 8) + osc_buf[3]; - if ((osc_tick[0] > osc_tick[1]) || (clock_tick[0] > clock_tick[1])) - { - dev9202_clk.count_index = 0; - return 1; - } - /* 存入校准缓存 */ - dev9202_clk.osc_count[dev9202_clk.count_index * 2] = osc_tick[0]; - dev9202_clk.osc_count[dev9202_clk.count_index * 2 + 1] = osc_tick[1]; - dev9202_clk.clk_count[dev9202_clk.count_index * 2] = clock_tick[0]; - dev9202_clk.clk_count[dev9202_clk.count_index * 2 + 1] = clock_tick[1]; - dev9202_clk.count_index++; - if (dev9202_clk.count_index >= 3) - { - dev9202_clk.count_index = 0; - for (i = 0; i < 2; i++) - { - count_vaild = count_vaild && (ABS((dev9202_clk.clk_count[2 * i + 2] - dev9202_clk.clk_count[2 * i]), (dev9202_clk.clk_count[2 * i + 3] - dev9202_clk.clk_count[2 * i + 1])) < VC9202_CFG_CLK_CHECK_DEVIATION); - count_vaild = count_vaild && (ABS((dev9202_clk.osc_count[2 * i + 2] - dev9202_clk.osc_count[2 * i]), (dev9202_clk.osc_count[2 * i + 3] - dev9202_clk.osc_count[2 * i + 1])) < VC9202_CFG_CLK_CHECK_DEVIATION); - count_vaild = count_vaild && (!(dev9202_clk.clk_count[2 * i + 2] == dev9202_clk.clk_count[2 * i])); /* avoid divisor==0, diffCountIsOk set false */ - } - if (count_vaild) - { - for (i = 0; i < 2; i++) - { - calc_div[i] = ((unsigned int)dev9202_clk.osc_count[2 * i + 2] - dev9202_clk.osc_count[2 * i]) * VC9202_CFG_CLK_CHECK_FREQUENCY / dev9202_info.work_frequency / ((unsigned int)dev9202_clk.clk_count[2 * i + 2] - dev9202_clk.clk_count[2 * i]) - 1; - if (calc_div[i] < (20000 / dev9202_info.work_frequency * 0.75f) || calc_div[i] > (20000 / dev9202_info.work_frequency * 1.25f)) - { - return 3; - } - } - /* 比较两次计算偏差是否合理 */ - if ((calc_div[1] - calc_div[0] <= 20) || (calc_div[0] - calc_div[1] <= 20)) - { - mean_div = (calc_div[1] + calc_div[0]) / 2; - reg_div1[0] = mean_div >> 8; - reg_div1[1] = mean_div; - usr_iic_write_bytes(0x14, reg_div1, 2); - dev9202_clk.count_index = 0; - dev9202_clk.osc_gap_cnt = 0; - dev9202_info.osc_clk_status = 1; - return 0; - } - } - } - return 2; -} -/******************************************************************************************************** - * 摘配带判断部分 - ********************************************************************************************************/ -/** - * @brief 佩戴检测,bio检测计算(内部阅读:f_BIOdetect,在BIO+PS均由佩戴产生的边缘时输出2佩戴;摘下时只依赖PS边缘) - * @param - bio_value bio采样值 - ps_value ps采样值 - * @retval bio结果 - */ -static int vc9202_drv_calc_biology_sense(unsigned short int bio_value, unsigned char ps_value, unsigned char env) -{ - static unsigned char calc_ps = 0; - static unsigned short int calc_bio = 0; - static int Bio_Diff_Value = 0; - int ret = 0; - if (bio_value) - { - calc_bio = bio_value; - Bio_Diff_Value = abs(Bio_Old_Value - calc_bio); - Bio_Old_Value = calc_bio; - } - if (ps_value) - { - calc_ps = ps_value; - } - if ((calc_ps < 100) && (env > 4)) - { - if (Bio_Diff_Value < VC9202_CFG_WEAR_PARAM_BIOIN * 0.2) - { - Bio_Max_Value = calc_bio; - Bio_Max_Diff_Value = Bio_Max_Value - (VC9202_CFG_WEAR_PARAM_BIOIN * 0.8); - Bio_Min_Diff_Value = Bio_Max_Value - (VC9202_CFG_WEAR_PARAM_BIOIN * 1.5); - } - } - if (Bio_Max_Diff_Value) - { - if ((calc_bio > Bio_Max_Diff_Value) && (Bio_Diff_Value < VC9202_CFG_WEAR_PARAM_BIOIN * 0.2)) - { - Bio_HOLD_cnt++; - if (Bio_HOLD_cnt > 4) - { - BIO_HOLD_DROP_FLAG = 1; - } - } - else if (calc_bio < Bio_Min_Diff_Value) - { - Bio_cnt++; - if (Bio_cnt > 2) - { - BIO_HOLD_DROP_FLAG = 2; - } - } - else - { - Bio_cnt = 0; - Bio_HOLD_cnt = 0; - BIO_HOLD_DROP_FLAG = 0; - } - } - uint32_t tm; - uapi_get_timestampe_ms(&tm); - // printf("before f_BIOdetect bio_value :%d , ps_value : %d , env : %d , tm : %d\n",bio_value,ps_value,env,tm); - // printf("before f_BIOdetect calc_bio :%d , calc_ps : %d , VC9202_CFG_WEAR_PARAM_PS : %d ,tm : %d , ret : %d\n",calc_bio,calc_ps,VC9202_CFG_WEAR_PARAM_PS,tm,ret); - ret = f_BIOdetect(calc_bio, calc_ps, VC9202_CFG_WEAR_PARAM_PS); - // printf("after f_BIOdetect calc_bio :%d , calc_ps : %d , VC9202_CFG_WEAR_PARAM_PS : %d ,tm : %d , ret : %d\n",calc_bio,calc_ps,VC9202_CFG_WEAR_PARAM_PS,tm,ret); - // printf("after f_BIOdetect bio_value :%d , ps_value : %d , env : %d , tm : %d\n",bio_value,ps_value,env,tm); - if (VC9202_BIO_STA_HOLD == ret) - { - vc9202_drv_set_algo_wear_status(WEAR_STA_HOLD); /* bio */ - bio_result = VC9202_BIO_STA_HOLD; - } - else if (VC9202_BIO_STA_DROP == ret) - { - bio_result = VC9202_BIO_STA_DROP; - } - return bio_result; -} -/** - * @brief 佩戴检测过程及状态 - * @param *pwear-佩戴结构体,env-环境光,ps-ps值,bio-活体值 - * @retval 识别改变结果 - */ -static VC9202WearChangeTypeDef vc9202_drv_wear_status_identify(VC9202WearInfoTypeDef *pwear, unsigned char env, unsigned char ps, unsigned short int bio) -{ - // printf("vc9202_drv_wear_status_identify bio : %d \n",bio); - VC9202WearChangeTypeDef ret_change = WEAR_NO_CHANGE; - int ret_bio_algo = VC9202_BIO_STA_NONE; - /* bio算法运算 */ - if (dev9202_info.enable_bio) - { - ret_bio_algo = vc9202_drv_calc_biology_sense(bio, ps, env); - } - else - { - ret_bio_algo = VC9202_BIO_STA_HOLD; /* 20230614 因为下面的条件把(ret_bio_algo== )佩戴的条件删了,所以此处必须添加,不然在未开bio的模式下无法佩戴*/ - } -#if (FUNC_DISABLE == VC9202_CFG_WEAR_THRESHOLD_EN) - BIO_HOLD_DROP_FLAG = 2; -#endif -#if (FUNC_DISABLE == VC9202_CFG_WEAR_BIO_EN) - ret_bio_algo = VC9202_BIO_STA_NONE; - BIO_HOLD_DROP_FLAG = 2; -#endif -#if (FUNC_DISABLE == VC9202_CFG_WEAR_ALG_EN) - alg_wear_status = WEAR_STA_HOLD; -#endif -#if (FUNC_DISABLE == VC9202_CFG_WEAR_ACT_EN) - gsnesor_axis_diff = 1; -#endif - switch (pwear->wear_status) - { - case WEAR_STA_DROP: - // printf("WEAR_STA_DROP ps : %d , env : %d , ret_bio_algo : %d , alg_wear_status : %d , gsnesor_axis_diff : %d , BIO_HOLD_DROP_FLAG : %d\n",ps,env,ret_bio_algo,alg_wear_status,gsnesor_axis_diff,BIO_HOLD_DROP_FLAG); - if ((ps >= VC9202_CFG_WEAR_PARAM_PS) && (env <= VC9202_CFG_WEAR_PARAM_ENVMIN) && (VC9202_BIO_STA_HOLD == ret_bio_algo) && - (WEAR_STA_HOLD == alg_wear_status) && (1 == gsnesor_axis_diff) && (BIO_HOLD_DROP_FLAG == 2)) - { - if (--pwear->wear_hold_cnt <= 0) - { - pwear->wear_hold_cnt = VC9202_CFG_WEAR_HOLD_CNT; - pwear->wear_drop_cnt = VC9202_CFG_WEAR_DROP_CNT; - ret_change = DROP_TO_HOLD; - } - } - else - { - pwear->wear_hold_cnt = VC9202_CFG_WEAR_HOLD_CNT; - } - break; - - case WEAR_STA_HOLD: - // printf("WEAR_STA_HOLD ps : %d , env : %d , ret_bio_algo : %d , alg_wear_status : %d , BIO_HOLD_DROP_FLAG : %d\n",ps,env,ret_bio_algo,alg_wear_status,BIO_HOLD_DROP_FLAG); - if ((ps < VC9202_CFG_WEAR_PARAM_PS) || (env > VC9202_CFG_WEAR_PARAM_ENVMIN) || (VC9202_BIO_STA_DROP == ret_bio_algo) || (WEAR_STA_DROP == alg_wear_status) || (BIO_HOLD_DROP_FLAG == 1)) - { - if ((WEAR_STA_DROP == alg_wear_status) || (ret_bio_algo == VC9202_BIO_STA_DROP)) - { - pwear->wear_drop_cnt = 1; - } - if (--pwear->wear_drop_cnt <= 0) - { - pwear->wear_hold_cnt = VC9202_CFG_WEAR_HOLD_CNT; - pwear->wear_drop_cnt = VC9202_CFG_WEAR_DROP_CNT; - ret_change = HOLD_TO_DROP; - } - } - else - { - pwear->wear_drop_cnt = VC9202_CFG_WEAR_DROP_CNT; - } - break; - default: - break; - } - return ret_change; -} - -/** - * @brief 佩戴检测及通道的开关 - * @param 无 - * @retval 佩戴检测状态 - */ -WearStatusTypeDef vc9202_drv_get_wear_status(void) -{ - WearStatusTypeDef wear_status = dev9202_wear.last_status; /* last status */ - VC9202WearChangeTypeDef calc_status = WEAR_NO_CHANGE; - unsigned char event = 0; - unsigned char en_int = 0; - unsigned char env_value = 0, ps_value = 0; - unsigned char bio_buffer[4] = {0}; - unsigned short int bio_value = 0; - unsigned char wear_interrupt = 0; - unsigned char slot_index = 0; -#if (VC9202_CFG_WEAR_DETECTION != FUNC_ENABLE) - return WEAR_IS_HOLD; -#endif - usr_iic_read_bytes(0x11, &en_int, 1); -#if 0 - usr_iic_read_bytes(0x02, &event, 1); -#else - event = dev9202_info.int_event; -#endif -#if (FUNC_ENABLE == VC9202_CFG_DRV_BY_TIMER) /* 定时触发时,不看中断原因,可能被清掉 */ - wear_interrupt = 1; -#else - /* 使能了PsInt,且使能PS */ - if ((event & VC9202_EVENT_PS_MARK) && (en_int & (1 << 4))) - { - wear_interrupt = 1; - } - /* 未使能PsInt下,ps_ppg同频通过fifo中断去识别摘配带 */ - if (event & VC9202_EVENT_FIFO_MARK) - { - wear_interrupt = 1; - } -#endif - /* 非心率模式,就算使能了运动量,也没有去做处理,直接置1忽略 */ - if (dev9202_info.work_mode != WORK_MODE_HR && dev9202_info.work_mode != WORK_MODE_WEAR) - { - gsnesor_axis_diff = 1; - } - if (wear_interrupt) - { -/* 读取佩戴检测所需的数据 */ -#if 0 - usr_iic_read_bytes(0x43, &env_value, 1); - usr_iic_read_bytes(0x46, &ps_value, 1); - usr_iic_read_bytes(0x4B, bio_buffer, 4); - bio_value = (bio_buffer[2] << 8) + bio_buffer[3]; -#else - env_value = dev9202_wear.wear_env; - ps_value = dev9202_wear.wear_ps; - bio_value = dev9202_wear.wear_bio; -#endif - /* 根据数据得出佩戴状态 */ - calc_status = vc9202_drv_wear_status_identify(&dev9202_wear, env_value, ps_value, bio_value); - if (DROP_TO_HOLD == calc_status) - { - wear_status = WEAR_STA_HOLD; - dev9202_wear.wear_status = wear_status; - dev9202_wear.last_status = wear_status; - InitParamTypeDef init_param = {dev9202_info.fifo_time, dev9202_info.work_mode}; - vc9202_drv_reg_init(&init_param); - } - else if (HOLD_TO_DROP == calc_status) - { - wear_status = WEAR_STA_DROP; - dev9202_wear.wear_status = wear_status; - dev9202_wear.last_status = wear_status; - /* 关灯操作:获取那些ppg通道使能/记录当前使能的通道,然后关闭通道 */ - for (slot_index = 0; slot_index <= 1; slot_index++) - { - if (dev9202_info.enslot[slot_index]) - { - vc9202_drv_channel_switch(slot_index, 0); - } - } - } /* end of(HOLD_TO_DROP == calc_status) */ - } - return wear_status; -} - -/******************************************************************************************************** - * IC状态读取部分,包括IC异常状态处理,常规数据的读取,ENV、PPG调整部分 - ********************************************************************************************************/ -/** - * @brief 等效电阻等级转化为寄存器参数 - * @param level 等效电阻等级 - * @retval 寄存器参数 - */ -static VC9202ResLevelTypeDef vc9202_drv_res_level_to_register(unsigned char level) -{ - VC9202ResLevelTypeDef reg; - reg.res_val = res_table[level].res; - reg.low_res = res_table[level].low; - if (res_table[level].offset >= 4) - { - reg.offset = 0; - reg.offset3 = 1; - } - else - { - reg.offset = res_table[level].offset; - reg.offset3 = 0; - } - return reg; -} - -/** - * @brief 寄存器参数转化为等效电阻等级 - * @param 寄存器参数 - * @retval 等效电阻等级 - */ -static unsigned char vc9202_drv_res_register_to_level(VC9202ResLevelTypeDef *preg) -{ - unsigned char index = 0; - unsigned char level = 0; - VC9202ResTableTypeDef table = {0}; - if (preg->offset3 == 1) - { - table.offset = 4; - } - else - { - table.offset = preg->offset; - } - table.res = preg->res_val; - table.low = preg->low_res; - for (index = 0; index < sizeof(res_table) / sizeof(res_table[0]); index++) - { - if (res_table[index].res == table.res && res_table[index].offset == table.offset && res_table[index].low == table.low) - { - level = index; - break; - } - } - return level; -} - -/** - * @brief 设置通道电流参数 - * @param 无 - * @retval 无 - */ -static void vc9202_drv_set_ppgSlot_current(unsigned char slot_index, unsigned char cur) -{ - unsigned char reg = 0; - unsigned char addr = 0x17 + slot_index; - cur = (cur > 0x7f) ? 0x7f : cur; - usr_iic_read_bytes(addr, ®, 1); - reg &= (1 << 7); - reg |= cur; - usr_iic_write_bytes(addr, ®, 1); -} - -/** - * @brief 设置通道电阻参数 - * @param 设置的通道号,设定的值 - * @retval 无 - */ -static void vc9202_drv_set_ppgSlot_resistance(unsigned char slot_index, unsigned char level) -{ - unsigned char reg_addr = 0x1A + slot_index; - unsigned char res_reg = 0; - unsigned char res_ext[2] = {0}; - VC9202ResLevelTypeDef res = {0}; - level = (level > VC9202_MAX_RES_LEVEL) ? VC9202_MAX_RES_LEVEL : level; - res = vc9202_drv_res_level_to_register(level); - usr_iic_read_bytes(0x22, res_ext, 2); - switch (slot_index) - { - case 0: - res_ext[0] &= ~(3 << 4); /* offset */ - res_ext[0] |= (res.offset << 4); - res_ext[0] &= ~(1 << 0); /* lowres */ - res_ext[0] |= (res.low_res << 0); - res_ext[1] &= ~(1 << 0); - res_ext[1] |= (res.offset3 << 0); - break; - case 1: - res_ext[0] &= ~(3 << 6); /* offset */ - res_ext[0] |= (res.offset << 6); - res_ext[0] &= ~(1 << 1); /* lowres */ - res_ext[0] |= (res.low_res << 1); - res_ext[1] &= ~(1 << 2); - res_ext[1] |= (res.offset3 << 2); - break; - default: - break; - } - usr_iic_read_bytes(reg_addr, &res_reg, 1); - res_reg &= (0x8f); - res_reg |= (res.res_val << 4); - usr_iic_write_bytes(reg_addr, &res_reg, 1); - usr_iic_write_bytes(0x22, res_ext, 2); -} -/** - * @brief 读取PPG饱和中断时的采样值 - * @param enfifo-是否使能fifo,slot_num-通道数,slot_index-通道号, *pdata 数据指针 - * @retval 返回当前读取地址 - */ -static unsigned char vc9202_drv_adjust_ppg_read(unsigned char enfifo, unsigned char slot_num, unsigned char slot_index, unsigned int *pdata) -{ - unsigned char write_index = 0, fifo_addr = 0; - unsigned char fifo_buff[2] = {0}; - /* PPG IRQ addr */ - usr_iic_read_bytes(0x03, &write_index, 1); - fifo_addr = write_index - slot_num * 2 + slot_index * 2; - fifo_addr = (fifo_addr < 0x80) ? (fifo_addr + 0x80) : (fifo_addr); - fifo_addr = enfifo ? fifo_addr : 0x80 + slot_index * 2; - /* read PPG data */ - usr_iic_read_bytes(fifo_addr, fifo_buff, 2); - *pdata = (fifo_buff[0] << 8) + fifo_buff[1]; - return write_index; -} - -/** - * @brief 参数调整时,添加调整标志位 - * @param 无 - * @retval 无 - */ -static void vc9202_drv_adjust_set_fifo_mark(unsigned char slot_index) // SamplingDataTypeDef **pp_result, unsigned char rindex, unsigned char windex, unsigned char slot_num ) -{ - unsigned char mark_ppg_index = 0; - unsigned char mark_offset = 0; - unsigned char rindex = dev9202_info.read_fifo_address; - unsigned char windex = 0; - usr_iic_read_bytes(0x03, &windex, 1); - /* calc PPGOffset */ - if (windex > rindex) - { - mark_offset = (windex - rindex); - } - else - { - mark_offset = windex + 128 - rindex; - } - if ((mark_offset < 2) || (mark_offset > 128)) - { - return; - } - mark_ppg_index = mark_offset / 2 - dev9202_info.slot_number + slot_index; /* 如果是双通道,要判断是那个通道产生的调整 */ - ppg_mark[mark_ppg_index] = 1; -} - -/** - * @brief 检测因电阻过大,电流的最小步长调整都会反复饱和的情况 - * @param dir 调整方向, slot_index 当前通道, res_level 当前电阻等级, cur 当前电流值 - * @retval 1:错误,0:正常 - */ -static unsigned char vc9202_drv_adjust_res_error(VC9202AgcDirTypeDef dir, unsigned char slot_index, uint8_t res_level, uint8_t cur) -{ - static VC9202AgcDirTypeDef lastDir = AGC_DIR_NULL; - static uint8_t last_level = 0; - static uint8_t last_cur[2][3] = {0}; - static uint8_t log_cnt = 0; - if (lastDir != dir && last_level == res_level) - { - last_cur[slot_index][0] = last_cur[slot_index][1]; - last_cur[slot_index][1] = last_cur[slot_index][2]; - last_cur[slot_index][2] = cur; - if (last_cur[slot_index][0] == last_cur[slot_index][2]) - log_cnt++; - } - else - { - log_cnt = 0; - } - lastDir = dir; - last_level = res_level; - if (log_cnt >= 3) - { - log_cnt = 0; - return 1; - } - else - { - return 0; - } -} - -/** - * @brief PPG饱和时,上/下调整电流电阻配置参数 - * @param *padjust-调整结构体,thh_res-电阻限值,thh_cur-电流限值,slot_index-通道编号 - * @retval 执行结果 - */ -static VC9202DrvRetTypeDef vc9202_drv_adjust_ppg_slot_current_res_config(VC9202AdjustSlotTypeDef *padjust, unsigned char thh_res, unsigned char thh_cur, unsigned char slot_index) -{ - unsigned char old_res_lvl = 0; - unsigned char old_current = 0; - unsigned short int old_current_step = 0; - old_res_lvl = padjust->res_level; - old_current = padjust->current; - old_current_step = padjust->info.current_step; - /* 电流已经最大,调电阻 */ - if (padjust->current == thh_cur) - { - if (old_res_lvl == thh_res) - { - return RET_PPG_ERR; - } - else - { - if (padjust->info.dir == AGC_DIR_UP) - { - padjust->res_level = (old_res_lvl >= VC9202_MAX_RES_LEVEL) ? (VC9202_MAX_RES_LEVEL) : (old_res_lvl + 1); - } - else - { - padjust->res_level = (old_res_lvl < 1) ? (0) : (old_res_lvl - 1); - } - vc9202_drv_adjust_set_fifo_mark(slot_index); - } - } - else /* 电流可调 */ - { - /* step calc */ - if (padjust->info.last_dir == AGC_DIR_NULL) - { - old_current_step *= 16; - } - else if (padjust->info.dir == padjust->info.last_dir) - { - if ((old_current_step == 1) || (old_current_step == 2)) - { - old_current_step = (old_current_step + 1) * 16; - } - else - { - old_current_step *= VC9202_ADJUST_INCREASE; - } - } - else - { - old_current_step *= VC9202_ADJUST_DECREASE; - } - padjust->info.current_step = old_current_step >> 4; - padjust->info.current_step = (padjust->info.current_step <= VC9202_ADJUST_STEP_MIN) ? VC9202_ADJUST_STEP_MIN : padjust->info.current_step; - padjust->info.current_step = (padjust->info.current_step >= VC9202_ADJUST_STEP_MAX) ? VC9202_ADJUST_STEP_MAX : padjust->info.current_step; - /* 调整方向 */ - if (padjust->info.dir == AGC_DIR_UP) - { - padjust->current = ((old_current + padjust->info.current_step) > thh_cur) ? thh_cur : (old_current + padjust->info.current_step); - } - else - { - padjust->current = (old_current < padjust->info.current_step) ? thh_cur : old_current - padjust->info.current_step; - } - vc9202_drv_adjust_set_fifo_mark(slot_index); - padjust->info.last_dir = padjust->info.dir; - } - if (vc9202_drv_adjust_res_error(padjust->info.dir, slot_index, padjust->res_level, padjust->current)) - { - if (padjust->res_level >= 13) - { - padjust->res_level--; - } - } - /* 调整后的电流电阻写入寄存器 */ - vc9202_drv_set_ppgSlot_resistance(slot_index, padjust->res_level); - vc9202_drv_set_ppgSlot_current(slot_index, padjust->current); - return RET_OK; -} - -/** - * @brief 环境光饱和中断调整电阻 - * @param *padjust-调整结构体,slot_index-通道编号 - * @retval 执行结果 - */ -static VC9202DrvRetTypeDef vc9202_drv_adjust_env_configure(VC9202AdjustSlotTypeDef *padjust, unsigned char slot_index) -{ - if (padjust->slot_env > VC9202_ENV_MAX_TH) - { - padjust->record_env = padjust->slot_env; - if (padjust->res_level != 0) - { - padjust->res_level--; - padjust->max_res_level = padjust->res_level; - vc9202_drv_adjust_set_fifo_mark(slot_index); - vc9202_drv_set_ppgSlot_resistance(slot_index, padjust->res_level); - } - else - { - return RET_ENV_ERR; - } - } - return RET_OK; -} - -/** - * @brief 如果产生overload,降低电流,和电流的最大限制,过载电流-1 - * @param *padjust-调整结构体,slot_index-通道编号,status-状态值 - * @retval 执行结果 - */ -static VC9202DrvRetTypeDef vc9202_drv_adjust_over_load_configure(VC9202AdjustSlotTypeDef *padjust, unsigned char slot_index, unsigned char status) -{ - unsigned char overload[3] = {status & VC9202_STATUS_OVERLOAD0, status & VC9202_STATUS_OVERLOAD1, status & VC9202_STATUS_OVERLOAD2}; - if (overload[slot_index]) - { - if (padjust->current != 0) - { - padjust->current--; - padjust->max_current = padjust->current; - vc9202_drv_adjust_set_fifo_mark(slot_index); - vc9202_drv_set_ppgSlot_current(slot_index, padjust->current); - } - else - { - return RET_OVERLOAD_ERR; - } - } - return RET_OK; -} - -/** - * @brief 获取PPG进行电流电阻的调整 - * @param *padjust-调整结构体,slot_index-通道编号,enfifo-是否使能fifo, slot_num-通道数 - * @retval 执行结果 - */ -static VC9202DrvRetTypeDef vc9202_drv_adjust_ppg_configure(VC9202AdjustSlotTypeDef *padjust, unsigned char slot_index, unsigned char enfifo, unsigned char slot_num) -{ - static unsigned char last_index = 0, cnt = 0; - VC9202DrvRetTypeDef vc_ret = RET_OK; - unsigned char windex = 0; - unsigned char index_gap = 0; - unsigned int data = 0; - // 根据通道号和是否enfifo获取产生ppg中断的ppg值。 - windex = vc9202_drv_adjust_ppg_read(enfifo, slot_num, slot_index, &data); - /* 修改last dir */ - if (enfifo) - { - index_gap = (windex > last_index) ? (windex - last_index) : (windex - last_index + 0x80); - if (index_gap != slot_num * 2) - { - padjust->info.last_dir = AGC_DIR_NULL; - } - cnt++; - if (cnt >= slot_num) - { - cnt = 0; - last_index = windex; - } - } - /* 根据ppg值进行电流、等效电阻上下调节 */ - if (data >= 3770) - { - padjust->info.dir = AGC_DIR_UP; - vc_ret |= vc9202_drv_adjust_ppg_slot_current_res_config(padjust, padjust->max_res_level, padjust->max_current, slot_index); - } - else if (data < 320) - { - padjust->info.dir = AGC_DIR_DOWN; - vc_ret |= vc9202_drv_adjust_ppg_slot_current_res_config(padjust, 0, 0, slot_index); - } - return vc_ret; -} - -/** - * @brief 最大电阻的调整,通过判断环境光,来恢复电阻的最大限制 - * @param *padjust-调整结构体,slot_index-通道编号 - * @retval 无 - */ -static void vc9202_drv_res_max_resize(VC9202AdjustSlotTypeDef *padjust, unsigned char slot_index) -{ - static unsigned short int count_qares[2] = {0}; - static unsigned short int count_pdres[2] = {0}; - unsigned char min_env = 0; - // 该通道得最大电阻已经是最大的等级了,无需恢复退出 - if (padjust->max_res_level >= VC9202_MAX_RES_LEVEL) - { - return; - } - /* 获取一个环境光比较值,取上一次环境光调整时的一半或者环境光中断阈值 */ - min_env = (padjust->record_env / 2 < VC9202_ENV_MAX_TH) ? (padjust->record_env / 2) : VC9202_ENV_MAX_TH; - if (padjust->slot_env < min_env) - { - /* 环境光一直小于1,持续超过30次,那么直接将电阻限制设置为最大 */ - if (padjust->slot_env <= 1) - { - count_pdres[slot_index] = 0; - count_qares[slot_index] = (count_qares[slot_index] == 30) ? 0 : count_qares[slot_index] + 1; - padjust->max_res_level = (count_qares[slot_index] == 30) ? VC9202_MAX_RES_LEVEL : padjust->max_res_level; - } - else - { - /* 环境光一直小于比较值,持续超过120次,那么直接将电阻限制+1 */ - count_qares[slot_index] = 0; - count_pdres[slot_index] = count_pdres[slot_index] + 1; - padjust->max_res_level = (count_pdres[slot_index] == 120) ? padjust->max_res_level + 1 : padjust->max_res_level; - } - } - else - { - count_pdres[slot_index] = 0; - count_qares[slot_index] = 0; - } -} - -/* 判断PS通道的过载和环境光是否异常 */ -VC9202DrvRetTypeDef vc9202_drv_ps_slot_status(VC9202AdjustSlotTypeDef *p_slot_ps, unsigned char event, unsigned char status) -{ - VC9202DrvRetTypeDef vc_ret = RET_OK; -#if (FUNC_ENABLE == VC9202_CFG_DRV_BY_TIMER) /* 定时触发时,不看中断原因,因为可能被清掉 */ - if (status & VC9202_STATUS_OVERLOAD2) - { - vc_ret |= RET_OVERLOAD_ERR; - } - if (p_slot_ps->slot_env > VC9202_ENV_MAX_TH) - { - vc_ret |= RET_ENV_ERR; - } -#else - if ((event & VC9202_EVENT_OV_MARK) && (status & VC9202_STATUS_OVERLOAD2)) - { - vc_ret |= RET_OVERLOAD_ERR; - } - if ((event & VC9202_EVENT_ENV_MARK) && (p_slot_ps->slot_env > VC9202_ENV_MAX_TH)) - { - vc_ret |= RET_ENV_ERR; - } -#endif - return vc_ret; -} -/** - * @brief 识别IC的中断状态及中断事件,并对不同的情况进行调整处理等 - * @param status-工作状态, event-中断事件 - * @retval 执行结果 - */ -static VC9202DrvRetTypeDef vc9202_drv_status_event_verify(unsigned char status, unsigned char event) -{ - VC9202DrvRetTypeDef vc_ret = RET_OK; - unsigned char index = 0; - unsigned char index_slot = 0; - if (status & (VC9202_STATUS_CONFLICT | VC9202_STATUS_INSAMPLE)) - { - return RET_STATUS_ERR; - } - /* PS通道异常判断 */ - vc_ret |= vc9202_drv_ps_slot_status(&dev9202_adjust[2], event, status); - /* PPG通道的环境光读取,异常中断处理 */ - for (index = 0; index < dev9202_info.slot_number; index++) - { - index_slot = (dev9202_info.slot_number == 2) ? index : (dev9202_info.enslot[0] ? 0 : 1); - /* 恢复最大电阻的限制,根据当前 */ - vc9202_drv_res_max_resize(&dev9202_adjust[index_slot], index_slot); - /* over load, max current */ - if (event & VC9202_EVENT_OV_MARK) - { - // printf("event & VC9202_EVENT_OV_MARK \n"); - vc_ret |= vc9202_drv_adjust_over_load_configure(&dev9202_adjust[index_slot], index_slot, status); - } - /* env, max res */ - if (event & VC9202_EVENT_ENV_MARK) - { - // printf("event & VC9202_EVENT_ENV_MARK \n"); - vc_ret |= vc9202_drv_adjust_env_configure(&dev9202_adjust[index_slot], index_slot); - } - /* ppg interruput */ - if (event & VC9202_EVENT_PPG_MARK) - { - vc_ret |= vc9202_drv_adjust_ppg_configure(&dev9202_adjust[index_slot], index_slot, dev9202_info.enfifo_div, dev9202_info.slot_number); - // printf("event & VC9202_EVENT_PPG_MARK vc_ret : 0x%x\n",vc_ret); - } - else - { - // printf("event : 0x%x \n",event); - dev9202_adjust[index].info.dir = AGC_DIR_NULL; - dev9202_adjust[index].info.last_dir = AGC_DIR_NULL; - } - } - return vc_ret; -} - -/******************************************************************************************************** - * fifo 读取部分 - ********************************************************************************************************/ -/** - * @brief 校验fifo读写的偏移的可用性,及fifo是否翻转等错误。 - * @param rindex-读地址,windex-写地址,slot_num-通道数量,fifo_div-fifo深度 - * @retval 无 - */ -static VC9202DrvRetTypeDef vc9202_drv_fifo_infomation_check(unsigned char *rindex, unsigned char *windex, unsigned char slot_num, unsigned char fifo_div) -{ - unsigned int clk_diffs = 0; - unsigned int clk_count = usr_get_clock_ticks(); - /* 间隔时间的校验,后续看是否需要补充 */ - clk_diffs = (dev9202_clk.last_clk_count < clk_count) ? (clk_count - dev9202_clk.last_clk_count) : (clk_count - dev9202_clk.last_clk_count + VC9202_CFG_CLK_CHECK_MAX); - if (clk_diffs > (unsigned int)((64.0f / dev9202_info.work_frequency) * 0.8f * VC9202_CFG_CLK_CHECK_FREQUENCY / dev9202_info.slot_number)) - { - *windex = 0; - *rindex = 0x80; - dev9202_clk.last_clk_count = clk_count; - return RET_FIFO_ERR; - } - /* 读写地址的校验 */ - if (*windex < 0x80) - { - *rindex = *rindex + (fifo_div + 1) * 2; - if (*rindex < 0x80) - { - *rindex += 0x80; - } - dev9202_clk.last_clk_count = clk_count; - return RET_FIFO_ERR; - } - if (*rindex < 0x80) - { - *rindex = *windex; - dev9202_clk.last_clk_count = clk_count; - return RET_FIFO_ERR; - } - if (*windex == *rindex) - { - dev9202_clk.last_clk_count = clk_count; - return RET_FIFO_ERR; - } - dev9202_clk.last_clk_count = clk_count; - return RET_OK; -} - -/** - * @brief 获取fifos数据 - * @param enfifo-是否使能fifo,p_result-数据地址,psize-数据大小,rindex-读地址,windex-写地址,slot_num-通道数量 - * @retval 无 - */ -static void vc9202_drv_read_fifo_data(unsigned char enfifo, SamplingDataTypeDef *p_result, unsigned char *psize, unsigned char *rindex, unsigned char *windex, unsigned char slot_num) -{ - unsigned char i = 0; - unsigned char fifo_length = 0; - unsigned char fifoData[128] = {0}; - unsigned char fifo_index_offset = 0; /*正常情况下:r=w, 异常情况下,r=w-fifo_index_offset */ - /*------------- disable fifo -------------*/ - if (!enfifo) - { - *psize = slot_num; - usr_iic_read_bytes(0x80, fifoData, slot_num * 2); - for (i = 0; i < *psize; i++) - { - p_result->ppg_data[i] = (fifoData[i * 2] << 8) + fifoData[i * 2 + 1]; - if (ppg_mark[i]) - { - ppg_mark[i] = 0; - p_result->ppg_data[i] |= 0x1000; // 0x01000000; - } - } - return; - } - /*------------- enable fifo -------------*/ - /* 读取解析fifo数据 */ - if (*windex > *rindex) - { - fifo_length = *windex - *rindex; - if ((fifo_length % (dev9202_info.slot_number * 2)) && (dev9202_info.slot_number >= 2)) /* 当是多通道,但是通道数与字节数对应不上的异常处理 */ - { - fifo_index_offset = fifo_length % (dev9202_info.slot_number * 2); - fifo_length = fifo_length - fifo_index_offset; /* 只读取满足通道数的fifo数量,如果未出现异常,fifo_index_offset=0,跟之前处理一样 */ - } - usr_iic_read_bytes(*rindex, fifoData, fifo_length); - *rindex = *windex - fifo_index_offset; - } - else - { - fifo_length = *windex + 0x80 - *rindex; - if ((fifo_length % (dev9202_info.slot_number * 2)) && (dev9202_info.slot_number >= 2)) /* 当是多通道,但是通道数与字节数对应不上的异常处理 */ - { - fifo_index_offset = fifo_length % (dev9202_info.slot_number * 2); - fifo_length = fifo_length - fifo_index_offset; /* 只读取满足通道数的fifo数量 */ - } - if (*windex == 0x80) /* 数据刚好在0xfe-0xff截至 */ - { - usr_iic_read_bytes(*rindex, fifoData, fifo_length); - if (fifo_index_offset) - { - *rindex = *windex + 0x80 - fifo_index_offset; - } - else - { - *rindex = *windex - fifo_index_offset; /* fifo_index_offset=0 */ - } - } - else /* (*windex != 0x80): 0x80及以后还有数据 */ - { - usr_iic_read_bytes(*rindex, fifoData, (256 - *rindex)); /* 获取rindex-0xff的数据 */ - usr_iic_read_bytes(0x80, &fifoData[256 - *rindex], (*windex - 0x80) - fifo_index_offset); /* 剩下的数据部分如果存在 */ - *rindex = *windex - fifo_index_offset; - } - } - - *psize = fifo_length / 2; - for (i = 0; i < *psize; i++) - { - p_result->ppg_data[i] = (fifoData[i * 2] << 8) + fifoData[i * 2 + 1]; - if (ppg_mark[i]) - { - ppg_mark[i] = 0; - p_result->ppg_data[i] |= 0x1000; // 0x01000000; - } - } -} - -/** - * @brief 校验fifo并获取结果 - * @param p_result-数据地址,psize-数据大小 - * @retval 执行结果 - */ -static VC9202DrvRetTypeDef vc9202_drv_read_fifo_result(SamplingDataTypeDef *p_result, unsigned char *psize) -{ - VC9202DrvRetTypeDef vc_ret = RET_OK; - unsigned char write_index = 0; - unsigned char event = 0; - event = dev9202_info.int_event; -#if (VC9202_CFG_DRV_BY_TIMER == FUNC_ENABLE) - event = VC9202_EVENT_FIFO_MARK; -#endif - if (event & VC9202_EVENT_FIFO_MARK) - { - usr_iic_read_bytes(0x03, &write_index, 1); - vc_ret |= vc9202_drv_fifo_infomation_check(&dev9202_info.read_fifo_address, &write_index, dev9202_info.slot_number, dev9202_info.enfifo_div); - if (RET_OK == vc_ret && dev9202_info.osc_clk_status) - { - vc9202_drv_read_fifo_data(dev9202_info.enfifo_div, p_result, psize, &dev9202_info.read_fifo_address, &write_index, dev9202_info.slot_number); - } - } - return vc_ret; -} - -/*********************************************************************************************************/ -/** - * @brief 读取相关采样值和寄存器值 - * @param 无 - * @retval 无 - */ -static unsigned char vc9202_drv_read_reg(SamplingDataTypeDef *read_reg) -{ - unsigned char reg_val[6] = {0}; - unsigned char res_ext[2] = {0}; - VC9202ResLevelTypeDef res = {0}; - - /* 4bit数据读取 */ - usr_iic_read_bytes(0x04, reg_val, 3); - read_reg->pre_val[0] = reg_val[0] & 0x0F; - read_reg->pre_val[1] = reg_val[1] & 0x0F; - read_reg->env_val[0] = (reg_val[0] >> 4) & 0x0F; - read_reg->env_val[1] = (reg_val[1] >> 4) & 0x0F; - read_reg->env_val[2] = (reg_val[2] >> 4) & 0x0F; - read_reg->ps_val = reg_val[2] & 0x0F; - - /* old param */ - usr_iic_read_bytes(0x17, reg_val, 6); - read_reg->led_cur[0] = reg_val[0] & 0x7F; - read_reg->led_cur[1] = reg_val[1] & 0x7F; - read_reg->led_cur[2] = reg_val[2] & 0x7F; - read_reg->pd_res[0] = (reg_val[3] >> 4) & 0x07; - read_reg->pd_res[1] = (reg_val[4] >> 4) & 0x07; - read_reg->pd_res[2] = (reg_val[5] >> 4) & 0x07; - /* 8bit数据读取 */ - usr_iic_read_bytes(0x41, reg_val, 6); - read_reg->aenv_val[0] = reg_val[0]; - read_reg->aenv_val[1] = reg_val[1]; - read_reg->aenv_val[2] = reg_val[2]; - read_reg->apre_val[0] = reg_val[3]; - read_reg->apre_val[1] = reg_val[4]; - read_reg->aps_val = reg_val[5]; - /* new param */ - usr_iic_read_bytes(0x22, res_ext, 2); - /* slot0 */ - dev9202_adjust[0].slot_env = read_reg->aenv_val[0]; - dev9202_adjust[0].current = read_reg->led_cur[0]; - res.res_val = read_reg->pd_res[0]; - res.low_res = (res_ext[0] >> 0) & 0x01; - res.offset = (res_ext[0] >> 4) & 0x03; - res.offset3 = 0; - dev9202_adjust[0].res_level = vc9202_drv_res_register_to_level(&res); - /* slot1 */ - dev9202_adjust[1].slot_env = read_reg->aenv_val[1]; - dev9202_adjust[1].current = read_reg->led_cur[1]; - res.res_val = read_reg->pd_res[1]; - res.low_res = (res_ext[0] >> 1) & 0x01; - res.offset = (res_ext[0] >> 6) & 0x03; - res.offset3 = 0; - dev9202_adjust[1].res_level = vc9202_drv_res_register_to_level(&res); - /* slot2 */ - dev9202_adjust[2].slot_env = read_reg->aenv_val[2]; - dev9202_adjust[2].current = read_reg->led_cur[2]; - dev9202_adjust[2].res_level = read_reg->pd_res[2]; - /* 如果有等效电阻的等级,那么传出等效等级 */ - read_reg->pd_res[0] = dev9202_adjust[0].res_level; - read_reg->pd_res[1] = dev9202_adjust[1].res_level; - read_reg->pd_res[2] = dev9202_adjust[2].res_level; - /* pdbias */ - usr_iic_read_bytes(0x47, reg_val, 4); - read_reg->apdbias_val[0] = reg_val[0]; - read_reg->apdbias_val[1] = reg_val[1]; - read_reg->apdbias_val[2] = reg_val[2]; - read_reg->apdbias_val[3] = reg_val[3] & 0xf; - read_reg->pdbias = read_reg->apdbias_val[2] * 16 + read_reg->apdbias_val[3]; - - usr_iic_read_bytes(0x4B, reg_val, 4); - read_reg->bio_val_i = (reg_val[0] << 8) + reg_val[1]; - read_reg->bio_val_o = (reg_val[2] << 8) + reg_val[3]; - - if ((read_reg->aps_val >> 4) == read_reg->ps_val) /* 防止数据错误,4bit与8bit不匹配,则不对佩戴数据进行更新,防止因为异常摘下 */ - { - dev9202_wear.wear_ps = read_reg->aps_val; - dev9202_wear.wear_env = read_reg->pdbias; - dev9202_wear.wear_bio = read_reg->bio_val_o; - } - return 0; -} - -// 注意,该部分需要分为两部分,一部分为中断调用,一部分为定时调用,保证低端客户的可用性较高 -/** - * @brief 通过宏定义#if (FUNC_ENABLE==VC9202_CFG_DRV_BY_TIMER) 已经对定时器调用方式做了对应的处理,现在通用一个函数接口即可 - * @param 无 - * @retval 无 - */ -static VC9202DrvRetTypeDef vc9202_drv_gpio_event_handler(SamplingDataTypeDef *pResult, unsigned char *psize) -{ - VC9202DrvRetTypeDef vc_ret = RET_OK; - switch (dev9202_info.work_mode) - { - case WORK_MODE_HR: - vc_ret |= vc9202_drv_status_event_verify(dev9202_info.work_status, dev9202_info.int_event); - vc9202_drv_calibration_osc_clk(); - vc_ret |= vc9202_drv_read_fifo_result(pResult, psize); - break; - case WORK_MODE_SPO2: - vc_ret |= vc9202_drv_status_event_verify(dev9202_info.work_status, dev9202_info.int_event); - vc9202_drv_calibration_osc_clk(); - vc_ret |= vc9202_drv_read_fifo_result(pResult, psize); - break; - case WORK_MODE_HRV: - vc_ret |= vc9202_drv_status_event_verify(dev9202_info.work_status, dev9202_info.int_event); - vc9202_drv_calibration_osc_clk(); - vc_ret |= vc9202_drv_read_fifo_result(pResult, psize); - break; - case WORK_MODE_STRESS: - vc_ret |= vc9202_drv_status_event_verify(dev9202_info.work_status, dev9202_info.int_event); - vc9202_drv_calibration_osc_clk(); - vc_ret |= vc9202_drv_read_fifo_result(pResult, psize); - break; - case WORK_MODE_WEAR: - vc_ret |= vc9202_drv_status_event_verify(dev9202_info.work_status, dev9202_info.int_event); - vc9202_drv_calibration_osc_clk(); - break; - case WORK_MODE_FACTORY: - if (dev9202_info.int_event & VC9202_EVENT_OV_MARK) - { - vc_ret |= vc9202_drv_adjust_over_load_configure(&dev9202_adjust[0], 0, dev9202_info.work_status); - } - pResult->led_cur[0] = dev9202_adjust[0].max_current; - break; - case WORK_MODE_FPC_TEST: - vc9202_test_handler(pResult, &vc9202_test_info); - break; - default: - break; - } - return vc_ret; -} - -/** - * @brief 初始化驱动参数 - * @param - @pInit fifo_div fifo分频深度 - @pInit enslot 通道使能配置 - * @retval 无 - */ -void vc9202_drv_system_param_init(unsigned char fifo_div, unsigned char enslot) -{ - unsigned char i = 0; - /* dev info param init */ - dev9202_info.enfifo_div = fifo_div; - dev9202_info.enslot[0] = (enslot & 0x01); - dev9202_info.enslot[1] = (enslot & 0x02) >> 1; - dev9202_info.slot_number = dev9202_info.enslot[0] + dev9202_info.enslot[1]; - - dev9202_info.osc_clk_status = 0; - dev9202_info.read_fifo_address = 0x80; - /* dev9202_adjust info param init */ - for (i = 0; i < 2; i++) - { - dev9202_adjust[i].max_current = VC9202_MAX_CUR_LEVEL; - dev9202_adjust[i].max_res_level = VC9202_MAX_RES_LEVEL; - dev9202_adjust[i].record_env = 0; - dev9202_adjust[i].info.dir = AGC_DIR_NULL; - dev9202_adjust[i].info.last_dir = AGC_DIR_NULL; - dev9202_adjust[i].info.current_step = 4; - } - dev9202_adjust[2].max_res_level = VC9202_MAX_RES_LEVEL; - /* dev9202_wear param init */ -#if (VC9202_CFG_WEAR_DEFAULT_STATUS == WEAR_IS_HOLD) - dev9202_info.wear_status = WEAR_STA_HOLD; - dev9202_wear.wear_status = WEAR_STA_HOLD; - dev9202_wear.last_status = (WEAR_STA_NONE == dev9202_wear.last_status) ? WEAR_STA_HOLD : dev9202_wear.last_status; -#else - dev9202_wear.wear_status = WEAR_STA_DROP; - dev9202_wear.last_status = (WEAR_STA_NONE == dev9202_wear.last_status) ? WEAR_STA_DROP : dev9202_wear.last_status; -#endif -#if (VC9202_CFG_WEAR_DETECTION != FUNC_ENABLE) - dev9202_info.wear_status = WEAR_STA_HOLD; - dev9202_wear.wear_status = WEAR_STA_HOLD; - dev9202_wear.last_status = WEAR_STA_HOLD; -#endif - if (dev9202_wear.last_status == WEAR_STA_DROP && dev9202_info.work_mode != WORK_MODE_FACTORY && dev9202_info.work_mode != WORK_MODE_FPC_TEST) - { - if (dev9202_info.enslot[0]) - { - vc9202_drv_channel_switch(0, 0); - } - if (dev9202_info.enslot[1]) - { - vc9202_drv_channel_switch(1, 0); - } - } - dev9202_wear.wear_status = dev9202_wear.last_status; - dev9202_info.wear_status = dev9202_wear.wear_status; - alg_wear_status = WEAR_STA_HOLD; - dev9202_wear.wear_drop_cnt = VC9202_CFG_WEAR_DROP_CNT; - dev9202_wear.wear_hold_cnt = VC9202_CFG_WEAR_HOLD_CNT; - vc9202_drv_clear_clk(); -#if 0 - f_BIOInit(VC9202_CFG_WEAR_PARAM_BIOIN, VC9202_CFG_WEAR_PARAM_PSIN); - bio_result = VC9202_BIO_STA_NONE; - if( dev9202_wear.last_status==WEAR_STA_HOLD ) - { - bio_result = VC9202_BIO_STA_HOLD; - } - else - { - bio_result = VC9202_BIO_STA_NONE; - } -#else - // printf("fifo_div : %d, enslot : %d \n", fifo_div, enslot ); - // printf("f_BIOedgeinit(%d, %d) \n", VC9202_CFG_WEAR_PARAM_BIOIN, VC9202_CFG_WEAR_PARAM_PSIN ); - if (VC9202_BIO_STA_NONE == bio_result) - { - uint32_t irq_sts = osal_irq_lock(); - f_BIOInit(VC9202_CFG_WEAR_PARAM_BIOIN, VC9202_CFG_WEAR_PARAM_PSIN); - osal_irq_restore(irq_sts); - // printf(" VC9202_BIO_STA_DROP == bio_result f_BIOedgeinit(%d, %d) \n", VC9202_CFG_WEAR_PARAM_BIOIN, VC9202_CFG_WEAR_PARAM_PSIN ); - } -#endif -} - -/********************************************************************************************************* - * 对外功能函数 - ********************************************************************************************************/ - -/** - * @brief 获取chip_id - * @param 无 - * @retval chip_id值 - */ -unsigned char vc9202_drv_get_chip_id(void) -{ - unsigned char chip_id = 0; - usr_iic_read_bytes(0x00, &chip_id, 1); - // printf("vc9202 chip id : 0x%x\n",chip_id); - return chip_id; -} - -/** - * @brief 开始采样 - * @param 无 - * @retval 无 - */ -void vc9202_drv_start_sampling(void) -{ - unsigned char temp = 0x00; - usr_iic_read_bytes(0x10, &temp, 1); - temp |= (1 << 7); - usr_iic_write_bytes(0x10, &temp, 1); -} - -/** - * @brief 停止采样 - * @param 无 - * @retval 无 - */ -void vc9202_drv_stop_sampling(void) -{ - unsigned char temp = 0x00; - usr_iic_read_bytes(0x10, &temp, 1); - temp &= ~(1 << 7); - usr_iic_write_bytes(0x10, &temp, 1); - bio_result = VC9202_BIO_STA_NONE; -} - -/** - * @brief 软复位 - * @param 无 - * @retval 无 - */ -void vc9202_drv_soft_reset(void) -{ - unsigned char reset_reg_cfg = 0x5A; - usr_iic_write_bytes(0x3B, &reset_reg_cfg, 1); -} - -/** - * @brief 独立使/失能某一物理通道 - * @param - @num_channel 通道编号(0,1,2) - @enable_flag 使能或失能标志位 - * @retval 0执行成功 - */ -unsigned char vc9202_drv_channel_switch(unsigned char num_channel, unsigned char enable_flag) -{ - unsigned char temp = 0x00; - usr_iic_read_bytes(0x10, &temp, 1); - if (num_channel > 2) - { - return 1; - } - if (enable_flag == 1) - { - temp |= (1 << num_channel); - usr_iic_write_bytes(0x10, &temp, 1); - /* 同频处理 */ - if (WORK_MODE_SPO2 == dev9202_info.work_mode) - { - usr_iic_read_bytes(0x11, &temp, 1); - temp &= ~(1 << 4); - usr_iic_write_bytes(0x11, &temp, 1); - temp = 0; - usr_iic_write_bytes(0x16, &temp, 1); - } - } - else if (enable_flag == 0) - { - temp &= ~(1 << num_channel); - usr_iic_write_bytes(0x10, &temp, 1); - /* 同频处理 */ - usr_iic_read_bytes(0x11, &temp, 1); - temp |= (1 << 4); - usr_iic_write_bytes(0x11, &temp, 1); - temp = dev9202_info.enfifo_div; - usr_iic_write_bytes(0x16, &temp, 1); - } - else - { - return 2; - } - return 0; -} - -/** - * @brief 获取中断原因 - * @param 无 - * @retval 中断原因 - */ -unsigned char vc9202_drv_get_int_reason(void) -{ - unsigned char int_reason = 0; - unsigned char int_enable = 0; - usr_iic_read_bytes(0x02, &int_reason, 1); - usr_iic_read_bytes(0x11, &int_enable, 1); - /* 在同频时,获取到的ps中断,并非ps所需要的中断 */ - if (!(int_enable & (1 << 4))) - { - int_reason &= ~(1 << 4); - } -#if (VC9202_CFG_DRV_BY_TIMER == FUNC_ENABLE) - int_reason = (VC9202_EVENT_PS_MARK | VC9202_EVENT_FIFO_MARK); -#endif - return int_reason; -} - -/** - * @brief 防止静电打死,自动恢复,定时去调用检查即可 - * @param 无 - * @retval - */ -void vc9202_drv_electrostatic_death(void) -{ - unsigned char work_reg = 1; - unsigned char bio_reg[2] = {1, 1}; - unsigned short bio_val = 0; - usr_iic_read_bytes(0x10, &work_reg, 1); - if(dev9202_info.enable_bio) - { - usr_iic_read_bytes(0x4D, bio_reg, 2); - } - bio_val = (bio_reg[1] << 8) + bio_reg[0]; - /* dev9202 death */ - if (0 == work_reg || 0 == bio_val) - { - InitParamTypeDef init_param = {dev9202_info.fifo_time, dev9202_info.work_mode}; - vc9202_drv_soft_reset(); - vc9202_drv_reg_init(&init_param); - } -} - -/** - * @brief 防止任务队列堆积处理,导致短时间连续执行 - * @param 无 - * @retval 0-pass,-1-fail - */ -#define CHECK_GAPTIME_RATIO 3/4 /* 最短中断时间的3/4,30ms,算上频率在[16K,24K]波动,限制的时间为[25~37]ms以内会被过滤掉 */ -static int vc9202_drv_check_running_gaptime(void) -{ - unsigned int last_count = dev9202_clk.last_clk_check; - unsigned int now_count = 0; - - unsigned int count1 = 0, count2 = 0; - unsigned int count_diff = 0; - unsigned char cnt_reg[4] = {0}; - int ret = 0; - unsigned char check_gap_time = (1000/dev9202_info.work_frequency)*CHECK_GAPTIME_RATIO; - usr_iic_read_bytes(0x07, cnt_reg, 4); - count1 = (cnt_reg[0] << 8) + cnt_reg[1]; - count2 = (cnt_reg[2] << 8) + cnt_reg[3]; - count_diff = (count1 <= count2) ? (count2 - count1) : (count2 - count1 + 0xffff); - /* count值获取正确有效 */ - if (count_diff <= 5) - { - now_count = count1; - } - count_diff = 8000; - if ((0 != now_count) && (0 != last_count)) - { - count_diff = (last_count <= now_count) ? (now_count - last_count) : (now_count - last_count + 0xffff); - } - /* 间隔时间过小,算上频率在[16K,24K]波动,限制的时间为[25~37]ms以内会被过滤掉 */ - if (count_diff <= 20 * check_gap_time) - { - ret = -1; - } - dev9202_clk.last_clk_check = now_count; - return ret; -} - -/** - * @brief 寄存器配置 - * @param - @pInit_Param->work_mode 工作模式 - @pInit_Param->sampling_gap_time FIFO中断间隔时间,FIFO深度 - * @retval 无 - */ -unsigned char vc9202_drv_reg_init(InitParamTypeDef *pInit_Param) -{ - unsigned short int clk_div = 0x0000; - unsigned char fifo_div = 0; - unsigned char reg_cfg[17] = {0x00, 0x1F, 0x8A, 0x00, 0x03, 0x1F, 0x00, 0x00, 0x80, 0x00, 0x57, 0x57, 0x07, 0x16, 0x56, 0x16, 0x00}; - unsigned char reg_new = (1 << 3); - unsigned char reg_bio_cfg[2] = {0x00, 0xA2}; -/* 设置中断触发方式 0上升沿 1下降沿 */ -#if VC9202_CFG_INTERRUPT_MODE - reg_cfg[1] |= (1 << 7); -#endif - -/* 设置中断电平保持时间 */ -#ifdef VC9202_CFG_INTERRUPT_TIME - reg_cfg[1] |= (VC9202_CFG_INTERRUPT_TIME << 5); -#endif - - /* 设置FIFO深度,FIFO/PS中断间隔时间,同时设置采样分频 */ - dev9202_info.work_frequency = VC9202_CFG_SAMPLE_RATE; - dev9202_info.work_mode = (WorkModeTypeDef)pInit_Param->work_mode; - dev9202_info.fifo_time = pInit_Param->sampling_gap_time; - if (WORK_MODE_HRV == dev9202_info.work_mode) - { - dev9202_info.work_frequency = 100; - dev9202_info.fifo_time = 200; - } - fifo_div = dev9202_info.fifo_time / (1000 / dev9202_info.work_frequency) - 1; - clk_div = (20000 / dev9202_info.work_frequency) - 1; - reg_cfg[3] = fifo_div; - reg_cfg[4] = (clk_div >> 8) & 0xFF; - reg_cfg[5] = (clk_div & 0xFF); - reg_cfg[6] = fifo_div; - - /* 设置PS通道PD电阻,LED电流 */ - reg_cfg[9] = VC9202_CFG_PS_SLOT_CUR; - reg_cfg[12] = VC9202_CFG_PS_SLOT_RES; - - switch (dev9202_info.work_mode) - { - case WORK_MODE_HR: - reg_cfg[0] = 0x45; -#if VC9202_CFG_IS_HALVE_CAP - reg_cfg[10] = 0x54; /* 根据发光时间设置滤波电阻 */ - reg_cfg[13] = 0x03; // 0x03; /* 绿灯(物理通道0)映射到逻辑通道0,并设置采样时长为50us */ - reg_cfg[16] = 0x01; /* 发光时间减半,开1倍过采 */ -#else - reg_cfg[10] = 0x57; /* 根据发光时间设置滤波电阻 0x57 */ - reg_cfg[13] = 0x16; /* 绿灯(物理通道0)映射到逻辑通道0,并设置采样时长为50us */ - reg_cfg[16] = 0x00; /* 发光时间减半,开1倍过采 */ -#endif - break; - - case WORK_MODE_SPO2: - reg_cfg[0] = 0x47; - reg_cfg[1] &= ~(1 << 4); /* 关闭PS中断 */ - reg_cfg[6] = 0x00; /* PS开同频,避免引入同频干扰 */ - reg_cfg[7] = 0x80; /* slot0(红光)开32倍增益 */ - reg_cfg[13] = 0xB6; /*B6-3 红外(物理通道2)映射到逻辑通道0,并设置采样时长为200us */ - reg_cfg[14] = 0x76; /*76-3 红光(物理通道1)映射到逻辑通道0,并设置采样时长为200us */ - reg_cfg[16] = 0x04; /* 开16倍过采 */ - break; - - case WORK_MODE_HRV: - reg_cfg[0] = 0x45; -#if VC9202_CFG_IS_HALVE_CAP - reg_cfg[10] = 0x54; /* 根据发光时间设置滤波电阻 */ - reg_cfg[13] = 0x03; /* 绿灯(物理通道0)映射到逻辑通道0,并设置采样时长为50us */ - reg_cfg[16] = 0x01; /* 发光时间减半,开1倍过采 */ -#else - reg_cfg[10] = 0x57; /* 根据发光时间设置滤波电阻 */ - reg_cfg[13] = 0x16; /* 绿灯(物理通道0)映射到逻辑通道0,并设置采样时长为50us */ - reg_cfg[16] = 0x00; /* 发光时间减半,开1倍过采 */ -#endif - reg_bio_cfg[1] = 0x00; - break; - - case WORK_MODE_STRESS: - reg_cfg[0] = 0x45; -#if VC9202_CFG_IS_HALVE_CAP - reg_cfg[10] = 0x54; /* 根据发光时间设置滤波电阻 */ - reg_cfg[13] = 0x03; /* 绿灯(物理通道0)映射到逻辑通道0,并设置采样时长为50us */ - reg_cfg[16] = 0x01; /* 发光时间减半,开1倍过采 */ -#else - reg_cfg[10] = 0x57; /* 根据发光时间设置滤波电阻 */ - reg_cfg[13] = 0x16; /* 绿灯(物理通道0)映射到逻辑通道0,并设置采样时长为50us */ - reg_cfg[16] = 0x00; /* 发光时间减半,开1倍过采 */ -#endif - break; - - case WORK_MODE_WEAR: - reg_cfg[0] = 0x44; - reg_cfg[1] = (reg_cfg[1] | (1 << 4)) & 0xF0; - break; - - case WORK_MODE_FACTORY: - reg_cfg[0] = 0x47; - reg_cfg[7] = 0xEF; - reg_cfg[8] = 0xEF; - reg_cfg[10] = 0x77; - reg_cfg[11] = 0x77; - break; - case WORK_MODE_FPC_TEST: - reg_cfg[0] = 0x47; - reg_cfg[7] = 0xEF; - reg_cfg[8] = 0xEF; - reg_cfg[10] = 0x77; - reg_cfg[11] = 0x77; - vc9202_test_init(&vc9202_test_info); - break; - default: - break; - } - usr_iic_write_bytes(0x10, reg_cfg, 17); /* 心率血氧相关寄存器配置 */ - usr_iic_write_bytes(0x22, ®_new, 1); - usr_iic_write_bytes(0x23, reg_bio_cfg, 2); /*BIO相关寄存器配置 */ - if (reg_bio_cfg[1] & 0x80) - { - dev9202_info.enable_bio = 1; - } - else - { - dev9202_info.enable_bio = 0; - } - vc9202_drv_system_param_init(fifo_div, reg_cfg[0]); - /* mode位置1,芯片开始工作 */ - vc9202_drv_start_sampling(); - return 0; -} - -/** - * @brief 传递采样数据 - * @param 采样数据保存地址,ppg数量 - * @retval 执行结果 - */ -unsigned char vc9202_drv_get_sampling_data(SamplingDataTypeDef *pSamplingData, unsigned char *psize) -{ - unsigned char ret = 0; - /* 读取状态及中断事件 */ - usr_iic_read_bytes(0x01, &dev9202_info.work_status, 1); - usr_iic_read_bytes(0x02, (unsigned char *)&dev9202_info.int_event, 1); - - // printf("dev9202_info.work_status : 0x%x ,dev9202_info.int_event : 0x%x\n",dev9202_info.work_status,dev9202_info.int_event); - - if (dev9202_info.work_status & 0xf8) /* 防止insample和conflict时数据错误,则不对设备进行处理 */ - { - // printf("dev9202_info.work_status & 0xf8 \n"); - dev9202_info.int_event = 0; /* 异常时,避免执行佩戴检测 */ - return 1; - } - if (-1 == vc9202_drv_check_running_gaptime()) - { - // printf("-1 == vc9202_drv_check_running_gaptime() \n"); - dev9202_info.int_event = 0; /* 异常时,避免执行佩戴检测 */ - return 1; - } - ret = vc9202_drv_read_reg(pSamplingData); - ret = (unsigned char)vc9202_drv_gpio_event_handler(pSamplingData, psize); - return ret; -} diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_driver_testmode.c b/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_driver_testmode.c deleted file mode 100644 index 763c08e75..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_driver_testmode.c +++ /dev/null @@ -1,176 +0,0 @@ -/********************************************************************************************************* - * Copyright(c) 2022, vcare Corporation. All rights reserved. - ********************************************************************************************************** - * @file vc9202_driver_testmode.c - * @brief - * @details - * @author - * @date - * @version - *********************************************************************************************************/ -//!!!注意:本文文件包含step1(id,频率,温度的读取判断),step2(bio是否满足变化/ps是否能够达到阈值)两步进行FPC测试,用于那些不使用测试板的测试的用户,排查基础问题 -//!!!注意:本文文件包含step1(id,频率,温度的读取判断),step2(bio是否满足变化/ps是否能够达到阈值)两步进行FPC测试,用于那些不使用测试板的测试的用户,排查基础问题 -//如果不需要,删除本文件和其他报错的地方即可 -#include "vc9202_common.h" -#include "vc9202_driver.h" - -VC9202TestInfoTypeDef vc9202_test_info = {0}; - -const static unsigned char disp_green[17] = {0xC5, 0x30, 0x8A, 0x40, 0x03, 0x1F, 0x00, - 0x30, 0x40, 0x5A, - 0x57, 0x37, 0x47, - 0x16, 0x56, 0x16, 0x00}; -const static unsigned char disp_red[17] = {0xC6, 0x30, 0x8A, 0x40, 0x03, 0x1F, 0x00, - 0x30, 0x40, 0x5A, - 0x57, 0x37, 0x47, - 0x16, 0x56, 0x16, 0x00}; -static unsigned int mcu_cnt[2] = {0}, chip_cnt[2] = {0}; -void vc9202_test_init(VC9202TestInfoTypeDef *ptest_info) -{ - mcu_cnt[0] = 0; - mcu_cnt[1] = 0; - chip_cnt[0] = 0; - chip_cnt[1] = 0; - memset(ptest_info, 0, sizeof(VC9202TestInfoTypeDef)); -} - -static unsigned int vc9202_test_real_frequency(void) -{ - unsigned char cnt_reg[4] = {0}; - unsigned int mcu_cnt_dif = 0; - unsigned int chp_cnt_dif = 0; - unsigned int calc_freq = 0; - - mcu_cnt[1] = mcu_cnt[0]; - chip_cnt[1] = chip_cnt[0]; - mcu_cnt[0] = usr_get_clock_ticks(); - usr_iic_read_bytes(0x07, cnt_reg, 4); - chip_cnt[0] = (cnt_reg[0] << 8) + cnt_reg[1]; - unsigned short cnt1 = (cnt_reg[0] << 8) + cnt_reg[1]; - unsigned short cnt2 = (cnt_reg[2] << 8) + cnt_reg[3]; - if (abs(cnt1 - cnt2) >= 10) - { - return 0xffff; - } - if ((0 == mcu_cnt[1]) || (0 == mcu_cnt[0])) - return 20 * 1000; - if ((0 == chip_cnt[1]) || (0 == chip_cnt[0])) - return 20 * 1000; - mcu_cnt_dif = (mcu_cnt[0] > mcu_cnt[1]) ? (mcu_cnt[0] - mcu_cnt[1]) : (VC9202_CFG_CLK_CHECK_MAX - mcu_cnt[1] + mcu_cnt[0]); - chp_cnt_dif = (chip_cnt[0] > chip_cnt[1]) ? (chip_cnt[0] - chip_cnt[1]) : (0xffff - chip_cnt[1] + chip_cnt[0]); - float timeDiff = (float)mcu_cnt_dif / (float)VC9202_CFG_CLK_CHECK_FREQUENCY; - calc_freq = (float)chp_cnt_dif / timeDiff; - if (calc_freq >= 0xffff) - calc_freq = 0xffff; - if (calc_freq <= 0) - calc_freq = 0; - return calc_freq; -} - -static int vc9202_test_led_glint(VC9202TestInfoTypeDef *ptest_info) -{ - static unsigned char glint_count = 0; - if (ptest_info->step1_ret && ptest_info->step2_ret) - { - glint_count++; - if (glint_count == 25) - { - usr_iic_write_bytes(0x10, (unsigned char *)disp_green, 17); - } - else if (glint_count == 50) - { - glint_count = 0; - usr_iic_write_bytes(0x10, (unsigned char *)disp_red, 17); - } - return 1; - } - return 0; -} -/*记录bio变化值的最大的差值,用于判断bio变化是否满足阈值判断*/ -static void vc9202_test_bio_variation(VC9202TestInfoTypeDef *ptest_info, unsigned short bio) -{ - unsigned short now_gap = 0; - ptest_info->biovalue_now[1] = ptest_info->biovalue_now[0]; - ptest_info->biovalue_now[0] = bio; - if (0 == ptest_info->biovalue_now[1] || 0 == ptest_info->biovalue_now[0]) - { - return; - } - now_gap = (ptest_info->biovalue_now[0] > ptest_info->biovalue_now[1]) ? (ptest_info->biovalue_now[0] - ptest_info->biovalue_now[1]) : (ptest_info->biovalue_now[1] - ptest_info->biovalue_now[0]); - if (now_gap > ptest_info->biovalue_max) - { - ptest_info->biovalue_max = now_gap; - ptest_info->biovalue_gap[0] = ptest_info->biovalue_now[0]; - ptest_info->biovalue_gap[1] = ptest_info->biovalue_now[1]; - } - return; -} -void vc9202_test_handler(SamplingDataTypeDef *pResult, VC9202TestInfoTypeDef *ptest_info) -{ - // 判断是否测试完成,只执行交替闪 - if (vc9202_test_led_glint(ptest_info)) - { - return; - } - // step1 计算频率 + 读取ID及中断原因 - if (0 == ptest_info->step1_ret) - { - ptest_info->max_current = pResult->led_cur[0]; - ptest_info->leak_pre_value = pResult->apre_val[0]; - ptest_info->frequency = vc9202_test_real_frequency(); - usr_iic_read_bytes(0x00, &ptest_info->icid, 1); - usr_iic_read_bytes(0x02, &ptest_info->reason, 1); - return; - } - // step2 bio.ps - if (0 != ptest_info->step1_ret && 0 == ptest_info->step2_ret) - { - ptest_info->ps_value = pResult->aps_val; - vc9202_test_bio_variation(ptest_info, pResult->bio_val_o); - } - return; -} - -// 在xx_user.c中调用 case WORK_MODE_FACTORY: factory_test_function( &data ); break; -#if 0 -static void fpc_test_function(SamplingDataTypeDef *pdata) -{ - extern VC9202TestInfoTypeDef vc9202_test_info; - /* 等待5次中断工作稳定 */ - if (vc9202_test_info.wait_cnt <= 5) - { - vc9202_test_info.wait_cnt++; - return; - } - /* 步骤一:常规数据读取判断是否在范围内,此处得数据请根据实际设计对参数进行调整 */ - if (0 == vc9202_test_info.step1_ret) - { - if (vc9202_test_info.icid == 0x21 && vc9202_test_info.reason & 0x3f && - vc9202_test_info.frequency >= 16000 && vc9202_test_info.frequency <= 24000) - { - vc9202_test_info.step1_ret = 1; - } - else - { - vc9202_test_info.step1_ret = 2; - } - } - /* 步骤二:bio/ps数据读取判断是否在范围内 */ - else if (0 == vc9202_test_info.step2_ret) - { - if (vc9202_test_info.biovalue_max >= 400 && vc9202_test_info.ps_value >= 200) - { - vc9202_test_info.step2_ret = 1; - } - } - /*注意:上述方式会一直等待,直到检测通过,也可以使用人为触发记录,进行比较两次触发时的记录值差距是否满足。 - 记录两次不同状态(模拟佩戴和摘下)下时的pdata->bio_val_o,比较差值 - 记录模拟佩戴下的pdata->ps_val,判断是否满足PS范围 - */ - /* 其中step1_ret和step2_ret,分别表示测试是否通过,由于step2_ret需要检测变化量,所以需要一直等待操作,如果测试通过后,驱动会控制红绿灯交替闪烁 */ - DEBUG("[FAT]icid=%#x,reason=%#x,frequency=%d,temperature=%d", vc9202_test_info.icid, vc9202_test_info.reason, vc9202_test_info.frequency, vc9202_test_info.temperature); - printf("[FAT]biovalue_max=%d,ps=%d,gap[%d,%d]", vc9202_test_info.biovalue_max, vc9202_test_info.ps_value, vc9202_test_info.biovalue_gap[0], vc9202_test_info.biovalue_gap[1]); - printf("[FAT]-ret(%d,%d)", vc9202_test_info.step1_ret, vc9202_test_info.step2_ret); -} - -#endif diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_hal.c b/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_hal.c deleted file mode 100644 index 815e80656..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_hal.c +++ /dev/null @@ -1,207 +0,0 @@ -/* - * @Author: penglei 1624952103@qq.com - * @Date: 2024-03-13 15:08:38 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-05-15 17:15:13 - * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c - * @Description: - * - * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. - */ - -#include -#include -#include -#include -#include - -#include "pm_control.h" -#include "platform_core.h" -#include "pinctrl_porting.h" -#include "hal_gpio.h" - -#ifdef PPG_VC9202 -#include "vc30x91x92x_common.h" -#include "vc9202_user.h" -#endif - -#ifdef PPG_HX3695 - - -hx3695_msg_callback_t g_send_msg_toUI = NULL; - -// typedef void (*hx3695_msg_callback_t)(uint8_t msg_type, uint8_t *msg_data, int32_t msg_datalen); -uint32_t hx3695_register_msg_callback(hx3695_msg_callback_t func) -{ - g_send_msg_toUI = func; - return 0; -} - -hx3695_msg_callback_t hx3695_get_send_msg_callback_func(void) -{ - return g_send_msg_toUI; -} - - -#include "hx3695.h" -#include "tyhx_hrs_custom.h" - -#endif - - -// S_AGPIO_L26 心率复位 PPG reset -#define GPIO_PIN_PRG_RESET S_AGPIO_L26 -// S_AGPIO_R0 PRG_LED_POWER ON 心率等电源控制脚 -#define GPIO_PIN_PRG_LED_ON S_AGPIO_R0 - -uint32_t tyhx_poweron(void) -{ - uapi_pin_set_mode(GPIO_PIN_PRG_RESET, (pin_mode_t)HAL_PIO_FUNC_GPIO); - uapi_gpio_set_dir(GPIO_PIN_PRG_RESET, GPIO_DIRECTION_OUTPUT); - uapi_gpio_set_val(GPIO_PIN_PRG_RESET, GPIO_LEVEL_HIGH); - - uapi_pin_set_mode(GPIO_PIN_PRG_LED_ON, (pin_mode_t)HAL_PIO_FUNC_GPIO); - uapi_gpio_set_dir(GPIO_PIN_PRG_LED_ON, GPIO_DIRECTION_OUTPUT); - uapi_gpio_set_val(GPIO_PIN_PRG_LED_ON, GPIO_LEVEL_HIGH); - LOS_Udelay(30); - return 0; -} -uint32_t tyhx_poweroff(void) -{ - uapi_pin_set_mode(GPIO_PIN_PRG_RESET, (pin_mode_t)HAL_PIO_FUNC_GPIO); - uapi_gpio_set_dir(GPIO_PIN_PRG_RESET, GPIO_DIRECTION_OUTPUT); - uapi_gpio_set_val(GPIO_PIN_PRG_RESET, GPIO_LEVEL_LOW); - - uapi_pin_set_mode(GPIO_PIN_PRG_LED_ON, (pin_mode_t)HAL_PIO_FUNC_GPIO); - uapi_gpio_set_dir(GPIO_PIN_PRG_LED_ON, GPIO_DIRECTION_OUTPUT); - uapi_gpio_set_val(GPIO_PIN_PRG_LED_ON, GPIO_LEVEL_LOW); - LOS_Mdelay(1); - return 0; -} - - -void ppg_send_cmd_to_vc9202_driver(char* mode, uint8_t enable) -{ -#ifdef PPG_VC9202 - WorkModeTypeDef md = WORK_MODE_NONE; -#elif defined PPG_HX3695 - WORK_MODE_T md = NULL_MODE; -#endif - if (strcmp(mode, "hrs") == 0) { -#ifdef PPG_VC9202 - md = WORK_MODE_HR; -#elif defined PPG_HX3695 - md = HRS_MODE; -#endif - } else if (strcmp(mode, "hrv") == 0) { -#ifdef PPG_VC9202 - md = WORK_MODE_HRV; -#elif defined PPG_HX3695 - md = HRV_MODE; -#endif - } else if (strcmp(mode, "spo2") == 0) { -#ifdef PPG_VC9202 - md = WORK_MODE_SPO2; -#elif defined PPG_HX3695 - md = SPO2_MODE; -#endif - } else if (strcmp(mode, "leaklight") == 0) { -#ifdef PPG_VC9202 - md = WORK_MODE_FACTORY; -#elif defined PPG_HX3695 - md = FT_LEAK_LIGHT_MODE; -#endif - } else if (strcmp(mode, "graycard") == 0) { -#ifdef PPG_VC9202 - md = WORK_MODE_FACTORY; -#elif defined PPG_HX3695 - md = FT_GRAY_CARD_MODE; -#endif - } else if (strcmp(mode, "ledoff") == 0) { -#ifdef PPG_VC9202 - md = WORK_MODE_NONE; -#elif defined PPG_HX3695 - md = FT_LED_OFF_MODE; -#endif - } else if (strcmp(mode, "wear") == 0) { -#ifdef PPG_VC9202 - md = WORK_MODE_WEAR; -#elif defined PPG_HX3695 - md = WEAR_MODE; -#endif - } else if (strcmp(mode, "single") == 0) { -#ifdef PPG_VC9202 - md = WORK_MODE_NONE; -#elif defined PPG_HX3695 - md = FT_SINGLE_CHECK_MODE; -#endif - }else if (strcmp(mode, "factory") == 0) { -#ifdef PPG_VC9202 - md = WORK_MODE_FACTORY; -#endif - }else if (strcmp(mode, "fpc") == 0) { -#ifdef PPG_VC9202 - md = WORK_MODE_FPC_TEST; -#endif - } - -#ifdef PPG_HX3695 - if (enable == 1 || md == FT_LED_OFF_MODE) -#elif defined PPG_VC9202 - if (enable == 1) -#endif - { - // ppg_service_running_stat = true; - // uapi_pm_control(PM_APP_WAKE_NEEDED); - tyhx_poweron(); -#ifdef PPG_HX3695 - hx3695_init(md); -#endif -#ifdef PPG_VC9202 - InitParamTypeDef pInit_Param = {0}; - pInit_Param.sampling_gap_time = 400; - pInit_Param.work_mode = md; - vc9202_usr_init(&pInit_Param); -#endif - } else { - -#ifdef PPG_HX3695 - // ppg_service_running_stat = false; - if(md == HRS_MODE|| md == FT_LEAK_LIGHT_MODE || md == FT_GRAY_CARD_MODE || md == WEAR_MODE || md == FT_SINGLE_CHECK_MODE) - { -#ifdef HRS_ALG_LIB - hx3695_hrs_disable(); - // PRINT("uapi_dev_runtime_get_sleep_monitoring_status : %d \n",uapi_dev_runtime_get_sleep_monitoring_status()); - // PRINT("uapi_dev_runtime_get_hrs_passivity_flag : %d \n",uapi_dev_runtime_get_hrs_passivity_flag()); - if(uapi_dev_runtime_get_sleep_monitoring_status() && uapi_dev_runtime_get_hrs_passivity_flag())//处于睡眠监测 且在心率周期检测期间 上报活体佩戴 - { - hx3695_wearstatus_update(); - uapi_dev_runtime_set_hrs_passivity(0);//清除被动检测runtime - } -#endif - }else if(md == HRV_MODE) - { -#ifdef HRV_ALG_LIB - hx3695_hrv_disable(); -#endif - }else if(md == SPO2_MODE) - { -#ifdef SPO2_ALG_LIB - hx3695_spo2_disable(); -#endif - } - else{ -#ifdef HRS_ALG_LIB - hx3695_hrs_disable(); -#endif - } - -#elif defined PPG_VC9202 - vc9202_usr_stop_sampling(); -#endif - - - // uapi_pm_control(PM_APP_WAKE_NONEED); - tyhx_poweroff(); - } -} \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_user.c b/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_user.c deleted file mode 100644 index 9cd777c2d..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_user.c +++ /dev/null @@ -1,652 +0,0 @@ -/********************************************************************************************************* - * Copyright(c) 2022, vcare Corporation. All rights reserved. - ********************************************************************************************************** - * @file vc9202_user.c - * @brief functional Module Layer - * @details The functional interface is implemented by calling the driver.contain init_func,irq_handler - * @author - * @date - * @version - *********************************************************************************************************/ -#include "algo.h" -#include "spo2Algo.h" -#include "vcSportMotionIntAlgo.h" -#include "vc9202_common.h" -#include "vc9202_user.h" -#include "vc9202_driver.h" -#include "custom_utils.h" -#include "platform_core.h" -#include "systick.h" -#include "pinctrl_porting.h" -#include "hal_gpio.h" -#include "los_tick.h" - -static WorkModeTypeDef work_mode = WORK_MODE_NONE; -AlgoCalcResultsTypeDef vc9202_alg_results = {0}; - -/* 蓝牙发送原始数据接口 */ -extern void vc9202_debug_send_heart_rate_data( SamplingDataTypeDef* presult ,GsensorTypeDef* paxis, unsigned char heart_rate, unsigned char algo_mode, unsigned char ppgsize ); -extern void vc9202_debug_send_spo2_data( SamplingDataTypeDef* presult ,GsensorTypeDef* paxis, unsigned char spo2_val, unsigned char ppgsize ); - -/********************************************************************************************************* - * PERIPHERAL FUNCTIONS - ********************************************************************************************************/ -#define CHIP_I2C_ADDRESS 0x33 -#define VC9202_I2C_BUS I2C_BUS_2 - -static uint32_t gr_ppg_data = 0; -static uint32_t red_ppg_data = 0; -static uint32_t ir_ppg_data = 0; - -static uint32_t leaklight_led_cur = 0; //最大电流,黑箱通道2 -static uint32_t leaklight_apre_val = 0;//绿灯强度,漏光模式通道1 -static uint32_t leaklight_aps_val = 0;//红外强度,灰卡模式通道3 - -static uint32_t graycard_apre_val = 0;//绿灯强度,漏光模式通道1 -static uint32_t graycard_aps_val = 0;//红外强度,灰卡模式通道3 - -/** - * @brief iic多字节写 - * @param - * @arg reg_addr:寄存器地址 - * @arg pBuffer:缓冲区指针 - * @arg num_bytes:写的字节数 - * @retval 无 - */ -unsigned char usr_iic_write_bytes(unsigned char reg_addr, unsigned char *pBuffer, unsigned char buf_size) -{ - custom_i2c_write_reg(CHIP_I2C_ADDRESS, reg_addr, 1, pBuffer, buf_size, VC9202_I2C_BUS); - return 0; -} - - -/** - * @brief iic多字节读 - * @param - * @arg reg_addr:寄存器地址 - * @arg pBuffer:缓冲区指针 - * @arg num_bytes:读的字节数 - * @retval 无 - */ -unsigned char usr_iic_read_bytes(unsigned char reg_addr, unsigned char *pBuffer, unsigned char buf_size) -{ - custom_i2c_read_regs(CHIP_I2C_ADDRESS, reg_addr, 1 , pBuffer, buf_size, VC9202_I2C_BUS); - return 0; -} - - -/** - * @brief 校验用时钟tick获取 - * @param 无 - * @retval 时钟tick - */ -unsigned int usr_get_clock_ticks(void) -{ - return uapi_systick_get_count(); -} - -/********************************************************************************************************* - * API FUNCTIONS - ********************************************************************************************************/ -/** - * @brief 获取chip_id - * @param 无 - * @retval chip_id值 - */ -void vc9202_usr_get_chip_id( unsigned char *pchip_id, unsigned char *pvers_id ) -{ - tyhx_poweron(); - usr_iic_read_bytes( 0x00, pchip_id, 1 ); - usr_iic_read_bytes( 0x40, pvers_id, 1 ); - tyhx_poweroff(); -} - -/** - * @brief 初始化 - * @param 无 - * @retval 无 - */ -void vc9202_usr_init( InitParamTypeDef *pInitParam ) -{ - memset( &vc9202_alg_results, 0 ,sizeof(vc9202_alg_results) ); - // vcSpo2AlgoInit(); - spo2AlgoInit(); - Algo_Init(); - vcSportMotionAlgoInit(); - work_mode = (WorkModeTypeDef)pInitParam->work_mode; - vc9202_drv_soft_reset(); - vc9202_drv_reg_init( pInitParam ); -} - -/** - * @brief 开始采样 - * @param 无 - * @retval 无 - */ -void vc9202_usr_start_sampling(void) -{ - vc9202_drv_start_sampling(); -} - - -/** - * @brief 停止采样 - * @param 无 - * @retval 无 - */ -void vc9202_usr_stop_sampling(void) -{ - vc9202_drv_stop_sampling(); -} - - -/** - * @brief 软复位 - * @param 无 - * @retval 无 - */ -void vc9202_usr_soft_reset(void) -{ - vc9202_drv_soft_reset(); -} - -/** - * @brief 独立使/失能某一物理通道 - * @param - @num_channel 通道编号(1,2,3) - @enable_flag 使能或失能标志位 - * @retval 0-成功,其他-失败 - */ -unsigned char vc9202_usr_channel_switch(unsigned char num_channel, unsigned char enable_flag) -{ - return vc9202_drv_channel_switch(num_channel, enable_flag); -} - -/** - * @brief 获取中断原因 - * @param @无 - @ int_reason 中断原因 - * @retval 中断原因 - */ -unsigned char vc9202_usr_get_int_reason(void) -{ - /* bit2:fifo,bit4:ps */ - return vc9202_drv_get_int_reason(); -} -/** - * @brief 获取佩戴检测结果 - * @param @无 - @ 无 - * @retval 佩戴检测结果 - */ -unsigned char vc9202_usr_get_wear_status(void) -{ - unsigned char sta = 0; - WearStatusTypeDef retSta = vc9202_drv_get_wear_status(); - if( WEAR_STA_DROP == retSta ) - { - sta = 0; - } - else - { - sta = 1; - } - return sta; -} - -/**********************************************************************/ - -#define ENABLE_GSENSOR 0 -/* gsensor 相关的示例代码 */ -#if ENABLE_GSENSOR -typedef struct -{ - int16_t AXIS_X; - int16_t AXIS_Y; - int16_t AXIS_Z; -} AxesRaw_t; -static void gsensor_data_match(AxesRaw_t *org_data, GsensorTypeDef *pGsensorParam, unsigned char ppg_size) -{ - const unsigned char arry10[] = {0, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12}; - const unsigned char arry20[] = {0, 2, 3, 5, 6, 8, 9, 11, 12, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30}; - /* ppglen = 10 抽样 */ - if( 10<=ppg_size ) - { - for (uint8_t i = 0; i < ppg_size; i++) - { - pGsensorParam->gsensor_x_axis[i] = org_data[arry10[i]].AXIS_X; - pGsensorParam->gsensor_y_axis[i] = org_data[arry10[i]].AXIS_Y; - pGsensorParam->gsensor_z_axis[i] = org_data[arry10[i]].AXIS_Z; - } - } - else /* ppglen = 20 、25抽样 */ - { - for (uint8_t i = 0; i < ppg_size; i++) - { - pGsensorParam->gsensor_x_axis[i] = org_data[arry20[i]].AXIS_X; - pGsensorParam->gsensor_y_axis[i] = org_data[arry20[i]].AXIS_Y; - pGsensorParam->gsensor_z_axis[i] = org_data[arry20[i]].AXIS_Z; - } - } -} -#endif - -static void get_gsensor_data( GsensorTypeDef *pGsensorParam, unsigned char *pgsensor_len, unsigned char ppg_size ) -{ - /* - Gsensor精度要求 ReadGsensorFIFO(+-4G11bit or +-8G12bit 256/g) - 一个fifo周期为800ms,20组ppg数据,需要获取800ms内至少获取ppgCount组gsensor数据(40ms*20),用于匹配20组ppg信号,此函数需要根据用户实际的gsensor进行匹配处理。 - */ -#if ENABLE_GSENSOR - unsigned char i = 0; - unsigned char gsensor_len = 0; - AxesRaw_t gsensor_buff[40] = {0}; - pGsensorParam->sampling_rate = 25; - pGsensorParam->sensing_range = 4; - pGsensorParam->effective_bits = 12; - // stk8321_get_fifo_data(&gsensor_len, gsensor_buff); - if (ppg_size == 0) - { - *pgsensor_len = gsensor_len; - /* 不抽样 */ - for (i = 0; i < *pgsensor_len; i++) - { - pGsensorParam->gsensor_x_axis[i] = gsensor_buff[i].AXIS_X; - pGsensorParam->gsensor_y_axis[i] = gsensor_buff[i].AXIS_Y; - pGsensorParam->gsensor_z_axis[i] = gsensor_buff[i].AXIS_Z; - } - } - /* æ­¤demo中gsensor的采样频率高于ppg采样,所以正常情况下,gsensor的数量一定是大于ppg的数据。特殊情况需要考虑ppg数量大于gsensor数量。需要对gsensor数据进行补长 */ - if( (gsensor_len>=ppg_size)&&(ppg_size!=0) ) - { - *pgsensor_len = ppg_size; - // gsensor_data_match( gsensor_buff,pGsensorParam, ppg_size ); - } - else if( (gsensor_lengsensor_x_axis[i] = gsensor_buff[i].AXIS_X; - pGsensorParam->gsensor_y_axis[i] = gsensor_buff[i].AXIS_Y; - pGsensorParam->gsensor_z_axis[i] = gsensor_buff[i].AXIS_Z; - } - for( i=gsensor_len; igsensor_x_axis[i] = gsensor_buff[gsensor_len-1].AXIS_X; - pGsensorParam->gsensor_y_axis[i] = gsensor_buff[gsensor_len-1].AXIS_Y; - pGsensorParam->gsensor_z_axis[i] = gsensor_buff[gsensor_len-1].AXIS_Z; - } - } -#endif -} - -static unsigned int vc9202_usr_gsensor_actuating_quantity(int x_axis, int y_axis, int z_axis) -{ - unsigned int ret_atc = 0; - unsigned int abs_sum_current = 0; - static unsigned int abs_sum_last = 0; - if(x_axis < 0) - { - x_axis = -x_axis; - } - if(y_axis < 0) - { - y_axis = -y_axis; - } - if(z_axis < 0) - { - z_axis = -z_axis; - } - abs_sum_current = x_axis + y_axis + z_axis; - if(abs_sum_last&&abs_sum_current) - { - if( ABS(abs_sum_last,abs_sum_current)>=40 ) - { - ret_atc = 1; - } - } - abs_sum_last = abs_sum_current; - /* 存在运动量时处理,释放掉心率算法摘下的状态 */ - if( ret_atc ) - { - vc9202_drv_set_algo_wear_status( WEAR_STA_HOLD ); - } - vc9202_drv_set_gsensor_actuating_quantity( ret_atc ); - return ret_atc; -} - -static short int alg_calculate_hr_handler( short int last_hr_val, SamplingDataTypeDef *pdata, unsigned char ppg_size, GsensorTypeDef *pgsensor, AlgoSportMode hr_alg_mode ) -{ - unsigned char i=0; - short int heart_rate_value = last_hr_val; - AlgoInputData_t alg_i_data={0}; - AlgoOutputData_t alg_o_data={0}; - /* 如果没有fifo则直接推出,此处return需要返回上一次的值 */ - if( ppg_size <= 0 ) - { - return heart_rate_value; - } - if(ppg_size>=40) - { - ppg_size = 40; - } - // printf("ppg_size : %d \n",ppg_size); - alg_i_data.envSample = pdata->env_val[0]; - for( i=0; igsensor_x_axis[i]; - alg_i_data.axes.y = pgsensor->gsensor_y_axis[i]; - alg_i_data.axes.z = pgsensor->gsensor_z_axis[i]; - alg_i_data.ppgSample = pdata->ppg_data[i]; - gr_ppg_data = (uint32_t)pdata->ppg_data[i]; - printf("pdata->ppg_data[%d] : %d \n",i,pdata->ppg_data[i]); - // printf(" i : alg_i_data.axes.x : %d ,alg_i_data.axes.y : %d , alg_i_data.axes.z : %d \n",i,alg_i_data.axes.x,alg_i_data.axes.y,alg_i_data.axes.z); - Algo_Input( &alg_i_data, 1000/25, hr_alg_mode, 1, 1 ); - } - Algo_Output( &alg_o_data ); - // printf("alg_o_data.hrData : %d \n",alg_o_data.hrData); - if( -1 == alg_o_data.hrData ) - { - vc9202_drv_set_algo_wear_status( WEAR_STA_DROP ); - } - else if( alg_o_data.hrData > 0 ) - { - heart_rate_value = alg_o_data.hrData; - } - return heart_rate_value; -} - -static unsigned char alg_calculate_spo2_handler( unsigned char last_spo2_val , SamplingDataTypeDef *pdata, unsigned char ppg_size, GsensorTypeDef *pgsensor, unsigned char spo2_alg_mode ) -{ - unsigned char i=0; - unsigned char spo2_value = last_spo2_val; - float ret_spo2 = 0.0f; - float ir_PPG = 0.0f; - float red_PPG = 0.0f; - float sport_flag = 0.0f; - /* 如果没有fifo则直接推出,此处return需要返回上一次的值 */ - if( ppg_size<=0 ) - { - return spo2_value; - } - for( i=0; ippg_data[i*2]; - red_PPG = (float)pdata->ppg_data[i*2+1]; - red_ppg_data = (uint32_t)red_PPG; - ir_ppg_data = (uint32_t)ir_PPG; - // printf("ir_PPG : %.3f , red_PPG : %.3f \n",ir_PPG,red_PPG); - // ret_spo2 = vcSpo2Calculate( red_PPG, ir_PPG ); - ret_spo2 = spo2Algo(red_PPG,ir_PPG,1); - sport_flag = vcSportMotionCalculate( pgsensor->gsensor_x_axis[i], pgsensor->gsensor_y_axis[i], pgsensor->gsensor_z_axis[i] ); - if ( (-1!=ret_spo2)&&(!sport_flag)) - { - spo2_value = (unsigned char)ret_spo2; - } - } - return spo2_value; -} - -static void factory_test_function( SamplingDataTypeDef *pdata ,uint16_t size) -{ - /* 最大电流 */ - unsigned char ledMaxCur = pdata->led_cur[0]; //最大电流,黑箱通道2 - /* 获取测试数据 */ - unsigned int pre0 = pdata->apre_val[0];//绿灯强度,漏光模式通道1 - unsigned int ps = pdata->aps_val;//红外强度,灰卡模式通道3 - /* 温度 */ - signed short int temp0 = pdata->temp_val_i; - signed short int temp1 = pdata->temp_val_o; - /* compare abs(bio0,bio1) */ - unsigned short int bio0 = pdata->bio_val_o; - unsigned short int bio1 = pdata->bio_val_o; - - // uint8_t leak_light_pass = 0; - // uint8_t gray_card_pass = 0; - // 黑箱测试: - printf("pdata->led_cur[0] : %d , pdata->apre_val[0] : %d , pdata->aps_val : %d \n",pdata->led_cur[0],pdata->apre_val[0],pdata->aps_val); - leaklight_led_cur = pdata->led_cur[0]; - leaklight_apre_val = pdata->apre_val[0]; - leaklight_aps_val = pdata->aps_val; - // if(pdata->led_cur[0] >= 100 && pdata->apre_val[0] <= 64 && pdata->aps_val <= 64) - // { - // leak_light_pass = 1; - // } - // else - // { - // leak_light_pass = 0; - // } - - // 灰卡测试: - printf("pdata->apre_val[0] : %d , pdata->aps_val : %d\n",pdata->apre_val[0],pdata->aps_val); - graycard_apre_val = pdata->apre_val[0]; - graycard_aps_val = pdata->aps_val; - - // if(pdata->apre_val[0] >= 210 && pdata->aps_val >= 210) - // { - // gray_card_pass = 1; - // } - // else - // { - // gray_card_pass = 0; - // } - -} -static void fpc_test_function(SamplingDataTypeDef *pdata) -{ - extern VC9202TestInfoTypeDef vc9202_test_info; - /* 等待5次中断工作稳定 */ - if (vc9202_test_info.wait_cnt <= 5) - { - vc9202_test_info.wait_cnt++; - return; - } - /* 步骤一:常规数据读取判断是否在范围内,此处得数据请根据实际设计对参数进行调整 */ - if (0 == vc9202_test_info.step1_ret) - { - if (vc9202_test_info.icid == 0x21 && vc9202_test_info.reason & 0x3f && - vc9202_test_info.frequency >= 16000 && vc9202_test_info.frequency <= 24000 ) - { - vc9202_test_info.step1_ret = 1; - } - else - { - vc9202_test_info.step1_ret = 2; - } - } - /* 步骤二:bio/ps数据读取判断是否在范围内 */ - else if (0 == vc9202_test_info.step2_ret) - { - if (vc9202_test_info.biovalue_max >= 60 && vc9202_test_info.ps_value >= 200) - { - vc9202_test_info.step2_ret = 1; - } - } - /*注意:上述方式会一直等待,直到检测通过,也可以使用人为触发记录,进行比较两次触发时的记录值差距是否满足。 - 记录两次不同状态(模拟佩戴和摘下)下时的pdata->bio_val_o,比较差值 - 记录模拟佩戴下的pdata->ps_val,判断是否满足PS范围 - */ - /* 其中step1_ret和step2_ret,分别表示测试是否通过,由于step2_ret需要检测变化量,所以需要一直等待操作,如果测试通过后,驱动会控制红绿灯交替闪烁 */ - printf("[FAT]icid=%#x,reason=%#x,frequency=%d,temperature=%d \n", vc9202_test_info.icid, vc9202_test_info.reason, vc9202_test_info.frequency, vc9202_test_info.temperature); - printf("[FAT]biovalue_max=%d,ps=%d,gap[%d,%d] \n", vc9202_test_info.biovalue_max, vc9202_test_info.ps_value, vc9202_test_info.biovalue_gap[0], vc9202_test_info.biovalue_gap[1]); - printf("[FAT]-ret(%d,%d) \n", vc9202_test_info.step1_ret, vc9202_test_info.step2_ret); -} - -void vc9202_usr_interrupt_handler( AlgoSportMode hr_alg_mode, unsigned char spo2_alg_mode ) -{ - unsigned char wear_status = WEAR_STA_NONE; - SamplingDataTypeDef data = {0}; - GsensorTypeDef gsensor_data = {0}; - unsigned char gsensor_size = 0; - unsigned char ppg_size = 0; - VC9202DrvRetTypeDef ret = vc9202_drv_get_sampling_data( &data, &ppg_size ); - // printf("ppg_size : %d work_mode : %d ret : %d\n",ppg_size,work_mode,ret); - switch ( work_mode ) - { - case WORK_MODE_HR: - // printf("11111 vc9202_usr_get_int_reason : 0x%x \n",vc9202_usr_get_int_reason()); - if( vc9202_usr_get_int_reason()&(VC9202_EVENT_PS_MARK|VC9202_EVENT_FIFO_MARK) ) - { - wear_status = vc9202_usr_get_wear_status(); - // printf("11111 wear_status : %d \n",wear_status); - get_gsensor_data(&gsensor_data, &gsensor_size, ppg_size); - if( gsensor_size>0 ) - { - vc9202_usr_gsensor_actuating_quantity( gsensor_data.gsensor_x_axis[0], gsensor_data.gsensor_y_axis[0], gsensor_data.gsensor_z_axis[0] ); - } - if(wear_status) - { - vc9202_alg_results.hr_rate = alg_calculate_hr_handler( vc9202_alg_results.hr_rate, &data, ppg_size, &gsensor_data, hr_alg_mode ); - // printf("vc9202_alg_results.hr_rate : %d \n",vc9202_alg_results.hr_rate); - vc9202_debug_send_heart_rate_data( &data, &gsensor_data, vc9202_alg_results.hr_rate, hr_alg_mode, ppg_size ); - } - else - { - vc9202_alg_results.hr_rate = 0; - Algo_Init(); - } - } - break; - - case WORK_MODE_SPO2: - if( vc9202_usr_get_int_reason()&(VC9202_EVENT_PS_MARK|VC9202_EVENT_FIFO_MARK) ) - { - wear_status = vc9202_usr_get_wear_status(); - get_gsensor_data(&gsensor_data, &gsensor_size, ppg_size); - if(wear_status) - { - vc9202_alg_results.spo2_val = alg_calculate_spo2_handler( vc9202_alg_results.spo2_val, &data, ppg_size/2, &gsensor_data, spo2_alg_mode ); - // printf("vc9202_alg_results.spo2_val : %d \n",vc9202_alg_results.spo2_val); - vc9202_debug_send_spo2_data( &data, &gsensor_data, vc9202_alg_results.spo2_val, ppg_size/2 ); - } - else - { - vc9202_alg_results.spo2_val = 0; - // vcSpo2AlgoInit(); - spo2AlgoInit(); - vcSportMotionAlgoInit(); - } - } - break; - - case WORK_MODE_HRV: - if( vc9202_usr_get_int_reason()&(VC9202_EVENT_PS_MARK|VC9202_EVENT_FIFO_MARK) ) - { - wear_status = vc9202_usr_get_wear_status(); - get_gsensor_data(&gsensor_data, &gsensor_size, ppg_size); - if(wear_status) - { - vc9202_alg_results.hr_rate = alg_calculate_hr_handler( vc9202_alg_results.hr_rate, &data, ppg_size, &gsensor_data, hr_alg_mode ); - /* 校验+算法HRV */ - } - else - { - vc9202_alg_results.hr_rate = 0; - Algo_Init(); - /* 清空数据+初始化算法 */ - } - } - break; - - case WORK_MODE_STRESS: - if( vc9202_usr_get_int_reason()&(VC9202_EVENT_PS_MARK|VC9202_EVENT_FIFO_MARK) ) - { - wear_status = vc9202_usr_get_wear_status(); - get_gsensor_data(&gsensor_data, &gsensor_size, ppg_size); - if(wear_status) - { - /* 校验+算法STRESS */ - } - else - { - /* 清空数据+初始化算法 */ - } - } - break; - - case WORK_MODE_WEAR: - if( vc9202_usr_get_int_reason() & VC9202_EVENT_PS_MARK ) - { - wear_status = vc9202_usr_get_wear_status(); - get_gsensor_data(&gsensor_data, &gsensor_size, ppg_size); - if( gsensor_size>0 ) - { - vc9202_usr_gsensor_actuating_quantity( gsensor_data.gsensor_x_axis[0], gsensor_data.gsensor_y_axis[0], gsensor_data.gsensor_z_axis[0] ); - } - /* 根据佩戴状态添加对应的处理代码 */ - if(wear_status) - { - // printf("111 wear \n"); - } - else - { - // printf("222 nowear \n"); - } - } - break; - case WORK_MODE_FACTORY: - factory_test_function( &data ,ppg_size); - break; - case WORK_MODE_FPC_TEST: - fpc_test_function(&data); - break; - - default: - break; - } -} - -uint32_t vc9202_get_hr_ppg_data(void) -{ - uint32_t ppg_data = gr_ppg_data; - gr_ppg_data = 0; - return ppg_data; -} - -void vc9202_get_spo2_ppg_data(uint32_t *ir_data,uint32_t *red_data) -{ - *ir_data = ir_ppg_data; - *red_data = red_ppg_data; - red_ppg_data = 0; - ir_ppg_data = 0; -} - -void vc9202_get_leaklight_data(uint32_t *led_cur,uint32_t *apre_val,uint32_t *aps_val) -{ - *led_cur = leaklight_led_cur; - *apre_val = leaklight_apre_val; - *aps_val = leaklight_aps_val; - - leaklight_led_cur = 0; - leaklight_apre_val = 0; - leaklight_aps_val = 0; -} - -void vc9202_get_graycard_data(uint32_t *apre_val,uint32_t *aps_val) -{ - *apre_val = graycard_apre_val; - *aps_val = graycard_aps_val; - - graycard_apre_val = 0; - graycard_aps_val = 0; -} - -#if 0 -int main(int argc, char *argv[]) -{ - board_driver_init(); //MCU外设初始化 - InitParamTypeDef config={400,WORK_MODE_HR}; //修改fifo间隔时间(关系到fifolength), 设定工作模式 - vc9102_usr_init( &config ); - while(1) - { - if( irq_msg ) - { - //调用时传入心率算法模式(日常、运动...)和血氧算法参数。 - vc9102_usr_interrupt_handler( algo_mode, 1 ); - } - } - return 0 -} -#endif - diff --git a/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_user_debug.c b/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_user_debug.c deleted file mode 100644 index c40192b8c..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc9202/src/vc9202_user_debug.c +++ /dev/null @@ -1,188 +0,0 @@ -/********************************************************************************************************* - * Copyright(c) 2022, vcare Corporation. All rights reserved. - ********************************************************************************************************** - * @file vc9202_user_debug.c - * @brief example,debug send original data - * @details - * @author - * @date - * @version - *********************************************************************************************************/ - -#include "vc9202_common.h" -#include "vc9202_user.h" - -// #include "os_timer.h" -// #include -// #include "wristband_global_data.h" -// extern RtkWristBandSysType_t RtkWristbandSys; - -static unsigned char ble_buf[1024]={0}; -static unsigned short int buf_size = 0; -static unsigned short int buf_index = 0; -#define BLE_PACK_SIZE 160 -#define TIMER_BLE_GAP 100 - -/********************************************************************************************************** - * 对苹果手机APP不能连续接收长段数据,利用软件定时器,进行分包发送 - * 创建软件定时器及数据分包处理 - */ -static void send_data_by_ble( unsigned char *pbuf, unsigned short int size ) -{ - // if (RtkWristbandSys.gap_conn_state == GAP_CONN_STATE_CONNECTED) - // { - // hr_ble_service_send_v3_notify(RtkWristbandSys.wristband_conn_id, hr_ser_id, pbuf, size); - // DBG_DIRECT("ble_send_buffer_size=%d",size); - // } -} - -static int timer_send_data_function(void) -{ - unsigned short int residue_size = 0; - //数据发送已经完成 - if( buf_index >= buf_size ) - { - return 0; - } - //判断剩余数据长度是否还需要分包 - residue_size = buf_size-buf_index; - if( residue_size <= BLE_PACK_SIZE ) - { - send_data_by_ble( &ble_buf[buf_index], residue_size ); - return 0; - } - else - { - send_data_by_ble( &ble_buf[buf_index], BLE_PACK_SIZE ); - buf_index +=BLE_PACK_SIZE; - return 1; - } -} - - -/* 创建软件定时器,如果数据太长通过软件定时器发送 */ -#define TIMER_ID 0xf0 -static void *debug_send_timer = NULL; -static void debug_send_timer_start(void) -{ - if( debug_send_timer ) - { - // os_timer_restart(&debug_send_timer, TIMER_BLE_GAP); - } -} -static void debug_send_timer_stop(void) -{ - if( debug_send_timer ) - { - os_timer_stop(&debug_send_timer); - } -} - -static void debug_send_timer_callback( void *p_handle ) -{ - if( timer_send_data_function() ) - { - /* 定时器继续循环 */ - // os_timer_restart(&debug_send_timer, TIMER_BLE_GAP); - } - else - { - /* 关闭定时器 */ - debug_send_timer_stop(); - } -} - -void vc9202_debug_send_timer_init( void ) -{ - if(debug_send_timer == NULL) - { - os_timer_create(&debug_send_timer, "debug_send_timer", TIMER_ID, TIMER_BLE_GAP, false, debug_send_timer_callback); - } - // os_timer_restart(&debug_send_timer, TIMER_BLE_GAP); - os_timer_stop(&debug_send_timer); -} - -static void debug_orginal_data_send( unsigned short int size ) -{ - buf_index = 0; - buf_size = size; - if( buf_size <= BLE_PACK_SIZE ) - { - send_data_by_ble( ble_buf, size ); - } - else - { - send_data_by_ble( ble_buf, BLE_PACK_SIZE ); - buf_index += BLE_PACK_SIZE; - debug_send_timer_start(); - } -} - -/**********************************************************************************************************/ -#define ORIGINAL_DATA_DEBUG_ENABLE (1) - -#if ORIGINAL_DATA_DEBUG_ENABLE - -void vc9202_debug_send_heart_rate_data( SamplingDataTypeDef* presult ,GsensorTypeDef* paxis, unsigned char heart_rate, unsigned char algo_mode, unsigned char ppgsize ) -{ - unsigned short int i = 0; - for( i=0; ippg_data[i] >> 8; - ble_buf[i*16 + 1 ] = presult->ppg_data[i] & 0xff; - ble_buf[i*16 + 2 ] = paxis->gsensor_x_axis[i] >> 8; - ble_buf[i*16 + 3 ] = paxis->gsensor_x_axis[i] & 0xff; - ble_buf[i*16 + 4 ] = paxis->gsensor_y_axis[i] >> 8; - ble_buf[i*16 + 5 ] = paxis->gsensor_y_axis[i] & 0xff; - ble_buf[i*16 + 6 ] = paxis->gsensor_z_axis[i] >> 8; - ble_buf[i*16 + 7 ] = paxis->gsensor_z_axis[i] & 0xff; - ble_buf[i*16 + 8 ] = heart_rate; - ble_buf[i*16 + 9 ] = presult->pd_res[0]; - ble_buf[i*16 + 10] = presult->led_cur[0]; - ble_buf[i*16 + 11] = presult->env_val[2]; - ble_buf[i*16 + 12] = presult->pre_val[0]; - ble_buf[i*16 + 13] = presult->bio_val_o>>8; - ble_buf[i*16 + 14] = presult->bio_val_o&0xff; - ble_buf[i*16 + 15] = presult->aps_val; - } - if( ppgsize > 0 ) - { - debug_orginal_data_send( ppgsize*16 ); - } -} - -/**************************************************************************************** - * - */ -void vc9202_debug_send_spo2_data( SamplingDataTypeDef* presult ,GsensorTypeDef* paxis, unsigned char spo2_val, unsigned char ppgsize ) -{ - unsigned short int i = 0; - for( i=0; ippg_data[i*2] >> 8; - ble_buf[i*16 + 1 ] = presult->ppg_data[i*2] & 0xff; - ble_buf[i*16 + 2 ] = paxis->gsensor_x_axis[i] >> 8; - ble_buf[i*16 + 3 ] = paxis->gsensor_x_axis[i] & 0xff; - ble_buf[i*16 + 4 ] = paxis->gsensor_y_axis[i] >> 8; - ble_buf[i*16 + 5 ] = paxis->gsensor_y_axis[i] & 0xff; - ble_buf[i*16 + 6 ] = presult->pre_val[0]; - ble_buf[i*16 + 7 ] = presult->pre_val[1]; - ble_buf[i*16 + 8 ] = presult->ppg_data[i*2+1] >> 8; - ble_buf[i*16 + 9 ] = presult->ppg_data[i*2+1] & 0xff; - ble_buf[i*16 + 10] = spo2_val; - ble_buf[i*16 + 11] = presult->env_val[2]; - ble_buf[i*16 + 12] = presult->pd_res[0]; - ble_buf[i*16 + 13] = presult->led_cur[0]; - ble_buf[i*16 + 14] = presult->pd_res[1]; - ble_buf[i*16 + 15] = presult->led_cur[1]; - } - if( ppgsize > 0 ) - { - debug_orginal_data_send( ppgsize*16 ); - } -} - -#endif - - - diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/CMakeLists.txt b/code/sdk/zhihui/drivers/ppg/vc921x/CMakeLists.txt deleted file mode 100644 index d91011b88..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/CMakeLists.txt +++ /dev/null @@ -1,62 +0,0 @@ -#=============================================================================== -# @brief cmake file -# Copyright (c) @CompanyNameMagicTag 2022-2023. All rights reserved. -#=============================================================================== -set(COMPONENT_NAME "ppg_sensor_vc921x") - -if("PPG_VC921X" IN_LIST DEFINES) -set(SOURCES ${SOURCES} - ${CMAKE_CURRENT_SOURCE_DIR}/src/vc921x_core.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vc921x_driver.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vc921x_original_data_send.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vc921x_user_app.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/vc921x_hal.c -) -set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR}/inc - -) - -else() -set(SOURCES ${SOURCES} -) -set(PUBLIC_HEADER - ${CMAKE_CURRENT_SOURCE_DIR} -) -endif() - - -set(PRIVATE_HEADER -) - -set(PRIVATE_DEFINES -) - -set(PUBLIC_DEFINES -) - -# use this when you want to add ccflags like -include xxx -set(COMPONENT_PUBLIC_CCFLAGS -) - -set(COMPONENT_CCFLAGS -) - -set(WHOLE_LINK - true -) - -set(MAIN_COMPONENT - false -) - -if("PPG_VC921X" IN_LIST DEFINES) - find_library(LIB_PATH_VC921X_1 lib/lib_BIO_v141_int_miniSDK_NA_01.a ${CMAKE_CURRENT_SOURCE_DIR}) - find_library(LIB_PATH_VC921X_2 lib/lib_hr_vH102_int_miniSDK_NA_01.a ${CMAKE_CURRENT_SOURCE_DIR}) - find_library(LIB_PATH_VC921X_3 lib/lib_spo2_vc30FS_float_V07_miniSDK_NA_01.a ${CMAKE_CURRENT_SOURCE_DIR}) - find_library(LIB_PATH_VC921X_4 lib/lib_sportMotion_std_int_miniSDK_NA_01.a ${CMAKE_CURRENT_SOURCE_DIR}) - - target_link_libraries(${TARGET_NAME} PRIVATE -Wl,--whole-archive ${LIB_PATH_VC921X_1} ${LIB_PATH_VC921X_2} ${LIB_PATH_VC921X_3} ${LIB_PATH_VC921X_4} PRIVATE -Wl,--whole-archive) -endif() -build_component() - diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/BIODetect_V14_1.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/BIODetect_V14_1.h deleted file mode 100644 index 9b14b9d68..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/BIODetect_V14_1.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * - * Created on: 2023-6-04 - * Author: runningHorse - */ - -#ifndef BIODETECT -#define BIODETECT - -#include -#include - -void f_BIOInit(int32_t gapDeltaBIO, int32_t gapDeltaPS); - -uint8_t f_BIOdetect(int32_t inputBIO, int32_t inputPS, int32_t PSth); - -char* bioVersion(void); - -#endif /* BIODETECT */ \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/algo.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/algo.h deleted file mode 100644 index 3e9531379..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/algo.h +++ /dev/null @@ -1,70 +0,0 @@ - -#ifndef APP_ALGO_ALGO_H -#define APP_ALGO_ALGO_H - -#include -#include - -typedef enum -{ - SPORT_TYPE_NORMAL =0x00, // 日常 - SPORT_TYPE_RUNNING =0x01, // 跑步 - SPORT_TYPE_RIDE_BIKE =0X02, // 骑行 - SPORT_TYPE_JUMP_ROPE =0X03, // 跳绳 - SPORT_TYPE_SWIMMING =0X04, // 游泳 - SPORT_TYPE_BADMINTON =0X05, // 羽毛球 - SPORT_TYPE_TABLE_TENNIS=0X06, // 乒乓球 - SPORT_TYPE_TENNIS =0X07, // 网球 - SPORT_TYPE_CLIMBING =0X08, // 爬山 - SPORT_TYPE_WALKING =0X09, // 徒步 - SPORT_TYPE_BASKETBALL =0X0A, // 篮球 - SPORT_TYPE_FOOTBALL =0X0B, // 足球 - SPORT_TYPE_BASEBALL =0X0C, // 棒球 - SPORT_TYPE_VOLLEYBALL =0X0D, // 排球 - SPORT_TYPE_CRICKET = 0X0E, // 板球 - SPORT_TYPE_RUGBY = 0X0F, // 橄榄球 - SPORT_TYPE_HOCKEY =0X10, // 曲棍球 - SPORT_TYPE_DANCE = 0X11, // 跳舞 - SPORT_TYPE_SPINNING = 0X12, // 动感单车 - SPORT_TYPE_YOGA = 0X13, // 瑜伽 - SPORT_TYPE_SIT_UP =0X14, // 仰卧起坐 - SPORT_TYPE_TREADMILL =0X15, // 跑步机 - SPORT_TYPE_GYMNASTICS =0X16, // 体操 - SPORT_TYPE_BOATING = 0X17, // 划船 - SPORT_TYPE_JUMPING_JACK = 0X18, // 开合跳 - SPORT_TYPE_FREE_TRAINING = 0X19,// 自由训练 - SPORT_TYPE_PERIODIC_MONITORING = 0X1A,// 定时监测模式 -} AlgoSportMode; -//未出现在上表中的运动形式均先以跑步输入 - - -typedef struct -{ - int32_t x; - int32_t y; - int32_t z; -}AlgoAxesData_t; - -typedef struct -{ - int32_t hrData; - int32_t reliability; -}AlgoOutputData_t; - -typedef struct -{ - AlgoAxesData_t axes; - int32_t ppgSample; - int32_t envSample; -}AlgoInputData_t; - -void Algo_Init(void); -void Algo_Input(AlgoInputData_t *pInputData,int32_t gaptime,AlgoSportMode sportMode,int16_t surfaceRecogMode,int16_t opticalAidMode); -void Algo_Output(AlgoOutputData_t *pOutputData); - - - -#endif /* APP_ALGO_ALGO_H_ */ - - - diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/spo2Algo_16bit.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/spo2Algo_16bit.h deleted file mode 100644 index a838c5ede..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/spo2Algo_16bit.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * File: main.h - * - * MATLAB Coder version : 3.3 - * C/C++ source code generated on : 09-Sep-2020 19:11:59 - */ - -/*************************************************************************/ -/* This automatically generated example C main file shows how to call */ -/* entry-point functions that MATLAB Coder generated. You must customize */ -/* this file for your application. Do not modify this file directly. */ -/* Instead, make a copy of this file, modify it, and integrate it into */ -/* your development environment. */ -/* */ -/* This file initializes entry-point function arguments to a default */ -/* size and value before calling the entry-point functions. It does */ -/* not store or use any values returned from the entry-point functions. */ -/* If necessary, it does pre-allocate memory for returned values. */ -/* You can use this file as a starting point for a main function that */ -/* you can deploy in your application. */ -/* */ -/* After you copy the file, and before you deploy it, you must make the */ -/* following changes: */ -/* * For variable-size function arguments, change the example sizes to */ -/* the sizes that your application requires. */ -/* * Change the example values of function arguments to the values that */ -/* your application requires. */ -/* * If the entry-point functions return values, store these values or */ -/* otherwise use them as required by your application. */ -/* */ -/*************************************************************************/ -#ifndef SPO2ALGO_16bit_H -#define SPO2ALGO_16bit_H - -/* Include Files */ -#include -#include -#include -#include -#include -//#include "rt_nonfinite.h" -//#include "rtwtypes.h" -//#include "spo2_algo_interface_types.h" - -/* Function Declarations */ -extern float vcSpo2Calculate_16bit(float r_ppg, float ir_ppg, float model); -extern int vcSpo2AlgoInit_16bit(void); -extern void vcSpo2AlgoTerminate_16bit(void); -extern char * -version_info_16bit(void); -#endif - -/* - * File trailer for main.h - * - * [EOF] - */ diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_core.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_core.h deleted file mode 100644 index 27f915d00..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_core.h +++ /dev/null @@ -1,325 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-09-22 17:39:10 - * @LastEditTime: 2024-03-21 15:58:48 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ - -#ifndef __VC921x_CORE_H__ -#define __VC921x_CORE_H__ - -#ifndef VC_PACKED -#define VC921x_PACKED //__attribute__((packed)) -#endif - -/*=============================================================== -regist_list_map start... -================================================================*/ -#define CORE921x_DEV_VER_ID_H_ADDR (0x00) -#define CORE921x_FDY_EXT_ID_L_ADDR (0x01) -#define CORE921x_WORK_STATUS1_ADDR (0x02) -#define CORE921x_WORK_STATUS2_ADDR (0x03) -#define CORE921x_FIFO_W_INDEX_ADDR (0x04) -#define CORE921x_OSC_CNT0_H_ADDR (0x05) -#define CORE921x_OSC_CNT0_L_ADDR (0x06) -#define CORE921x_OSC_CNT1_H_ADDR (0x07) -#define CORE921x_OSC_CNT1_L_ADDR (0x08) - -/**************************************************************** - * ic sample param structure, 0x09 - 0x23 = 28byte - ***************************************************************/ -#define CORE921x_SAMPLE_DATA_ADDR_BASE (0x09) -typedef struct -{ - /* env data, 6byte_12bit[12,0] */ - unsigned char slot0_envh6; - unsigned char slot0_envl6; - unsigned char slot1_envh6; - unsigned char slot1_envl6; - unsigned char slot2_envh6; - unsigned char slot2_envl6; - /* ps data 3byte */ - unsigned char slot0_ps; - unsigned char slot1_ps; - unsigned char slot2_ps; - /* bio data 4byte */ - unsigned char bioinn_valh; - unsigned char bioinn_vall; - unsigned char bioext_valh; - unsigned char bioext_vall; - /* temp data 6byte */ - unsigned char tempslot0_valh; /* temp0-inside */ - unsigned char tempslot0_vall; - unsigned char tempslot1_valh; /* temp1-external */ - unsigned char tempslot1_vall; - unsigned char tempref_valh; /* temp_ext_ref */ - unsigned char tempref_vall; -} VC921x_PACKED core921x_reg_result_t; - -/**************************************************************** - * ic config param structure.[SLOT_CONFIG] - ***************************************************************/ -#define CORE921x_CONFIG_SLOT_ADDR_BASE (0x40) -typedef struct -{ - unsigned char oversample : 3; - unsigned char freq_isps : 1; - unsigned char rxgain : 3; - unsigned char enable : 1; -} VC921x_PACKED core921x_slot_ppg_cfg0bit; -typedef struct -{ - unsigned char env_time : 4; - unsigned char sample_time : 2; - unsigned char txch : 2; -} VC921x_PACKED core921x_slot_ppg_cfg1bit; -typedef struct -{ - unsigned char current : 7; - unsigned char storefifo : 1; -} VC921x_PACKED core921x_slot_cfg2bit; -typedef struct -{ - unsigned char sc : 4; - unsigned char resistance : 4; -} VC921x_PACKED core921x_slot_cfg3bit; -/*---[slot regist map]---*/ -typedef struct -{ - union /* 1_byte */ - { - unsigned char byte; - core921x_slot_ppg_cfg0bit bits; - } slot_cfg0; - union /* 2_byte */ - { - unsigned char byte; - core921x_slot_ppg_cfg1bit bits; - } slot_cfg1; - union /* 3_byte */ - { - unsigned char byte; - core921x_slot_cfg2bit bits; - } slot_cfg2; - union /* 4_byte */ - { - unsigned char byte; - core921x_slot_cfg3bit bits; - } slot_cfg3; -} VC921x_PACKED core921x_slot_config_t; - -/**************************************************************** - * ic config param structure.[PD_CONFIG + IRQ_RATE_CONFIG + IRQ_CONFIG] - ***************************************************************/ -#define CORE921x_INT_RATE_IRQ_CONFIG_ADDR_BASE (0x4C) - -typedef struct -{ - unsigned char slot0_pdch : 2; - unsigned char slot1_pdch : 2; - unsigned char slot2_pdch : 2; - unsigned char reserved : 2; -} VC921x_PACKED core921x_pd_cfgbit; - -typedef struct -{ - unsigned char anti_current : 3; - unsigned char reserved1 : 1; - unsigned char deslot0 : 1; - unsigned char deslot1 : 1; - unsigned char deslot2 : 1; - unsigned char reserved2 : 1; -} VC921x_PACKED core921x_anti_cfgbit_1120mpw; - -typedef struct -{ - unsigned char anti_current : 3; - unsigned char deslot0 : 1; - unsigned char deslot1 : 1; - unsigned char deslot2 : 1; - unsigned char antiTxch : 2; -} VC921x_PACKED core921x_anti_cfgbit; - -typedef struct -{ - unsigned char cpd : 3; - unsigned char fifo_en : 1; - unsigned char fifoformat : 1; - unsigned char bio_disfreqHop : 1; /* del function */ - unsigned char i2crelease_en : 1; - unsigned char deenv_en : 1; -} VC921x_PACKED core921x_com_cfgbit; -typedef struct -{ - unsigned char ppgthl : 4; - unsigned char ppgthh : 4; -} VC921x_PACKED core921x_ppgth_cfgbit; - -typedef struct -{ - unsigned char intppg_en : 1; - unsigned char intov_en : 1; - unsigned char intfifo_en : 1; - unsigned char intfreq2_en : 1; - unsigned char intlen : 2; - unsigned char intdir : 1; - unsigned char intmode : 1; -} VC921x_PACKED core921x_int_cfgbit; - -typedef struct -{ - /* 1byte pdch_config */ - union - { - unsigned char byte; - core921x_pd_cfgbit bits; - } pd_cfg; - /* 2_byte:anti_slot */ - union - { - unsigned char byte; - core921x_anti_cfgbit bits; - }; - /* 3_byte:com&pdcfg */ - union - { - unsigned char byte; - core921x_com_cfgbit bits; - } com_cfg; - /* 4~7_byte */ - unsigned char freq1_divH; - unsigned char freq1_divL; /* ppg_freq1_div = 20K / rete1 */ - unsigned char freq2_div; /* ps_freq2_div = ppg_freq / rate2 */ - unsigned char freq3_div; /* fifo_freq3_div = ps_freq / rate3 */ - /* 8_byte */ - union - { - unsigned char byte; - core921x_ppgth_cfgbit bits; - } ppgth_cfg; - /* 9_byte */ - union - { - unsigned char byte; - core921x_int_cfgbit bits; - } int_cfg; -} VC921x_PACKED core921x_common_config_t; - -/**************************************************************** - * ic config param structure.[EXTRA_CONFIG] - ***************************************************************/ -#define CORE921x_EXTRA_CONFIG_ADDR_BASE (0x54) - -typedef struct -{ - /* byte1 */ - unsigned char bio_freq : 2; - unsigned char bio_pdch : 2; - unsigned char bio_mode : 2; /* 00/01 work in freq2,noFIFO/inFIFO, single sample data - 10/11 work in freq1,inFIFO, single sample data / the sum data on freq2 */ - unsigned char bio_inn_en : 1; - unsigned char bio_ext_en : 1; -} VC921x_PACKED core921x_bio_cfg0bit; -typedef struct -{ - unsigned char bio_time : 3; - unsigned char bio_capadd : 5; -} VC921x_PACKED core921x_bio_cfg1bit; - -typedef struct -{ - unsigned char temp_currset : 3; - unsigned char temp_reserved_1 : 1; - unsigned char temp_slotch : 2; - unsigned char temp_reserved_2 : 1; - unsigned char temp_enable : 1; -} VC921x_PACKED core921x_temp_cfgbit; -typedef struct -{ - union /* 1_byte */ - { - unsigned char byte; - core921x_bio_cfg0bit bits; - } bio_cfg0; - union /* 2_byte */ - { - unsigned char byte; - core921x_bio_cfg1bit bits; - } bio_cfg1; - union /* 3_byte */ - { - unsigned char byte; - core921x_temp_cfgbit bits; - } temp0_cfg; - union /* 4_byte */ - { - unsigned char byte; - core921x_temp_cfgbit bits; - } temp1_cfg; -} VC921x_PACKED core921x_extra_config_t; // core921x_extra_config_t - -typedef struct -{ - unsigned char ovtype : 1; - unsigned char cmpset : 2; - unsigned char reserved : 1; - unsigned char ppg_resulution : 2; - unsigned char adc_speed : 1; /* reserved */ - unsigned char env_clkdiv : 1; /* reserved */ -} VC921x_PACKED core921x_adc_config_t; - -typedef struct -{ - unsigned char ovtype : 1; - unsigned char reserved : 3; - unsigned char ppg_resulution : 2; - unsigned char adc_speed : 1; /* reserved */ - unsigned char env_clkdiv : 1; /* reserved */ -} VC921x_PACKED core921x_adc_config_t_1120mpw; - -/**************************************************************** - * work_cmd & fifo_data structure - ***************************************************************/ -#define CORE921x_WORK_CMD_ADDR_BASE (0X7B) -#define CORE921x_WORK_CMD_SIZE (1) -/* fifo addr */ -#define CORE921x_FIFO_READADDR_INDEX (0xFE) -#define CORE921x_FIFO_DATA_ADDR (0xff) - -/**************************************************************** - * inline func: vc921x_core_memset,vc921x_core_memcpy - ***************************************************************/ -#ifndef NULL -#define NULL (void *)0 -#endif -static inline void *vc921x_core_memset(void *dest, int set, unsigned int n) -{ - if (dest == NULL || n <= 0) - { - return NULL; - } - char *pdest = (char *)dest; - while (n-- > 0) - { - *pdest++ = set; - } - return dest; -} -static inline void *vc921x_core_memcpy(void *dest, void *src, unsigned int n) -{ - if (dest == NULL || src == NULL) - { - return NULL; - } - char *pdest = (char *)dest; - char *psrc = (char *)src; - while (n--) - { - *pdest++ = *psrc++; - } - return dest; -} - -#endif /* __VC921x_CORE_H__ */ diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_core_com.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_core_com.h deleted file mode 100644 index 47c170662..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_core_com.h +++ /dev/null @@ -1,458 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-09-22 17:39:10 - * @LastEditTime: 2024-04-09 15:26:54 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ -//!!!!!!注意:本头文件不允许用户自己包含及调用相关的API,仅允许vc921x_driver.c包含,避免出错或者是产生的ROM占用 -//!!!!!!注意:本头文件不允许用户自己包含及调用相关的API,仅允许vc921x_driver.c包含,避免出错或者是产生的ROM占用 -#ifndef __VC921x_CORE_COM_H__ -#define __VC921x_CORE_COM_H__ - -#include "vc921x_sample_result.h" -#include "vc921x_driver_config.h" - -/* 如果需要指定变量到对应的字段在次定义,且重新编译 */ -#define CORE921x_DATA_RAM_SECTION //__attribute__((section(".core921xdata"))) -#define CORE921x_FUNC_RAM_SECTION //__attribute__((section(".core921xfunc"))) -/*============================================================================ - * CORE921x_DEBUG :debug interface - ===========================================================================*/ -// #define CORE921x_DEBUG_VERSION -/* 在编译库的时候,-D CORE921x_DEBUG_VERSION 对代码进行分版本生成库(debug/release) */ -#ifdef CORE921x_DEBUG_VERSION -extern void log_direct(unsigned int info, const char *fmt, ...); -#define CORE921x_DEBUG_LOG(fmt, ...) \ - do \ - { \ - log_direct((33 << 24), "[CORE921x_LOG]line(%d)" fmt, __LINE__, ##__VA_ARGS__); \ - } while (0) -#define CORE921x_DEBUG_ERR(fmt, ...) \ - do \ - { \ - log_direct((33 << 24), "[CORE921x_ERR]line(%d)" fmt, __LINE__, ##__VA_ARGS__); \ - } while (0) -#else -#define CORE921x_DEBUG_LOG(fmt, ...) -#define CORE921x_DEBUG_ERR(fmt, ...) -#endif - -#if 0 // CORE921x_DEBUG_LOG example -extern int (*vc921x_dbglog_user)(const char *, ...); -#define CORE921x_DEBUG_LOG(fmt, ...) \ - do \ - { \ - if (vc921x_dbglog_user) \ - vc921x_dbglog_user("[CORE921x_LOG]%s(%d)" fmt, __func__, __LINE__, ##__VA_ARGS__); \ - } while (0) -#define CORE921x_DEBUG_ERR(fmt, ...) \ - do \ - { \ - if (vc921x_dbglog_user) \ - vc921x_dbglog_user("[CORE921x_ERR]%s(%d)" fmt, __func__, __LINE__, ##__VA_ARGS__); \ - } while (0) -//#else -#define CORE921x_DEBUG_LOG(fmt, ...) -#define CORE921x_DEBUG_ERR(fmt, ...) -#endif - -/*============================================================================ - * IC resources marco - ===========================================================================*/ - /* VC921x IC type ID */ -#define VC921x_DEV_REV_ID 0x24 -#define VC921x_FDY_VER_ID0 0x10 - -#define VC921x_FDY_VER_ID1 0x30 - -#define VC921x_DEFAULT_FREQ (20000) /* 20K */ -/* work event */ -#define VC921x_EVENT_BIO_FLOW (1 << 6) -#define VC921x_EVENT_INSAMPLE (1 << 5) -#define VC921x_EVENT_CONFLICT (1 << 4) -#define VC921x_EVENT_INTPS_RDY (1 << 3) -#define VC921x_EVENT_INTFIFO_RDY (1 << 2) -#define VC921x_EVENT_INTOVLOAD (1 << 1) -#define VC921x_EVENT_INTPPG_STA (1 << 0) -/* work status */ -#define VC921x_STATUS_CH2_OVERLOAD (1 << 2) -#define VC921x_STATUS_CH1_OVERLOAD (1 << 1) -#define VC921x_STATUS_CH0_OVERLOAD (1 << 0) -/* enable event */ -#define VC921x_EN_EVT_FREQ2 (1 << 3) -#define VC921x_EN_EVT_FIFO (1 << 2) -#define VC921x_EN_EVT_OVLD (1 << 1) -#define VC921x_EN_EVT_PPG (1 << 0) - -typedef enum -{ - VC921x_CFG_DISABLE = 0, - VC921x_CFG_ENABLE = 1, -} VC921x_CFG_FUNC; - -typedef enum -{ - VC921x_PPG_SLOT_0 = 0, - VC921x_PPG_SLOT_1 = 1, - VC921x_PPG_SLOT_2 = 2, /* fix=ps */ -} VC921x_PPG_SLOT_I; /* 逻辑工作通道 */ - -typedef enum -{ - VC921x_PPG_TXCH_0 = 0, /* default:green */ - VC921x_PPG_TXCH_1 = 1, /* default: red */ - VC921x_PPG_TXCH_2 = 2, /* fix=ps,or irled */ -} VC921x_PPG_TXCH_I; /* 物理发光通道 */ - -typedef enum -{ - VC921x_FREQ_PPG = 0, /* high */ - VC921x_FREQ_PS = 1, /* low */ -} VC921x_FREQ_SEL; - -typedef enum -{ - VC921x_NO_STORE = 0, - VC921x_IN_STORE = 1, -} VC921x_STORE_FIFO; - -typedef enum -{ - VC921x_IO_PUSH_PULL = 0, - VC921x_IO_OPEN_DRAIN = 1, -} VC921x_IO_MODE; -typedef enum -{ - VC921x_IO_DIR_UP_EDGE = 0, - VC921x_IO_DIR_DOWN_EDGE = 1, -} VC921x_IO_DIR; - -typedef enum -{ - VC921x_IO_PULSE_TIM_100US = 0, - VC921x_IO_PULSE_TIM_200US = 1, - VC921x_IO_PULSE_TIM_400US = 2, - VC921x_IO_PULSE_TIM_800US = 3, -} VC921x_IO_PULSE_TIM; - -typedef enum -{ - VC921x_SAMPLE_TIM_50US = 0, - VC921x_SAMPLE_TIM_100US = 1, - VC921x_SAMPLE_TIM_150US = 2, - VC921x_SAMPLE_TIM_200US = 3, -} VC921x_SAMPLE_TIM; - -typedef enum -{ - VC921x_SLOT_CHSEL_NONE= 0, - VC921x_SLOT_CHSEL_PD01= 1, - VC921x_SLOT_CHSEL_PD10= 2, - VC921x_SLOT_CHSEL_PD11= 3, -}VC921x_SLOT_CHSEL; - -typedef enum -{ - VC921x_BIO_NOFIFO_PS_SGL= 0, - VC921x_BIO_INFIFO_PS_SGL= 1, - VC921x_BIO_INFIFO_PPG_SGL= 2, - VC921x_BIO_INFIFO_PPG_SUM= 3, -}VC921x_BIO_MODE; - -typedef enum -{ - VC921x_BIO_CHSEL_NONE= 0, - VC921x_BIO_CHSEL_ETP0= 1, - VC921x_BIO_CHSEL_ETP1= 2, - VC921x_BIO_CHSEL_PD11= 3, -}VC921x_BIO_CHSEL; - -typedef enum -{ - VC921x_TEMP_SLOT_INN = 0, - VC921x_TEMP_SLOT_EXT0 = 1, - VC921x_TEMP_SLOT_EXT1 = 2, -}VC921x_TEMP_SLOT; - -typedef enum -{ - VC921x_ADC_RESOLUTION_16BIT = 0, - VC921x_ADC_RESOLUTION_18BIT = 1, - VC921x_ADC_RESOLUTION_20BIT = 2, - VC921x_ADC_RESOLUTION_22BIT = 3, -}VC921x_ADC_RESOLUTION; - -typedef enum -{ - VC921x_STOP_WORK_CMD = 0, - VC921x_START_WORK_CMD, - VC921x_RESET_SOFT_CMD, - VC921x_WORK_CMD_NUM, -} VC921x_WORK_CMD; -/*============================================================================ - * VC921x_CORE_API - ===========================================================================*/ -/**************************************************************************** - * @description: 获取内核驱动版本信息 - * @param {char} **ppver - * @return {int} 0(success),-1(read/write/ticks func_pointer error) - ****************************************************************************/ -static inline int core921x_read_software_version(char **ppver) -{ - extern int __core921x_read_software_version(char **ppver); - return __core921x_read_software_version(ppver); -} - -/**************************************************************************** - * @description: 读取ic的ID参数 - * @param {unsigned char} *pid1 版本ID - * @param {unsigned char} *pid2 扩展ID - * @return {int} 0(success),-1(read/write error),1(parameter error),2(ic_id error) - ****************************************************************************/ -static inline int core921x_read_id(unsigned char *pid1, unsigned char *pid2) -{ - extern int __core921x_read_id(unsigned char *pid1, unsigned char *pid2); - return __core921x_read_id(pid1, pid2); -} - -/**************************************************** - * @description: 读取中断事件和过载状态 - * @param {int} *pevt 事件状态 - * @param {unsigned char} *povsta 过载状态 - * @return {int} 0(success),-1(read/write error) - ****************************************************/ -static inline int core921x_read_event_status(unsigned char *pevt, unsigned char *povsta, unsigned char *pwindex_bak, unsigned char *pwindex_rel ) -{ - extern int __core921x_read_event_status(unsigned char *pevt, unsigned char *povsta, unsigned char *pwindex_bak, unsigned char *pwindex_rel); - return __core921x_read_event_status(pevt, povsta, pwindex_bak, pwindex_rel ); -} - -/*************************************************************************** - * @description: 读取时钟tick - * @param {unsigned int} *ptick0 - * @param {unsigned int} *ptick1 - * @return {int} 0(success),-1(read/write error) - ****************************************************************************/ -static inline int core921x_read_rcosc_tick(unsigned short int *ptick0, unsigned short int *ptick1) -{ - extern int __core921x_read_rcosc_tick(unsigned short int *ptick0, unsigned short int *ptick1); - return __core921x_read_rcosc_tick(ptick0, ptick1); -} - -/**************************************************************************** - * @description: 读取基础采样数据 - * @param {result_t} *psample_ret - * @return {int} 0(success),-1(read/write error) - ****************************************************************************/ -static inline int core921x_read_output(vc921x_sample_info_t *psample_ret) -{ - extern int __core921x_read_output(vc921x_sample_info_t * psample_ret); - return __core921x_read_output(psample_ret); -} - -/**************************************************************************** - * @description: 读取fifo_PPG数据 - * @param {result_t} *psample_ret - * @param {unsigned char} *pread_fifoaddr - * @return {int} 0(success),-1(read/write error),1(analysis err) - ****************************************************************************/ -static inline int core921x_read_fifo_data(vc921x_sample_info_t *psample_ret, unsigned char *pread_fifoaddr, unsigned char read_windex) -{ - extern int __core921x_read_fifo_data(vc921x_sample_info_t * psample_ret, unsigned char *pread_fifoaddr, unsigned char read_windex); - return __core921x_read_fifo_data(psample_ret, pread_fifoaddr, read_windex); -} - -/* 通道相关配置 */ -static inline int core921x_set_enable_config(VC921x_PPG_SLOT_I slot_index, VC921x_CFG_FUNC config_enable) -{ - extern int __core921x_set_slot_enable_config(VC921x_PPG_SLOT_I slot_index, VC921x_CFG_FUNC config_enable); - return __core921x_set_slot_enable_config(slot_index, config_enable); -} - -static inline int core921x_set_slot_fix_param_config(VC921x_PPG_SLOT_I slot_index, unsigned char rxgain, VC921x_CFG_FUNC freq_isps, unsigned char oversample, VC921x_PPG_TXCH_I txslot, VC921x_SAMPLE_TIM sample_tim, VC921x_CFG_FUNC slot_infifo ) -{ - extern int __core921x_set_slot_fix_param_config(VC921x_PPG_SLOT_I slot_index, unsigned char rxgain, VC921x_CFG_FUNC freq_isps, unsigned char oversample, VC921x_PPG_TXCH_I txchsel, VC921x_SAMPLE_TIM sample_tim, VC921x_CFG_FUNC slot_infifo ); - return __core921x_set_slot_fix_param_config(slot_index, rxgain, freq_isps, oversample, txslot, sample_tim, slot_infifo ); -} - -static inline int core921x_read_slot_adjust_param(unsigned char *pmax_res, unsigned char *pmin_res, unsigned char *pmax_curr, unsigned char *pmin_curr) -{ - extern int __core921x_read_slot_adjust_param(unsigned char *pmax_res, unsigned char *pmin_res, unsigned char *pmax_curr, unsigned char *pmin_curr); - return __core921x_read_slot_adjust_param(pmax_res, pmin_res, pmax_curr, pmin_curr); -} -static inline int core921x_read_slot_current_res(VC921x_PPG_SLOT_I slot_index, unsigned char *pslot_curr, unsigned char *pslot_reslvl) -{ - extern int __core921x_read_slot_current_res(VC921x_PPG_SLOT_I slot_index, unsigned char *pslot_curr, unsigned char *pslot_reslvl); - return __core921x_read_slot_current_res(slot_index, pslot_curr, pslot_reslvl); -} - -static inline int core921x_set_ppgslot_current(VC921x_PPG_SLOT_I slot_index, unsigned char current) -{ - extern int __core921x_set_ppgslot_current(VC921x_PPG_SLOT_I slot_index, unsigned char current); - return __core921x_set_ppgslot_current(slot_index, current); -} - -static inline int core921x_set_ppgslot_resistance(VC921x_PPG_SLOT_I slot_index, unsigned char res_level, unsigned char allow_oversample ) -{ - extern int __core921x_set_ppgslot_resistance(VC921x_PPG_SLOT_I slot_index, unsigned char res_level, unsigned char allow_oversample ); - return __core921x_set_ppgslot_resistance(slot_index, res_level, allow_oversample ); -} -/*--------------------------------------------------------------*/ -extern int __core921x_set_slotx_pd_config( VC921x_SLOT_CHSEL slot0_pd, VC921x_SLOT_CHSEL slot1_pd, VC921x_SLOT_CHSEL slot2_pd ); -extern int __core921x_set_anti_slot_config( unsigned char anti_current, VC921x_CFG_FUNC deslot0, VC921x_CFG_FUNC deslot1, VC921x_CFG_FUNC deslot2, VC921x_PPG_TXCH_I antich ); -extern int __core921x_set_adc_config( VC921x_ADC_RESOLUTION adc_resulution, VC921x_CFG_FUNC ovdata_sum_enable ); -extern int __core921x_set_common_config(VC921x_CFG_FUNC deenv_en, VC921x_CFG_FUNC i2crelease_en, VC921x_CFG_FUNC bio_disfreqHop, VC921x_CFG_FUNC fifo_format, VC921x_CFG_FUNC fifo_en, unsigned char cpd); -static inline int core921x_set_common_config(unsigned char fifo_enable, unsigned fifo_format, unsigned char adc_resolution, VC921x_SLOT_CHSEL slot0_pd, VC921x_SLOT_CHSEL slot1_pd, VC921x_SLOT_CHSEL slot2_pd ) -{ - VC921x_CFG_FUNC fifo_enable_cfg = (fifo_enable) ? VC921x_CFG_ENABLE : VC921x_CFG_DISABLE; - VC921x_CFG_FUNC fifo_format_cfg = (fifo_format) ? VC921x_CFG_ENABLE : VC921x_CFG_DISABLE; - VC921x_ADC_RESOLUTION adc_resolution_cfg = VC921x_ADC_RESOLUTION_16BIT; - switch ( adc_resolution ) - { - case 16:adc_resolution_cfg=VC921x_ADC_RESOLUTION_16BIT; break; - case 18:adc_resolution_cfg=VC921x_ADC_RESOLUTION_18BIT; break; - case 20:adc_resolution_cfg=VC921x_ADC_RESOLUTION_20BIT; break; - case 22:adc_resolution_cfg=VC921x_ADC_RESOLUTION_22BIT; break; - default:adc_resolution_cfg=VC921x_ADC_RESOLUTION_16BIT; break; - } - __core921x_set_slotx_pd_config( slot0_pd, slot1_pd, slot2_pd ); - __core921x_set_anti_slot_config( 0/*0-7*/, VC921x_CFG_DISABLE,VC921x_CFG_DISABLE,VC921x_CFG_DISABLE, VC921x_PPG_TXCH_2 ); - __core921x_set_adc_config( adc_resolution_cfg, VC921x_CFG_DISABLE /* ov_type */ ); - return __core921x_set_common_config(VC921x_CFG_ENABLE, VC921x_CFG_ENABLE, VC921x_CFG_ENABLE/*dis_biofreq_hop*/, fifo_format_cfg, fifo_enable_cfg, 0); -} -/* 频率设置相关API */ -/**************************************************************************** - * @description: (ppg=20K/div1,ps=ppg/div2,fifo=ps/div3) - * @param {unsigned short int} div1 - * @param {unsigned char} div2 - * @param {unsigned char} div3 - * @return {int} 0(success),-1(read/write error) - ****************************************************************************/ -static inline int core921x_set_sample_frequency(unsigned short int div1, unsigned char div2, unsigned char div3) -{ - extern int __core921x_set_sample_frequency(unsigned short int div1, unsigned char div2, unsigned char div3); - return __core921x_set_sample_frequency(div1 - 1, div2 - 1, div3 - 1); -} - -static inline int core921x_set_threshold_config(unsigned char ppgth_h, unsigned char ppgth_l) -{ - extern int __core921x_set_threshold_config(unsigned char ppgth_h, unsigned char ppgth_l); - return __core921x_set_threshold_config(ppgth_h, ppgth_l); -} -static inline int core921x_set_interrupt_config(unsigned char evt_en) -{ - extern int __core921x_set_interrupt_config(VC921x_IO_MODE int_mode, VC921x_IO_DIR int_dir, VC921x_IO_PULSE_TIM int_len, unsigned char evt_en); - return __core921x_set_interrupt_config(VC921x_IO_PUSH_PULL, VC921x_IO_DIR_UP_EDGE, VC921x_IO_PULSE_TIM_100US, evt_en); -} - -static inline int core921x_set_bioslot_config(vc921x_sample_info_t *psample_info, unsigned char addcap) -{ - unsigned char bio_time = 6; - if( VC921x_BIO_INFIFO_PPG_SGL==psample_info->extra_result.biofifo_mode || VC921x_BIO_INFIFO_PPG_SUM==psample_info->extra_result.biofifo_mode ) - { -#if (VC921x_PS_WORK_FREQUENCY_CONFIG==1) - bio_time = 3; /* (ps=(25/13)hz~520ms,ps_div=13,fifo_div=1) 5200us */ -#elif (VC921x_PS_WORK_FREQUENCY_CONFIG==0) - switch (psample_info->ps_div) /* time = 2^n * 50 * ps_div */ - { - case 5: /* ppg=25,ps=5 */ - bio_time = 5; /* default 8ms:5-4-3-2-1 , 4ms:4-3-2-1-0 */ - break; - case 10: - bio_time = 4; - break; - case 20: - bio_time = 3; - break; - case 40: - bio_time = 2; - break; - case 80: - bio_time = 1; - break; - default: - CORE921x_DEBUG_ERR("fifo time error when underclocking"); - break; - } -#endif - } - extern int __core921x_set_bioslot_config(VC921x_CFG_FUNC bioinn_en, VC921x_CFG_FUNC bioext_en, VC921x_BIO_MODE biofifo_mode, VC921x_BIO_CHSEL bio_chsel, unsigned char biofreq, unsigned char biocap, unsigned char biotime) ; - return __core921x_set_bioslot_config((VC921x_CFG_FUNC)psample_info->extra_result.bioinn_enwork, - (VC921x_CFG_FUNC)psample_info->extra_result.bioext_enwork, - (VC921x_BIO_MODE)psample_info->extra_result.biofifo_mode, - VC921x_CFG_BIO_CHANNL_SELECT, - 2, addcap, bio_time); -} -static inline int core921x_set_bioinn_addcap(vc921x_sample_info_t *psample_info,unsigned char biocap) -{ - extern int __core921x_set_bioinn_addcap(unsigned char biocap); - return __core921x_set_bioinn_addcap(biocap); -} - -static inline int core921x_set_temperature_config(vc921x_sample_info_t *psample_info) -{ - extern int __core921x_set_temperature_config(VC921x_CFG_FUNC tempslot0_en, VC921x_TEMP_SLOT tempslot0_chsel, unsigned char tempslot0_current, - VC921x_CFG_FUNC tempslot1_en, VC921x_TEMP_SLOT tempslot1_chsel, unsigned char tempslot1_current ); - return __core921x_set_temperature_config((VC921x_CFG_FUNC)psample_info->extra_result.tempslot0_enwork, VC921x_TEMP_SLOT_INN, psample_info->extra_result.tempslot0_setcur, - (VC921x_CFG_FUNC)psample_info->extra_result.tempslot1_enwork, VC921x_TEMP_SLOT_EXT1, psample_info->extra_result.tempslot1_setcur ); -} - -/**************************************************************************** - * @description: 设置RCOSC校准值 - * @param {unsigned char} oscfreq - * @return {int} 0(success),-1(read/write error) - ****************************************************************************/ -static inline int core921x_set_rcosc_frequency(unsigned char oscfreq) -{ - extern int __core921x_set_rcosc_frequency(unsigned char oscset); - return __core921x_set_rcosc_frequency(oscfreq); -} - -/**************************************************************************** - * @description: - * @param {VC921x_WORK_CMD} cmd - * @return {int} 0(success),-1(read/write error),1(parameter error) - ****************************************************************************/ -static inline int core921x_write_work_cmd(VC921x_WORK_CMD cmd) -{ - extern int __core921x_write_work_cmd(VC921x_WORK_CMD cmd); - return __core921x_write_work_cmd(cmd); -} - -/*============================================================================ - * IC config ppg/ps slot function - ===========================================================================*/ -static inline int core921x_sample_slotx_config(VC921x_PPG_SLOT_I slot_index ,vc921x_sample_info_t *psample_info, VC921x_PPG_TXCH_I ppg_tx, unsigned char rxgain, unsigned char oversample, VC921x_SAMPLE_TIM sampletime) -{ - /* ppg slot0 config */ - VC921x_CFG_FUNC freq_isps = (1==psample_info->slot_result[slot_index].slot_freq_sel)?VC921x_CFG_ENABLE:VC921x_CFG_DISABLE; - if (psample_info->slot_result[slot_index].slot_enwork) - { - core921x_set_ppgslot_current(slot_index, psample_info->slot_result[slot_index].slot_current); - core921x_set_ppgslot_resistance(slot_index, psample_info->slot_result[slot_index].slot_resistance, 0 ); - core921x_set_slot_fix_param_config(slot_index, rxgain, freq_isps, oversample, ppg_tx, sampletime, psample_info->slot_result[slot_index].slot_storefifo ); - core921x_set_enable_config(slot_index, VC921x_CFG_ENABLE); - } - return 0; -} -/*=====================================================================================================================================*/ -extern int core921x_check_nto_version_init(void); -/**************************************************************** - * CORE_API.write()/set() - * common interface to write/read configuration - * write or set config registers, debug or other function. - ***************************************************************/ - -extern int vc921x_param_write_flash(unsigned char *pdata, unsigned int size); -extern int vc921x_param_read_flash(unsigned char *pdata, unsigned int size); - -extern void *vc921x_malloc(unsigned int size); -extern void vc921x_free(void *ptr); - -extern int vc921x_read_register(unsigned char regaddr, unsigned char *pbuf, unsigned short int size); -extern int vc921x_write_register(unsigned char regaddr, unsigned char *pbuf, unsigned short int size); -extern unsigned int vc921x_get_cputimer_tick(void); - -#endif /* __VC921x_CORE_COM_H__ */ diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_driver.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_driver.h deleted file mode 100644 index 36f5bc36e..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_driver.h +++ /dev/null @@ -1,127 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-09-22 17:39:10 - * @LastEditTime: 2023-12-21 15:37:20 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ - -#ifndef __VC921x_DRIVER_H__ -#define __VC921x_DRIVER_H__ - -#include "vcare_device_com.h" -/**************************************************************************** - * WearStatus_t - ***************************************************************************/ -#define VC921x_BIO_STA_NONE 0 -#define VC921x_BIO_STA_DROP 1 -#define VC921x_BIO_STA_HOLD 2 - -typedef enum -{ - VC921x_WEAR_NO_CHANGE = 0, - VC921x_HOLD_TO_DROP, - VC921x_DROP_TO_HOLD, -} vc921x_wear_change; - -typedef struct -{ - unsigned char hold_cnt; - unsigned char drop_cnt; - wear_status wear_status; - wear_status last_status; - wear_status algo_wear_status; - wear_status acce_wear_status; - int bio_wear_result; - unsigned short int last_ps_data[2]; - -} vc921x_wear_info; - -/**************************************************************************** - * oscclk_t - ***************************************************************************/ -typedef struct -{ - /* calc real frequency */ - unsigned int osc_count[6]; - unsigned int clk_count[6]; - unsigned char count_index; - unsigned char osc_gap_cnt; - unsigned short int rcosc_frequency; - /* check interrupt gaptime */ - unsigned short int last_check_ticks; - /* startup need get calc value */ - unsigned char rcosc_calibration; - unsigned char clk_calc_freq_status; /* calculate frequency finished */ - unsigned char clk_calc_status; /* calculate rcsoc status finished */ - -} vc921x_clk_info; - -/**************************************************************************** - * adjust_t - ***************************************************************************/ -#define VC921x_ADJUST_DIR_NONE 0 -#define VC921x_ADJUST_DIR_UP 1 -#define VC921x_ADJUST_DIR_DOWN 2 - -typedef struct -{ - unsigned char direction; - unsigned char direction_last; - unsigned short int current_step; -} vc921x_adjust_param; - -typedef struct -{ - unsigned char const_max_current; /* ic参数确定的最大电流电阻,固定 */ - unsigned char const_min_current; - unsigned char const_max_res_level; - unsigned char const_min_res_level; - unsigned char max_current; /* ic工作环境的最大电流电阻,可变 */ - unsigned char max_res_level; - unsigned char current; /* ic当前工作的最大电流电阻,可变 */ - unsigned char res_level; - - vc921x_adjust_param adj_param; - -} vc921x_adjust_info; -typedef struct -{ - int work_mode; - unsigned short ppg_div; - unsigned char ps_div; - unsigned char fifo_div; - unsigned char drop_div; - unsigned char hr_algo_mode; - - unsigned char int_event; - unsigned char ov_status; - unsigned char read_fifo_address; - unsigned char write_fifo_address_bak; /* write_addr when fifo event */ - unsigned char write_fifo_address_rel; /* write_addr at present */ - - int optimal_bio_gap; - int optimal_bio_temp; - unsigned char optimal_cap; - unsigned char optimal_bio_valid; - unsigned char ppg_max_thval; - unsigned char ppg_min_thval; - - unsigned char ppg_convert_ps; /* 如果不使用PS频率采集PS,使用PPGir来对佩戴检测进行识别,需要设置为1 */ - - unsigned char param_read_finished_sync; - unsigned char fifo_read_finished_sync; - unsigned char fifo_read_data_valid; /* 0-havn't fifo data, 1-normal fifo data, 2-read fifo data when fifo_windex offset */ - unsigned char event_read_finished_sync; - -} vc921x_drv_info; - -typedef struct -{ - work_mode mode; - int (*mode_init)(void); - int (*mode_handler)(const void *ops_self, vcare_ppg_device_t *pdev); -} vc921x_mode_ops; - -#endif /* __VC9211x_DRIVER_H__ */ diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_driver_com.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_driver_com.h deleted file mode 100644 index 55b1142a5..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_driver_com.h +++ /dev/null @@ -1,148 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-09-22 17:39:10 - * @LastEditTime: 2023-09-26 15:22:19 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ - -#ifndef __VC921x_DRIVER_COM_H__ -#define __VC921x_DRIVER_COM_H__ - -#include "vcare_device_com.h" -/********************************************************************************************************* - * DRV_API - ********************************************************************************************************/ -/* 注意: -VC921x - fifo长度最长只有192字节,在多通道时,一次fifo的缓存不能超过192字节 - -typical: -ppg_div=800, ps_div=5, fifo_div=5 (ppg-25hz, psbio-5hz, fifo-1hz) 1000ms (921x_max=20*4+4*6=104) -ppg_div=800, ps_div=5, fifo_div=4 (ppg-25hz, psbio-5hz, fifo-1.25hz) 800ms (921x_max=20*4+4*6=104) -ppg_div=400, ps_div=10, fifo_div=2 (ppg-50hz, psbio-5hz, fifo-2.5hz) 400ms (921x_max=20*4+2*6=92) -ppg_div=200, ps_div=20, fifo_div=1 (ppg-100hz,psbio-5hz, fifo-5hz) 200ms (921x_max=20*4+1*6=88) -*/ -/**************************************************************************** - * @description: 初始化并且开始进行采样 - * @param {void} *pdevice - * @param {int} workmode - * @param {unsigned short int} ppgdiv - * @param {unsigned char} psdiv - * @param {unsigned char} fifodiv - * @return {*} - ****************************************************************************/ -int vc921x_drv_init_start_work(void *pdevice, int workmode, unsigned short int ppgdiv, unsigned char psdiv, unsigned char fifodiv, unsigned char dropdiv); -/**************************************************************************** - * @description: 获取驱动版本,IC的主ID,次ID - * @param {char} * - * @param {unsigned char} *pid1 - * @param {unsigned char} *pid2 - * @return {*} - ****************************************************************************/ -int vc921x_drv_get_hwsw_infomation(char **str_drv_ver, unsigned char *pid1, unsigned char *pid2); -/**************************************************************************** - * @description: 软复位IC并且退出工作(如需重新工作需要重新调用初始化) - * @param {void} *device - * @return {*} - ****************************************************************************/ -int vc921x_drv_exit_stop_work(void *device); -/**************************************************************************** - * @description: 软复位IC(如需重新工作需要重新调用初始化) - * @param {void} *device - * @return {*} - ****************************************************************************/ -int vc921x_drv_software_reset(void *device); -/**************************************************************************** - * @description: 唤醒工作(可以唤醒调用sleep停止工作) - * @param {void} *device - * @return {*} - ****************************************************************************/ -int vc921x_drv_wakeup_work(void *device); -/**************************************************************************** - * @description: 休眠工作(休眠后可以用wakeup唤醒工作) - * @param {void} *device - * @return {*} - ****************************************************************************/ -int vc921x_drv_sleep_work(void *device); -/**************************************************************************** - * @description: 心率算法扩展的摘下状态设置 - * @param {void} *device - * @param {int} status - * @return {*} - ****************************************************************************/ -int vc921x_drv_set_algo_wear_status(void *device, int status); -/**************************************************************************** - * @description: 运动量判断佩戴的状态设置 - * @param {void} *device - * @param {int} status - * @return {*} - ****************************************************************************/ -int vc921x_drv_set_acce_wear_status(void *device, int status); -/**************************************************************************** - * @description: 获取参数并且进行佩戴状态判断 - * @param {void} *device - * @return {*} - ****************************************************************************/ -wear_status vc921x_drv_get_wear_status(void *device); -/**************************************************************************** - * @description: 获取具体的佩戴状态各子状态 - * @param {unsigned char} *bio_ret - * @param {unsigned char} *algo_ret - * @param {unsigned char} *acce_ret - * @return {*} - ****************************************************************************/ -void vc921x_drv_get_wear_detail_result( unsigned char *bio_ret, unsigned char *algo_ret, unsigned char *acce_ret ); -/**************************************************************************** - * @description: 获取采样数据,包含PPG,PS,BIO,TMEP - * @param {void} *device - * @return {*} - ****************************************************************************/ -int vc921x_drv_get_result_handler(void *device); -/**************************************************************************** - * @description: 是否为fifo中断事件 - * @param {void} *pdevice - * @return {*} - ****************************************************************************/ -int vc921x_drv_is_fifo_event(void *pdevice); -/**************************************************************************** - * @description: 是否为PS中断事件 - * @param {void} *pdevice - * @return {*} - ****************************************************************************/ -int vc921x_drv_is_ps_event(void *pdevice); -/**************************************************************************** - * @description: 是否为PPG中断事件 - * @param {void} *pdevice - * @return {*} - ****************************************************************************/ -int vc921x_drv_is_ppg_event(void *pdevice); -/**************************************************************************** - * @description: 配平校准活体 - * @param {void} *pdevice - * @return {*} - ****************************************************************************/ -int vc921x_drv_clear_reset_bio_param(void *pdevice); -/**************************************************************************** - * @description: 同步驱动状态,清理状态数据 - * @param {void} *pdevice - * @return {*} - ****************************************************************************/ -int vc921x_drv_finished_sync(void *pdevice); -/**************************************************************************** - * @description: 提前读取中断信息,避免任务延时响应导致信息被刷掉 - * @param {*} - * @return {*} - ****************************************************************************/ -void vc921x_drv_read_event_infomation_byIRQ(void); -/**************************************************************************** - * @description: 软件定时器读取RO信息,用于定时温度检测 - * @param {*} - * @return {*} - ****************************************************************************/ -int vc921x_drv_read_check_temperature_abnormal( void *pdevice, unsigned char *p_freq_ret, unsigned char *p_temp_ret, unsigned short *pdev_cnt1, unsigned short *pdev_cnt2 ); - -int vc921x_drv_memroy_alloc(void); -int vc921x_drv_memroy_free(void); - -#endif /* __DRV_DEV_MANAGER_H__ */ diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_driver_config.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_driver_config.h deleted file mode 100644 index 15acae30e..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_driver_config.h +++ /dev/null @@ -1,115 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-09-22 17:39:10 - * @LastEditTime: 2024-03-21 11:16:25 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ -#ifndef __VC921x_DRIVER_CONFIG_H__ -#define __VC921x_DRIVER_CONFIG_H__ - -/* wear default status select */ -#define VC921x_WEAR_DFT_NONE (0) -#define VC921x_WEAR_DFT_DROP (1) -#define VC921x_WEAR_DFT_HOLD (2) -/* function enable select */ -#define VC921x_FUNC_DISABLE (0) -#define VC921x_FUNC_ENABLE (1) - -#define VC921x_FREQUENCY_MAX 20000 -#define VC921x_FREQUENCY_MIN 19900 -//#define VC921x_CFG_MCU_TICK_FREQUENCY 32000 // counter 32K -extern unsigned short int VC921x_CFG_MCU_TICK_FREQUENCY; /* extern unsigned short int VC921x_CFG_MCU_TICK_FREQUENCY; */ -#define VC921x_CFG_MCU_TICK_MAX 0xffffff // 24-bit counters -#define VC921x_CFG_CLK_CALC_DEVIATION 3 -#define VC921x_CFG_CLK_CALC_GAPTIME 10 // interrupt gap times( 25hz_fifo_irq:20*40~0.4sec; 5hz_fifo_irq: 20*200 ~ 2sec; 1.25hz_fifo_irq: 10*800 ~ 8sec ) - -#define VC921x_CFG_CLK_CLAC_IRQGAP_EN (VC921x_FUNC_DISABLE) -/* interrupt run check timegap,dont write "(3/4)" !!! */ -/* 25hz(40ms~30ms), 50hz(20ms~15ms), 100hz(10ms~7ms) */ -#define VC921x_IRQ_GAP_RATIO 3/4 - -#define VC921x_CFG_IRQ_BY_TIMER_EN (VC921x_FUNC_DISABLE) -/* notice:ps_freq = ppg_freq/drop_div, and VC921x_PS_WORK_FREQUENCY_CONFIG(0). */ -#define VC921x_CFG_DROP_REDUCE_FREQ (VC921x_FUNC_ENABLE) - -#define VC921x_CFG_DEFAULT_PPGGAIN_EN (1) /* 1-最小使用2倍增益, 0-最小使用单倍增益 */ - -/**************************************************************************** - * Configuration hardware:PD/BIO channl; sport heartrate param; - ***************************************************************************/ -/* (VC921x_SLOT_CHSEL_PD11):setting ppgchx pd0+pd1, (VC921x_SLOT_CHSEL_PD01),setting pd0, (VC921x_SLOT_CHSEL_PD10),setting pd1 vc921x_core_com.h@VC921x_SLOT_CHSEL*/ -#define VC921x_CFG_PPG_CHANNL_SELECT (VC921x_SLOT_CHSEL_PD11) -/* (VC921x_BIO_CHSEL_PD11),setting biochx pd0+pd1, (VC921x_BIO_CHSEL_ETP1),setting extern touch vc921x_core_com.h@VC921x_BIO_CHSEL*/ -#define VC921x_CFG_BIO_CHANNL_SELECT (VC921x_BIO_CHSEL_PD11) -#define VC921x_CFG_SPORT_HR_OVERSAMPLE (3) /* oversample = 2^N */ -#define VC921x_CFG_SPORT_HR_SAMPLETIME (VC921x_SAMPLE_TIM_200US) - -/**************************************************************************** - * Configuration wear parameters - ***************************************************************************/ -#define VC921x_CFG_WEAR_DETECTION (VC921x_FUNC_ENABLE) -#define VC921x_CFG_WEAR_DEFAULT_STA (VC921x_WEAR_DFT_HOLD) -#define VC921x_CFG_WEAR_BIO_EN (VC921x_FUNC_ENABLE) -#define VC921x_CFG_WEAR_ALG_EN (VC921x_FUNC_DISABLE) -#define VC921x_CFG_WEAR_ACC_EN (VC921x_FUNC_DISABLE) -#define VC921x_CFG_WEAR_HOLD_CNT (1) -#define VC921x_CFG_WEAR_DROP_CNT (3) -/* sensor serial default wear param */ -#define VC921x_CFG_WEAR_BIO_OLD_EN (VC921x_FUNC_DISABLE) /* 使用算法相对的方式计算活体的佩戴状态 */ -#define VC921x_WEAR_PARAM_ENVMIN 100 /* 80nA/D */ -#define VC921x_WEAR_PARAM_ENVMAX 400 -#define VC921x_WEAR_PARAM_PSTH 0xA000 /* 16bit:0xA400~40960 , 8bit:0xA0~160 */ -#define VC921x_WEAR_PARAM_PS_DELTA 0x3000 /* 16bit:0x3000~12288 , 8bit:0x30~48 */ -#define VC921x_WEAR_PARAM_BIO_DELTA 100 /* bio0/1,建议取测试变化量的45%作为参数设置 */ - -//#define VC921x_WEAR_PARAM_BIO_ABS_HOLD 200 /* 80% */ -//#define VC921x_WEAR_PARAM_BIO_ABS_DROP 160 /* 50% */ -extern unsigned short int VC921x_WEAR_PARAM_BIO_ABS_HOLD; /* extern unsigned short int VC921x_WEAR_PARAM_BIO_ABS_HOLD; */ -extern unsigned short int VC921x_WEAR_PARAM_BIO_ABS_DROP; /* extern unsigned short int VC921x_WEAR_PARAM_BIO_ABS_DROP; */ - -/* 约定最后的一个slot一定作为红外采样 */ -#define VC921x_WEAR_PARAM_PS_CURRENT 0x25 /*range:0-0x7F */ -#define VC921x_WEAR_PARAM_PS_RESISTANCE 6 /*range:0-13 */ -#define VC921x_WEAR_PARAM_PS_GAIN 1 /* 2^n */ - -#if VC921x_CFG_DEFAULT_PPGGAIN_EN -#define VC921x_PPG_CURT 0x40 -#define VC921x_PPG_RESISTANCE 9 /* 9-1 ~ 4.48M */ -#define VC921x_PPG_GAIN 1 -/* Set the maximum current parameter in FAT1/FAT2 work_mode */ -#define VC921x_FAT_GREEN_MAX_CURT 0x60 /* 0-0x7F */ -#define VC921x_FAT_RED_MAX_CURT 0x60 /* 0-0x7F */ -#define VC921x_FAT_IR_MAX_CURT 0x60 /* 0-0x7F */ -#define VC921x_FAT_RESISTANCE 9 /* 9~4.48M, 11~8.96M */ -#define VC921x_FAT_GAIN 1 -#else -#define VC921x_PPG_CURT 0x40 -#define VC921x_PPG_RESISTANCE 11 /* 9-1 ~ 4.48M */ -#define VC921x_PPG_GAIN 0 -/* Set the maximum current parameter in FAT1/FAT2 work_mode */ -#define VC921x_FAT_GREEN_MAX_CURT 0x60 /* 0-0x7F */ -#define VC921x_FAT_RED_MAX_CURT 0x60 /* 0-0x7F */ -#define VC921x_FAT_IR_MAX_CURT 0x60 /* 0-0x7F */ -#define VC921x_FAT_RESISTANCE 11 /* 9~4.48M, 11~8.96M */ -#define VC921x_FAT_GAIN 0 -#endif - -/**************************************************************************** - * PPG AUTO ADJUST PARAMETERS - ***************************************************************************/ -#define VC921x_PPG_MIN_DEFT_THVAL (0x6) -#define VC921x_PPG_MAX_DEFT_THVAL (0xA) /*0xA~0xB*/ -#define VC921x_PPG_SPO2_MIN_DEFT_THVAL (0x09) -#define VC921x_PPG_SPO2_MAX_DEFT_THVAL (0x0A) /* 0x0A~0x0B */ -#define VC921x_ADJ_I_INCREASE 22 // 1.4 << 4 = 22.4//1.4f -#define VC921x_ADJ_I_DECREASE 11 // 0.7 << 4 = 11.2//0.7f -#define VC921x_ADJ_I_STEP_MAX 8 -#define VC921x_ADJ_I_STEP_MIN 1 -#define VC921x_ADJ_I_STEP_DFT 4 // default step - -/* fix 16bit ppg */ -#define VC921x_PPG_CONV_BIT4(data) ((data)>>4) - -#endif /* __VC921x_DRIVER_CONFIG_H__ */ diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_hal.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_hal.h deleted file mode 100644 index 5e4a11664..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_hal.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * @Author: penglei 1624952103@qq.com - * @Date: 2024-06-07 11:18:26 - * @LastEditors: SnickerSun snickersun@163.com - * @LastEditTime: 2024-12-27 16:08:24 - * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.h - * @Description: - * - * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. - */ -#ifndef VC_921X_H__ -#define VC_921X_H__ -#ifdef __cplusplus -#if __cplusplus -extern "C" { -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#include "stdint.h" - -typedef uint32_t PPG_CMD_TYPE_T ; - -#ifdef PPG_HX3695 - -#include "tyhx_hrs_custom.h" - - - -typedef enum{ - HX3695_MSG_TYPE_HRS_UPDATE, - HX3695_MSG_TYPE_HRV_UPDATE, - HX3695_MSG_TYPE_SPO2_UPDATE, - HX3695_MSG_TYPE_LEAKLIGHT_UPDATE, - HX3695_MSG_TYPE_GRAYCARD_UPDATE, - HX3695_MSG_TYPE_WEARSTAT_UPDATE, - HX3695_MSG_TYPE_STATIC_HRS_UPDATE, -} hx3695_msg_type_t; - - -typedef void (*hx3695_msg_callback_t)(uint8_t msg_type, uint8_t *msg_data, int32_t msg_datalen); -uint32_t hx3695_register_msg_callback(hx3695_msg_callback_t func); -hx3695_msg_callback_t hx3695_get_send_msg_callback_func(void); - -#endif - -void ppg_send_cmd_to_vc921x_driver(char* mode, uint8_t enable); - -#ifdef __cplusplus -#if __cplusplus -} -#endif /* __cplusplus */ -#endif /* __cplusplus */ - -#endif \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_sample_result.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_sample_result.h deleted file mode 100644 index 9b164f4dc..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_sample_result.h +++ /dev/null @@ -1,158 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-09-22 17:39:10 - * @LastEditTime: 2024-03-21 10:49:02 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ -#ifndef __VC921x_SAMPLE_RESULT_H__ -#define __VC921x_SAMPLE_RESULT_H__ - -/**************************************************************************** -drviver vc921x RAM: -core+driver: 400bytes + fifo_data_memory <= 1kb -fifo_data_memory static: 128*2 + 64*(2*2+2*1) = 448 bytes -fifo_data_memory dynamic: 128*x + 64*(2*y+2*z) = 0~448 bytes -fifo_data_memory fixdync: -*/ -#define VC921x_USE_STATIC_MEMORY (0) -#define VC921x_USE_FIXDYNC_MEMORY (1) /* memory is allocated when the device is registered and freed when the device is deregistered */ -#define VC921x_USE_MEMORY_SELECT (VC921x_USE_STATIC_MEMORY) -#define VC921x_PPGSLOT_BUFFER_NUM (64) /* memory_buffer(40~64) = enable_ppgslot_num * ( VC921x_PPGSLOT_BUFFER_NUM * sizeof(unsigned short int) ) */ -#define VC921x_PS2SLOT_BUFFER_NUM (32) /* memory_buffer(20~32) = enable_bioslot_num * ( VC921x_PS2SLOT_BUFFER_NUM * sizeof(unsigned short int) ) + 1*( VC921x_PS2SLOT_BUFFER_NUM * sizeof(unsigned short int) ) */ - -/* ps sample frequency config, if work_fast,the frequency=12.5hz, otherwise is 5hz -[0] ps= 5hz~200ms, fifo_time=1000ms, 800ms, 600ms, 400ms, 200ms -[1] ps=(1000/520)hz~520ms, fifo_time=520ms(25hz), 260ms(50hz), 130ms(100hz), user defined time, ps-fifo working on the same frequency (~9201,VC30F). - !!!notice: need config bio_param_time @ vc30fx_core_com.h @ core30fx_set_bioslot_config -[2]........ -*/ -#define VC921x_PS_WORK_FREQUENCY_CONFIG (0) - -/* ppg/ps slot parameter description: -slot_config: structure handle. -enwork: slot configuration enable work, 0-disbale, 1-work_ppg, 2-work_ps. -freqsel: frequency selection, 0-ppg_frequency, 1-ps_frequency. vc921x_core_com.h:enum@VC921x_FREQ_SEL. -storefifo: fifo configuration, 0-nofifo,1-infifo, available when slot_freq_sel is ps_frequency. @VC921x_STORE_FIFO. -current: ppg_slot work current set(0x00~0x7f). -resistance: ppg_slot work resistance set(0~13). -*/ -#define VC921x_SLOT_PARAM_CONFIG(slot_config, enwork, freqsel, storefifo, current, resistance) \ - { \ - slot_config.slot_enwork = enwork; \ - slot_config.slot_freq_sel = freqsel; \ - slot_config.slot_storefifo = storefifo; \ - slot_config.slot_current = current; \ - slot_config.slot_resistance = resistance; \ - } -#define VC921x_PPG_SLOT_PARAM_CONFIG(slot_config, current, resistance) VC921x_SLOT_PARAM_CONFIG(slot_config, 1, VC921x_FREQ_PPG, VC921x_IN_STORE, current, resistance) -/*------PS slot default use slot2------*/ -#define VC921x_PS_SLOT_PARAM_CONFIG(slot_config, storefifo, current, resistance) VC921x_SLOT_PARAM_CONFIG(slot_config, 2, VC921x_FREQ_PS, storefifo, current, resistance) -/* bio slot parameter description: -bio_config: structure handle. -inn_enable: inside slot configuration enable work, @VC921x_CFG_FUNC. -ext_enable: external slot configuration enable work, @VC921x_CFG_FUNC. -fifo_mode: fifo and ppgmode configuration, @VC921x_BIO_MODE. -*/ -#define VC921x_BIO_SLOT_PARAM_CONFIG(bio_config, inn_enable, ext_enable, fifo_mode ) \ - { \ - bio_config.bioinn_enwork = inn_enable; \ - bio_config.bioext_enwork = ext_enable; \ - bio_config.biofifo_mode = fifo_mode; \ - } -/* tmp slot parameter description: -tmp_config: structure handle. -inn_enable: inside slot configuration enable work, @VC921x_CFG_FUNC. -ext_enable: external slot configuration enable work, @VC921x_CFG_FUNC. -setcur: external slot config work current(0~7). -*/ -#define VC921x_TMP_SLOT_PARAM_CONFIG(tmp_config, slot0_enable, slot1_enable, setcur) \ - { \ - tmp_config.tempslot0_enwork = slot0_enable; \ - tmp_config.tempslot1_enwork = slot1_enable; \ - tmp_config.tempslot0_setcur = setcur; \ - tmp_config.tempslot1_setcur = setcur; \ - } - -/**************************************************************** - * structures:vc921x_sample_info_t - ***************************************************************/ -typedef struct -{ - /* slot_config */ - unsigned char slot_enwork; /* slot_enwork, 0-disbale, 1-work_ppg, 2-work_ps. */ - unsigned char slot_freq_sel; /* 0-ppg_frequency, 1-ps_frequency. vc921x_core_com.h, @VC921x_FREQ_SEL. */ - unsigned char slot_storefifo; /* 0-nofifo,1-infifo, available when slot_freq_sel is ps_frequency. */ - unsigned char slot_led_sel; /* 0-green led, 1-red led, 2-infrared led */ - /* slot_variable_config */ - unsigned char slot_current; /* 0~0x7F */ - unsigned char slot_resistance; /* 0~13/0~23 */ - /* slot_result */ - unsigned short int env_data; - union - { - unsigned short int ps_data; - unsigned short int pre_data; - } u; - unsigned char ppg_num; - unsigned char ppg_buffer[VC921x_PPGSLOT_BUFFER_NUM*3]; /* 按字节存储,可以节省最大RAM */ -} vc921x_sample_slot_t; - -typedef struct -{ - /* bio_slot config */ - unsigned char bioinn_enwork; - unsigned char bioext_enwork; - unsigned char biofifo_mode; /* @VC921x_BIO_MODE */ - /* temp_slot config */ - unsigned char tempslot0_enwork; - unsigned char tempslot0_setcur; - unsigned char tempslot1_enwork; - unsigned char tempslot1_setcur; - /* extern result */ - unsigned char bio_fifo_num; - unsigned short int bioinn_data; - unsigned short int bioext_data; - unsigned short int bioabs_calc; /* abs(base-ext_now)?thh */ - unsigned short int temp0_data; - unsigned short int temp1_data; - unsigned short int tempref_data; - unsigned short int bioinn_buffer[VC921x_PS2SLOT_BUFFER_NUM]; - unsigned short int bioext_buffer[VC921x_PS2SLOT_BUFFER_NUM]; -} vc921x_sample_extra_t; - -typedef struct -{ - unsigned char ic_type_id; - unsigned char ic_ficv_id; - unsigned short int ppg_div; /* ppg_frequency = 20K / ppg_div */ - unsigned char ps_div; /* ps_frequency = ppg_frequency / ps_div */ - unsigned char fifo_div; /* fifo_frequency = ps_frequency / fifo_div */ - unsigned char hold_div; /* ps/fifo_frequency = ppg_frequency / hold_div */ - unsigned char drop_div; /* ps/fifo_frequency = ppg_frequency / drop_div */ - unsigned char fifo_enable; /* fifo_enable = 1*/ - unsigned char fifo_format; /* fifo_format,0:16bit, 1:24bit */ - unsigned char adc_resolution; /* */ - unsigned char wear_drop_flag; /* send original data flag as drop event happens */ - vc921x_sample_extra_t extra_result; - vc921x_sample_slot_t slot_result[3]; -} vc921x_sample_info_t; - -static inline unsigned int VC921x_GET_SLOT_SAMPLE_DATA( vc921x_sample_info_t* psample_info, unsigned char slot_index, unsigned char ppg_index ) -{ - if( psample_info->fifo_format == 0 ) - { - return (psample_info->slot_result[slot_index].ppg_buffer[ppg_index*2]<<8) + (psample_info->slot_result[slot_index].ppg_buffer[ppg_index*2+1] ); - } - else - { - return (psample_info->slot_result[slot_index].ppg_buffer[ppg_index*3]<<16) + (psample_info->slot_result[slot_index].ppg_buffer[ppg_index*3+1]<<8) + (psample_info->slot_result[slot_index].ppg_buffer[ppg_index*3+2] ); - } -} -static inline unsigned int VC921x_GET_SLOT_PS_DATA( vc921x_sample_info_t* psample_info, unsigned char ppg_index ) -{ - return (psample_info->slot_result[2].ppg_buffer[ppg_index*2]<<8) + (psample_info->slot_result[2].ppg_buffer[ppg_index*2+1] ); -} - -#endif /* __VC921x_SAMPLE_RESULT_H__ */ diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_user_app.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_user_app.h deleted file mode 100644 index e4c85209b..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vc921x_user_app.h +++ /dev/null @@ -1,47 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-09-22 17:39:10 - * @LastEditTime: 2023-10-17 09:50:21 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ -#ifndef __VC921x_USER_APP_H__ -#define __VC921x_USER_APP_H__ - -#include "vcare_device_com.h" - -/* vc921x设备函数接口 */ -void vc921x_usr_device_init( InitParamTypeDef *pinitconfig ); -void vc921x_usr_get_dev_info(unsigned char *pchip_id, unsigned char *pvers_id, char **drv_name, char **dev_name); -void vc921x_usr_start_work(void); -void vc921x_usr_stop_work(void); -void vc921x_usr_soft_reset(void); -void vc921x_usr_reset_bio_param(void); -int vc921x_usr_get_wear_status(void); -void vc921x_usr_get_event_status_byIRQ(void); -void vc921x_usr_device_handler( unsigned char heart_algo_mode, unsigned char spo2_algo_mode ); -void vc921x_usr_check_temperature_abnormal(void); - - -void tyhx_poweron(void); -void tyhx_poweroff(void); - - -/* 获取vc921x设备/如果动态内存则会申请驱动内存,以下为获取的设备API,设备对象中会记录一部分计算参数和结果,用户需要直接使用即可,具体参考头文件"vcare_device_com.h": -{ - .dev_init = vc921x_usr_device_init, - .get_dev_info = vc921x_usr_get_dev_info, - .start_work = vc921x_usr_start_work, - .stop_work = vc921x_usr_stop_work, - .soft_reset = vc921x_usr_soft_reset, - .get_events = NULL, - .set_slot_enable = NULL, - .reset_bio_param = vc921x_usr_reset_bio_param, - .get_wear_status = vc921x_usr_get_wear_status, - .dev_irq_handler = vc921x_usr_device_handler, -}; -*/ -vcare_ppg_device_t *get_vc921x_device(void); - -#endif // ! diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vcSportMotionIntAlgo.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/vcSportMotionIntAlgo.h deleted file mode 100644 index 9b4e7f307..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vcSportMotionIntAlgo.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef VC_SPORT_MOTION_ALGO_H -#define VC_SPORT_MOTION_ALGO_H - -#include -#include -#include - - -void vcSportMotionAlgoInit(void); -int32_t vcSportMotionCalculate(int32_t x, int32_t y, int32_t z); -char *sportMotionVersion(void); -#endif diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vcare_device_com.h b/code/sdk/zhihui/drivers/ppg/vc921x/inc/vcare_device_com.h deleted file mode 100644 index a73436433..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/inc/vcare_device_com.h +++ /dev/null @@ -1,200 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-02-23 17:47:18 - * @LastEditTime: 2023-11-14 17:38:46 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ - -#ifndef __VCARE_DEVICE_COM_H__ -#define __VCARE_DEVICE_COM_H__ - -/* parameter type sleep and retain */ -#ifndef PARAM_RETAIN -#define PARAM_RETAIN -#endif -/* define NULL 0 */ -#ifndef NULL -#define NULL ((void *)0) -#endif - -/* gsensor struct,user peripheral data */ -typedef struct -{ - short int xData[40]; - short int yData[40]; - short int zData[40]; -} gsensor_axes; - -typedef enum -{ - WEAR_STA_NONE = 0, - WEAR_STA_DROP, - WEAR_STA_HOLD, -} wear_status; - -typedef enum -{ - WORK_MODE_HR = 0, - WORK_MODE_SPO2, - WORK_MODE_HRV, - WORK_MODE_STRESS, - WORK_MODE_BLOODPRESSURE, - WORK_MODE_WEAR, - WORK_MODE_TEMPERATURE, - WORK_MODE_FACTORY0, - WORK_MODE_FACTORY1, - WORK_MODE_HRSPO2, - - WORK_MODE_UNDEFINED, - WORK_MODE_NUMBER, -} work_mode; - -typedef struct -{ - unsigned short sampling_gap_time; /* reserved. */ - unsigned char work_mode; /* work_mode,WorkModeTypeDef/unsigned char */ - unsigned char hr_algo_mode; -}InitParamTypeDef; - - -typedef void (*FUNC_DEV_INIT)( InitParamTypeDef *pInitconfig ); -typedef void (*FUNC_GET_DEV_INFO)(unsigned char *pchip_id, unsigned char *pvers_id, char **drv_name, char **dev_name); -typedef void (*FUNC_START_WORK)(void); -typedef void (*FUNC_STOP_WORK)(void); -typedef void (*FUNC_SOFT_RESET)(void); -typedef int (*FUNC_GET_EVENTS)(void); -typedef int (*FUNC_GET_WEAR_STATUS)(void); -typedef void (*FUNC_SET_SLOT_ENABLE)(unsigned char slot_index, unsigned char slot_enable); -typedef void (*FUNC_BIO_RESET_PARAM)(void); -typedef void (*FUNC_DEV_IRQ_HANDLER)(unsigned char heart_algo_mode, unsigned char spo2_algo_mode); -typedef void (*FUNC_DEV_CHK_TEMP_ERR)(void); - -typedef struct -{ - FUNC_DEV_INIT dev_init; - FUNC_GET_DEV_INFO get_dev_info; /* reserved */ - FUNC_START_WORK start_work; - FUNC_STOP_WORK stop_work; - FUNC_SOFT_RESET soft_reset; - FUNC_GET_EVENTS get_events; /* reserved */ - FUNC_GET_WEAR_STATUS get_wear_status; - FUNC_SET_SLOT_ENABLE set_slot_enable; /* reserved */ - FUNC_BIO_RESET_PARAM reset_bio_param; - FUNC_DEV_IRQ_HANDLER dev_irq_handler; - FUNC_DEV_CHK_TEMP_ERR dev_check_temp_error; -} dev_ops; - -typedef struct -{ - char *dev_name; - unsigned char id1; - unsigned char id2; - unsigned char dev_work_status; /* 0-don't work, 1-working */ - - unsigned char heart_algo_mode; - unsigned char spo2_algo_mode; - work_mode workmode; - wear_status wear; - /* raw result */ - void *result; - /* device ops */ - const dev_ops *ops; - /* calc result */ - int heart_rate; - int spo2; - int hrv; - int stress; - int ecg; - int temperature0; - int temperature1; - int blood_pressure; -} vcare_ppg_device_t; - -/**-------------------- defined functions --------------------**/ -#define ENABLE_MY_MEMFUNC 1 -#if ENABLE_MY_MEMFUNC -static inline void *vcare_memset(void *dest, int set, unsigned int n) -{ - if (dest == NULL || n <= 0) - { - return NULL; - } - char *pdest = (char *)dest; - while (n-- > 0) - { - *pdest++ = set; - } - return dest; -} - -static inline void *vcare_memcpy(void *dest, void *src, unsigned int n) -{ - if (dest == NULL || src == NULL) - { - return NULL; - } - char *pdest = (char *)dest; - char *psrc = (char *)src; - while (n--) - { - *pdest++ = *psrc++; - } - return dest; -} - -/* 2^(n/16) */ -static const float exponent_tab[]={1.000000,1.044274,1.090508,1.138789,1.189207,1.241858,1.296840,1.354256,1.414214, - 1.476826,1.542211,1.610490,1.681793,1.756252,1.834008,1.915207,2.000000}; -static inline float vcare_I_exponent_func( float base_i, unsigned char data_i ) -{ - unsigned char data_h = (data_i>>4)&0xf; - unsigned char data_l = (data_i>>0)&0xf; - return (base_i*(1<(bit_n))?((format_n)-(bit_n)):0) -#define CORE921x_DATA_FORMAT_COVNVERT(format_n,bit_n,data) ( (data)>>( CORE921x_FORMAT_ADCBIT_COMPARE( format_n, bit_n ) ) ) - -static const char CORE921x_VERSION[] = "core921x_v0.22"; - -/* rxgain+pdres ~ level */ -struct vc921x_core_res_table -{ - unsigned char level; - unsigned char pdres; - unsigned char rxgain; -}; -#if VC921x_CFG_DEFAULT_PPGGAIN_EN -#define MAX_RES_LEVEL 21 -#define MIN_RES_LEVEL 0 -#define MAX_CURRENT 0x7f -#define MIN_CURRENT 0 -const struct vc921x_core_res_table vc921x_res_table[] = - { - /* level, pdres, rxgain */ - {0, 0, 1}, /* 200K */ - {1, 1, 1}, - {2, 2, 1}, /* 400K */ - {3, 3, 1}, - {4, 4, 1}, /* 800K */ - {5, 5, 1}, - {6, 6, 1}, /* 1.6M */ - {7, 7, 1}, - {8, 8, 1},/* 3.2M */ - {9, 9, 1}, - {10, 10, 1}, /* 6.4M */ - {11, 11, 1}, /*8.96M*/ - {12, 12, 1}, - {13, 13, 1}, /*17.92*/ - {14, 12, 2}, - {15, 13, 2},/*35.84*/ - {16, 12, 3}, - {17, 13, 3},/*71.68*/ - {18, 12, 4}, - {19, 13, 4}, /* 143.36 */ - {20, 12, 5}, - {21, 13, 5}, /* 286.72 */ -}; -#else -#define MAX_RES_LEVEL 23 -#define MIN_RES_LEVEL 0 -#define MAX_CURRENT 0x7f -#define MIN_CURRENT 0 -const struct vc921x_core_res_table vc921x_res_table[] = - { - /* level, pdres, rxgain */ - {0, 0, 0}, /* 100K */ - {1, 1, 0}, - {2, 2, 0}, /* 200K */ - {3, 3, 0}, - {4, 4, 0}, /* 400K */ - {5, 5, 0}, - {6, 6, 0}, /* 800K */ - {7, 7, 0}, - {8, 8, 0}, /* 1.6M */ - {9, 9, 0}, - {10, 10, 0},/* 3.2M */ - {11, 11, 0}, - {12, 12, 0}, /* 6.4M */ - {13, 13, 0}, /*8.96M*/ - {14, 12, 1}, - {15, 13, 1}, /*17.92*/ - {16, 12, 2}, - {17, 13, 2},/*35.84*/ - {18, 12, 3}, - {19, 13, 3},/*71.68*/ - {20, 12, 4}, - {21, 13, 4}, /* 143.36 */ - {22, 12, 5}, - {23, 13, 5}, /* 286.72 */ -}; -#endif - -static unsigned char core921x_nto_version=0; /* 0127nto or(0808-1120mpw) */ -static unsigned char core921x_0808mpw=0; /* 0808mpw ~ 1120mpw */ -/* 需要在刚刚初始化完成之后去调用判断 */ -CORE921x_FUNC_RAM_SECTION int core921x_check_nto_version_init(void) -{ - unsigned char mpw0808_test=0xA0; - unsigned char read_buffer[4]={0}; - unsigned short count1=0, count2=0; - unsigned int delay_tick=1000; - vc921x_write_register(0x5C, &mpw0808_test, 1); - mpw0808_test=0; - vc921x_read_register(0x5C, &mpw0808_test, 1); - if( mpw0808_test==0xA0 ) - { - core921x_0808mpw=0; - mpw0808_test=0; - vc921x_write_register(0x5C, &mpw0808_test, 1); /* write 0, clear DEBUG register. */ - } - else - { - core921x_0808mpw=1; - } - /* 0127nto ~ 0808_1120mpw */ - vc921x_read_register( 0x05, &read_buffer[0], 2 ); - while(delay_tick--); - vc921x_read_register( 0x07, &read_buffer[2], 2 ); - count1 = (read_buffer[0]<<8)+read_buffer[1]; - count2 = (read_buffer[2]<<8)+read_buffer[3]; - if( count2-count1>=1 && count2-count1<=255 ) - { - core921x_nto_version=0; - } - else - { - core921x_nto_version=1; - } - CORE921x_DEBUG_LOG("0127nto=%d~0808mpw=%d", core921x_nto_version,core921x_0808mpw); - return core921x_nto_version; -} - -CORE921x_FUNC_RAM_SECTION static unsigned char get_level_by_res_rxgain(unsigned char pdres, unsigned char rxgain) -{ - unsigned char index = 0; - for (index = 0; index < sizeof(vc921x_res_table) / sizeof(vc921x_res_table[0]); index++) - { - if ((vc921x_res_table[index].pdres == pdres) && (vc921x_res_table[index].rxgain == rxgain)) - { - return vc921x_res_table[index].level; - } - } - return 0; -} -CORE921x_FUNC_RAM_SECTION static int get_res_rxgain_by_level(unsigned char level, unsigned char *ppdres, unsigned char *prxgain) -{ - *ppdres = vc921x_res_table[level].pdres; - *prxgain = vc921x_res_table[level].rxgain; - return 0; -} - -/**************************************************************** - * CORE_API.read() - * read IC event or sample data - ***************************************************************/ -CORE921x_FUNC_RAM_SECTION int __core921x_read_software_version(char **ppver) // -{ - if (ppver) - { - *ppver = (char *)CORE921x_VERSION; - return 0; - } - return -1; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_read_id(unsigned char *pid1, unsigned char *pid2) // -{ - int ret = 0; - if ((NULL == pid1) || (NULL == pid2)) - { - return 1; - } - ret = vc921x_read_register(CORE921x_DEV_VER_ID_H_ADDR, pid1, 1); - ret = vc921x_read_register(CORE921x_FDY_EXT_ID_L_ADDR, pid2, 1); - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_read_event_status(unsigned char *pevt, unsigned char *povsta, unsigned char *pwindex_bak, unsigned char *pwindex_rel ) // -{ - int ret = 0; - unsigned char reg[4] = {0}; - ret = vc921x_read_register(CORE921x_WORK_STATUS1_ADDR, reg, 4); - if (pevt) - { - *pevt = reg[0]; - } - if (povsta) - { - *povsta = reg[1]; - } - if( core921x_nto_version ) - { - if (pwindex_bak) - { - *pwindex_bak = reg[2]; - } - if (pwindex_rel) - { - *pwindex_rel = reg[3]; - } - } - else - { - if (pwindex_bak) - { - *pwindex_bak = reg[2]; - } - } - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_read_rcosc_tick(unsigned short int *ptick0, unsigned short int *ptick1) // -{ - int ret = 0; - unsigned char reg[4] = {0}; - if( core921x_nto_version==1 ) - { - ret = vc921x_read_register(CORE921x_OSC_CNT0_H_ADDR+1, reg, 4); - } - else - { - ret = vc921x_read_register(CORE921x_OSC_CNT0_H_ADDR, reg, 4); - } - if (ptick0) - { - *ptick0 = (reg[0] << 8) + reg[1]; - } - if (ptick1) - { - *ptick1 = (reg[2] << 8) + reg[3]; - } - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_read_output(vc921x_sample_info_t *psample_ret) -{ - int ret = 0; - core921x_reg_result_t reg_result = {0}; - if( core921x_nto_version==1 ) - { - ret = vc921x_read_register(CORE921x_SAMPLE_DATA_ADDR_BASE+1, (unsigned char *)®_result, sizeof(core921x_reg_result_t)); - } - else - { - ret = vc921x_read_register(CORE921x_SAMPLE_DATA_ADDR_BASE, (unsigned char *)®_result, sizeof(core921x_reg_result_t)); - } - - if (psample_ret) - { - psample_ret->slot_result[0].env_data = (reg_result.slot0_envh6 << 8) | reg_result.slot0_envl6; - psample_ret->slot_result[1].env_data = (reg_result.slot1_envh6 << 8) | reg_result.slot1_envl6; - psample_ret->slot_result[2].env_data = (reg_result.slot2_envh6 << 8) | reg_result.slot2_envl6; - - psample_ret->slot_result[0].u.ps_data = reg_result.slot0_ps; - psample_ret->slot_result[1].u.ps_data = reg_result.slot1_ps; - psample_ret->slot_result[2].u.ps_data = reg_result.slot2_ps; - - psample_ret->extra_result.bioinn_data = (reg_result.bioinn_valh << 8) | reg_result.bioinn_vall; - psample_ret->extra_result.bioext_data = (reg_result.bioext_valh << 8) | reg_result.bioext_vall; - psample_ret->extra_result.temp0_data = (reg_result.tempslot0_valh << 8) | reg_result.tempslot0_vall; - psample_ret->extra_result.temp1_data = (reg_result.tempslot1_valh << 8) | reg_result.tempslot1_vall; - psample_ret->extra_result.tempref_data = (reg_result.tempref_valh << 8) | reg_result.tempref_vall; - } - return ret; -} - -/*------------------------------------------------------------------------------------------------------------------------------------- -fifo 解析数据相关的函数功能模块 --------------------------------------------------------------------------------------------------------------------------------------*/ -CORE921x_FUNC_RAM_SECTION static inline int fifo_calc_sample_slot_nums(vc921x_sample_info_t *psample_ret, unsigned char *p_ppgfreq_slotnum, unsigned char *p_psfreq_slotnum, unsigned char *p_bioppgfreq_slotnum) -{ - /* 1 ppg slot infomation */ - for( unsigned char i=0; i<3; i++ ) - { - if( psample_ret->slot_result[i].slot_enwork==1 && psample_ret->slot_result[i].slot_freq_sel==VC921x_FREQ_PPG ) - { - (*p_ppgfreq_slotnum)++; - } - else if( psample_ret->slot_result[i].slot_enwork==2 && psample_ret->slot_result[i].slot_freq_sel==VC921x_FREQ_PS && psample_ret->slot_result[i].slot_storefifo==VC921x_IN_STORE ) - { - (*p_psfreq_slotnum)++; - } - } - - /* 3 bio slot infomation */ - if ((psample_ret->extra_result.bioext_enwork==1||psample_ret->extra_result.bioinn_enwork==1)&&(psample_ret->extra_result.biofifo_mode==VC921x_BIO_INFIFO_PS_SGL||psample_ret->extra_result.biofifo_mode==VC921x_BIO_INFIFO_PPG_SUM)) - { - if (psample_ret->extra_result.bioext_enwork == 1) - { - (*p_psfreq_slotnum)++; - } - if (psample_ret->extra_result.bioinn_enwork == 1) - { - (*p_psfreq_slotnum)++; - } - } - else if ((psample_ret->extra_result.bioext_enwork==1||psample_ret->extra_result.bioinn_enwork==1)&&(psample_ret->extra_result.biofifo_mode==VC921x_BIO_INFIFO_PPG_SGL)) - { - if (psample_ret->extra_result.bioext_enwork == 1) - { - (*p_bioppgfreq_slotnum)++; - } - if (psample_ret->extra_result.bioinn_enwork == 1) - { - (*p_bioppgfreq_slotnum)++; - } - } - CORE921x_DEBUG_LOG("slotnum_ppgfreq[%d],slotnum_psfreq[%d], slotnum_bioppg[%d]", *p_ppgfreq_slotnum, *p_psfreq_slotnum, *p_bioppgfreq_slotnum); - return 0; -} - -CORE921x_FUNC_RAM_SECTION static inline int read_data_from_fifo_buffer(const unsigned char *pbuffer, unsigned char *poffset, unsigned char fifo_format_is24bit, unsigned char adc_resolution ) -{ - int data = 0; - if( fifo_format_is24bit ) - { - if( (*poffset)+2 >=192 ) return 0; - data = (pbuffer[(*poffset)]<<16) + (pbuffer[(*poffset)+1]<<8) + pbuffer[(*poffset)+2]; - data = CORE921x_DATA_FORMAT_COVNVERT( 24, adc_resolution, data ); - *poffset += 3; - } - else - { - if( (*poffset)+1 >=192 ) return 0; - data = (pbuffer[(*poffset)] << 8) + pbuffer[(*poffset) + 1]; - data = CORE921x_DATA_FORMAT_COVNVERT( 16, adc_resolution, data ); - *poffset += 2; - } - return data; -} - -CORE921x_FUNC_RAM_SECTION static inline int write_data_to_fifo_buffer( unsigned char *pbuffer, unsigned char offset, unsigned int ppg_data, unsigned char fifo_format_is24bit ) -{ - if( fifo_format_is24bit ) - { - if( offset*3+2>=VC921x_PPGSLOT_BUFFER_NUM*3 ) return -1; - pbuffer[offset*3+0]=(ppg_data>>16)&0xff; - pbuffer[offset*3+1]=(ppg_data>>8) &0xff; - pbuffer[offset*3+2]=(ppg_data>>0) &0xff; - } - else - { - if( offset*2+1>=VC921x_PPGSLOT_BUFFER_NUM*3 ) return -1; - pbuffer[offset*2+0]=(ppg_data>>8) &0xff; - pbuffer[offset*2+1]=(ppg_data>>0) &0xff; - } - return 0; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_read_fifo_data(vc921x_sample_info_t *psample_ret, unsigned char *pread_fifoaddr, unsigned char read_windex) // -{ - int ret = 0; - unsigned char i = 0, j = 0; - unsigned char rindex = *pread_fifoaddr; - unsigned char read_size = 0, wait_size = 0;; - unsigned char fifo_data[192] = {0}; - /* fifo有效通道数量 */ - unsigned char ppg_freq_slot_num = 0; /* ppg频率下ppg_slot的数量*/ - unsigned char ps_freq_slot_num = 0; /* ps频率下psbio_slot的数量*/ - unsigned char bio_ppgfreq_slot_num = 0; /* ppg频率下bio_slot的数量 */ - unsigned char ppg_ps_fifo_ratio = 0; /* ppg频率与ps频率的占比,用于计算有效ps频率的fifo数据位置 */ - - unsigned char fifo_bytes= 0; /* fifo_bytes= group_len*fifo_div */ - unsigned char group_len = 0; /* ppg0(slot1,2) ppg1(slot1,2) ps(1,2) */ - unsigned char group_num = 0; /* group_len * group_num = fifosize */ - /* array(ppg_freq+ps_freq) */ - unsigned char ppg_freq_array_len = 0; - unsigned char ps_freq_array_len = 0; - unsigned char array_offset = 0; /* group 组内偏移 */ - unsigned char slot_index = 0; - /* 当bio模式为VC921x_BIO_INFIFO_PPG_SGL,需要驱动进行加算 */ - unsigned short int bioext_ppgsgl_sum=0,bioinn_ppgsgl_sum=0; - /* 解析临时缓存ppg数据 */ - unsigned int analysis_ppg_data=0; - /************* 1.获取配置参数 *************/ - if (!psample_ret) - return 1; - ppg_ps_fifo_ratio = psample_ret->ps_div; /* 假设25/10=2.5hz,ppg频率中间隔10个,插入一个ps */ - fifo_calc_sample_slot_nums(psample_ret, &ppg_freq_slot_num, &ps_freq_slot_num, &bio_ppgfreq_slot_num); /* 获取各个fifo信息 */ - /* calc ppgfreq_fifodata/psfreq_fifodata array length, group length=ppg*ratio+ps */ - if( 1==psample_ret->fifo_format ) - { - ppg_freq_array_len += (ppg_freq_slot_num*3); - } - else - { - ppg_freq_array_len += (ppg_freq_slot_num*2); - } - ppg_freq_array_len+= (bio_ppgfreq_slot_num*2); - ps_freq_array_len += (ps_freq_slot_num * 2); - group_len = ppg_freq_array_len * ppg_ps_fifo_ratio + ps_freq_array_len; - fifo_bytes= group_len*psample_ret->fifo_div; - CORE921x_DEBUG_LOG("group_len(%d)=(%d*%d)+%d", group_len, ppg_freq_array_len, ppg_ps_fifo_ratio, ps_freq_array_len); - if(group_len==0||fifo_bytes==0) - { - return -1; - } - /************** 2.校验参数读取 *************/ - /* group=[ ppg0(slot0,slot1)+ppg1(slot0,slot1)+...ppgN(slot0,slot1)+ps(ps,bioinn,bioext) ] - fifo =[ group0,group1... ]n */ - if (0 == psample_ret->fifo_enable) - { - CORE921x_DEBUG_LOG("psample_ret->fifo_enable=%d", psample_ret->fifo_enable); - rindex = 0x00; /*disable fifo:fifo=ps频率,数据始于,0x00 */ - } - if (read_windex == rindex) /* 数据溢出或则无数据 */ - { - return -2; - } - if (read_windex > rindex) /* rindex-windex */ - { - wait_size = (read_windex - rindex); - } - else /* [rindex-192]+[0-windex] */ - { - wait_size = 192 - rindex + read_windex; - } - if( wait_size < fifo_bytes ) - { - CORE921x_DEBUG_ERR("[%x~%x]waite_size=%d, fifo_bytes=%d", rindex, read_windex, wait_size, fifo_bytes ); - return -3; - } - /* windex error process, the windex cover all fifo area and more than the rindex. */ - if (wait_size % fifo_bytes) - { - read_size = (wait_size/fifo_bytes)*fifo_bytes; - CORE921x_DEBUG_ERR("read_fifo_bytes(%d)/group_len(%d) != 0 read_size[%d]", wait_size, fifo_bytes, read_size ); - ret=1; - if( core921x_nto_version ) - { - return ret; - } - } - else - { - read_size=wait_size; - } - *pread_fifoaddr = ((rindex + read_size) >= 192) ? (rindex + read_size - 192) : (rindex + read_size); - ret = vc921x_write_register(CORE921x_FIFO_READADDR_INDEX, &rindex, 1); - ret = vc921x_read_register(CORE921x_FIFO_DATA_ADDR, &fifo_data[0], read_size); - - CORE921x_DEBUG_LOG("[%#x]-[%#x],fifo_bytes=%d,", rindex, read_windex, read_size); - CORE921x_DEBUG_LOG("PPG_data[0- 8]:0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x", fifo_data[0], fifo_data[1], fifo_data[2], fifo_data[3], fifo_data[4], fifo_data[5], fifo_data[6], fifo_data[7]); - CORE921x_DEBUG_LOG("PPG_data[9-16]:0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x", fifo_data[8], fifo_data[9], fifo_data[10], fifo_data[11], fifo_data[12], fifo_data[13], fifo_data[14], fifo_data[15]); - CORE921x_DEBUG_LOG("..............:0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x,0x%02x", fifo_data[read_size - 8], fifo_data[read_size - 7], fifo_data[read_size - 6], fifo_data[read_size - 5], fifo_data[read_size - 4], fifo_data[read_size - 3], fifo_data[read_size - 2], fifo_data[read_size - 1]); - /******** 3.group,array,cell analysis ********/ - if(group_len==0) - { - return 3; - } - group_num = read_size / group_len; - for (i = 0; i < group_num; i++) /* i=0~N,每次所有通道的采样PPG群数,每个群的处理 */ - { - array_offset = i * group_len; - bioinn_ppgsgl_sum=0,bioext_ppgsgl_sum=0; - /* ppg_freq array analysis*/ - for (j = 0; j < ppg_ps_fifo_ratio; j++) /* j=0-n,每个群里面拥有的ppg_freq的组数轮询 */ - { - for (slot_index = 0; slot_index < 3; slot_index++) - { - if (1 == psample_ret->slot_result[slot_index].slot_enwork && VC921x_FREQ_PPG == psample_ret->slot_result[slot_index].slot_freq_sel) - { - psample_ret->slot_result[slot_index].ppg_num += 1; - analysis_ppg_data = read_data_from_fifo_buffer(fifo_data, &array_offset, psample_ret->fifo_format, psample_ret->adc_resolution ); - write_data_to_fifo_buffer( psample_ret->slot_result[slot_index].ppg_buffer, psample_ret->slot_result[slot_index].ppg_num-1, analysis_ppg_data, psample_ret->fifo_format ); - CORE921x_DEBUG_LOG("slot_result[%d].ppg_data[%d]=%d", slot_index, i*ppg_ps_fifo_ratio+j, analysis_ppg_data ); - } - } - if( bio_ppgfreq_slot_num && VC921x_BIO_INFIFO_PPG_SGL==psample_ret->extra_result.biofifo_mode ) /* VC921x_BIO_INFIFO_PPG_SGL */ - { - if (1 == psample_ret->extra_result.bioinn_enwork) bioinn_ppgsgl_sum+=read_data_from_fifo_buffer(fifo_data, &array_offset, 0, 16 ); - if (1 == psample_ret->extra_result.bioext_enwork) bioext_ppgsgl_sum+=read_data_from_fifo_buffer(fifo_data, &array_offset, 0, 16 ); - } - } - if( bio_ppgfreq_slot_num && VC921x_BIO_INFIFO_PPG_SGL==psample_ret->extra_result.biofifo_mode ) - { - psample_ret->extra_result.bio_fifo_num += 1; - if (1 == psample_ret->extra_result.bioinn_enwork) - { - psample_ret->extra_result.bioinn_buffer[i] = bioinn_ppgsgl_sum; - CORE921x_DEBUG_LOG("result.bioinn_buffer[%d]=%d", i, psample_ret->extra_result.bioinn_buffer[i]); - } - if (1 == psample_ret->extra_result.bioext_enwork) - { - psample_ret->extra_result.bioext_buffer[i] = bioext_ppgsgl_sum; - CORE921x_DEBUG_LOG("result.bioext_buffer[%d]=%d", i, psample_ret->extra_result.bioext_buffer[i]); - } - } - /* ps_freq array analysis */ - // CORE921x_DEBUG_LOG("PS_ARRAY_OFFSET=(%d)?(%d)", ppg_freq_array_len * ppg_ps_fifo_ratio, array_offset); - /* 数据交换处理 */ - if ( VC921x_BIO_INFIFO_PS_SGL==psample_ret->extra_result.biofifo_mode ) - { - if (2 == psample_ret->slot_result[2].slot_enwork && VC921x_IN_STORE == psample_ret->slot_result[2].slot_storefifo) - { - psample_ret->slot_result[2].ppg_num += 1; - analysis_ppg_data = read_data_from_fifo_buffer( fifo_data, &array_offset, 0, 16 ); - write_data_to_fifo_buffer( psample_ret->slot_result[2].ppg_buffer, psample_ret->slot_result[2].ppg_num-1, analysis_ppg_data, 0 ); - CORE921x_DEBUG_LOG("slot_result[2].ps_data[%d]=%d", i, analysis_ppg_data); - } - if ( 1 == psample_ret->extra_result.bioinn_enwork || 1 == psample_ret->extra_result.bioext_enwork) - { - psample_ret->extra_result.bio_fifo_num += 1; - if (1 == psample_ret->extra_result.bioinn_enwork) - { - psample_ret->extra_result.bioinn_buffer[i] = read_data_from_fifo_buffer(fifo_data, &array_offset, 0, 16 ); - CORE921x_DEBUG_LOG("result.bioinn_buffer[%d]=%d", i, psample_ret->extra_result.bioinn_buffer[i]); - } - if (1 == psample_ret->extra_result.bioext_enwork) - { - psample_ret->extra_result.bioext_buffer[i] = read_data_from_fifo_buffer(fifo_data, &array_offset, 0, 16 ); - CORE921x_DEBUG_LOG("result.bioext_buffer[%d]=%d", i, psample_ret->extra_result.bioext_buffer[i]); - } - } - } - else if(VC921x_BIO_INFIFO_PPG_SUM == psample_ret->extra_result.biofifo_mode) - { - if ( 1==psample_ret->extra_result.bioinn_enwork||1==psample_ret->extra_result.bioext_enwork ) - { - psample_ret->extra_result.bio_fifo_num += 1; - if (1 == psample_ret->extra_result.bioinn_enwork) - { - psample_ret->extra_result.bioinn_buffer[i] = read_data_from_fifo_buffer(fifo_data, &array_offset, 0, 16 ); - CORE921x_DEBUG_LOG("result.bioinn_buffer[%d]=%d", i, psample_ret->extra_result.bioinn_buffer[i]); - } - if (1 == psample_ret->extra_result.bioext_enwork) - { - psample_ret->extra_result.bioext_buffer[i] = read_data_from_fifo_buffer(fifo_data, &array_offset, 0, 16 ); - CORE921x_DEBUG_LOG("result.bioext_buffer[%d]=%d", i, psample_ret->extra_result.bioext_buffer[i]); - } - } - if (2 == psample_ret->slot_result[2].slot_enwork && VC921x_IN_STORE == psample_ret->slot_result[2].slot_storefifo) - { - psample_ret->slot_result[2].ppg_num += 1; - analysis_ppg_data = read_data_from_fifo_buffer(fifo_data, &array_offset, 0, 16 ); - write_data_to_fifo_buffer( psample_ret->slot_result[2].ppg_buffer, psample_ret->slot_result[2].ppg_num-1, analysis_ppg_data, 0 ); - CORE921x_DEBUG_LOG("slot_result[2].ps_data[%d]=%d", i, analysis_ppg_data); - } - } - else /* VC921x_BIO_NOFIFO_PS_SGL VC921x_BIO_INFIFO_PPG_SGL */ - { - if (2 == psample_ret->slot_result[2].slot_enwork && VC921x_IN_STORE == psample_ret->slot_result[2].slot_storefifo) - { - psample_ret->slot_result[2].ppg_num += 1; - analysis_ppg_data = read_data_from_fifo_buffer(fifo_data, &array_offset, 0, 16 ); - write_data_to_fifo_buffer( psample_ret->slot_result[2].ppg_buffer, psample_ret->slot_result[2].ppg_num-1, analysis_ppg_data, 0 ); - CORE921x_DEBUG_LOG("slot_result[2].ps_data[%d]=%d", i, analysis_ppg_data); - } - } - } /* end of for(i 7) ? 7 : oversample; - slotcfg.slot_cfg1.bits.txch = txchsel; - slotcfg.slot_cfg2.bits.storefifo = slot_infifo; - - switch (sample_tim) - { - case VC921x_SAMPLE_TIM_50US: - slotcfg.slot_cfg1.bits.env_time = 2; - slotcfg.slot_cfg1.bits.sample_time = 0; - slotcfg.slot_cfg3.bits.sc = 3; /* env_time_config+1 */ - break; - case VC921x_SAMPLE_TIM_100US: - slotcfg.slot_cfg1.bits.env_time = 5; - slotcfg.slot_cfg1.bits.sample_time = 1; - slotcfg.slot_cfg3.bits.sc = 6; - break; - case VC921x_SAMPLE_TIM_150US: - slotcfg.slot_cfg1.bits.env_time = 8; - slotcfg.slot_cfg1.bits.sample_time = 2; - slotcfg.slot_cfg3.bits.sc = 9; - break; - case VC921x_SAMPLE_TIM_200US: - slotcfg.slot_cfg1.bits.env_time = 11; - slotcfg.slot_cfg1.bits.sample_time = 3; - slotcfg.slot_cfg3.bits.sc = 12; - break; - default: - slotcfg.slot_cfg1.bits.env_time = 5; - slotcfg.slot_cfg1.bits.sample_time = 1; - slotcfg.slot_cfg3.bits.sc = 6; - break; - } - ret = vc921x_write_register(slot_base_addr, (unsigned char *)&slotcfg, sizeof(core921x_slot_config_t)); - return ret; -} - -/* PPG通道及调整的函数接口 */ -CORE921x_FUNC_RAM_SECTION int __core921x_read_slot_adjust_param(unsigned char *pmax_res, unsigned char *pmin_res, unsigned char *pmax_curr, unsigned char *pmin_curr) -{ - *pmax_res = MAX_RES_LEVEL; - *pmin_res = MIN_RES_LEVEL; - *pmax_curr = MAX_CURRENT; - *pmin_curr = MIN_CURRENT; - return 0; -} - -/* 电流+电阻等级的读写,这部分是在使用过程中会反复调用的 */ -CORE921x_FUNC_RAM_SECTION int __core921x_read_slot_current_res(VC921x_PPG_SLOT_I slot_index, unsigned char *pslot_curr, unsigned char *pslot_reslvl) -{ - int ret = 0; - core921x_slot_config_t slotcfg = {0}; - /* read current */ - unsigned char cfg2_addr = CORE921x_CONFIG_SLOT_ADDR_BASE + (slot_index * 4) + 2; - ret = vc921x_read_register(cfg2_addr, (unsigned char *)&slotcfg.slot_cfg2, 1); - if (pslot_curr) - { - *pslot_curr = slotcfg.slot_cfg2.bits.current; - } - /* read reslvl */ - unsigned char cfg0_addr = CORE921x_CONFIG_SLOT_ADDR_BASE + (slot_index * 4); - unsigned char cfg3_addr = CORE921x_CONFIG_SLOT_ADDR_BASE + (slot_index * 4) + 3; - vc921x_read_register(cfg0_addr, (unsigned char *)&slotcfg.slot_cfg0, 1); - vc921x_read_register(cfg3_addr, (unsigned char *)&slotcfg.slot_cfg3, 1); - if (pslot_reslvl) - { - //*pslot_reslvl = slotcfg.slot_cfg3.bits.resistance; - *pslot_reslvl = get_level_by_res_rxgain(slotcfg.slot_cfg3.bits.resistance, slotcfg.slot_cfg0.bits.rxgain); - } - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_ppgslot_current(VC921x_PPG_SLOT_I slot_index, unsigned char current) -{ - int ret = 0; - core921x_slot_cfg2bit slotcfg2 = {0}; - unsigned char cfg2_addr = CORE921x_CONFIG_SLOT_ADDR_BASE + (slot_index * 4) + 2; - ret = vc921x_read_register(cfg2_addr, (unsigned char *)&slotcfg2, 1); - slotcfg2.current = (current >= MAX_CURRENT) ? MAX_CURRENT : current; - ret = vc921x_write_register(cfg2_addr, (unsigned char *)&slotcfg2, 1); - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_ppgslot_resistance(VC921x_PPG_SLOT_I slot_index, unsigned char res_level, unsigned char allow_oversample ) -{ - int ret = 0; - unsigned char res = 0, rxgain = 0; - core921x_slot_ppg_cfg0bit slotcfg0 = {0}; - core921x_slot_cfg3bit slotcfg3 = {0}; - unsigned char cfg0_addr = CORE921x_CONFIG_SLOT_ADDR_BASE + (slot_index * 4); - unsigned char cfg3_addr = CORE921x_CONFIG_SLOT_ADDR_BASE + (slot_index * 4) + 3; - ret = vc921x_read_register(cfg0_addr, (unsigned char *)&slotcfg0, 1); - ret = vc921x_read_register(cfg3_addr, (unsigned char *)&slotcfg3, 1); - res_level = (res_level >= MAX_RES_LEVEL) ? MAX_RES_LEVEL : res_level; - get_res_rxgain_by_level(res_level, &res, &rxgain); - slotcfg3.resistance = res; - slotcfg0.rxgain=rxgain; -#if 1 - if (slot_index <= 1 && allow_oversample) - { - slotcfg0.oversample = 1 * rxgain; - } -#endif - ret = vc921x_write_register(cfg0_addr, (unsigned char *)&slotcfg0, 1); - ret = vc921x_write_register(cfg3_addr, (unsigned char *)&slotcfg3, 1); - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_slotx_pd_config( VC921x_SLOT_CHSEL slot0_pd, VC921x_SLOT_CHSEL slot1_pd, VC921x_SLOT_CHSEL slot2_pd ) -{ - int ret = 0; - core921x_pd_cfgbit pd_config = {0}; - pd_config.slot0_pdch = slot0_pd; - pd_config.slot1_pdch = slot1_pd; - pd_config.slot2_pdch = slot2_pd; - ret = vc921x_write_register(0x4C, (unsigned char *)&pd_config, sizeof(pd_config)); - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_anti_slot_config( unsigned char anti_current, VC921x_CFG_FUNC deslot0, VC921x_CFG_FUNC deslot1, VC921x_CFG_FUNC deslot2, VC921x_PPG_TXCH_I antich ) -{ - int ret = 0; - core921x_anti_cfgbit anti_config = {0}; - core921x_anti_cfgbit_1120mpw anti_config_1120mpw={0}; - if( core921x_nto_version ) - { - anti_config.anti_current = anti_current>=7?7:anti_current; - anti_config.deslot0 = deslot0; - anti_config.deslot1 = deslot1; - anti_config.deslot2 = deslot2; - anti_config.antiTxch=antich; - ret = vc921x_write_register(0x4D, (unsigned char *)&anti_config, sizeof(core921x_anti_cfgbit)); - } - else - { - if( core921x_0808mpw ) return ret; - anti_config_1120mpw.anti_current = anti_current>=7?7:anti_current; - anti_config_1120mpw.deslot0 = deslot0; - anti_config_1120mpw.deslot1 = deslot1; - anti_config_1120mpw.deslot2 = deslot2; - ret = vc921x_write_register(0x4D, (unsigned char *)&anti_config_1120mpw, sizeof(core921x_anti_cfgbit_1120mpw)); - } - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_common_config(VC921x_CFG_FUNC deenv_en, VC921x_CFG_FUNC i2crelease_en, VC921x_CFG_FUNC bio_disfreqHop, VC921x_CFG_FUNC fifo_format, VC921x_CFG_FUNC fifo_en, unsigned char cpd) -{ - int ret = 0; - core921x_com_cfgbit com_config = {0}; - com_config.deenv_en = deenv_en; - com_config.i2crelease_en = i2crelease_en; - com_config.bio_disfreqHop = bio_disfreqHop; - com_config.fifoformat = fifo_format; - com_config.fifo_en = fifo_en; - com_config.cpd = cpd; - if( core921x_0808mpw ) - { - com_config.bio_disfreqHop = 0; /* deFlick */ - ret = vc921x_write_register(0x4D, (unsigned char *)&com_config, sizeof(com_config)); - } - else - { - ret = vc921x_write_register(0x4E, (unsigned char *)&com_config, sizeof(com_config)); - } - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_sample_frequency(unsigned short int div1, unsigned char div2, unsigned char div3) -{ - int ret = 0; - unsigned char freq_config[4] = {0}; - freq_config[0] = (div1 >> 8); - freq_config[1] = (div1 & 0xFF); - freq_config[2] = div2; - freq_config[3] = div3; - if( core921x_0808mpw ) - { - ret = vc921x_write_register(0x4E, freq_config, sizeof(freq_config)); - } - else - { - ret = vc921x_write_register(0x4F, freq_config, sizeof(freq_config)); - } - return ret; -} - -/**************************************************************** - * CORE_API.write()/set() - * txchx_comconfig & ppg threshold configuration - * write or set config registers - ***************************************************************/ -CORE921x_FUNC_RAM_SECTION int __core921x_set_threshold_config(unsigned char ppgth_h, unsigned char ppgth_l) -{ - int ret = 0; - core921x_ppgth_cfgbit ppgth_config = {0}; - ppgth_config.ppgthh = (ppgth_h >= 0xf) ? 0xf : ppgth_h; - ppgth_config.ppgthl = (ppgth_l >= 0xf) ? 0xf : ppgth_l; - if( core921x_0808mpw ) - { - ret = vc921x_write_register(0x52, (unsigned char *)&ppgth_config, 1); - } - else - { - ret = vc921x_write_register(0x53, (unsigned char *)&ppgth_config, 1); - } - return ret; -} -/**************************************************************** - * CORE_API.write()/set() - * extra(ADC,BIO,temperature,AT/DT) configuration - * write or set config registers - ***************************************************************/ -CORE921x_FUNC_RAM_SECTION int __core921x_set_interrupt_config(VC921x_IO_MODE int_mode, VC921x_IO_DIR int_dir, VC921x_IO_PULSE_TIM int_len, unsigned char evt_en) -{ - int ret = 0; - core921x_int_cfgbit int_config = {0}; - int_config.intmode = (unsigned char)int_mode; - int_config.intdir = (unsigned char)int_dir; - int_config.intlen = (unsigned char)int_len; - if (evt_en & VC921x_EN_EVT_FREQ2) - { - int_config.intfreq2_en = 1; - } - if (evt_en & VC921x_EN_EVT_FIFO) - { - int_config.intfifo_en = 1; - } - if (evt_en & VC921x_EN_EVT_OVLD) - { - int_config.intov_en = 1; - } - if (evt_en & VC921x_EN_EVT_PPG) - { - int_config.intppg_en = 1; - } - if( core921x_0808mpw ) - { - ret = vc921x_write_register(0x53, (unsigned char *)&int_config, sizeof(int_config)); - } - else - { - ret = vc921x_write_register(0x54, (unsigned char *)&int_config, sizeof(int_config)); - } - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_bioslot_config(VC921x_CFG_FUNC bioinn_en, VC921x_CFG_FUNC bioext_en, VC921x_BIO_MODE biofifo_mode, VC921x_BIO_CHSEL bio_chsel, unsigned char biofreq, unsigned char biocap, unsigned char biotime) -{ - int ret = 0; - core921x_bio_cfg0bit bio_config0 = {0}; - core921x_bio_cfg1bit bio_config1 = {0}; - bio_config0.bio_inn_en = bioinn_en; - bio_config0.bio_ext_en = bioext_en; - bio_config0.bio_mode = biofifo_mode; - bio_config0.bio_pdch = bio_chsel; - bio_config0.bio_freq = (biofreq > 3) ? 3 : biofreq; - - bio_config1.bio_capadd = (biocap > 0x1f) ? (0x1f) : biocap; - bio_config1.bio_time = (biotime > 0x7) ? (0xf) : biotime; - if( core921x_0808mpw ) - { - ret = vc921x_write_register(0x54, (unsigned char *)&bio_config0, 1); - ret = vc921x_write_register(0x55, (unsigned char *)&bio_config1, 1); - } - else - { - ret = vc921x_write_register(0x55, (unsigned char *)&bio_config0, 1); - ret = vc921x_write_register(0x56, (unsigned char *)&bio_config1, 1); - } - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_bioinn_addcap(unsigned char biocap) -{ - int ret = 0; - core921x_bio_cfg1bit bio_config1 = {0}; - if( core921x_0808mpw ) - { - vc921x_read_register(0x55, (unsigned char *)&bio_config1, 1); - bio_config1.bio_capadd = (biocap > 0x1f) ? (0x1f) : biocap; - ret = vc921x_write_register(0x55, (unsigned char *)&bio_config1, 1); - } - else - { - vc921x_read_register(0x56, (unsigned char *)&bio_config1, 1); - bio_config1.bio_capadd = (biocap > 0x1f) ? (0x1f) : biocap; - ret = vc921x_write_register(0x56, (unsigned char *)&bio_config1, 1); - } - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_temperature_config(VC921x_CFG_FUNC tempslot0_en, VC921x_TEMP_SLOT tempslot0_chsel, unsigned char tempslot0_current, -VC921x_CFG_FUNC tempslot1_en, VC921x_TEMP_SLOT tempslot1_chsel, unsigned char tempslot1_current ) -{ - int ret = 0; - core921x_temp_cfgbit temp_config[2] = {0}; - temp_config[0].temp_enable = tempslot0_en; - temp_config[0].temp_slotch = tempslot0_chsel; - temp_config[0].temp_currset = (tempslot0_current >= 7) ? 7 : tempslot0_current; - temp_config[1].temp_enable = tempslot1_en; - temp_config[1].temp_slotch = tempslot1_chsel; - temp_config[1].temp_currset = (tempslot1_current >= 7) ? 7 : tempslot1_current; - if(core921x_0808mpw) - { - ret = vc921x_write_register(0x56, (unsigned char *)&temp_config, sizeof(temp_config)); - } - else - { - ret = vc921x_write_register(0x57, (unsigned char *)&temp_config, sizeof(temp_config)); - } - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_adc_config( VC921x_ADC_RESOLUTION adc_resulution, VC921x_CFG_FUNC ovdata_sum_enable ) -{ - int ret=0; - core921x_adc_config_t adc_config={0}; - core921x_adc_config_t_1120mpw adc_config_1120mpw={0}; - if( core921x_nto_version ) - { - adc_config.ppg_resulution=adc_resulution; - adc_config.ovtype = ovdata_sum_enable; - adc_config.cmpset = 3; - adc_config.env_clkdiv=0; - adc_config.adc_speed=0; - ret = vc921x_write_register(0x59, (unsigned char *)&adc_config, sizeof(adc_config)); - } - else - { - adc_config_1120mpw.ppg_resulution=adc_resulution; - adc_config_1120mpw.ovtype = ovdata_sum_enable; - adc_config_1120mpw.reserved = 0; - adc_config_1120mpw.env_clkdiv=0; - adc_config_1120mpw.adc_speed=0; - if( core921x_0808mpw ) - { - ret = vc921x_write_register(0x58, (unsigned char *)&adc_config_1120mpw, sizeof(adc_config_1120mpw)); - } - else - { - ret = vc921x_write_register(0x59, (unsigned char *)&adc_config_1120mpw, sizeof(adc_config_1120mpw)); - } - } - //CORE921x_DEBUG_LOG("write register adc_resulution=[%d],ovdata_sum_enable=[%d]", adc_resulution, ovdata_sum_enable); - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_set_rcosc_frequency(unsigned char oscset) -{ - int ret = 0; - if( core921x_0808mpw ) - { - ret = vc921x_write_register(0x59, &oscset, 1); - } - else - { - ret = vc921x_write_register(0x5A, &oscset, 1); - } - return ret; -} - -CORE921x_FUNC_RAM_SECTION int __core921x_write_work_cmd(VC921x_WORK_CMD cmd) // -{ - int ret = 0; - unsigned char wcmd = 0; - switch (cmd) - { - case VC921x_STOP_WORK_CMD: - wcmd = 0x00; - break; - case VC921x_START_WORK_CMD: - wcmd = 0x5A; - break; - case VC921x_RESET_SOFT_CMD: - wcmd = 0xA5; - break; - default: - return 1; - } - ret = vc921x_write_register(CORE921x_WORK_CMD_ADDR_BASE, &wcmd, 1); - return ret; -} diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_driver.c b/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_driver.c deleted file mode 100644 index 1f6b548fd..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_driver.c +++ /dev/null @@ -1,1907 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-11-03 01:20:20 - * @LastEditTime: 2024-04-11 20:37:31 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ -#include "vc921x_core_com.h" -#include "vc921x_driver_config.h" -#include "vc921x_driver.h" - -#if (VC921x_CFG_WEAR_BIO_OLD_EN==VC921x_FUNC_ENABLE) -#include "BIODetect_V14_1.h" -#endif - -#ifndef VC_ABS_MAX -#define VC_ABS_MAX(a, b, max) (((a) > (b)) ? ((a) - (b)) : (max + (a) - (b))) -#endif -#ifndef VC_ABS -#define VC_ABS(a, b) (((a) > (b)) ? ((a) - (b)) : ((b) - (a))) -#endif - -#ifndef VC921x_ENV_CONVERT -#define VC921x_ENV_CONVERT( hex_env ) (((hex_env)>>8)*50+((hex_env)&0xff)) -#endif - -unsigned short int VC921x_CFG_MCU_TICK_FREQUENCY=32000; /* extern unsigned short int VC921x_CFG_MCU_TICK_FREQUENCY; */ -unsigned short int VC921x_WEAR_PARAM_BIO_ABS_HOLD=100; /* extern unsigned short int VC921x_WEAR_PARAM_BIO_ABS_HOLD; */ -unsigned short int VC921x_WEAR_PARAM_BIO_ABS_DROP=100; /* extern unsigned short int VC921x_WEAR_PARAM_BIO_ABS_HOLD; */ - -unsigned int vc921x_calc_ps_reflect_thh( unsigned char psI, unsigned char psR, unsigned char ps_adcbit ) -{ - unsigned int calc_psthh = 0; - float fix_I = vcare_I_exponent_func( 0.8f, VC921x_WEAR_PARAM_PS_CURRENT ); - float fix_R = vcare_R_exponent_func( 100.0f, VC921x_WEAR_PARAM_PS_RESISTANCE ); - float real_I= vcare_I_exponent_func( 0.8f, psI ); -#if VC921x_CFG_DEFAULT_PPGGAIN_EN - float real_R= vcare_R_exponent_func( 200.0f, psR ); /* !!notice:gain_min=1 */ -#else - float real_R= vcare_R_exponent_func( 100.0f, psR ); /* !!notice:gain_min=0 */ -#endif - unsigned int adc_gain=1<<(ps_adcbit-16); - float k = (real_I*real_R)/(fix_I*fix_R*(1<wear_drop_flag = 0; - if (drv_info_handle->fifo_read_data_valid) - { - /* ppg ps slot */ - for (i = 0; i < 3; i++) - { - presult_info->slot_result[i].ppg_num = 0; - vcare_memset(presult_info->slot_result[i].ppg_buffer, 0, sizeof(presult_info->slot_result[i].ppg_buffer)); - } - /* bioinn bioext */ - presult_info->extra_result.bio_fifo_num = 0; - vcare_memset(presult_info->extra_result.bioinn_buffer, 0, sizeof(presult_info->extra_result.bioinn_buffer)); - vcare_memset(presult_info->extra_result.bioext_buffer, 0, sizeof(presult_info->extra_result.bioext_buffer)); - } -} - -/******************************************************************************************************** - * 驱动参数保存部分 - ********************************************************************************************************/ -static int drv_infomation_param_save(void) -{ - int ret = 0; - unsigned char save_buf[12] = {0}; - save_buf[0] = 0xAA; - save_buf[1] = drv_info_handle->optimal_bio_valid = 1; - save_buf[2] = drv_info_handle->optimal_cap; - - save_buf[3] = (drv_info_handle->optimal_bio_gap >> 24) & 0xff; /* calibration deviation */ - save_buf[4] = (drv_info_handle->optimal_bio_gap >> 16) & 0xff; - save_buf[5] = (drv_info_handle->optimal_bio_gap >> 8) & 0xff; - save_buf[6] = (drv_info_handle->optimal_bio_gap >> 0) & 0xff; - save_buf[7] = (drv_info_handle->optimal_bio_temp >> 24) & 0xff; /* temperature deviation */ - save_buf[8] = (drv_info_handle->optimal_bio_temp >> 16) & 0xff; - save_buf[9] = (drv_info_handle->optimal_bio_temp >> 8) & 0xff; - save_buf[10] = (drv_info_handle->optimal_bio_temp >> 0) & 0xff; - ret = vc921x_param_write_flash(save_buf, sizeof(save_buf)); - VCARE_DBG_LOG("save bio param: %d,%d,%d,%d(temp)", drv_info_handle->optimal_bio_valid, drv_info_handle->optimal_cap, drv_info_handle->optimal_bio_gap, drv_info_handle->optimal_bio_temp); - return ret; /* successed return 0 */ -} -static int drv_infomation_param_load(void) -{ - int ret = 0; - unsigned char load_buf[12] = {0}; - ret = vc921x_param_read_flash(load_buf, sizeof(load_buf)); - if (load_buf[0] == 0xAA) - { - drv_info_handle->optimal_bio_valid = load_buf[1]; - drv_info_handle->optimal_cap = load_buf[2]; - drv_info_handle->optimal_bio_gap = (int)((load_buf[3] << 24) + (load_buf[4] << 16) + (load_buf[5] << 8) + (load_buf[6])); - drv_info_handle->optimal_bio_temp= (int)((load_buf[7] << 24) + (load_buf[8] << 16) + (load_buf[9] << 8) + (load_buf[10])); - } - else - { - drv_info_handle->optimal_bio_valid = 0; - drv_info_handle->optimal_cap = 0; - drv_info_handle->optimal_bio_gap = 0; - drv_info_handle->optimal_bio_temp=0; - ret=0; - } - VCARE_DBG_LOG("load bio param: %d,%d,%d,%d(temp)", drv_info_handle->optimal_bio_valid, drv_info_handle->optimal_cap, drv_info_handle->optimal_bio_gap, drv_info_handle->optimal_bio_temp); - return ret; /* successed return 0 */ -} -/* clear param,and */ -static int drv_infomation_param_reset(void) -{ - drv_info_handle->optimal_bio_valid = 0; - drv_info_handle->optimal_cap = 0; - drv_info_handle->optimal_bio_gap = 0; - drv_info_handle->optimal_bio_temp=0; - /* init [dichotomy]param */ - last_ext_bio=0; - remember_biomax_mark=0; - remember_biomin_mark=0; - remember_biomax_value = 0; - remember_biomin_value = 0; - /* 二分中值及采样标志 */ - last_inn_bio_mid=0; - set_flg_mid=0; - /* 二分初始数据 */ - set_cap_max=31; - set_cap_mid=16; - set_cap_min=1; - return 0; -} -/***************************************************************************** - * driver_work_mode table: - * {WORK_MODE, MODE_INIT_FUNC, MODE_HANDLER_FUNC } - *****************************************************************************/ -static const vc921x_mode_ops *sel_mode_ops = NULL; -static int drv_heartrate_mode_init(void); -static int drv_spo2_mode_init(void); -static int drv_bloodpressure_mode_init(void); -static int drv_wear_mode_init(void); -static int drv_temperature_mode_init(void); -static int drv_factory_green_ps_mode_init(void); -static int drv_factory_ir_red_mode_init(void); -static int drv_hrspo2_mode_init(void); -/*handler*/ -static int drv_ppg_mode_handler(const void *ops_self, vcare_ppg_device_t *pdev); -static int drv_factory_mode_handler(const void *ops_self, vcare_ppg_device_t *pdev); - -static const vc921x_mode_ops mode_ops[] = - { - /* work_mode, work_mode_init, work_mode_handler */ - {WORK_MODE_HR, drv_heartrate_mode_init, drv_ppg_mode_handler}, - {WORK_MODE_SPO2, drv_spo2_mode_init, drv_ppg_mode_handler}, - {WORK_MODE_HRV, drv_heartrate_mode_init, drv_ppg_mode_handler}, - {WORK_MODE_STRESS, drv_heartrate_mode_init, drv_ppg_mode_handler}, - {WORK_MODE_BLOODPRESSURE, drv_bloodpressure_mode_init, drv_ppg_mode_handler}, - {WORK_MODE_WEAR, drv_wear_mode_init, drv_ppg_mode_handler}, - {WORK_MODE_TEMPERATURE, drv_temperature_mode_init, drv_ppg_mode_handler}, - {WORK_MODE_FACTORY0, drv_factory_green_ps_mode_init, drv_factory_mode_handler}, - {WORK_MODE_FACTORY1, drv_factory_ir_red_mode_init, drv_factory_mode_handler}, - {WORK_MODE_HRSPO2, drv_hrspo2_mode_init, drv_ppg_mode_handler}, -}; - -/****************************************************************************** - * 初始化部分 - ******************************************************************************/ -static void drv_infomation_param_init(vcare_ppg_device_t *pdev) -{ - int i; - unsigned char max_cur = 0, min_cur = 0, max_res_lvl = 0, min_res_lvl = 0; - /* slot_adjust param */ - core921x_read_slot_adjust_param(&max_res_lvl, &min_res_lvl, &max_cur, &min_cur); - for (i = 0; i < 3; i++) - { - adjust_info_handle[i]->const_max_current = max_cur; - adjust_info_handle[i]->const_min_current = min_cur; - adjust_info_handle[i]->max_current = max_cur; - adjust_info_handle[i]->const_max_res_level = max_res_lvl; - adjust_info_handle[i]->const_min_res_level = min_res_lvl; - adjust_info_handle[i]->max_res_level = max_res_lvl; - adjust_info_handle[i]->adj_param.current_step = VC921x_ADJ_I_STEP_DFT; - adjust_info_handle[i]->adj_param.direction = VC921x_ADJUST_DIR_NONE; - adjust_info_handle[i]->adj_param.direction_last = VC921x_ADJUST_DIR_NONE; - } - /* dev_wear param */ - drv_info_handle->optimal_bio_valid =1; /* 先置1,等待在factory模式下主动清除后进行配平 */ -#if (VC921x_WEAR_DFT_HOLD == VC921x_CFG_WEAR_DEFAULT_STA) - wear_info_handle->last_status = (WEAR_STA_NONE == wear_info_handle->last_status) ? WEAR_STA_HOLD : wear_info_handle->last_status; -#else - #if (VC921x_CFG_WEAR_BIO_OLD_EN!=VC921x_FUNC_ENABLE) - /* 注意:只能非边沿活体的条件下,第一次或者停止工作后,重置活体状态为DROP。边沿的方式调用stop因为机制问题,无论如何都不能完美处理stop之后的状态 */ - wear_info_handle->bio_wear_result = (WEAR_STA_NONE == wear_info_handle->last_status) ? VC921x_BIO_STA_DROP : wear_info_handle->bio_wear_result; - #endif - wear_info_handle->last_status = (WEAR_STA_NONE == wear_info_handle->last_status) ? WEAR_STA_DROP : wear_info_handle->last_status; -#endif -#if (VC921x_FUNC_ENABLE != VC921x_CFG_WEAR_DETECTION) - wear_info_handle->last_status = WEAR_STA_HOLD; -#endif - /* 切换模式如果为摘下时,需要关灯 */ - if (wear_info_handle->last_status == WEAR_STA_DROP && (drv_info_handle->work_mode != WORK_MODE_FACTORY0 && drv_info_handle->work_mode != WORK_MODE_FACTORY1)) - { - for (i = 0; i < 3; i++) - { - if (sample_info_handle->slot_result[i].slot_enwork == 1) - { - core921x_set_enable_config((VC921x_PPG_SLOT_I)i, VC921x_CFG_DISABLE); - sample_info_handle->slot_result[i].slot_enwork = 0; - } - if( drv_info_handle->ppg_convert_ps ) - { - drv_info_handle->ppg_convert_ps=0; - VC921x_PS_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[2] /*slot2_ps*/, VC921x_IN_STORE /*storefifo*/, VC921x_WEAR_PARAM_PS_CURRENT /*current*/, VC921x_WEAR_PARAM_PS_RESISTANCE /*resistance*/); - core921x_sample_slotx_config( VC921x_PPG_SLOT_2, sample_info_handle, VC921x_PPG_TXCH_2, VC921x_WEAR_PARAM_PS_GAIN /*rxgain*/, 0 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - } - } - } - wear_info_handle->wear_status = wear_info_handle->last_status; - pdev->wear = wear_info_handle->last_status; - - wear_info_handle->drop_cnt = VC921x_CFG_WEAR_DROP_CNT; - wear_info_handle->hold_cnt = VC921x_CFG_WEAR_HOLD_CNT; - wear_info_handle->acce_wear_status = WEAR_STA_HOLD; - wear_info_handle->algo_wear_status = WEAR_STA_HOLD; - /* dev_clk param */ - drv_calibration_clk_clear(); - /* read_fifo_address */ - drv_info_handle->read_fifo_address = 0; - if( drv_info_handle->work_mode==WORK_MODE_SPO2 || drv_info_handle->work_mode==WORK_MODE_HRSPO2 ) - { - drv_info_handle->ppg_max_thval = VC921x_PPG_SPO2_MAX_DEFT_THVAL; - drv_info_handle->ppg_min_thval = VC921x_PPG_SPO2_MIN_DEFT_THVAL; - } - else - { - drv_info_handle->ppg_max_thval = VC921x_PPG_MAX_DEFT_THVAL; - drv_info_handle->ppg_min_thval = VC921x_PPG_MIN_DEFT_THVAL; - } - if (wear_info_handle->bio_wear_result == VC921x_BIO_STA_NONE) - { -#if (VC921x_CFG_WEAR_BIO_OLD_EN==VC921x_FUNC_ENABLE) - f_BIOInit( VC921x_WEAR_PARAM_BIO_DELTA, VC921x_WEAR_PARAM_PS_DELTA ); - VCARE_DBG_LOG("f_BIOedgeinit(%d, %d, %d)", VC921x_WEAR_PARAM_BIO_DELTA, VC921x_WEAR_PARAM_PS_DELTA ); -#endif - } -} - -static int drv_calc_bioinn_auto_addcap(unsigned char status, vc921x_sample_info_t *psample_info) -{ - unsigned char finished_set=0; - unsigned char finished_mark=0; - if (status & VC921x_EVENT_INTPS_RDY) - { - if (drv_info_handle->optimal_bio_valid) - { - return 0; - } - /* 判断是否bioext发生变化,如果变化太大,那么直接校准失败 */ - if( last_ext_bio!=0 && VC_ABS(last_ext_bio,psample_info->extra_result.bioext_data)>=20 ) - { - VCARE_DBG_ERR("calc bioinn error, bioext running..."); - } - last_ext_bio = psample_info->extra_result.bioext_data; - /* 二分法校准,循环赋值,设置参数与采样值呈负相关 */ - if( set_flg_mid==1 ) - { - set_flg_mid=0; - last_inn_bio_mid=psample_info->extra_result.bioinn_data; - } - if( last_inn_bio_mid==0 ) - { - core921x_set_bioinn_addcap(psample_info,set_cap_mid); - set_flg_mid=1; - return 0; - } - /* 在合理范围内快速退出 */ - if( (psample_info->extra_result.bioext_data-VC921x_CALC_BIOINN_OFFSET)<=last_inn_bio_mid && (psample_info->extra_result.bioext_data+VC921x_CALC_BIOINN_OFFSET)>=last_inn_bio_mid ) - { - finished_set=set_cap_mid; - finished_mark=1; - VCARE_DBG_LOG("(+-100)now set cap[%d,%d,%d],now_bio_val[%d](%d) ->set[%d]", set_cap_min,set_cap_mid, set_cap_max, - last_inn_bio_mid, psample_info->extra_result.bioext_data, last_inn_bio_mid ); - } - else /* 不在范围,范围比较大,继续二分 */ - { - /* 检索完成,需要再min和max中取一个值 */ - if( (set_cap_max-set_cap_min)<=1 ) - { - if(remember_biomax_mark==1) - { - remember_biomax_mark=0; - remember_biomax_value = psample_info->extra_result.bioinn_data; - } - if( remember_biomin_mark==1 ) - { - remember_biomin_mark=0; - remember_biomin_value = psample_info->extra_result.bioinn_data; - } - if( remember_biomax_value==0 ) - { - remember_biomax_mark=1; - core921x_set_bioinn_addcap(psample_info,set_cap_max); - return 0; - } - if( remember_biomin_value==0 ) - { - remember_biomin_mark=1; - core921x_set_bioinn_addcap(psample_info,set_cap_min); - return 0; - } - if( VC_ABS(remember_biomin_value,psample_info->extra_result.bioext_data) <= VC_ABS(remember_biomax_value,psample_info->extra_result.bioext_data) ) - { - finished_set=set_cap_min;/* 取min,结束 */ - last_inn_bio_mid = remember_biomin_value; - } - else - { - finished_set=set_cap_max;/* 取max,结束 */ - last_inn_bio_mid = remember_biomax_value; - } - finished_mark=1; - VCARE_DBG_LOG("mingap(%d)[%d],maxgap(%d)[%d]->(%d)",set_cap_min,VC_ABS(remember_biomin_value,psample_info->extra_result.bioext_data), - set_cap_max,VC_ABS(remember_biomax_value,psample_info->extra_result.bioext_data), finished_set); - } - /* 继续执行二分逼近 */ - if( last_inn_bio_midextra_result.bioext_data ) - { - VCARE_DBG_LOG("(midset[%d]", set_cap_min,set_cap_mid, set_cap_max, - last_inn_bio_mid, psample_info->extra_result.bioext_data, (set_cap_min+set_cap_mid)/2 ); - set_cap_max = set_cap_mid; - set_cap_mid = (set_cap_min+set_cap_mid)/2; - set_flg_mid = 1; - core921x_set_bioinn_addcap(psample_info,set_cap_mid); - } - else if( last_inn_bio_mid>psample_info->extra_result.bioext_data ) - { - VCARE_DBG_LOG("(mid>bioext)now set cap[%d,%d,%d],now_bio_val[%d](%d) ->set[%d]", set_cap_min,set_cap_mid, set_cap_max, - last_inn_bio_mid, psample_info->extra_result.bioext_data, (set_cap_max+set_cap_mid)/2 ); - set_cap_min = set_cap_mid; - set_cap_mid = (set_cap_max+set_cap_mid)/2; - set_flg_mid = 1; - core921x_set_bioinn_addcap(psample_info,set_cap_mid); - } - else if( last_inn_bio_mid==psample_info->extra_result.bioext_data ) /* 完全相等,直接结束 */ - { - VCARE_DBG_LOG("(mid=bioext)now set cap[%d,%d,%d],now_bio_val[%d](%d) ->set[%d]", set_cap_min,set_cap_mid, set_cap_max, - last_inn_bio_mid, psample_info->extra_result.bioext_data, set_cap_mid); - finished_set=set_cap_mid; - finished_mark=1; - } - } - if( finished_mark ) /* 查找结束处理 */ - { - drv_info_handle->optimal_cap = finished_set; - drv_info_handle->optimal_bio_gap = last_inn_bio_mid - psample_info->extra_result.bioext_data; - drv_info_handle->optimal_bio_temp= psample_info->extra_result.temp0_data; /* inn_temp */ - /* set optimal_cap */ - core921x_set_bioinn_addcap(psample_info,drv_info_handle->optimal_cap); - VCARE_DBG_LOG("optimal_cap=%d, optimal_bio_gap=%d", drv_info_handle->optimal_cap, drv_info_handle->optimal_bio_gap ); - /* save flash_ok */ - drv_infomation_param_save(); - } - } - return -1; -} - -static void drv_calibration_entry_fast_irq( void ) -{ - core921x_set_interrupt_config( VC921x_EN_EVT_FREQ2|VC921x_EN_EVT_FIFO | VC921x_EN_EVT_OVLD | VC921x_EN_EVT_PPG ); -} -static void drv_calibration_exit_fast_irq( void ) -{ - if( drv_info_handle->work_mode==WORK_MODE_FACTORY0 || drv_info_handle->work_mode==WORK_MODE_FACTORY1 ) - { - core921x_set_interrupt_config( VC921x_EN_EVT_FREQ2 | VC921x_EN_EVT_FIFO | VC921x_EN_EVT_OVLD ); - } - else - { - core921x_set_interrupt_config( VC921x_EN_EVT_FIFO | VC921x_EN_EVT_OVLD | VC921x_EN_EVT_PPG ); - } -} - -static void drv_common_register_config( vc921x_drv_info *pdrv_info ) -{ - sample_info_handle->ppg_div = pdrv_info->ppg_div; - sample_info_handle->ps_div = pdrv_info->ps_div; - sample_info_handle->fifo_div = pdrv_info->fifo_div; - sample_info_handle->hold_div = pdrv_info->ps_div; - sample_info_handle->drop_div = pdrv_info->drop_div; -#if (VC921x_CFG_DROP_REDUCE_FREQ==VC921x_FUNC_ENABLE && 0==VC921x_PS_WORK_FREQUENCY_CONFIG) - if( WEAR_STA_DROP==wear_info_handle->wear_status ) - { - sample_info_handle->ps_div= pdrv_info->drop_div; - sample_info_handle->fifo_div=1; - } -#endif - sample_info_handle->fifo_enable = 1; - sample_info_handle->adc_resolution = 16; /* adc位数设置=16,18,20,22,注意初版0808mp的22bitADC不可用 */ - sample_info_handle->fifo_format = ( sample_info_handle->adc_resolution>=18 )?1:0; - core921x_set_common_config(sample_info_handle->fifo_enable, sample_info_handle->fifo_format, sample_info_handle->adc_resolution, - VC921x_CFG_PPG_CHANNL_SELECT, VC921x_CFG_PPG_CHANNL_SELECT, VC921x_CFG_PPG_CHANNL_SELECT); - /* set frequency and enable IRQ */ - core921x_set_sample_frequency(sample_info_handle->ppg_div, sample_info_handle->ps_div, sample_info_handle->fifo_div); - core921x_set_interrupt_config( VC921x_EN_EVT_FIFO | VC921x_EN_EVT_OVLD | VC921x_EN_EVT_PPG ); - /* ps2 */ - VC921x_PS_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[2] /*slot2_ps*/, VC921x_IN_STORE /*storefifo*/, VC921x_WEAR_PARAM_PS_CURRENT /*current*/, VC921x_WEAR_PARAM_PS_RESISTANCE /*resistance*/); - core921x_sample_slotx_config( VC921x_PPG_SLOT_2, sample_info_handle, VC921x_PPG_TXCH_2, VC921x_WEAR_PARAM_PS_GAIN/*rxgain*/, 0 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - /* bio */ -#if (VC921x_FUNC_ENABLE == VC921x_CFG_WEAR_BIO_EN) - VC921x_BIO_SLOT_PARAM_CONFIG(sample_info_handle->extra_result, VC921x_CFG_ENABLE /*bio_innenable*/, VC921x_CFG_ENABLE /*bio_extenable*/, VC921x_BIO_INFIFO_PPG_SUM /*biofifo_mode*/); - core921x_set_bioslot_config(sample_info_handle, drv_info_handle->optimal_cap); -#endif - /* inn-slot0,用于修正活体问题偏差及检验IC异常状态 */ - VC921x_TMP_SLOT_PARAM_CONFIG(sample_info_handle->extra_result, VC921x_CFG_ENABLE /*tmpslot0_enable*/, VC921x_CFG_ENABLE /*tmpslot1_enable*/, 6 /*tmp_setcur*/); - core921x_set_temperature_config(sample_info_handle); -} - -static int drv_heartrate_mode_init(void) -{ - unsigned char hr_over_sample_config=0; - VC921x_SAMPLE_TIM sample_time_config = VC921x_SAMPLE_TIM_100US; - if( WORK_MODE_HR==sel_mode_ops->mode ) - { - hr_over_sample_config = 0; - sample_info_handle->adc_resolution = 16; /* adc位数设置=16,18,20 */ - if( drv_info_handle->hr_algo_mode != 0 ) /* 20240531.心率普通模式特殊配置,开启16倍过采,200us发光@algo.h */ - { - hr_over_sample_config = VC921x_CFG_SPORT_HR_OVERSAMPLE; - sample_time_config = VC921x_CFG_SPORT_HR_SAMPLETIME; - } - sample_info_handle->fifo_format = ( sample_info_handle->adc_resolution>=18 )?1:0; - core921x_set_common_config(sample_info_handle->fifo_enable, sample_info_handle->fifo_format, sample_info_handle->adc_resolution, - VC921x_CFG_PPG_CHANNL_SELECT, VC921x_CFG_PPG_CHANNL_SELECT, VC921x_CFG_PPG_CHANNL_SELECT); - } - /* ppg0 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[0] /*slot0_ppg*/, VC921x_PPG_CURT /*current*/, VC921x_PPG_RESISTANCE /*resistance*/); - core921x_sample_slotx_config( VC921x_PPG_SLOT_0, sample_info_handle, VC921x_PPG_TXCH_0, VC921x_PPG_GAIN /*rxgain*/, hr_over_sample_config /*oversample,2^N*/, sample_time_config); - return 0; -} - -static int drv_spo2_mode_init(void) -{ - sample_info_handle->adc_resolution = 16; /* adc位数设置=16,18,20,22 */ - sample_info_handle->fifo_format = ( sample_info_handle->adc_resolution>=18 )?1:0; - core921x_set_common_config(sample_info_handle->fifo_enable, sample_info_handle->fifo_format, sample_info_handle->adc_resolution, - VC921x_CFG_PPG_CHANNL_SELECT, VC921x_CFG_PPG_CHANNL_SELECT, VC921x_CFG_PPG_CHANNL_SELECT); - /* ppg0 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[0] /*slot0_ppg*/, VC921x_PPG_CURT /*current*/, VC921x_PPG_RESISTANCE /*resistance*/); - core921x_sample_slotx_config(VC921x_PPG_SLOT_0, sample_info_handle, VC921x_PPG_TXCH_2, VC921x_PPG_GAIN /*rxgain*/, 3 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - /* ppg1 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[1] /*slot0_ppg*/, VC921x_PPG_CURT /*current*/, VC921x_PPG_RESISTANCE /*resistance*/); - core921x_sample_slotx_config(VC921x_PPG_SLOT_1, sample_info_handle, VC921x_PPG_TXCH_1, VC921x_PPG_GAIN /*rxgain*/, 3 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - return 0; -} -static int drv_bloodpressure_mode_init(void) -{ - /* ppg0 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[0] /*slot0_ppg*/, VC921x_PPG_CURT /*current*/, VC921x_PPG_RESISTANCE /*resistance*/); - core921x_sample_slotx_config(VC921x_PPG_SLOT_0, sample_info_handle, VC921x_PPG_TXCH_2, VC921x_PPG_GAIN /*rxgain*/, 0 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - return 0; -} -static int drv_wear_mode_init(void) -{ - return 0; -} -static int drv_factory_green_ps_mode_init(void) -{ - /* ppg0 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[0] /*slot0_ppg*/, VC921x_FAT_GREEN_MAX_CURT /*current*/, VC921x_FAT_RESISTANCE /*resistance*/); - core921x_sample_slotx_config(VC921x_PPG_SLOT_0, sample_info_handle, VC921x_PPG_TXCH_0, VC921x_FAT_GAIN /*rxgain*/, 0 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - /* ppg1 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[1] /*slot0_ppg*/, VC921x_FAT_RED_MAX_CURT /*current*/, VC921x_FAT_RESISTANCE /*resistance*/); - core921x_sample_slotx_config(VC921x_PPG_SLOT_1, sample_info_handle, VC921x_PPG_TXCH_1, VC921x_FAT_GAIN /*rxgain*/, 0 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - /* ps2 */ - VC921x_PS_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[2] /*slot2_ps*/, VC921x_IN_STORE /*storefifo*/, VC921x_WEAR_PARAM_PS_CURRENT /*current*/, VC921x_WEAR_PARAM_PS_RESISTANCE /*resistance*/); - core921x_sample_slotx_config(VC921x_PPG_SLOT_2, sample_info_handle, VC921x_PPG_TXCH_2, VC921x_WEAR_PARAM_PS_GAIN/*rxgain*/, 0 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - /* bio/temp */ -#if (VC921x_FUNC_ENABLE == VC921x_CFG_WEAR_BIO_EN) - VC921x_BIO_SLOT_PARAM_CONFIG(sample_info_handle->extra_result, VC921x_CFG_ENABLE /*bio_innenable*/, VC921x_CFG_ENABLE /*bio_extenable*/, VC921x_BIO_INFIFO_PPG_SUM /*biofifo_mode*/ ); - core921x_set_bioslot_config(sample_info_handle, drv_info_handle->optimal_cap); -#endif - /* += enable freq2ps irq */ - core921x_set_interrupt_config( VC921x_EN_EVT_FREQ2 | VC921x_EN_EVT_FIFO | VC921x_EN_EVT_OVLD ); - return 0; -} -static int drv_factory_ir_red_mode_init(void) -{ - /* ppg0 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[0] /*slot0_ppg*/, VC921x_FAT_IR_MAX_CURT /*current*/, VC921x_FAT_RESISTANCE /*resistance*/); - core921x_sample_slotx_config(VC921x_PPG_SLOT_0, sample_info_handle, VC921x_PPG_TXCH_2, VC921x_FAT_GAIN /*rxgain*/, 0 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - /* ppg1 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[1] /*slot0_ppg*/, VC921x_FAT_RED_MAX_CURT /*current*/, VC921x_FAT_RESISTANCE /*resistance*/); - core921x_sample_slotx_config(VC921x_PPG_SLOT_1, sample_info_handle, VC921x_PPG_TXCH_1, VC921x_FAT_GAIN /*rxgain*/, 0 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - /* ps2 */ - VC921x_PS_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[2] /*slot2_ps*/, VC921x_IN_STORE /*storefifo*/, VC921x_WEAR_PARAM_PS_CURRENT /*current*/, VC921x_WEAR_PARAM_PS_RESISTANCE /*resistance*/); - core921x_sample_slotx_config(VC921x_PPG_SLOT_2, sample_info_handle, VC921x_PPG_TXCH_2, VC921x_WEAR_PARAM_PS_GAIN/*rxgain*/, 0 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - /* bio/temp */ -#if (VC921x_FUNC_ENABLE == VC921x_CFG_WEAR_BIO_EN) - VC921x_BIO_SLOT_PARAM_CONFIG(sample_info_handle->extra_result, VC921x_CFG_ENABLE /*bio_innenable*/, VC921x_CFG_ENABLE /*bio_extenable*/, VC921x_BIO_INFIFO_PPG_SUM /*biofifo_mode*/ ); - core921x_set_bioslot_config(sample_info_handle, drv_info_handle->optimal_cap); -#endif - VC921x_TMP_SLOT_PARAM_CONFIG(sample_info_handle->extra_result, VC921x_CFG_ENABLE /*tmpslot0_enable*/, VC921x_CFG_ENABLE /*tmpslot1_enable*/, 6 /*tmp_setcur*/); - core921x_set_temperature_config(sample_info_handle); - /* += enable freq2ps irq */ - core921x_set_interrupt_config( VC921x_EN_EVT_FREQ2 | VC921x_EN_EVT_FIFO | VC921x_EN_EVT_OVLD ); - return 0; -} -static int drv_temperature_mode_init(void) -{ - return 0; -} - -static int drv_hrspo2_mode_init(void) -{ - drv_info_handle->ppg_convert_ps=1; - /* ppg0 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[0] /*slot0_ppg*/, VC921x_PPG_CURT /*current*/, VC921x_PPG_RESISTANCE /*resistance*/); - core921x_sample_slotx_config( VC921x_PPG_SLOT_0, sample_info_handle, VC921x_PPG_TXCH_0, VC921x_PPG_GAIN /*rxgain*/, 0 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - /* ppg1 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[1] /*slot0_ppg*/, VC921x_PPG_CURT /*current*/, VC921x_PPG_RESISTANCE /*resistance*/); - core921x_sample_slotx_config( VC921x_PPG_SLOT_1, sample_info_handle, VC921x_PPG_TXCH_1, VC921x_PPG_GAIN /*rxgain*/, 3 /*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - /* ppg-ps2 */ - VC921x_PPG_SLOT_PARAM_CONFIG(sample_info_handle->slot_result[2] /*slot2_ppg*/, VC921x_PPG_CURT /*current*/, VC921x_PPG_RESISTANCE /*resistance*/); - core921x_sample_slotx_config( VC921x_PPG_SLOT_2, sample_info_handle, VC921x_PPG_TXCH_2, VC921x_PPG_GAIN /*rxgain*/, 3/*oversample,2^N*/, VC921x_SAMPLE_TIM_100US); - return 0; -} - -static void drv_work_init(vcare_ppg_device_t *pdev, int mode, unsigned short int ppg_div, unsigned char ps_div, unsigned char fifo_div, unsigned char drop_div, unsigned char algo_mode) -{ - if( VC921x_DEV_REV_ID==pdev->id1 && VC921x_FDY_VER_ID0==pdev->id2 ) - { - sample_info_handle->ic_type_id = VC921x_DEV_REV_ID; - sample_info_handle->ic_ficv_id = VC921x_FDY_VER_ID0; - } - else - { - VCARE_DBG_ERR("vc921x id error"); - return ; - } - /* set & init param */ - drv_info_handle->work_mode = mode; - drv_info_handle->ppg_div = ppg_div; - drv_info_handle->ps_div = ps_div; - drv_info_handle->fifo_div = fifo_div; - drv_info_handle->drop_div = drop_div; - drv_info_handle->hr_algo_mode = algo_mode; /* 新增传入算法模式,配置不同心率配置 */ - drv_info_handle->ppg_convert_ps=0; - drv_infomation_param_load(); - core921x_write_work_cmd(VC921x_RESET_SOFT_CMD); - core921x_write_work_cmd(VC921x_STOP_WORK_CMD); - core921x_write_work_cmd(VC921x_START_WORK_CMD); - drv921x_nto_version = core921x_check_nto_version_init(); /* 初始化判断1120mpw和0127nto */ - core921x_write_work_cmd(VC921x_RESET_SOFT_CMD); - core921x_write_work_cmd(VC921x_STOP_WORK_CMD); - /* 公共配置初始化 */ - drv_common_register_config( drv_info_handle ); - /* 模式配置初始化 */ - if (sel_mode_ops) - { - if (sel_mode_ops->mode_init) sel_mode_ops->mode_init(); - } - else - { - return; - } - /* 驱动参数初始化*/ - drv_infomation_param_init(pdev); - /* 血样模式配置不同的阈值 */ - core921x_set_threshold_config(drv_info_handle->ppg_max_thval, drv_info_handle->ppg_min_thval); -#if 1 - unsigned char config_debug_reg[32] = {0}; - unsigned char debug_index = 0; - vc921x_read_register(0x40, config_debug_reg, 26); - VCARE_DBG_LOG("[0x40]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); - debug_index += 8; - VCARE_DBG_LOG("[0x48]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); - debug_index += 8; - VCARE_DBG_LOG("[0x50]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); - debug_index += 8; - VCARE_DBG_LOG("[0x58]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); -#endif - core921x_write_work_cmd(VC921x_START_WORK_CMD); -} - -/******************************************************************************************************** - *佩戴检测部分代码 - ********************************************************************************************************/ -#if (VC921x_CFG_WEAR_BIO_OLD_EN==VC921x_FUNC_ENABLE) -static int drv_calc_biology_sense( vc921x_wear_info *pwear_info, vc921x_sample_info_t *presult, unsigned short int bioinn_data, unsigned short int bioext_data, unsigned short int ps_data ) -{ - static unsigned int calc_ps = 0; - static int calc_bio_ext=0; - int ret = 0; - /* bio ps 有效判断 */ - if( bioext_data && ps_data ) - { - calc_bio_ext = bioext_data; - calc_ps = ps_data; - } - ret = f_BIOdetect(calc_bio_ext, calc_ps, VC921x_WEAR_PARAM_PSTH); - VCARE_DBG_LOG("__f_TPedge(%d,%d,%d)=%d =>[%d]", calc_bio_ext, calc_ps, VC921x_WEAR_PARAM_PSTH, ret, pwear_info->bio_wear_result); - if ( VC921x_BIO_STA_HOLD == ret) - { - pwear_info->bio_wear_result = VC921x_BIO_STA_HOLD; - pwear_info->algo_wear_status = WEAR_STA_HOLD; /* bio重新佩戴重置心率算法佩戴状态 */ - } - else if ( VC921x_BIO_STA_DROP == ret) - { - pwear_info->bio_wear_result = VC921x_BIO_STA_DROP; - } - return pwear_info->bio_wear_result; -} -#else -static int drv_calc_biology_sense_absolute(vc921x_wear_info *pwear_info, vc921x_sample_info_t *presult, unsigned short int bioinn_data, unsigned short int bioext_data, unsigned short int ps_data) -{ - unsigned short int bio_refence_base = 0; - unsigned char bio_ps_decline = 0; /* 1-单次下降满足,2-连续下降满足 */ - if (presult->extra_result.bioinn_enwork == 0 && presult->extra_result.bioext_enwork ==0 ) - { - return VC921x_BIO_STA_NONE; - } - if( !drv_info_handle->optimal_bio_valid ) - { - return VC921x_BIO_STA_NONE; - } - /* ps 有效判断 */ - if (ps_data) - { - /* 单次下降达到阈值 */ - if (pwear_info->last_ps_data[0] > ps_data && (pwear_info->last_ps_data[0] - ps_data) >= VC921x_WEAR_PARAM_PS_DELTA) - { - bio_ps_decline = 1; - } - /*连续两次供下降达到了阈值的1.5倍,避免刚好遇到两次采样缓慢下降的情况*/ - if ((pwear_info->last_ps_data[1] > pwear_info->last_ps_data[0]) && (pwear_info->last_ps_data[0] > ps_data) && (pwear_info->last_ps_data[1] - ps_data) >= (VC921x_WEAR_PARAM_PS_DELTA * 15 / 10)) - { - bio_ps_decline = 2; - } - /* buffer move */ - pwear_info->last_ps_data[1] = pwear_info->last_ps_data[0]; - pwear_info->last_ps_data[0] = ps_data; - } - /* bio 有效判断 */ - if (bioinn_data && bioext_data) - { - int real_bio_gap = drv_info_handle->optimal_bio_gap+(drv_info_handle->optimal_bio_temp-presult->extra_result.temp0_data)/36.0f*1.735f; - VCARE_DBG_LOG("calc_temp=%f", (drv_info_handle->optimal_bio_temp-presult->extra_result.temp0_data)/36.0f*1.735f ); - bio_refence_base = bioinn_data - real_bio_gap; - VCARE_DBG_LOG("bio_gap=%d(real=%d), bio_base=%d, bio_ext=%d, abs_gap(%d?[%d,%d])", - drv_info_handle->optimal_bio_gap, real_bio_gap, bio_refence_base, - bioext_data, VC_ABS(bioext_data, bio_refence_base), VC921x_WEAR_PARAM_BIO_ABS_DROP, VC921x_WEAR_PARAM_BIO_ABS_HOLD); - presult->extra_result.bioabs_calc = VC_ABS(bioext_data, bio_refence_base); - if (VC_ABS(bioext_data, bio_refence_base) >= VC921x_WEAR_PARAM_BIO_ABS_HOLD) - { - pwear_info->bio_wear_result = VC921x_BIO_STA_HOLD; - pwear_info->algo_wear_status = WEAR_STA_HOLD; /* bio重新佩戴重置心率算法佩戴状态 */ - } - else if ((VC_ABS(bioext_data, bio_refence_base) <= VC921x_WEAR_PARAM_BIO_ABS_DROP) && bio_ps_decline) - { - pwear_info->bio_wear_result = VC921x_BIO_STA_DROP; - } - } - return pwear_info->bio_wear_result; -} -#endif - -static vc921x_wear_change drv_wear_status_identify(vc921x_wear_info *pwear_info, vc921x_sample_info_t *presult) -{ - vc921x_wear_change ret_change = VC921x_WEAR_NO_CHANGE; - int ret_bio_algo = VC921x_BIO_STA_NONE; - /* 根据是否存入fifo对参数进行取值 和 采样次数进行判断 */ - unsigned char data_index = 0; - unsigned char sample_num = 1; - unsigned int ps = 0; - unsigned short int env = 0; - unsigned short int bioinn = 0; - unsigned short int bioext = 0; - unsigned int calc_psthh=VC921x_WEAR_PARAM_PSTH; - - if (presult->slot_result[2].slot_storefifo == 1) - { - sample_num = presult->slot_result[2].ppg_num; - } - if( drv_info_handle->ppg_convert_ps ) - { - sample_num=1; - } - for (data_index = 0; data_index < sample_num; data_index++) - { - if (presult->slot_result[2].slot_storefifo == 1) - { - ps = VC921x_GET_SLOT_PS_DATA(presult, data_index ); - } - else - { - ps = presult->slot_result[2].u.ps_data << 8; - } - if (presult->extra_result.biofifo_mode == VC921x_BIO_NOFIFO_PS_SGL) - { - bioinn = presult->extra_result.bioinn_data; - bioext = presult->extra_result.bioext_data; - } - else - { - bioinn = presult->extra_result.bioinn_buffer[data_index]; - bioext = presult->extra_result.bioext_buffer[data_index]; - } - env = presult->slot_result[2].env_data; -#if (VC921x_FUNC_DISABLE == VC921x_CFG_WEAR_BIO_EN) - ret_bio_algo = VC921x_BIO_STA_NONE; -#else - if( drv_info_handle->ppg_convert_ps ) - { - ret_bio_algo = VC921x_BIO_STA_NONE; - } - else - { - #if (VC921x_CFG_WEAR_BIO_OLD_EN==VC921x_FUNC_ENABLE) - ret_bio_algo = drv_calc_biology_sense( pwear_info, presult, bioinn, bioext, ps ); - #else - ret_bio_algo = drv_calc_biology_sense_absolute(pwear_info, presult, bioinn, bioext, ps); - #endif - } -#endif - VCARE_DBG_LOG("status[%d] ps=%d,env=%d,bio_inn ext=(%d,%d)>bioret=%d", pwear_info->wear_status, ps, env, bioinn, bioext, ret_bio_algo); - VCARE_DBG_LOG("extern heart_algo_ret=%d,gsnesor_axis_ret=%d", pwear_info->algo_wear_status, pwear_info->acce_wear_status); -#if (VC921x_FUNC_DISABLE == VC921x_CFG_WEAR_ALG_EN) - pwear_info->algo_wear_status = WEAR_STA_HOLD; -#endif -#if (VC921x_FUNC_DISABLE == VC921x_CFG_WEAR_ACC_EN) - pwear_info->acce_wear_status = WEAR_STA_HOLD; -#endif - if( drv_info_handle->ppg_convert_ps ) - { - calc_psthh=vc921x_calc_ps_reflect_thh( presult->slot_result[2].slot_current, presult->slot_result[2].slot_resistance, presult->adc_resolution ); - VCARE_DBG_LOG("PS,fix(%d-%d),dyn(%d-%d)", ps, VC921x_WEAR_PARAM_PSTH, \ - VC921x_GET_SLOT_SAMPLE_DATA(presult, 2, presult->slot_result[2].ppg_num-1 ) ,calc_psthh ); - ps=VC921x_GET_SLOT_SAMPLE_DATA(presult, 2, presult->slot_result[2].ppg_num-1 ); - } - switch (pwear_info->wear_status) - { - case WEAR_STA_DROP: - if ((ps >= calc_psthh) && (env <= VC921x_WEAR_PARAM_ENVMIN) && (VC921x_BIO_STA_NONE == ret_bio_algo || VC921x_BIO_STA_HOLD == ret_bio_algo) && - (WEAR_STA_HOLD == pwear_info->algo_wear_status) && (WEAR_STA_HOLD == pwear_info->acce_wear_status)) - { - VCARE_DBG_LOG("drop->hold_cnt=%d", pwear_info->hold_cnt); - if (--pwear_info->hold_cnt <= 0) - { - pwear_info->hold_cnt = VC921x_CFG_WEAR_HOLD_CNT; - pwear_info->drop_cnt = VC921x_CFG_WEAR_DROP_CNT; - pwear_info->wear_status = WEAR_STA_HOLD; - ret_change = VC921x_DROP_TO_HOLD; - goto CHANGE_RETURN; - } - } - else - { - pwear_info->hold_cnt = VC921x_CFG_WEAR_HOLD_CNT; - } - break; - case WEAR_STA_HOLD: - if ((ps < calc_psthh) || (env > VC921x_WEAR_PARAM_ENVMAX) || (VC921x_BIO_STA_DROP == ret_bio_algo) || (WEAR_STA_DROP == pwear_info->algo_wear_status)) - { - if ((WEAR_STA_DROP == pwear_info->algo_wear_status) || (VC921x_BIO_STA_DROP == ret_bio_algo)) - { - pwear_info->drop_cnt = 1; - } - VCARE_DBG_LOG("hold->drop_cnt=%d", pwear_info->drop_cnt); - if (--pwear_info->drop_cnt <= 0) - { - pwear_info->hold_cnt = VC921x_CFG_WEAR_HOLD_CNT; - pwear_info->drop_cnt = VC921x_CFG_WEAR_DROP_CNT; - pwear_info->wear_status = WEAR_STA_DROP; - ret_change = VC921x_HOLD_TO_DROP; - goto CHANGE_RETURN; - } - } - else - { - pwear_info->drop_cnt = VC921x_CFG_WEAR_DROP_CNT; - } - break; - default: - break; - } - } -CHANGE_RETURN: - return ret_change; -} - -static int drv_read_wear_sample_data(vc921x_sample_info_t *pwear_result_info) -{ - drv_read_sample_param(pwear_result_info); - drv_read_fifo_data(pwear_result_info); - if( !clk_info_handle->clk_calc_status ) - { - pwear_result_info->slot_result[0].ppg_num=0;/* clear ppg_data number, the clock_frequency wait calibration */ - pwear_result_info->slot_result[1].ppg_num=0; - } - return 0; -} - -static wear_status drv_get_wear_status(vcare_ppg_device_t *pdev) -{ - wear_status calc_status = wear_info_handle->last_status; - vc921x_wear_change wear_change = VC921x_WEAR_NO_CHANGE; - vc921x_sample_info_t *result_info_ptr = pdev->result; -#if (VC921x_CFG_WEAR_DETECTION == VC921x_FUNC_DISABLE) - return WEAR_STA_HOLD; -#endif - drv_read_event_status(drv_info_handle); - drv_read_wear_sample_data(result_info_ptr); - VCARE_DBG_LOG("fifo_read_data_valid=%d", drv_info_handle->fifo_read_data_valid); - /* 数据读取及处理 */ - if ( drv_info_handle->fifo_read_data_valid ) - { - wear_change = drv_wear_status_identify(wear_info_handle, result_info_ptr); - if (VC921x_DROP_TO_HOLD == wear_change) - { - calc_status = WEAR_STA_HOLD; - wear_info_handle->wear_status = calc_status; - wear_info_handle->last_status = calc_status; - pdev->wear = calc_status; - drv_calibration_clk_clear(); - drv_work_init(pdev, drv_info_handle->work_mode, drv_info_handle->ppg_div, drv_info_handle->ps_div, drv_info_handle->fifo_div, drv_info_handle->drop_div, drv_info_handle->hr_algo_mode ); - } - else if (VC921x_HOLD_TO_DROP == wear_change) - { - calc_status = WEAR_STA_DROP; - wear_info_handle->wear_status = calc_status; - wear_info_handle->last_status = calc_status; - pdev->wear = calc_status; - /* 必须重新初始化,重置windex,否则摘下的瞬间,会出现windex错误偏移,导致数据解析出错 */ - drv_work_init(pdev, drv_info_handle->work_mode, drv_info_handle->ppg_div, drv_info_handle->ps_div, drv_info_handle->fifo_div, drv_info_handle->drop_div, drv_info_handle->hr_algo_mode); - result_info_ptr->wear_drop_flag = 1; /* 用于发送摘下时原始数据标志 */ - } - } - return calc_status; -} - -/******************************************************************************************************** - * 自动化调整部分代码 - ********************************************************************************************************/ -static int drv_adjust_overload_max_current(vc921x_sample_info_t *psample_result_info, unsigned char overload, int event) -{ - int ret = 0; - unsigned char slot_i = 0; - vc921x_adjust_info *padjust_info = NULL; - unsigned char ovload_mark[3] = {overload & VC921x_STATUS_CH0_OVERLOAD, overload & VC921x_STATUS_CH1_OVERLOAD, overload & VC921x_STATUS_CH2_OVERLOAD}; - for (slot_i = 0; slot_i < 3; slot_i++) - { - padjust_info = adjust_info_handle[slot_i]; - if (ovload_mark[slot_i]) - { - VCARE_DBG_LOG("ovload_mark[%d] now_cur=%d", slot_i, padjust_info->current); - if (padjust_info->current != 0) - { - padjust_info->current--; - padjust_info->max_current = padjust_info->current; - padjust_info->const_max_current = padjust_info->max_current; - /* set adjust mark & adjust param */ - core921x_set_ppgslot_current((VC921x_PPG_SLOT_I)slot_i, padjust_info->current); - } - else - { - ret = -1; - } - } - } - return ret; -} -static int drv_adjust_slot_current_res(vc921x_adjust_info *padjust_info, unsigned char slot_index, unsigned char thh_res_level, unsigned char thh_current) -{ - unsigned char allow_oversample = 0; - unsigned char old_res_level = padjust_info->res_level; - unsigned char old_current = padjust_info->current; - unsigned short int old_current_step = padjust_info->adj_param.current_step; - VCARE_DBG_LOG("ADF_SLOT[%d]-dir(%d)-I_R thh[%d,%d] I_R now(%d,%d)", slot_index, padjust_info->adj_param.direction, thh_res_level, thh_current, old_res_level, old_current); - if (padjust_info->current == thh_current) - { - if (padjust_info->res_level == thh_res_level) - { - VCARE_DBG_ERR("RESLVL-OFFSET-LOW IS MAX/MIN--[%d]>=[%d]", old_res_level, thh_res_level); - return -1; - } - else - { - if (padjust_info->adj_param.direction == VC921x_ADJUST_DIR_UP) - { - padjust_info->res_level = (old_res_level >= thh_res_level) ? (thh_res_level) : (old_res_level + 1); - } - else - { - padjust_info->res_level = (old_res_level <= thh_res_level) ? (thh_res_level) : (old_res_level - 1); - } - /* 20241030.电阻降到默认+4以下时,限制最大电流到约0x65,下调故当前电流置为最小 */ - if( drv_info_handle->work_mode!=WORK_MODE_FACTORY0 && drv_info_handle->work_mode!=WORK_MODE_FACTORY1 && padjust_info->res_level < VC921x_PPG_RESISTANCE+4 ) - { - padjust_info->max_current = 0x65; - padjust_info->current = (padjust_info->adj_param.direction == VC921x_ADJUST_DIR_UP)? padjust_info->max_current: padjust_info->const_min_current; - } - else if( drv_info_handle->work_mode!=WORK_MODE_FACTORY0 && drv_info_handle->work_mode!=WORK_MODE_FACTORY1 && padjust_info->res_level >= VC921x_PPG_RESISTANCE+4 ) - { - padjust_info->max_current = padjust_info->const_max_current; - padjust_info->current = (padjust_info->adj_param.direction == VC921x_ADJUST_DIR_UP)? padjust_info->max_current: padjust_info->const_min_current; - } - } - } - else - { - /* calc step */ - if (padjust_info->adj_param.direction_last == VC921x_ADJUST_DIR_NONE) - { - old_current_step *= 16; - } - else if (padjust_info->adj_param.direction_last == padjust_info->adj_param.direction) - { - old_current_step = (old_current_step == 1 || old_current_step == 2) ? ((old_current_step + 1) * 16) : (old_current_step * VC921x_ADJ_I_INCREASE); /* 同向加大步长,但是在1和2的时候,1.4倍无法使整型增长,就直接+1 */ - } - else - { - old_current_step = old_current_step * VC921x_ADJ_I_DECREASE; - } - padjust_info->adj_param.current_step = old_current_step >> 4; - padjust_info->adj_param.current_step = (padjust_info->adj_param.current_step <= VC921x_ADJ_I_STEP_MIN) ? VC921x_ADJ_I_STEP_MIN : padjust_info->adj_param.current_step; - padjust_info->adj_param.current_step = (padjust_info->adj_param.current_step >= VC921x_ADJ_I_STEP_MAX) ? VC921x_ADJ_I_STEP_MAX : padjust_info->adj_param.current_step; - /* adjust current */ - if (VC921x_ADJUST_DIR_UP == padjust_info->adj_param.direction) - { - padjust_info->current = ((old_current + padjust_info->adj_param.current_step) > thh_current) ? thh_current : (old_current + padjust_info->adj_param.current_step); - } - else if (VC921x_ADJUST_DIR_DOWN == padjust_info->adj_param.direction) - { - padjust_info->current = (old_current < padjust_info->adj_param.current_step) ? thh_current : old_current - padjust_info->adj_param.current_step; - } - padjust_info->adj_param.direction_last = padjust_info->adj_param.direction; - } - VCARE_DBG_LOG("index=%d,res_level=%d,current=%d,step=%d", slot_index, padjust_info->res_level, padjust_info->current, padjust_info->adj_param.current_step); - if (WORK_MODE_HR == drv_info_handle->work_mode) /* 暂定得是只有心率模式下支持修改过采配置 */ - { - allow_oversample = 0; - } - core921x_set_ppgslot_resistance((VC921x_PPG_SLOT_I)slot_index, padjust_info->res_level, allow_oversample ); - core921x_set_ppgslot_current((VC921x_PPG_SLOT_I)slot_index, padjust_info->current); - return 0; -} - -static int drv_adjust_slot_ppg_overflow(vc921x_sample_info_t *psample_result_info, int event) -{ - unsigned char slot_i = 0; - unsigned int over_ppgdata = 0; - vc921x_adjust_info *padjust_info = NULL; - vc921x_sample_slot_t *pslot_ret = NULL; - for (slot_i = 0; slot_i < 3; slot_i++) - { - padjust_info = adjust_info_handle[slot_i]; - pslot_ret = &psample_result_info->slot_result[slot_i]; - over_ppgdata = pslot_ret->u.pre_data; - if (1 == pslot_ret->slot_enwork) - { - VCARE_DBG_LOG("ppg_overflow(%d)=4bit[%d]", over_ppgdata, VC921x_PPG_CONV_BIT4(over_ppgdata) ); - if (VC921x_PPG_CONV_BIT4(over_ppgdata) > drv_info_handle->ppg_max_thval) - { - padjust_info->adj_param.direction = VC921x_ADJUST_DIR_DOWN; - drv_adjust_slot_current_res(padjust_info, slot_i, padjust_info->const_min_res_level, padjust_info->const_min_current); - } - else if (VC921x_PPG_CONV_BIT4(over_ppgdata) < drv_info_handle->ppg_min_thval) - { - padjust_info->adj_param.direction = VC921x_ADJUST_DIR_UP; - drv_adjust_slot_current_res(padjust_info, slot_i, padjust_info->max_res_level, padjust_info->max_current); - } - else - { - padjust_info->adj_param.direction = VC921x_ADJUST_DIR_NONE; - padjust_info->adj_param.direction_last = VC921x_ADJUST_DIR_NONE; - VCARE_DBG_LOG("slot[%d] in the range,clear slot adjustment direction", slot_i); - } - } - } - return 0; -} - -static int drv_auto_adjust_slot_config(int event, unsigned char ov_status) -{ - if( wear_info_handle->wear_status==WEAR_STA_DROP ) - { - return -1; - } - if ((event&VC921x_EVENT_INTOVLOAD)||VC921x_CFG_IRQ_BY_TIMER_EN) - { - drv_adjust_overload_max_current(sample_info_handle, ov_status, event); - } - if((event&VC921x_EVENT_INTPPG_STA)||VC921x_CFG_IRQ_BY_TIMER_EN) - { - drv_adjust_slot_ppg_overflow(sample_info_handle, event); - } - else - { - /* clear adjust_param */ - adjust_info_handle[0]->adj_param.direction = VC921x_ADJUST_DIR_NONE; - adjust_info_handle[0]->adj_param.direction_last = VC921x_ADJUST_DIR_NONE; - adjust_info_handle[1]->adj_param.direction = VC921x_ADJUST_DIR_NONE; - adjust_info_handle[1]->adj_param.direction_last = VC921x_ADJUST_DIR_NONE; - adjust_info_handle[2]->adj_param.direction = VC921x_ADJUST_DIR_NONE; - adjust_info_handle[2]->adj_param.direction_last = VC921x_ADJUST_DIR_NONE; - } - return 0; -} - -/******************************************************************************************************** - * 时钟校准部分 - *******************************************************************************************************/ -static int drv_calibration_oscclk_frequency(vc921x_clk_info *pclk_info) -{ - unsigned char count_vaild = 1; - unsigned char i = 0; - unsigned int clock_tick[2] = {0}; - unsigned short int osc_tick[2] = {0}; - unsigned short osc_frequency[2]; - - clock_tick[0] = vc921x_get_cputimer_tick(); - core921x_read_rcosc_tick(&osc_tick[0], &osc_tick[1]); - clock_tick[1] = vc921x_get_cputimer_tick(); - if ((osc_tick[0] > osc_tick[1]) || (clock_tick[0] > clock_tick[1])) - { - pclk_info->count_index = 0; - VCARE_DBG_ERR("osc/clk ticks is error\n"); - return 1; - } - pclk_info->osc_count[pclk_info->count_index * 2] = osc_tick[0]; - pclk_info->osc_count[pclk_info->count_index * 2 + 1] = osc_tick[1]; - pclk_info->clk_count[pclk_info->count_index * 2] = clock_tick[0]; - pclk_info->clk_count[pclk_info->count_index * 2 + 1] = clock_tick[1]; - pclk_info->count_index++; - if (pclk_info->count_index >= 3) - { - pclk_info->count_index = 0; - for (i = 0; i < 2; i++) - { - count_vaild = count_vaild && (VC_ABS(VC_ABS_MAX(pclk_info->clk_count[2 * i + 2], pclk_info->clk_count[2 * i], VC921x_CFG_MCU_TICK_MAX), VC_ABS_MAX(pclk_info->clk_count[2 * i + 3], pclk_info->clk_count[2 * i + 1], VC921x_CFG_MCU_TICK_MAX)) < VC921x_CFG_CLK_CALC_DEVIATION); - count_vaild = count_vaild && (VC_ABS(VC_ABS_MAX(pclk_info->osc_count[2 * i + 2], pclk_info->osc_count[2 * i], 0xffff), VC_ABS_MAX(pclk_info->osc_count[2 * i + 3], pclk_info->osc_count[2 * i + 1], 0xffff)) < VC921x_CFG_CLK_CALC_DEVIATION); - count_vaild = count_vaild && (!(pclk_info->clk_count[2 * i + 2] == pclk_info->clk_count[2 * i])); /* avoid divisor==0, diffCountIsOk set false */ - count_vaild = count_vaild && (!(pclk_info->osc_count[2 * i + 2] == pclk_info->osc_count[2 * i])); /* avoid divisor==0, diffCountIsOk set false */ - } - if (count_vaild) - { - for (i = 0; i < 2; i++) - { - osc_frequency[i] = VC_ABS_MAX((unsigned int)pclk_info->osc_count[2 * i + 2], pclk_info->osc_count[2 * i], 0xffff) * VC921x_CFG_MCU_TICK_FREQUENCY / VC_ABS_MAX((unsigned int)pclk_info->clk_count[2 * i + 2], pclk_info->clk_count[2 * i], VC921x_CFG_MCU_TICK_MAX); - VCARE_DBG_LOG("f20kOsc[20K_%d]=(%d)", i, osc_frequency[i]); - } - if (VC_ABS(osc_frequency[0], osc_frequency[1]) <= 20) - { - pclk_info->rcosc_frequency = (osc_frequency[0] + osc_frequency[1]) / 2; - pclk_info->clk_calc_freq_status = 1; - } - return 0; - } - } - return 2; -} - -static int drv_auto_calibration_oscclk(vc921x_clk_info *pclk_info) -{ - /* calibration the osc frequency by method of bisection */ - if (pclk_info->clk_calc_freq_status && pclk_info->rcosc_frequency) - { - pclk_info->clk_calc_freq_status = 0; - if (pclk_info->rcosc_frequency >= VC921x_FREQUENCY_MAX) - { - if( drv921x_nto_version ) - { - rcosc_min = (rcosc_mid <= 0xfe) ? rcosc_mid + 1 : 0xff; - } - else - { - rcosc_min = (rcosc_mid <= 0x7e) ? rcosc_mid + 1 : 0x7f; - } - } - else if (pclk_info->rcosc_frequency <= VC921x_FREQUENCY_MIN) - { - rcosc_max = (rcosc_mid >= 1) ? (rcosc_mid - 1) : 0; - } - else - { - pclk_info->clk_calc_status = 1; /* calibration finished mark */ - pclk_info->osc_gap_cnt = 0; - rcosc_max = rcosc_mid + 2; /* 修正成功后,扩张一个调整点的范围,以便温漂时调整余量 */ - rcosc_min = rcosc_mid - 2; - } - rcosc_mid = (rcosc_max + rcosc_min) / 2; - VCARE_DBG_LOG("min,max[%d,%d]~min(%d)", rcosc_min, rcosc_max, rcosc_mid); - core921x_set_rcosc_frequency(rcosc_mid); - pclk_info->rcosc_calibration = rcosc_mid; - /* 如果发生温漂,修改收缩的上下限,进行缓慢修正时钟 */ - if ((pclk_info->rcosc_frequency <= VC921x_FREQUENCY_MIN) && VC_ABS(rcosc_max, rcosc_min) <= 2) - { - rcosc_min -= 2; - VCARE_DBG_LOG("!!!temp->min,max[%d,%d]~min(%d)", rcosc_min, rcosc_max, rcosc_mid); - } - if ((pclk_info->rcosc_frequency >= VC921x_FREQUENCY_MAX) && VC_ABS(rcosc_max, rcosc_min) <= 2) - { - rcosc_max += 2; - VCARE_DBG_LOG("!!!temp->min,max[%d,%d]~min(%d)", rcosc_min, rcosc_max, rcosc_mid); - } - } - return 0; -} - -static int drv_calibration_oscclk_config(vcare_ppg_device_t *pdev) -{ - vc921x_clk_info *pclk_info = clk_info_handle; -#if 1 - if (pclk_info->clk_calc_status) -#else - if (pclk_info->clk_calc_status && pclk_info->osc_gap_cnt <= VC921x_CFG_CLK_CALC_GAPTIME) -#endif - { - pclk_info->osc_gap_cnt++; - return 0; - } - /* calibration clk running, enter fast irq config */ - drv_calibration_entry_fast_irq( ); - drv_calibration_oscclk_frequency(pclk_info); - drv_auto_calibration_oscclk(pclk_info); - if( pclk_info->clk_calc_status ) /* calibration clk finished, exit fast irq config */ - { - startup_inntemperature = sample_info_handle->extra_result.temp0_data; - drv_calibration_exit_fast_irq( ); - } - return 1; -} -static void drv_calibration_clk_clear(void) -{ - static unsigned char is_first_run = 1; - vc921x_clk_info *pclk_info = clk_info_handle; - pclk_info->last_check_ticks = 0; - pclk_info->osc_gap_cnt = 0; - pclk_info->count_index = 0; - pclk_info->clk_calc_freq_status = 0; - /* 校验频率温度清空 */ - check_cpu_tick[0]=0,check_cpu_tick[1]=0; - check_dev_tick[0]=0,check_dev_tick[1]=0; - if (is_first_run == 1) - { - is_first_run = 0; - if( drv921x_nto_version ) - { - rcosc_max = 255,rcosc_min = 0,rcosc_mid = 127; - } - else - { - rcosc_max = 127,rcosc_min = 0,rcosc_mid = 63; - } - pclk_info->clk_calc_status = 0; - core921x_set_rcosc_frequency(rcosc_mid); - } - else - { - if( pclk_info->rcosc_calibration==0 ) - { - if( drv921x_nto_version ) - { - rcosc_max = 255,rcosc_min = 0,rcosc_mid = 127; - } - else - { - rcosc_max = 127,rcosc_min = 0,rcosc_mid = 63; - } - pclk_info->clk_calc_status = 0; - pclk_info->rcosc_calibration=rcosc_mid; - } - core921x_set_rcosc_frequency(pclk_info->rcosc_calibration); - } -} - -static int drv_check_running_gaptime(void) -{ -#if VC921x_CFG_CLK_CLAC_IRQGAP_EN - int ret = 0; - unsigned short int curr_ticks = 0; - unsigned short int ticks_chk, ticks_gap = 0; - unsigned short int ticks1 = 0, ticks2 = 0; - unsigned char times_gap = 0; - core921x_read_rcosc_tick(&ticks1, &ticks2); - times_gap = (1000 * drv_info_handle->ppg_div / VC921x_DEFAULT_FREQ) * VC921x_IRQ_GAP_RATIO; - ticks_chk = (ticks2 >= ticks1) ? (ticks2 - ticks1) : (0xffff + ticks2 - ticks1); - if (ticks_chk <= 10) - { - curr_ticks = ticks1; - } - else - { /* IC问题,可能出现其中一个tick低位出现异常,如果出现异常则取另外一共tick作为运算准 */ - curr_ticks = (ticks2&0xff)?(ticks2):(ticks1); - VCARE_DBG_ERR("read check tick failed(%d,%d)", ticks1, ticks2); - } - // ticks_gap = 2000; - if (0 != curr_ticks && 0 != clk_info_handle->last_check_ticks) - { - ticks_gap = (curr_ticks >= clk_info_handle->last_check_ticks) ? (curr_ticks - clk_info_handle->last_check_ticks) : (0xffff + curr_ticks - clk_info_handle->last_check_ticks); - } - if (ticks_gap <= 20 * times_gap) /* 20k,1ms~20ticks */ - { - VCARE_DBG_ERR("last(%d)now(%d)gap[%d<%d]", clk_info_handle->last_check_ticks, curr_ticks, ticks_gap, 20 * times_gap); - ret = -1; - } - clk_info_handle->last_check_ticks = curr_ticks; - return ret; -#else - return 0; -#endif -} - -static void drv_fifo_error_softreset( void ) -{ - static unsigned char last_add_mark=0; - unsigned char save_config[32]={0}; - /* 软复位,清空所有数据,避免传入算法或者引起其他异常 */ - drv_sample_result_memroy_finished( sample_info_handle ); - vc921x_read_register( 0x40, save_config, sizeof(save_config) ); - core921x_write_work_cmd( VC921x_STOP_WORK_CMD ); - core921x_write_work_cmd( VC921x_RESET_SOFT_CMD ); - drv_info_handle->read_fifo_address = 0; - vc921x_write_register( 0x40, save_config, sizeof(save_config) ); - core921x_write_work_cmd( VC921x_START_WORK_CMD ); - if( last_add_mark==0 ) - { - last_add_mark=1; - core921x_set_rcosc_frequency( clk_info_handle->rcosc_calibration-1 ); - } - else - { - last_add_mark=0; - core921x_set_rcosc_frequency( clk_info_handle->rcosc_calibration+1 ); - } - #if 1 - unsigned char config_debug_reg[32] = {0}; - unsigned char debug_index = 0; - vc921x_read_register(0x40, config_debug_reg, 32); - VCARE_DBG_LOG("[0x40]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); - debug_index += 8; - VCARE_DBG_LOG("[0x48]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); - debug_index += 8; - VCARE_DBG_LOG("[0x50]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); - debug_index += 8; - VCARE_DBG_LOG("[0x58]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); - #endif -} -/******************************************************************************************************** - *数据读取部分 - ********************************************************************************************************/ -static int drv_read_fifo_data(vc921x_sample_info_t *psample_result) -{ - int read_fifo_ret = 0; - vc921x_sample_info_t *sample_result_ptr = psample_result; - unsigned char bio_fifo_error_cnt=0; - unsigned char bio_fifo_error_flg=0; - unsigned char ps_fifo_error_flg=0; - if (!sample_result_ptr) - { - return -1; - } - /* fifo中断 */ - if (0 != drv_info_handle->fifo_read_finished_sync) - { - return 0; - } - drv_info_handle->fifo_read_finished_sync = 1; - read_fifo_ret = core921x_read_fifo_data(sample_result_ptr, &drv_info_handle->read_fifo_address, drv_info_handle->write_fifo_address_bak); - VCARE_DBG_LOG("read_fifo updata read address: %d, write_address:%d, write_address_rel:%d",drv_info_handle->read_fifo_address, drv_info_handle->write_fifo_address_bak, drv_info_handle->write_fifo_address_rel ); - if (read_fifo_ret>=0) - { - drv_info_handle->fifo_read_data_valid = 1; - /* nto版本直接更新read_addr */ - if( drv921x_nto_version ) - { - if( read_fifo_ret==1 ) - { - drv_info_handle->read_fifo_address = drv_info_handle->write_fifo_address_bak; - /* fifo错误,清空fifo数据 */ - VCARE_DBG_LOG("===PS_FIFO_ERROR===") ; - drv_sample_result_memroy_finished( sample_info_handle ); - return read_fifo_ret; - } - } - else - { - if( read_fifo_ret==1 && (drv_info_handle->int_event&VC921x_EN_EVT_FIFO) && !(drv_info_handle->int_event&VC921x_EVENT_INSAMPLE) ) /* 当出现了fifo中断,且并不是fifo数量的倍数时,可以认定为错位,进行纠错处理 */ - { - drv_info_handle->read_fifo_address = drv_info_handle->write_fifo_address_bak; - drv_info_handle->fifo_read_data_valid = 2; - VCARE_DBG_LOG("delay response read_addr updata:%d=write_addr:%d", drv_info_handle->read_fifo_address, drv_info_handle->write_fifo_address_bak); - } - /* 20240119.校验RO_PS与fifo_PS是否异常(如果异常则可以判断为fifo异常错位:1.过度延后导致的fifo覆盖反转,2.ICfifo数据异常丢失) - * 20240229.添加bio的全部出现0xff的情况,判断为fifo异常错位 - */ - if( sample_result_ptr->extra_result.bioext_enwork && sample_result_ptr->extra_result.bio_fifo_num!=0 ) - { - for( bio_fifo_error_cnt=0; bio_fifo_error_cntextra_result.bio_fifo_num; bio_fifo_error_cnt++ ) - { - VCARE_DBG_LOG("bio=%x ~ 0xff",sample_result_ptr->extra_result.bioext_buffer[bio_fifo_error_cnt] ); - if( (sample_result_ptr->extra_result.bioext_buffer[bio_fifo_error_cnt]&0xff) != 0xff ) - { - bio_fifo_error_cnt=0; - break; - } - } - VCARE_DBG_LOG("bio_num=%d,%d",sample_result_ptr->extra_result.bio_fifo_num, bio_fifo_error_cnt); - if( sample_result_ptr->extra_result.bio_fifo_num==bio_fifo_error_cnt ) - { - bio_fifo_error_flg=1; - } - } - if( sample_result_ptr->slot_result[2].slot_enwork==2 && sample_result_ptr->slot_result[2].ppg_num!=0 ) - { - VCARE_DBG_LOG("last_ps=%x ~ %x",VC921x_GET_SLOT_PS_DATA(sample_result_ptr, sample_result_ptr->slot_result[2].ppg_num-1), sample_result_ptr->slot_result[2].u.ps_data ); - if( VC921x_GET_SLOT_PS_DATA(sample_result_ptr, sample_result_ptr->slot_result[2].ppg_num-1)>>8 != sample_result_ptr->slot_result[2].u.ps_data ) - { - ps_fifo_error_flg=1; - } - } - /* bio_fifo_error || ps_fifo_error */ - if( bio_fifo_error_flg || ps_fifo_error_flg ) - { - VCARE_DBG_LOG("===PS_FIFO_ERROR===") ; - drv_fifo_error_softreset(); - return read_fifo_ret; - } - } - /* 20241018.在insample的时候,如果出现中断延时处理/定时器,获取到的RO_bio的值可能还未完全采样计算完成,需要从fifo中更新数据 */ - if( (VC921x_CFG_IRQ_BY_TIMER_EN||drv_info_handle->int_event&VC921x_EVENT_INSAMPLE||0==drv_info_handle->int_event) && (VC921x_BIO_NOFIFO_PS_SGL!=sample_result_ptr->extra_result.biofifo_mode) ) - { - if( sample_result_ptr->extra_result.bioext_enwork && - sample_result_ptr->extra_result.bioext_data != sample_result_ptr->extra_result.bioext_buffer[sample_result_ptr->extra_result.bio_fifo_num-1] ) - { - sample_result_ptr->extra_result.bioext_data = sample_result_ptr->extra_result.bioext_buffer[sample_result_ptr->extra_result.bio_fifo_num-1]; - VCARE_DBG_ERR("INSAMPLE_ERR_EXTBIO-modify=%d",sample_result_ptr->extra_result.bioext_data); - } - if( sample_result_ptr->extra_result.bioinn_enwork && - sample_result_ptr->extra_result.bioinn_data != sample_result_ptr->extra_result.bioinn_buffer[sample_result_ptr->extra_result.bio_fifo_num-1]) - { - sample_result_ptr->extra_result.bioinn_data = sample_result_ptr->extra_result.bioinn_buffer[sample_result_ptr->extra_result.bio_fifo_num-1]; - VCARE_DBG_ERR("INSAMPLE_ERR_INNBIO-modify=%d",sample_result_ptr->extra_result.bioinn_data); - } - } - } - else - { - VCARE_DBG_ERR("read_fifo_ret error(%d)", read_fifo_ret); - return read_fifo_ret; - } - return 0; -} - -static int drv_read_sample_param(vc921x_sample_info_t *psample_ret) -{ - unsigned char slot_i = 0; - unsigned char slot_current = 0, slot_res_lvl = 0; - if (0 == drv_info_handle->param_read_finished_sync) - { - core921x_read_output(psample_ret); - VCARE_DBG_LOG("env(0x)=%x-%x-%x(%d,%d,%d)", psample_ret->slot_result[0].env_data, - psample_ret->slot_result[1].env_data, - psample_ret->slot_result[2].env_data, - VC921x_ENV_CONVERT(psample_ret->slot_result[0].env_data), - VC921x_ENV_CONVERT(psample_ret->slot_result[1].env_data), - VC921x_ENV_CONVERT(psample_ret->slot_result[2].env_data)); - VCARE_DBG_LOG("ppg/ps_data=%d-%d-%d", psample_ret->slot_result[0].u.ps_data, psample_ret->slot_result[1].u.ps_data, psample_ret->slot_result[2].u.ps_data); - VCARE_DBG_LOG("bio01_data=%d-%d", psample_ret->extra_result.bioinn_data, psample_ret->extra_result.bioext_data); - VCARE_DBG_LOG("temp01_data=%d-%d-ref(%d)", psample_ret->extra_result.temp0_data, psample_ret->extra_result.temp1_data, psample_ret->extra_result.tempref_data); - - psample_ret->slot_result[0].env_data = VC921x_ENV_CONVERT(psample_ret->slot_result[0].env_data); - psample_ret->slot_result[1].env_data = VC921x_ENV_CONVERT(psample_ret->slot_result[1].env_data); - psample_ret->slot_result[2].env_data = VC921x_ENV_CONVERT(psample_ret->slot_result[2].env_data); - for (slot_i = 0; slot_i < 3; slot_i++) - { - core921x_read_slot_current_res((VC921x_PPG_SLOT_I)slot_i, &slot_current, &slot_res_lvl); - psample_ret->slot_result[slot_i].slot_current = slot_current; - psample_ret->slot_result[slot_i].slot_resistance = slot_res_lvl; - adjust_info_handle[slot_i]->current = slot_current; - adjust_info_handle[slot_i]->res_level = slot_res_lvl; - } - drv_info_handle->param_read_finished_sync = 1; - VCARE_DBG_LOG("slot[0]cur%d,res%d ^ slot[1]cur%d,res%d ^ slot[2]cur%d,res%d", - psample_ret->slot_result[0].slot_current, psample_ret->slot_result[0].slot_resistance, - psample_ret->slot_result[1].slot_current, psample_ret->slot_result[1].slot_resistance, - psample_ret->slot_result[2].slot_current, psample_ret->slot_result[2].slot_resistance); - } - return 0; -} - -static int drv_read_event_status(vc921x_drv_info *pdrv_info) -{ - if (0 == pdrv_info->event_read_finished_sync) - { - core921x_read_event_status(&pdrv_info->int_event, &pdrv_info->ov_status, &pdrv_info->write_fifo_address_bak, &pdrv_info->write_fifo_address_rel); - pdrv_info->event_read_finished_sync = 1; - VCARE_DBG_LOG("read_event=[%x], read_status=[%x], read_Windex=[%x]~rel[%x]", pdrv_info->int_event, pdrv_info->ov_status, pdrv_info->write_fifo_address_bak, pdrv_info->write_fifo_address_rel ); - } - return 0; -} - -/******************************************************************************************************** - * 中断事件处理部分调用逻辑 - ********************************************************************************************************/ -static int drv_ppg_mode_handler(const void *ops_self, vcare_ppg_device_t *pdev) -{ - int ret = 0; - vc921x_sample_info_t *sample_result_ptr = pdev->result; - vc921x_mode_ops *self_ptr = (vc921x_mode_ops *)ops_self; - drv_calibration_oscclk_config( pdev ); - if( 1 == clk_info_handle->clk_calc_status ) - { - ret = drv_auto_adjust_slot_config(drv_info_handle->int_event, drv_info_handle->ov_status); - } - if (ret >= 0 && 1 == clk_info_handle->clk_calc_status) - { - drv_read_fifo_data(sample_result_ptr); - } - else - { - VCARE_DBG_ERR("WORK_MODE_[%d] clk_status[%d]", self_ptr->mode, clk_info_handle->clk_calc_status); - } - return ret; -} -static int drv_factory_mode_handler(const void *ops_self, vcare_ppg_device_t *pdev) -{ - int ret = 0; - unsigned short int base =0; - vc921x_sample_info_t *sample_result_ptr = pdev->result; - drv_calibration_oscclk_config( pdev ); - if (drv_info_handle->int_event & VC921x_EVENT_INTOVLOAD) - { - ret = drv_adjust_overload_max_current(sample_result_ptr, drv_info_handle->ov_status, drv_info_handle->int_event); - } - drv_read_fifo_data(sample_result_ptr); - if( 1==clk_info_handle->clk_calc_status ) - { - drv_calc_bioinn_auto_addcap(drv_info_handle->int_event, sample_result_ptr); - } - base = sample_result_ptr->extra_result.bioinn_data - drv_info_handle->optimal_bio_gap; - sample_result_ptr->extra_result.bioabs_calc = VC_ABS( sample_result_ptr->extra_result.bioext_data, base ); - return ret; -} - -/********************************************************************************************************* - * DRV_API 对外功能模块部分 - ********************************************************************************************************/ -int vc921x_drv_init_start_work(void *pdevice, int workmode, unsigned short int ppgdiv, unsigned char psdiv, unsigned char fifodiv, unsigned char dropdiv) -{ - vcare_ppg_device_t *pdev = (vcare_ppg_device_t *)pdevice; - char *drv_ver = NULL; - unsigned char mode_count = 0; - unsigned char mode_index = 0; - vcare_memset(sample_info_handle, 0, sizeof(vc921x_sample_info_t)); - pdev->result = sample_info_handle; /* 采样指针传递 */ - core921x_read_software_version(&drv_ver); - core921x_read_id(&pdev->id1, &pdev->id2); /* 0x24, 0x10 */ - VCARE_DBG_LOG("[%s]devID0-2=0x%02x 0x%02x", drv_ver, pdev->id1, pdev->id2); - mode_count = sizeof(mode_ops) / sizeof(mode_ops[0]); - sel_mode_ops = NULL; - for (mode_index = 0; mode_index < mode_count; mode_index++) - { - if (workmode == mode_ops[mode_index].mode) - { - sel_mode_ops = &mode_ops[mode_index]; - break; - } - } - if (!sel_mode_ops) - { - VCARE_DBG_ERR("work_mode is error(NULL),please code mode"); - return -1; - } - drv_work_init(pdev, workmode, ppgdiv, psdiv, fifodiv, dropdiv, pdev->heart_algo_mode); - return 0; -} -int vc921x_drv_get_hwsw_infomation(char **str_drv_ver, unsigned char *pid1, unsigned char *pid2) -{ - core921x_read_software_version(str_drv_ver); - core921x_read_id(pid1, pid2); - return 0; -} -int vc921x_drv_exit_stop_work(void *pdevice) -{ - wear_info_handle->last_status = WEAR_STA_NONE; - core921x_write_work_cmd(VC921x_RESET_SOFT_CMD); - core921x_write_work_cmd(VC921x_STOP_WORK_CMD); - return 0; -} -int vc921x_drv_software_reset(void *pdevice) -{ - wear_info_handle->last_status = WEAR_STA_NONE; - return core921x_write_work_cmd(VC921x_RESET_SOFT_CMD); -} -int vc921x_drv_wakeup_work(void *pdevice) -{ - return core921x_write_work_cmd(VC921x_START_WORK_CMD); -} -int vc921x_drv_sleep_work(void *pdevice) -{ - wear_info_handle->last_status = WEAR_STA_NONE; - return core921x_write_work_cmd(VC921x_STOP_WORK_CMD); -} -int vc921x_drv_set_algo_wear_status(void *pdevice, int status) -{ - wear_info_handle->algo_wear_status = (status == -1) ? (WEAR_STA_DROP) : (WEAR_STA_HOLD); - return 0; -} -int vc921x_drv_set_acce_wear_status(void *pdevice, int status) -{ - /* 产生运动量,清除心率摘下标志 */ - if (0 == status) - { - wear_info_handle->acce_wear_status = WEAR_STA_DROP; - } - else - { - wear_info_handle->acce_wear_status = WEAR_STA_HOLD; - wear_info_handle->algo_wear_status = WEAR_STA_HOLD; - } - return 0; -} -wear_status vc921x_drv_get_wear_status(void *pdevice) -{ - vcare_ppg_device_t *pdev = (vcare_ppg_device_t *)pdevice; - if (!sel_mode_ops) - { - return WEAR_STA_HOLD; - } - if (pdev->workmode == WORK_MODE_FACTORY0 || pdev->workmode == WORK_MODE_FACTORY1) - { - return WEAR_STA_HOLD; - } - return drv_get_wear_status(pdevice); -} - -void vc921x_drv_get_wear_detail_result( unsigned char *bio_ret, unsigned char *algo_ret, unsigned char *acce_ret ) -{ - *bio_ret = (VC921x_BIO_STA_HOLD==wear_info_handle->bio_wear_result)?1:0; - *algo_ret = (WEAR_STA_HOLD==wear_info_handle->algo_wear_status)?1:0; - *acce_ret = (WEAR_STA_HOLD==wear_info_handle->acce_wear_status)?1:0; -} - -/* irq/timer callback interface. */ -int vc921x_drv_get_result_handler(void *pdevice) -{ - vcare_ppg_device_t *pdev = (vcare_ppg_device_t *)pdevice; - pdev->result = sample_info_handle; - vc921x_sample_info_t *sample_result_ptr = pdev->result; - if (!sample_result_ptr || !sel_mode_ops ) - { - return -2; - } - /* 读取基础采样数据 */ - drv_read_event_status(drv_info_handle); - if( drv_info_handle->int_event==0 ) - { - return -1; - } - if (drv_info_handle->int_event & VC921x_EVENT_CONFLICT) - { - VCARE_DBG_ERR("work_status=%x", drv_info_handle->int_event); - return -1; - } - /* check gap time */ - if (0 != drv_check_running_gaptime()) - { - VCARE_DBG_ERR("running gaptime"); - return -1; - } - drv_read_sample_param(sample_result_ptr); - /* 模式数据处理 */ - if (sel_mode_ops->mode_handler) - { - sel_mode_ops->mode_handler(sel_mode_ops, pdev); - } - return 0; -} - -void vc921x_drv_read_event_infomation_byIRQ(void) -{ - drv_read_event_status(drv_info_handle); -} - -int vc921x_drv_is_fifo_event(void *pdevice) -{ - if( drv_info_handle->fifo_read_data_valid ) - { - return 1; - } - return 0; -} -int vc921x_drv_is_ps_event(void *pdevice) -{ - if (drv_info_handle->int_event & (VC921x_EVENT_INTPS_RDY)) - { - return 1; - } - return 0; -} -int vc921x_drv_is_ppg_event(void *pdevice) -{ - if (drv_info_handle->int_event & (VC921x_EVENT_INTPPG_STA)) - { - return 1; - } - return 0; -} -int vc921x_drv_clear_reset_bio_param(void *pdevice) -{ - drv_infomation_param_reset(); - core921x_set_bioinn_addcap( sample_info_handle, set_cap_mid ); - return 0; -} - -unsigned char vc921x_drv_check_frequency_abnormal( unsigned short dev_tick1, unsigned short dev_tick2, unsigned int cpu_tick1, unsigned int cpu_tick2 ) -{ - static unsigned short calc_freq[2]={0}; - unsigned int cpu_tick_diff=0,dev_tick_diff=0; - float gap_time_diff=0.0f; - if( !clk_info_handle->clk_calc_status ) return 0; - check_cpu_tick[1] = check_cpu_tick[0]; - check_dev_tick[1] = check_dev_tick[0]; - check_cpu_tick[0] = cpu_tick1; - check_dev_tick[0] = dev_tick1; - if( VC_ABS_MAX(dev_tick2,dev_tick1,0xffff)>=20 || VC_ABS_MAX(cpu_tick2, cpu_tick1, VC921x_CFG_MCU_TICK_MAX)>=32 ) - { - check_cpu_tick[0]=0,check_cpu_tick[1]=0; - check_dev_tick[0]=0,check_dev_tick[1]=0; - return 0; - } - if (0 == check_cpu_tick[1]||0 == check_cpu_tick[0]) - { - return 0; - } - if (0 == check_dev_tick[1]||0==check_dev_tick[0]) - { - return 0; - } - cpu_tick_diff = VC_ABS_MAX( check_cpu_tick[0], check_cpu_tick[1], VC921x_CFG_MCU_TICK_MAX ); - dev_tick_diff = VC_ABS_MAX( check_dev_tick[0], check_dev_tick[1], 0xFFFF ); - gap_time_diff = (float)cpu_tick_diff/(float)VC921x_CFG_MCU_TICK_FREQUENCY; - calc_freq[1] = calc_freq[0]; - calc_freq[0] = (float)dev_tick_diff/gap_time_diff; - if( calc_freq[0]&& calc_freq[1] && VC_ABS( calc_freq[0], calc_freq[1] )<=100 ) - { - VCARE_DBG_LOG("check temp freq=[%d][%d](%d,%d)", calc_freq[0],calc_freq[1], cpu_tick_diff, dev_tick_diff ); - if( 20000>=calc_freq[0] && (20000-calc_freq[0])/40 >= 60 ) /* 相较于上电时的频率温升60即返回出错 */ - { - check_cpu_tick[0]=0,check_cpu_tick[1]=0; - check_dev_tick[0]=0,check_dev_tick[1]=0; - return 1; - } - } - return 0; -} -#define CHECK_BUFF_SIZE 20 -int vc921x_drv_read_check_temperature_abnormal( void *pdevice, unsigned char *p_freq_ret, unsigned char *p_temp_ret, unsigned short *pdev_cnt1, unsigned short *pdev_cnt2 ) -{ - static unsigned char fiil_mark=0; - static unsigned char fill_index=0; - static unsigned short check_innbio_buff[CHECK_BUFF_SIZE]={0}; - static unsigned short check_extbio_buff[CHECK_BUFF_SIZE]={0}; - static unsigned short check_tick1_buff[CHECK_BUFF_SIZE]={0}; - static unsigned short check_tick2_buff[CHECK_BUFF_SIZE]={0}; - unsigned int check_clk_tick[2]={0}; - unsigned char i=0; - int check_ret=0; - *p_freq_ret = 0; - *p_temp_ret = 0; - - drv_read_sample_param( sample_info_handle ); - drv_info_handle->param_read_finished_sync = 0; /* 读取完成之后不置同步标志,该数据仅做异常检测 */ - /****** 进入临界区 ******/ - check_clk_tick[0] = vc921x_get_cputimer_tick(); - core921x_read_rcosc_tick( pdev_cnt1, pdev_cnt2 ); - check_clk_tick[1] = vc921x_get_cputimer_tick(); - /****** 退出临界区 ******/ - check_innbio_buff[fill_index]=sample_info_handle->extra_result.bioinn_data; - check_extbio_buff[fill_index]=sample_info_handle->extra_result.bioext_data; - check_tick1_buff[fill_index]=*pdev_cnt1; - check_tick2_buff[fill_index]=*pdev_cnt2; - /* 检验频率温度是否正常 */ - *p_freq_ret = vc921x_drv_check_frequency_abnormal( *pdev_cnt1, *pdev_cnt2, check_clk_tick[0], check_clk_tick[1] ); - /* 检验内部温度是否正常 */ -#if 0 /* 使用上电时的内部温度和当前的相对温度进行比较 或者是 内部一致就使用绝对比较 */ - if( sample_info_handle->extra_result.temp0_data>0 && startup_inntemperature>sample_info_handle->extra_result.temp0_data && (startup_inntemperature-sample_info_handle->extra_result.temp0_data)>=1000 ) -#else - if( sample_info_handle->extra_result.temp0_data>0 && sample_info_handle->extra_result.temp0_data<=18000 ) /* 如果客户那边内部得温度常温都在19000左右,就可以直接判断绝对值 */ -#endif - { - *p_temp_ret = 1; - } - /* 校验bio/rctick是否卡死且不为0 */ - if( ++fill_index >=CHECK_BUFF_SIZE ) - { - fill_index=0; - fiil_mark=1; - } - if( fiil_mark ) - { - for( i=0; iextra_result.bioext_enwork||0==sample_info_handle->extra_result.bioinn_enwork ) - { - check_ret++;break; /* bio未使能,忽略++ */ - } - if( check_innbio_buff[i]!=check_innbio_buff[i+1]||check_extbio_buff[i]!=check_extbio_buff[i+1] ) - { - check_ret++;break; /* bio未卡死,通过++ */ - } - } - for( i=0; iparam_read_finished_sync = 0; - drv_info_handle->fifo_read_finished_sync = 0; - drv_info_handle->event_read_finished_sync = 0; - drv_info_handle->fifo_read_data_valid = 0; - -#if 1 - unsigned char config_debug_reg[32] = {0}; - unsigned char debug_index = 0; - vc921x_read_register(0x40, config_debug_reg, 32); - VCARE_DBG_LOG("[0x40]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); - debug_index += 8; - VCARE_DBG_LOG("[0x48]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); - debug_index += 8; - VCARE_DBG_LOG("[0x50]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); - debug_index += 8; - VCARE_DBG_LOG("[0x58]0x%02x,0x%02x,0x%02x,0x%02x 0x%02x,0x%02x,0x%02x,0x%02x", config_debug_reg[0 + debug_index], config_debug_reg[1 + debug_index], config_debug_reg[2 + debug_index], config_debug_reg[3 + debug_index], - config_debug_reg[4 + debug_index], config_debug_reg[5 + debug_index], config_debug_reg[6 + debug_index], config_debug_reg[7 + debug_index]); -#endif - return 0; -} diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_hal.c b/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_hal.c deleted file mode 100644 index 648fb7eef..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_hal.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * @Author: penglei 1624952103@qq.com - * @Date: 2024-03-13 15:08:38 - * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-05-15 11:56:40 - * @FilePath: /FD230/code/sdk/drivers/peripheral/ppg/hx3695/hx3695_hal.c - * @Description: - * - * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. - */ - -#include -#include -#include -#include -#include -#include "pm_control.h" -#include "vc921x_user_app.h" - -static vcare_ppg_device_t *vc921x_device = NULL; - -void ppg_send_cmd_to_vc921x_driver(char* mode, uint8_t enable) -{ - work_mode md = 1; - if (strcmp(mode, "hrs") == 0) { - md = WORK_MODE_HR; - } else if (strcmp(mode, "hrv") == 0) { - md = WORK_MODE_HRV; - } else if (strcmp(mode, "spo2") == 0) { - md = WORK_MODE_SPO2; - } else if (strcmp(mode, "leaklight") == 0) { - md = WORK_MODE_UNDEFINED; - } else if (strcmp(mode, "graycard") == 0) { - md = WORK_MODE_UNDEFINED; - } else if (strcmp(mode, "ledoff") == 0) { - md = WORK_MODE_UNDEFINED; - } else if (strcmp(mode, "wear") == 0) { - md = WORK_MODE_WEAR; - } else if (strcmp(mode, "single") == 0) { - md = WORK_MODE_UNDEFINED; - }else if (strcmp(mode, "factory") == 0) { - md = WORK_MODE_UNDEFINED; - }else if (strcmp(mode, "fpc") == 0) { - md = WORK_MODE_UNDEFINED; - }else if (strcmp(mode, "int") == 0) { - if(vc921x_device) - vc921x_device->ops->dev_irq_handler(0,0); - return; - } - - if (enable == 1) - { - // ppg_service_running_stat = true; - // uapi_pm_control(PM_APP_WAKE_NEEDED); - tyhx_poweron(); - - vc921x_device = get_vc921x_device(); - if(!vc921x_device) - { - printf("get_vc921x_device failed !!!\n"); - tyhx_poweroff(); - return; - } - InitParamTypeDef pInit_Param = {0}; - pInit_Param.sampling_gap_time = 400; - pInit_Param.work_mode = md; - vc921x_device->ops->dev_init(&pInit_Param); - - } else { - - // uapi_pm_control(PM_APP_WAKE_NONEED); - vc921x_device->ops->stop_work(); - tyhx_poweroff(); - } -} \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_original_data_send.c b/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_original_data_send.c deleted file mode 100644 index 30e608675..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_original_data_send.c +++ /dev/null @@ -1,267 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-09-22 17:39:10 - * @LastEditTime: 2024-02-26 09:49:05 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ -/* system include */ -// #include "os_timer.h" -// #include -// #include "wristband_global_data.h" -// extern RtkWristBandSysType_t RtkWristbandSys; -/* vcare include */ -#include "vcare_device_com.h" -#include "vc921x_sample_result.h" - -static unsigned char ble_buf[2000] = {0}; -static unsigned short int buf_size = 0; -static unsigned short int buf_index = 0; -#define BLE_PACK_SIZE 200 -#define TIMER_BLE_GAP 10 - -static void debug_orginal_data_send(unsigned short int size); -/********************************************************************************************************* - * 调试蓝牙数据格式: - * [0~7]slot0_8bytes - * { - * .[0~2]ppg_data(h,m,l) - * .[3]ppg_mark - * .[4]resistance - * .[5]current - * .[6~7]env_bit14(h,l) - * } - * [ 8~15]slot1_8bytes{...} - * [16~23]slot2_8bytes{...} - * [24~25]bio0_2bytes(h,l) - * [26~27]bio1_2bytes(h,l) - * [28~29]ps_slot3_2bytes(h,l) - * [30~35]gsensorx/y/z(h,l) or tempRefADC, tempExtADC, temperature - * [36]hr - * [37]spo2 - * [38]algo_mode - * [39]wear_bioret(bit7) | algoret(bit6) | acceret(bit5) | wear_drv(bit3~bit0) - * - * #define FRAME_SIZE 40 - *********************************************************************************************************/ -#define ORIGINAL_DATA_DEBUG_ENABLE (1) -#if ORIGINAL_DATA_DEBUG_ENABLE - -#define HR_PPG_SLOT 0 -#define IR_PPG_SLOT 1 -#define RD_PPG_SLOT 2 -#define PS_PPG_SLOT 3 -/* 单采样帧字节数 */ -#define FRAME_SIZE 40 - -float vc921x_calc_sample_data_coefficient( unsigned int ppg_data, unsigned char ppg_I, unsigned char ppg_R, unsigned char ppg_bits ); -extern void vc921x_drv_get_wear_detail_result( unsigned char *bio_ret, unsigned char *algo_ret, unsigned char *acce_ret ); - -void vc921x_send_orginal_data(vcare_ppg_device_t *pdev, gsensor_axes *pgsensor, unsigned char ppgsize) -{ - unsigned char i = 0; - unsigned char j = 0; - unsigned char slot_k = 0; - unsigned char psfreq_index = 0; - /* wear all result param */ - unsigned char bio_result=0, algo_result=0, acce_result=0; - vc921x_sample_info_t *presult = (vc921x_sample_info_t *)pdev->result; - memset(ble_buf, 0, sizeof(ble_buf)); - vc921x_drv_get_wear_detail_result( &bio_result, &algo_result, &acce_result ); - unsigned char calc_slot=0; - vc921x_calc_sample_data_coefficient( VC921x_GET_SLOT_SAMPLE_DATA(presult, calc_slot, ppgsize-1), presult->slot_result[calc_slot].slot_current, presult->slot_result[calc_slot].slot_resistance, - presult->adc_resolution ); - - for (i = 0; i < ppgsize; i++) - { - j = 0; - /* 0-23,slot_ppg:3*8=24 */ - for (slot_k = 0; slot_k < 3; slot_k++) - { - ble_buf[i * FRAME_SIZE + j++] = (VC921x_GET_SLOT_SAMPLE_DATA(presult, slot_k, i)>>16)&0xff; - ble_buf[i * FRAME_SIZE + j++] = (VC921x_GET_SLOT_SAMPLE_DATA(presult, slot_k, i)>>8) &0xff; - ble_buf[i * FRAME_SIZE + j++] = (VC921x_GET_SLOT_SAMPLE_DATA(presult, slot_k, i)>>0) &0xff; - - ble_buf[i * FRAME_SIZE + j++] = (presult->adc_resolution-16)/2; - ble_buf[i * FRAME_SIZE + j++] = presult->slot_result[slot_k].slot_resistance; - ble_buf[i * FRAME_SIZE + j++] = presult->slot_result[slot_k].slot_current; - ble_buf[i * FRAME_SIZE + j++] = (presult->slot_result[slot_k].env_data >> 8) & 0xff; - ble_buf[i * FRAME_SIZE + j++] = (presult->slot_result[slot_k].env_data >> 0) & 0xff; - } - /*24-29 bio:2*2 + ps:2 */ - psfreq_index =(presult->wear_drop_flag)?(i/presult->hold_div):(i / presult->ps_div); - if (presult->extra_result.biofifo_mode != 0) //VC921x_BIO_NOFIFO_PS_SGL - { - ble_buf[i * FRAME_SIZE + j++] = (presult->extra_result.bioinn_buffer[psfreq_index] >> 8) & 0xff; - ble_buf[i * FRAME_SIZE + j++] = (presult->extra_result.bioinn_buffer[psfreq_index] >> 0) & 0xff; - ble_buf[i * FRAME_SIZE + j++] = (presult->extra_result.bioext_buffer[psfreq_index] >> 8) & 0xff; - ble_buf[i * FRAME_SIZE + j++] = (presult->extra_result.bioext_buffer[psfreq_index] >> 0) & 0xff; - } - else - { - ble_buf[i * FRAME_SIZE + j++] = (presult->extra_result.bioinn_data >> 8) & 0xff; - ble_buf[i * FRAME_SIZE + j++] = (presult->extra_result.bioinn_data >> 0) & 0xff; - ble_buf[i * FRAME_SIZE + j++] = (presult->extra_result.bioext_data >> 8) & 0xff; - ble_buf[i * FRAME_SIZE + j++] = (presult->extra_result.bioext_data >> 0) & 0xff; - } - if (presult->slot_result[2].slot_storefifo) - { - ble_buf[i * FRAME_SIZE + j++] = (VC921x_GET_SLOT_PS_DATA(presult, psfreq_index) >> 8) & 0xff; - ble_buf[i * FRAME_SIZE + j++] = (VC921x_GET_SLOT_PS_DATA(presult, psfreq_index) >> 0) & 0xff; - } - else - { - ble_buf[i * FRAME_SIZE + j++] = (presult->slot_result[2].u.ps_data >> 8) & 0xff; - ble_buf[i * FRAME_SIZE + j++] = (presult->slot_result[2].u.ps_data >> 0) & 0xff; - } -/* 30-35 xyz:2*3=6*/ -#if 1 - ble_buf[i * FRAME_SIZE + j++] = pgsensor->xData[i] >> 8; - ble_buf[i * FRAME_SIZE + j++] = pgsensor->xData[i] & 0xff; - ble_buf[i * FRAME_SIZE + j++] = pgsensor->yData[i] >> 8; - ble_buf[i * FRAME_SIZE + j++] = pgsensor->yData[i] & 0xff; - ble_buf[i * FRAME_SIZE + j++] = pgsensor->zData[i] >> 8; - ble_buf[i * FRAME_SIZE + j++] = pgsensor->zData[i] & 0xff; -#else /* temp result */ - ble_buf[i * FRAME_SIZE + j++] = presult->extra_result.tempref_data >> 8; - ble_buf[i * FRAME_SIZE + j++] = presult->extra_result.tempref_data & 0xff; - ble_buf[i * FRAME_SIZE + j++] = presult->extra_result.temp0_data >> 8; - ble_buf[i * FRAME_SIZE + j++] = presult->extra_result.temp0_data & 0xff; - ble_buf[i * FRAME_SIZE + j++] = presult->extra_result.temp1_data >> 8; - ble_buf[i * FRAME_SIZE + j++] = presult->extra_result.temp1_data & 0xff; -#endif - /* 36-spo2,37-hr,38-algo_mode */ - ble_buf[i * FRAME_SIZE + j++] = pdev->heart_rate; - ble_buf[i * FRAME_SIZE + j++] = pdev->spo2; - ble_buf[i * FRAME_SIZE + j++] = pdev->heart_algo_mode; - /* [39]wear_bioret(bit7) | algoret(bit6) | acceret(bit5) | wear_drv(bit3~bit0) */ - ble_buf[i * FRAME_SIZE + j++] = (bio_result<<7)|(algo_result<<6)|(acce_result<<5)| (pdev->wear & 0xf); - } - debug_orginal_data_send(ppgsize * FRAME_SIZE); -} - -#endif - -void vc921x_send_orginal_data_debug_mark_data( void ) -{ - for(int i=0; i= buf_size) - { - return 0; - } - // 判断剩余数据长度是否还需要分包 - residue_size = buf_size - buf_index; - if (residue_size <= BLE_PACK_SIZE) - { - send_data_by_ble(&ble_buf[buf_index], residue_size); - return 0; - } - else - { - send_data_by_ble(&ble_buf[buf_index], BLE_PACK_SIZE); - buf_index += BLE_PACK_SIZE; - return 1; - } -} - -/* 创建软件定时器,如果数据太长通过软件定时器发送 */ -#define TIMER_ID 0xf0 -static void *debug_send_timer = NULL; -static void debug_send_timer_start(void) -{ - if (debug_send_timer) - { - os_timer_restart(&debug_send_timer, TIMER_BLE_GAP); - } -} -static void debug_send_timer_stop(void) -{ - if (debug_send_timer) - { - os_timer_stop(&debug_send_timer); - } -} - -static void debug_send_timer_callback(void *p_handle) -{ - if (timer_send_data_function()) - { - /* 定时器继续循环 */ - os_timer_restart(&debug_send_timer, TIMER_BLE_GAP); - } - else - { - /* 关闭定时器 */ - debug_send_timer_stop(); - } -} - -void vc921x_send_orginal_data_timer_init(void) -{ - // if (debug_send_timer == NULL) - // { - // os_timer_create(&debug_send_timer, "debug_send_timer", TIMER_ID, TIMER_BLE_GAP, false, debug_send_timer_callback); - // } - // os_timer_restart(&debug_send_timer, TIMER_BLE_GAP); - // os_timer_stop(&debug_send_timer); -} - -static void debug_orginal_data_send(unsigned short int size) -{ - buf_index = 0; - buf_size = size; - printf("debug_orginal_data_send = %d", size); -#if 1 - if (buf_size <= BLE_PACK_SIZE) - { - send_data_by_ble(ble_buf, size); - } - else - { - send_data_by_ble(ble_buf, BLE_PACK_SIZE); - buf_index += BLE_PACK_SIZE; - debug_send_timer_start(); - } -#else - for (unsigned char i = 0; i * 8 < size; i++) - { - printf("[%d~%d]:%02x %02x %02x %02x , %02x %02x %02x %02x", i * 8, (i + 1) * 8, - ble_buf[i * 8], ble_buf[i * 8 + 1], ble_buf[i * 8 + 2], ble_buf[i * 8 + 3], ble_buf[i * 8 + 4], ble_buf[i * 8 + 5], ble_buf[i * 8 + 6], ble_buf[i * 8 + 7]); - } -#endif -} diff --git a/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_user_app.c b/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_user_app.c deleted file mode 100644 index c6b2281cb..000000000 --- a/code/sdk/zhihui/drivers/ppg/vc921x/src/vc921x_user_app.c +++ /dev/null @@ -1,897 +0,0 @@ -/********************************************************************************************** - * @Copyright(c) 2023, Chengdu vcaresensor Microelectronics Corporation. All rights reserved. - * @Author: Tse - * @Date: 2023-09-22 17:39:10 - * @LastEditTime: 2024-04-11 20:38:21 - * @LastEditors: Tse - * @Description: - **********************************************************************************************/ -/* 驱动头文件 */ -#include "vc921x_driver_com.h" -#include "vc921x_sample_result.h" -#include "vc921x_user_app.h" -/* 算法头文件 */ -#include "algo.h" -#include "spo2Algo_16bit.h" -#include "vcSportMotionIntAlgo.h" -#include "custom_utils.h" -#include "custom_utils.h" -#include "pinctrl_porting.h" -#include "hal_gpio.h" -#include "vcare_device_com.h" - -#define VC921X_I2C_BUS I2C_BUS_2 -#define CHIP_I2C_ADDRESS 0x33 - -/* vcare_ppg_device */ -static vcare_ppg_device_t vc921x_dev = {"vc921x", 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0}; -/* G-Sensor Data */ -static gsensor_axes vc921x_gsensor_data = {0}; - -static void vc921x_get_board_gsensor_data(unsigned short int *pgsensor_len, unsigned short int ppg_count); -static unsigned int vc921x_gsensor_actuating_quantity(int x_axis, int y_axis, int z_axis); -static int vc921x_heart_rate_calculate(vcare_ppg_device_t *pdev, unsigned char hr_slot ); -static int vc921x_spo2_calculate(vcare_ppg_device_t *pdev, unsigned char ir_slot, unsigned char red_slot); - - -// S_AGPIO_L26 心率复位 PPG reset -#define GPIO_PIN_PRG_RESET S_AGPIO_L26 -// S_AGPIO_R0 PRG_LED_POWER ON 心率等电源控制脚 -#define GPIO_PIN_PRG_LED_ON S_AGPIO_R0 - -void tyhx_poweron(void) -{ - // uapi_pin_set_mode(GPIO_PIN_PRG_RESET, (pin_mode_t)HAL_PIO_FUNC_GPIO); - // uapi_gpio_set_dir(GPIO_PIN_PRG_RESET, GPIO_DIRECTION_OUTPUT); - // uapi_gpio_set_val(GPIO_PIN_PRG_RESET, GPIO_LEVEL_HIGH); - - uapi_pin_set_mode(GPIO_PIN_PRG_LED_ON, (pin_mode_t)HAL_PIO_FUNC_GPIO); - uapi_gpio_set_dir(GPIO_PIN_PRG_LED_ON, GPIO_DIRECTION_OUTPUT); - uapi_gpio_set_val(GPIO_PIN_PRG_LED_ON, GPIO_LEVEL_HIGH); - LOS_Mdelay(50); -} -void tyhx_poweroff(void) -{ - // uapi_pin_set_mode(GPIO_PIN_PRG_RESET, (pin_mode_t)HAL_PIO_FUNC_GPIO); - // uapi_gpio_set_dir(GPIO_PIN_PRG_RESET, GPIO_DIRECTION_OUTPUT); - // uapi_gpio_set_val(GPIO_PIN_PRG_RESET, GPIO_LEVEL_LOW); - - uapi_pin_set_mode(GPIO_PIN_PRG_LED_ON, (pin_mode_t)HAL_PIO_FUNC_GPIO); - uapi_gpio_set_dir(GPIO_PIN_PRG_LED_ON, GPIO_DIRECTION_OUTPUT); - uapi_gpio_set_val(GPIO_PIN_PRG_LED_ON, GPIO_LEVEL_LOW); - - LOS_Mdelay(1); -} - -/**************************************************************************** - * @description: 驱动参数保存/读取 - * @param {unsigned int} size - * @return {*} - ****************************************************************************/ -int vc921x_param_write_flash(unsigned char *pdata, unsigned int size) -{ - uapi_save_file_data("/user/userdata/vc921x.bin",pdata,size,"wb"); - return 0; -} -int vc921x_param_read_flash(unsigned char *pdata, unsigned int size) -{ - uapi_get_file_data("/user/userdata/vc921x.bin",pdata,&size); - return 0; -} - -/**************************************************************************** - * @description: 内存申请 - * @param {unsigned int} size - * @return {*} - ****************************************************************************/ -void *vc921x_malloc(unsigned int size) -{ - return malloc(size); -} -/**************************************************************************** - * @description: 内存释放 - * @param {void} *ptr - * @return {*} - ****************************************************************************/ -void vc921x_free(void *ptr) -{ - if (ptr) - { - free(ptr); - } -} -/**************************************************************************** - * @description: - * @param {unsigned char} regaddr - * @param {unsigned char*} pbuf - * @param {unsigned short int} size - * @return {*} - ****************************************************************************/ -int vc921x_read_register(unsigned char regaddr, unsigned char *pbuf, unsigned short int size) -{ - custom_i2c_read_regs(CHIP_I2C_ADDRESS, regaddr, 1 , pbuf, size, VC921X_I2C_BUS); - return 0; -} -int vc921x_write_register(unsigned char regaddr, unsigned char *pbuf, unsigned short int size) -{ - custom_i2c_write_reg(CHIP_I2C_ADDRESS, regaddr, 1, pbuf, size, VC921X_I2C_BUS); - return 0; -} -unsigned int vc921x_get_cputimer_tick(void) -{ - return uapi_systick_get_count(); -} - -/*********************************************************************************************************/ -/* user gsensor code */ -#define ENABLE_GSENSOR 0 -//#include "module_gsensor_stk8321.h" -//#include "hub_gsensor.h" -const unsigned char arry10[] = {0, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12}; -const unsigned char arry20[] = {0, 2, 3, 5, 6, 8, 9, 11, 12, 13, 15, 16, 18, 19, 21, 22, 24, 25, 27, 28}; -static void vc921x_get_board_gsensor_data(unsigned short int *pgsensor_len, unsigned short int ppg_count) -{ - int i = 0; - unsigned char gsensor_len = 0; - memset(&vc921x_gsensor_data, 0, sizeof(vc921x_gsensor_data)); -#if ENABLE_GSENSOR - /* Gsensor精度要求 ReadGsensorFIFO(+-4G11bit or +-8G12bit 256/g) 例如一个fifo周期为1sec,25组ppg数据,需要获取1sec内25组gsensor数据(40ms*25),用于匹配25组ppg信号。 - 如果ppg频率高于ppg频率则对进行抽样处理,以下代码仅参考 */ - AxesRaw_t gsensor_buff[40] = {0}; - stk8321_get_fifo_data(&gsensor_len, gsensor_buff); - VCARE_DBG_LOG("gsensor_len[%d]-ppgsize[%d]", gsensor_len, ppg_count); - if (0 == ppg_count) - { - /* 不抽样 */ - *pgsensor_len = gsensor_len; - for (i = 0; i < *pgsensor_len; i++) - { -#if (BOARD_VERSION == BOARD_NEW_BOARD) - vc921x_gsensor_data.xData[i] = gsensor_buff[i].AXIS_X; - vc921x_gsensor_data.yData[i] = gsensor_buff[i].AXIS_Y; - vc921x_gsensor_data.zData[i] = gsensor_buff[i].AXIS_Z; -#elif (BOARD_VERSION == BOARD_OLD_BOARD) - vc921x_gsensor_data.xData[i] = gsensor_buff[i].AXIS_Y; - vc921x_gsensor_data.yData[i] = gsensor_buff[i].AXIS_X; - vc921x_gsensor_data.zData[i] = gsensor_buff[i].AXIS_Z; -#endif - } - } - /* æ­¤demo中gsensor的采样频率高于ppg采样,所以正常情况下,gsensor的数量一定是大于ppg的数据。特殊情况需要考虑ppg数量大于gsensor数量。需要对gsensor数据进行补长 */ - if ((gsensor_len >= ppg_count) && (ppg_count != 0)) - { - *pgsensor_len = ppg_count; - /* ppglen = 10 抽样 */ - if (10 == ppg_count) - { - for (i = 0; i < ppg_count; i++) - { -#if (BOARD_VERSION == BOARD_NEW_BOARD) - vc921x_gsensor_data.xData[i] = gsensor_buff[arry10[i]].AXIS_X; - vc921x_gsensor_data.yData[i] = gsensor_buff[arry10[i]].AXIS_Y; - vc921x_gsensor_data.zData[i] = gsensor_buff[arry10[i]].AXIS_Z; -#elif (BOARD_VERSION == BOARD_OLD_BOARD) - vc921x_gsensor_data.xData[i] = gsensor_buff[arry10[i]].AXIS_Y; - vc921x_gsensor_data.yData[i] = gsensor_buff[arry10[i]].AXIS_X; - vc921x_gsensor_data.zData[i] = gsensor_buff[arry10[i]].AXIS_Z; -#endif - } - } - else /* ppglen = 20 、25抽样 */ - { - for (i = 0; i < ppg_count; i++) - { -#if (BOARD_VERSION == BOARD_NEW_BOARD) - vc921x_gsensor_data.xData[i] = gsensor_buff[arry20[i]].AXIS_X; - vc921x_gsensor_data.yData[i] = gsensor_buff[arry20[i]].AXIS_Y; - vc921x_gsensor_data.zData[i] = gsensor_buff[arry20[i]].AXIS_Z; -#elif (BOARD_VERSION == BOARD_OLD_BOARD) - vc921x_gsensor_data.xData[i] = gsensor_buff[arry20[i]].AXIS_Y; - vc921x_gsensor_data.yData[i] = gsensor_buff[arry20[i]].AXIS_X; - vc921x_gsensor_data.zData[i] = gsensor_buff[arry20[i]].AXIS_Z; -#endif - } - } - } - else if ((gsensor_len < ppg_count) && (gsensor_len != 0)) /* gsensor不足补全 */ - { - *pgsensor_len = ppg_count; - for (i = 0; i < gsensor_len; i++) - { -#if (BOARD_VERSION == BOARD_NEW_BOARD) - vc921x_gsensor_data.xData[i] = gsensor_buff[i].AXIS_X; - vc921x_gsensor_data.yData[i] = gsensor_buff[i].AXIS_Y; - vc921x_gsensor_data.zData[i] = gsensor_buff[i].AXIS_Z; -#elif (BOARD_VERSION == BOARD_OLD_BOARD) - vc921x_gsensor_data.xData[i] = gsensor_buff[i].AXIS_Y; - vc921x_gsensor_data.yData[i] = gsensor_buff[i].AXIS_X; - vc921x_gsensor_data.zData[i] = gsensor_buff[i].AXIS_Z; -#endif - } - for (i = gsensor_len; i < ppg_count; i++) - { -#if (BOARD_VERSION == BOARD_NEW_BOARD) - vc921x_gsensor_data.xData[i] = gsensor_buff[gsensor_len - 1].AXIS_X; - vc921x_gsensor_data.yData[i] = gsensor_buff[gsensor_len - 1].AXIS_Y; - vc921x_gsensor_data.zData[i] = gsensor_buff[gsensor_len - 1].AXIS_Z; -#elif (BOARD_VERSION == BOARD_OLD_BOARD) - vc921x_gsensor_data.xData[i] = gsensor_buff[gsensor_len - 1].AXIS_Y; - vc921x_gsensor_data.yData[i] = gsensor_buff[gsensor_len - 1].AXIS_X; - vc921x_gsensor_data.zData[i] = gsensor_buff[gsensor_len - 1].AXIS_Z; -#endif - } - } -#endif -} - -/**************************************************************************** - * @description: gsensor判断是否存在运动 - * @param {int} x_axis - * @param {int} y_axis - * @param {int} z_axis - * @return {*} - ****************************************************************************/ -static unsigned int vc921x_gsensor_actuating_quantity(int x_axis, int y_axis, int z_axis) -{ - unsigned int ret_atc = 0; - unsigned int abs_sum_current = 0; - static unsigned int abs_sum_last = 0; - if (x_axis < 0) - { - x_axis = -x_axis; - } - if (y_axis < 0) - { - y_axis = -y_axis; - } - if (z_axis < 0) - { - z_axis = -z_axis; - } - abs_sum_current = x_axis + y_axis + z_axis; - if (abs_sum_last && abs_sum_current) - { - if (((abs_sum_last > abs_sum_current) ? (abs_sum_last - abs_sum_current) : (abs_sum_current - abs_sum_last)) >= 40) - { - VCARE_DBG_LOG("ACTIVE..."); - ret_atc = 1; - } - } - abs_sum_last = abs_sum_current; - vc921x_drv_set_acce_wear_status(&vc921x_dev, ret_atc); - return ret_atc; -} - -/**************************************************************************** - * @description: ppg数据加入心率算法 - * @param {vcare_ppg_device_t} *pdev - * @return {*} - ****************************************************************************/ -static int vc921x_heart_rate_calculate(vcare_ppg_device_t *pdev, unsigned char hr_slot ) -{ - int heartRate = 0; - unsigned char reliability = 0; - AlgoInputData_t algoInputData_t = {0}; - AlgoOutputData_t algoOutputData = {0}; - vc921x_sample_info_t *result_info = NULL; - vc921x_sample_slot_t *result = NULL; - unsigned char adc_param = 0; - int i = 0; - if (!pdev) - { - return -1; - } - heartRate = pdev->heart_rate; - result_info = (vc921x_sample_info_t *)pdev->result; - result = &result_info->slot_result[hr_slot]; /* 驱动中初始化slot0为心率绿光ppg */ - adc_param = (result_info->adc_resolution-16)/2; - for (i = 0; i < result->ppg_num; i++) - { - algoInputData_t.axes.x = vc921x_gsensor_data.xData[i]; - algoInputData_t.axes.y = vc921x_gsensor_data.yData[i]; - algoInputData_t.axes.z = vc921x_gsensor_data.zData[i]; - algoInputData_t.envSample = result->env_data; - algoInputData_t.ppgSample = (adc_param<<24)|VC921x_GET_SLOT_SAMPLE_DATA(result_info, hr_slot, i ); /* 驱动中初始化slot0为心率绿光ppg */ - Algo_Input(&algoInputData_t, 1000 / 25, (AlgoSportMode)pdev->heart_algo_mode, 0, 0); - VCARE_DBG_LOG("mode[%d]-[%d] (%d)ppg=%d, x=%d, y=%d, z=%d \n", pdev->heart_algo_mode, i, adc_param, algoInputData_t.ppgSample&0xffffff, \ - algoInputData_t.axes.x, algoInputData_t.axes.y, algoInputData_t.axes.z); - } - Algo_Output(&algoOutputData); - heartRate = algoOutputData.hrData; - reliability = algoOutputData.reliability; - if (-1 == heartRate) - { - Algo_Init(); - /* call heart algo wear status check,[-1] */ - vc921x_drv_set_algo_wear_status(pdev, heartRate); - VCARE_DBG_LOG("ALGO_STA=-1"); - } - VCARE_DBG_LOG("ALGO-HR[%d][%d]", heartRate, reliability); - return heartRate; -} - -/**************************************************************************** - * @description: 血氧PPG数据加入血氧算法 - * @param {vcare_ppg_device_t} *pdev - * @return {*} - ****************************************************************************/ -static int vc921x_spo2_calculate(vcare_ppg_device_t *pdev, unsigned char red_slot, unsigned char ir_slot) -{ - vc921x_sample_info_t *result_info = NULL; - float spo2CalValue = -1.0f; - int spo2Value = 0; - unsigned char sportFlag = 0; - unsigned char adc_param = 0; - unsigned int ir_ppg_data = 0, red_ppg_data = 0; - if (!pdev) - { - return -1; - } - spo2Value = pdev->spo2; - result_info = (vc921x_sample_info_t *)pdev->result; - adc_param = (result_info->adc_resolution-16)/2; - for (int i = 0; i < result_info->slot_result[ir_slot].ppg_num; i++) - { - red_ppg_data= (adc_param<<24)|VC921x_GET_SLOT_SAMPLE_DATA(result_info, red_slot, i ); - ir_ppg_data = (adc_param<<24)|VC921x_GET_SLOT_SAMPLE_DATA(result_info, ir_slot, i ); - spo2CalValue = vcSpo2Calculate_16bit( red_ppg_data, ir_ppg_data, 1); - sportFlag = vcSportMotionCalculate(vc921x_gsensor_data.xData[i], vc921x_gsensor_data.yData[i], vc921x_gsensor_data.zData[i]); - if (-1 != (int)spo2CalValue && spo2CalValue <= 100 && 0 == sportFlag) - { - spo2Value = (int)spo2CalValue; - } - VCARE_DBG_LOG("[%d](%d) ppg_ir=%d, ppg_red=%d, x=%d, y=%d, z=%d", i, adc_param, \ - ir_ppg_data&0xffffff, red_ppg_data&0xffffff, \ - vc921x_gsensor_data.xData[i], vc921x_gsensor_data.yData[i], vc921x_gsensor_data.zData[i]); - } - VCARE_DBG_LOG("ALGO-SPO2[%d][%f]", (unsigned short int)spo2Value, spo2CalValue); - return spo2Value; -} - -/******************************************************************************************************** - * 温度功能部分,需要进行对数运算,必须包含math库 - ********************************************************************************************************/ -#include "math.h" -/* fix Rref = 10K R */ -#define REF_R 10 -/* NTC parameter */ -#define NTC_B 3380 -#define NTC_T (273.15f + 25) /* 25摄氏度下的绝对温度 */ -#define NTC_R 10 /* 10K */ -/* vc921x parameter */ -const unsigned char vc921x_temperature_current[] = {0, 2, 4, 8, 12, 16, 20, 24}; -static signed short int get_ntc_temperature(float ntc_value) -{ - signed short int temperature = 0; - float tmp = 0.0f; - tmp = 1 / (1 / NTC_T + (log(ntc_value / NTC_R) / NTC_B)) - 273.15f; - temperature = (signed short int)(tmp * 10); - VCARE_DBG_LOG("[CALC_TMP]=%d(%4.2f)", temperature, tmp); - return temperature; -} -static void vc921x_temperature_ntc_calculate(vcare_ppg_device_t *pdev) -{ - unsigned char ext_I = 0; - float ext_R = 0.0f; - vc921x_sample_info_t *presult_t = (vc921x_sample_info_t *)pdev->result; - if(presult_t->extra_result.tempslot1_enwork && presult_t->extra_result.temp1_data && presult_t->extra_result.tempref_data ) - { - /* 采样值转换为电阻值 */ - ext_I = vc921x_temperature_current[presult_t->extra_result.tempslot1_setcur]; - if (0 != ext_I) - { - ext_R = (float)(20 * REF_R * presult_t->extra_result.temp1_data) / (float)(presult_t->extra_result.tempref_data * ext_I); - VCARE_DBG_LOG("ext_R=%f", ext_R); - pdev->temperature1 = get_ntc_temperature(ext_R); - } - } -} - -/********************************************************************************************************* - * USER_API - ********************************************************************************************************/ -/* -!!!只针对[心率/摘配带]模式,其他模式均为自适应固定时间fifo时间,注意修改之前需要确认在使用的配置模式下,fifo不会溢出,否则将无法正确获取数据 -if( vc921x_PS_WORK_FAST_FREQUENCY==1 ) (ms) -{ps=12.5hz: fifotime=800,720,640,560...80} -else -{ps=5hz: fifotime=1000,800,600,400,200} -*/ -/**************************************************************************** - * @description: 初始化IC并启动工作 - * @param {InitParamTypeDef} *pinitconfig - * @return {*} - ****************************************************************************/ -void vc921x_usr_device_init( InitParamTypeDef *pinitconfig ) -{ - // tyhx_poweron(); - int algo_confirm_ret=0; - unsigned short int ppgdiv = 0; - unsigned char psdiv = 0; - unsigned char fifodiv = 0; - unsigned char dropdiv =20; /* drop_sta:ps_freq = ppg_hz/drop_div */ - unsigned char frequency=25; /* default frequency=25hz */ - /* ppg_freq=20K/ppgdiv, ps_freq=ppg_freq/psdiv, fifodiv=psfreq/fifodiv - * fifo_max=192byte. The amount of byte by once sampling must not be greater than fifo_max(192bytes). - */ - extern unsigned short int VC921x_CFG_MCU_TICK_FREQUENCY; /* mcu tick frequency parameter */ - extern unsigned short int VC921x_WEAR_PARAM_BIO_ABS_HOLD; /* factory calibration parameter-hold */ - extern unsigned short int VC921x_WEAR_PARAM_BIO_ABS_DROP; /* factory calibration parameter-drop */ - VC921x_CFG_MCU_TICK_FREQUENCY=32000; - VC921x_WEAR_PARAM_BIO_ABS_HOLD=150; /* save_diff*8/10 */ - VC921x_WEAR_PARAM_BIO_ABS_DROP=100; /* save_diff*5/10 */ - - vc921x_dev.workmode = (work_mode)pinitconfig->work_mode; - vc921x_dev.heart_algo_mode = pinitconfig->hr_algo_mode; - switch (pinitconfig->work_mode) - { - case WORK_MODE_HR: - case WORK_MODE_SPO2: - case WORK_MODE_WEAR: - case WORK_MODE_FACTORY0: - case WORK_MODE_FACTORY1: - case WORK_MODE_UNDEFINED: - case WORK_MODE_HRSPO2: - frequency=25; - break; - case WORK_MODE_STRESS: - frequency=50; - break; - case WORK_MODE_HRV: - case WORK_MODE_BLOODPRESSURE: - frequency=100; - break; - default: - break; - } - ppgdiv = 20000 / frequency; /* ppg_freq = frequency */ -#if (VC921x_PS_WORK_FREQUENCY_CONFIG==1) - psdiv = pinitconfig->sampling_gap_time*25/1000; /* 520ms ~ ps_div=13, fifo_div=1, 注意设置初始化参数的时间时,要估算一次fifo长度和fifo总长度的关系 */ - fifodiv = 1; - if( WORK_MODE_FACTORY0==pinitconfig->work_mode || WORK_MODE_FACTORY1==pinitconfig->work_mode ) - { - frequency=50; - ppgdiv = 20000 / frequency; - psdiv = pinitconfig->sampling_gap_time*25/1000; /* 注意:别修改psdiv,在有活体的配置里面,会影响活体的时间参数.所以此处通过提高一倍ppg频率,进而加快FAT模式的中断数据更新 */ - fifodiv=1; - } -#elif( VC921x_PS_WORK_FREQUENCY_CONFIG==0 ) /* ps=5hz */ - dropdiv =20; - if (frequency == 25) - { - psdiv = 5; - fifodiv = 4; /* ppg=25hz, psbio=5hz, fifo=1.25hz,fifotime=800ms */ - if( WORK_MODE_SPO2==pinitconfig->work_mode ) - { - fifodiv=2; - } - } - else if (frequency == 50) - { - psdiv = 10; - fifodiv = 2; /* ppg=50hz, psbio=5hz, fifo=2.5hz,fifotime=400ms */ - } - else if (frequency == 100) - { - psdiv = 20; - fifodiv = 1; /* ppg=100hz, psbio=5hz, fifo=5hz, fifotime=200ms */ - } - if( WORK_MODE_HR==pinitconfig->work_mode || WORK_MODE_WEAR==pinitconfig->work_mode ) - { - fifodiv = pinitconfig->sampling_gap_time*50/10000; - } - if( WORK_MODE_HRSPO2==pinitconfig->work_mode ) - { - fifodiv=2; - } - if( WORK_MODE_FACTORY0==pinitconfig->work_mode || WORK_MODE_FACTORY1==pinitconfig->work_mode ) - { - dropdiv = psdiv; - fifodiv=1; - } -#endif - /* 先初始化启动心率芯片 */ - vc921x_drv_init_start_work(&vc921x_dev, pinitconfig->work_mode, ppgdiv, psdiv, fifodiv, dropdiv); - vc921x_dev.dev_work_status = 1; - /* 如果需要保持测试值,比如24h的心率模式,初始化时则不清除记录值心率值,避免初始化后出现一段为0的情况 */ - vc921x_dev.heart_rate = 0; - vc921x_dev.stress=0; - vc921x_dev.hrv = 0; - vc921x_dev.spo2 = 0; - vc921x_dev.blood_pressure=0; - vc921x_dev.ecg=0; - /****** algo_identify_init ******/ - //algo_confirm_ret = Algo_Confirm_init( RtkWristbandSys.SecondCountRTC ); //1704038400 - Algo_Init(); - vcSpo2AlgoInit_16bit(); - vcSportMotionAlgoInit(); - VCARE_DBG_LOG("work_mode=%d,algo_confirm=%d", pinitconfig->work_mode, algo_confirm_ret ); -} - -/**************************************************************************** - * @description: 获取IC及驱动相关参数 - * @param {unsigned char} *pchip_id - * @param {unsigned char} *pvers_id - * @param {char} * - * @param {char} * - * @return {*} - ****************************************************************************/ -void vc921x_usr_get_dev_info(unsigned char *pchip_id, unsigned char *pvers_id, char **drv_name, char **dev_name) -{ - /* pchip_id=0x24, pvers_id=0x10... */ - vc921x_drv_get_hwsw_infomation(drv_name, pchip_id, pvers_id); -} -/**************************************************************************** - * @description: 开始工作 - * @return {*} - ****************************************************************************/ -void vc921x_usr_start_work(void) -{ - vc921x_drv_wakeup_work(&vc921x_dev); - vc921x_dev.dev_work_status = 1; -} -/**************************************************************************** - * @description: 停止工作 - * @return {*} - ****************************************************************************/ -void vc921x_usr_stop_work(void) -{ - vc921x_drv_sleep_work(&vc921x_dev); - vc921x_dev.dev_work_status = 0; -} -/**************************************************************************** - * @description: 软复位 - * @return {*} - ****************************************************************************/ -void vc921x_usr_soft_reset(void) -{ - vc921x_drv_software_reset(&vc921x_dev); - vc921x_dev.dev_work_status = 0; -} -/**************************************************************************** - * @description: 活体IC参数重置校准 - * @return {*} - ****************************************************************************/ -void vc921x_usr_reset_bio_param(void) -{ - vc921x_drv_clear_reset_bio_param(&vc921x_dev); -} -/**************************************************************************** - * @description: 获取佩戴状态 - * @return {*} - ****************************************************************************/ -int vc921x_usr_get_wear_status(void) -{ - if (WEAR_STA_HOLD == vc921x_dev.wear) - { - return 1; - } - return 0; -} -/**************************************************************************** - * @description: 定时器校验当前IC状态,如果发生异常,则重启LDO后初始化 - * @return {*} - ****************************************************************************/ -void vc921x_usr_check_temperature_abnormal(void) -{ - unsigned char check_same_ret = 0, check_freq_ret = 0, check_temp_ret = 0; - unsigned short check_cnt1 = 0, check_cnt2 = 0; - check_same_ret = vc921x_drv_read_check_temperature_abnormal(&vc921x_dev, &check_freq_ret, &check_temp_ret, &check_cnt1, &check_cnt2); - vc921x_temperature_ntc_calculate(&vc921x_dev); - vc921x_sample_info_t *result_info = (vc921x_sample_info_t *)vc921x_dev.result; - VCARE_DBG_LOG("status(%d),psbio_0(%d,%d),cnt=%d,%d,same_ret=%d,freq_ret=%d,temp_ret=%d, temp_ext=%d",vc921x_dev.dev_work_status, - result_info->slot_result[2].u.ps_data, result_info->extra_result.bioext_data, check_cnt1, check_cnt2, - check_same_ret, check_freq_ret, check_temp_ret, vc921x_dev.temperature1); - - if (1 == vc921x_dev.dev_work_status && /* IC处于工作状态 */ - ((result_info->slot_result[2].u.ps_data==0 && (result_info->extra_result.bioext_data==0&&result_info->extra_result.bioext_enwork)) /* ps和bio同时异常,或者RCOSC异常 */ - || (check_cnt1 == 0 && check_cnt2 == 0) - || (1 == check_same_ret) /* bio-cnt其中之一已经不再变化 */ - || (1 == check_freq_ret) /* 频率温度异常 */ - || (1 == check_temp_ret) /* 内部温度异常 */ - || vc921x_dev.temperature1 >= 600)) /* NTC温度异常,如果硬件NC则会固定250 */ - { - /* 1.close ldo, 2.delay(200ms), 3.open ldo, 4.delay(10ms), 5.init_dev */ - //extern void vcare_ldo_power_ctrl(unsigned char onoff); - //vcare_ldo_power_ctrl(0); - //platform_delay_ms(200); - //vcare_ldo_power_ctrl(1); - //platform_delay_ms(10); - vc921x_drv_init_start_work(&vc921x_dev, vc921x_dev.workmode, result_info->ppg_div, result_info->ps_div, result_info->fifo_div, result_info->drop_div); - } -} - -/**************************************************************************** - * @description: 中断事件处理事件 - * @param {unsigned char} heart_algo_mode - * @param {unsigned char} spo2_algo_mode - * @return {*} - ****************************************************************************/ -void vc921x_usr_device_handler( unsigned char heart_algo_mode, unsigned char spo2_algo_mode ) -{ - unsigned short int ppg_num = 0; - unsigned short int gsensor_num = 0; - vc921x_sample_info_t *sample_result_info_ptr = (vc921x_sample_info_t *)vc921x_dev.result; - if( !vc921x_dev.dev_work_status ) return; - VCARE_DBG_LOG("------------------"); - vc921x_dev.heart_algo_mode = heart_algo_mode; - vc921x_dev.spo2_algo_mode = spo2_algo_mode; - vc921x_drv_get_result_handler(&vc921x_dev); - vc921x_dev.wear = vc921x_drv_get_wear_status(&vc921x_dev); - if (vc921x_drv_is_ps_event(&vc921x_dev) || vc921x_drv_is_fifo_event(&vc921x_dev)) - { - //disp_data.wear_sta = vc921x_dev.wear; - //disp_data.disp_bio_val = sample_result_info_ptr->extra_result.bioext_data; - //disp_data.disp_bio_abs = sample_result_info_ptr->extra_result.bioabs_calc; - //VCARE_DBG_LOG("bio_absgap=%d, bioext=%d", disp_data.disp_bio_abs, disp_data.disp_bio_val ); - } - switch (vc921x_dev.workmode) - { - case WORK_MODE_HR: - if (vc921x_drv_is_fifo_event(&vc921x_dev)) - { - ppg_num = sample_result_info_ptr->slot_result[0].ppg_num; - if (ppg_num > 40) - break; - vc921x_get_board_gsensor_data(&gsensor_num, ppg_num); - if (gsensor_num) - { - vc921x_gsensor_actuating_quantity(vc921x_gsensor_data.xData[0], vc921x_gsensor_data.yData[0], vc921x_gsensor_data.zData[0]); - } - printf("vc921x_dev.wear : %d \n",vc921x_dev.wear); - if (WEAR_STA_HOLD == vc921x_dev.wear) - { - vc921x_dev.heart_rate = vc921x_heart_rate_calculate(&vc921x_dev, 0); - printf("vc921x_dev.heart_rate : %d \n",vc921x_dev.heart_rate); - //vc921x_send_orginal_data(&vc921x_dev, &vc921x_gsensor_data, ppg_num); - } - else - { - vc921x_dev.heart_rate = 0; - //vc921x_send_orginal_data(&vc921x_dev, &vc921x_gsensor_data, (ppg_num?ppg_num:1) ); - Algo_Init(); - } - //disp_data.hr_rate = vc921x_dev.heart_rate; - } - break; - case WORK_MODE_SPO2: - if (vc921x_drv_is_fifo_event(&vc921x_dev)) - { - ppg_num = sample_result_info_ptr->slot_result[1].ppg_num; - if (ppg_num > 40) - break; - vc921x_get_board_gsensor_data(&gsensor_num, ppg_num); - if (WEAR_STA_HOLD == vc921x_dev.wear) - { - vc921x_dev.spo2 = vc921x_spo2_calculate(&vc921x_dev, 1, 0); - //vc921x_send_orginal_data(&vc921x_dev, &vc921x_gsensor_data, ppg_num); - } - else - { - vc921x_dev.spo2 = 0; - vcSpo2AlgoInit_16bit(); - vcSportMotionAlgoInit(); - } - printf("vc921x_dev.spo2 : %d \n",vc921x_dev.spo2); - //disp_data.spo2_val = vc921x_dev.spo2; - } - break; - case WORK_MODE_HRV: - if (vc921x_drv_is_fifo_event(&vc921x_dev)) - { - ppg_num = sample_result_info_ptr->slot_result[0].ppg_num; - if (ppg_num > 40) - break; - vc921x_get_board_gsensor_data(&gsensor_num, ppg_num); - if (WEAR_STA_HOLD == vc921x_dev.wear) - { /*wear is hold,call_algo_func*/ - //vc921x_send_orginal_data(&vc921x_dev, &vc921x_gsensor_data, ppg_num); - } - else - { /*wear is drop,clear_algo_data*/ - } - } - break; - case WORK_MODE_STRESS: - if (vc921x_drv_is_fifo_event(&vc921x_dev)) - { - ppg_num = sample_result_info_ptr->slot_result[0].ppg_num; - if (ppg_num > 40) - break; - vc921x_get_board_gsensor_data(&gsensor_num, ppg_num); - if (WEAR_STA_HOLD == vc921x_dev.wear) - { /*wear is hold,call_algo_func*/ - //vc921x_send_orginal_data(&vc921x_dev, &vc921x_gsensor_data, ppg_num); - } - else - { /*wear is drop,clear_algo_data*/ - } - //disp_data.hr_rate = vc921x_dev.heart_rate; - } - break; - case WORK_MODE_BLOODPRESSURE: - if (vc921x_drv_is_fifo_event(&vc921x_dev)) - { - ppg_num = sample_result_info_ptr->slot_result[0].ppg_num; - if (ppg_num > 40) - break; - vc921x_get_board_gsensor_data(&gsensor_num, ppg_num); - if (WEAR_STA_HOLD == vc921x_dev.wear) - { /*wear is hold,call_algo_func*/ - //vc921x_send_orginal_data(&vc921x_dev, &vc921x_gsensor_data, ppg_num); - } - else - { /*wear is drop,clear_algo_data*/ - } - } - break; - case WORK_MODE_WEAR: - if (vc921x_drv_is_fifo_event(&vc921x_dev)) - { - vc921x_get_board_gsensor_data(&gsensor_num, ppg_num); - if (gsensor_num) - { - vc921x_gsensor_actuating_quantity(vc921x_gsensor_data.xData[0], vc921x_gsensor_data.yData[0], vc921x_gsensor_data.zData[0]); - } - //vc921x_send_orginal_data(&vc921x_dev, &vc921x_gsensor_data, sample_result_info_ptr->slot_result[2].ppg_num); - } - break; - case WORK_MODE_TEMPERATURE: - vc921x_temperature_ntc_calculate(&vc921x_dev); - //vc921x_send_orginal_data(&vc921x_dev, &vc921x_gsensor_data, 1); - //disp_data.temperature_value0 = vc921x_dev.temperature0; - //disp_data.temperature_value1 = vc921x_dev.temperature1; - break; - case WORK_MODE_FACTORY0: - //disp_data.gImx = sample_result_info_ptr->slot_result[0].slot_current; - //disp_data.gPre = sample_result_info_ptr->slot_result[0].u.pre_data; - //disp_data.rImx = sample_result_info_ptr->slot_result[1].slot_current; - //disp_data.rPre = sample_result_info_ptr->slot_result[1].u.pre_data; - //disp_data.ps = sample_result_info_ptr->slot_result[2].u.ps_data; - break; - case WORK_MODE_FACTORY1: - //disp_data.iImx = sample_result_info_ptr->slot_result[0].slot_current; - //disp_data.iPre = sample_result_info_ptr->slot_result[0].u.pre_data; - //disp_data.rImx = sample_result_info_ptr->slot_result[1].slot_current; - //disp_data.rPre = sample_result_info_ptr->slot_result[1].u.pre_data; - break; - case WORK_MODE_HRSPO2: - if (vc921x_drv_is_fifo_event(&vc921x_dev)) - { - ppg_num = sample_result_info_ptr->slot_result[0].ppg_num; - if (ppg_num > 40) - break; - vc921x_get_board_gsensor_data(&gsensor_num, ppg_num); - if (WEAR_STA_HOLD == vc921x_dev.wear) - { - vc921x_dev.heart_rate = vc921x_heart_rate_calculate(&vc921x_dev, 0); - vc921x_dev.spo2 = vc921x_spo2_calculate(&vc921x_dev, 1, 2); - //vc921x_send_orginal_data(&vc921x_dev, &vc921x_gsensor_data, ppg_num); - } - else - { - vc921x_dev.spo2 = 0; - vcSpo2AlgoInit_16bit(); - vcSportMotionAlgoInit(); - vc921x_dev.heart_rate = 0; - Algo_Init(); - } - //disp_data.spo2_val = vc921x_dev.spo2; - //disp_data.hr_rate = vc921x_dev.heart_rate; - } - break; - case WORK_MODE_UNDEFINED: - break; - default: - break; - } - /* 同步处理数据,清理fifo_buffer内存,为下次采样做准备 */ - vc921x_drv_finished_sync(&vc921x_dev); -} - -static const dev_ops vc921x_ops = - { - .dev_init = vc921x_usr_device_init, - .get_dev_info = vc921x_usr_get_dev_info, - .start_work = vc921x_usr_start_work, - .stop_work = vc921x_usr_stop_work, - .soft_reset = vc921x_usr_soft_reset, - .get_events = NULL, - .set_slot_enable = NULL, - .reset_bio_param = vc921x_usr_reset_bio_param, - .get_wear_status = vc921x_usr_get_wear_status, - .dev_irq_handler = vc921x_usr_device_handler, - .dev_check_temp_error = vc921x_usr_check_temperature_abnormal, -}; - -vcare_ppg_device_t *get_vc921x_device(void) -{ - vc921x_dev.ops = &vc921x_ops; - if (vc921x_drv_memroy_alloc()) - { - return NULL; - } - return &vc921x_dev; -} - -/************************************************************************ - * 以下为MCU外设初始化,任务调用 - * example function task_demo_application - ***********************************************************************/ -#if 0 -/* 系统头文件 */ -#include "os_task.h" -//..... -/* 驱动头文件 */ -#include "task_vcare_demo.h" -#include "vc921x_user_app.h" -/* 心率算法头文件 */ -#include "algo.h" - -#define DEMO_TASK_PRIORITY 2 //!< Task priorities -#define DEMO_TASK_STACK_SIZE 1024 * 3 //!< Task stack size -void *demo_task_handle; //!< APP Task handle -void *demo_queue_handle; -static void board_init(void); -void task_demo_application(void *pvParameters) -{ - T_IO_MSG demo_msg; - AlgoSportMode demo_heart_algo_mode = SPORT_TYPE_NORMAL; - unsigned char demo_spo2_algo_mode = 0; - InitParamTypeDef init_config={ 800, WORK_MODE_HR }; - vcare_ppg_device_t *ppg_dev = NULL; - os_msg_queue_create(&demo_queue_handle, 0x10, sizeof(T_IO_MSG)); - /* 通过芯片固定的id寄存器去获取ID,辨别不同的ppg设备,并且获取对应的设备对象 */ - unsigned char id0=0,id1=0; - i2c_read(0x00,&id0,1); - i2c_read(0x01,&id1,1); - if( id0==0x24) /* id0=0x24 */ - { - ppg_dev = get_vc921x_device(); - } - if( ppg_dev ) - { - board_init(); - init_config.work_mode = WORK_MODE_HR; - //init_config.work_mode = WORK_MODE_SPO2; - //init_config.work_mode = WORK_MODE_HRV; - //init_config.work_mode = WORK_MODE_BLOODPRESSURE; - //init_config.work_mode = WORK_MODE_WEAR; - //init_config.work_mode = WORK_MODE_TEMPERATURE; - //init_config.work_mode = WORK_MODE_FACTORY0; - //init_config.work_mode = WORK_MODE_FACTORY1; - ppg_dev->ops->dev_init( &init_config ); - } - while (1) - { - if (os_msg_recv(demo_queue_handle, &demo_msg, 0xFFFFFFFF) == true) - { - switch (demo_msg.subtype) - { - case DEMO_MSG_VC_IRQ_EVENT: - ppg_dev->ops->dev_irq_handler( demo_heart_algo_mode, demo_spo2_algo_mode ); - break; - case DEMO_MSG_KEY_IRQ_EVENT: - //调用初始化切换工作模式,调用ppg_dev->ops->dev_init(...)进行模式切换 - //demo_work_mode_switch(); - break; - case DEMO_MSG_ERR_IRQ: - ppg_device->ops->dev_check_temp_error(); /* 定时校验IC工作状态,并处理异常 */ - break; - default: - break; - } - } - } /* while(1) */ -} - -void task_demo_creat(void) -{ - //example app creat - if (os_task_create(&demo_task_handle, "demo", task_demo_application, NULL, DEMO_TASK_STACK_SIZE, DEMO_TASK_PRIORITY) != true) - { - VCARE_DBG_LOG(" demo_task creat is failed\r\n "); - } -} - -#endif /* end of example function */ diff --git a/code/sdk/zhihui/drivers/rotary_encoder/CMakeLists.txt b/code/sdk/zhihui/drivers/rotary_encoder/CMakeLists.txt index 25532568e..8fbccd694 100644 --- a/code/sdk/zhihui/drivers/rotary_encoder/CMakeLists.txt +++ b/code/sdk/zhihui/drivers/rotary_encoder/CMakeLists.txt @@ -48,6 +48,8 @@ set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/mixo/mixo_ots_driver.c ${CMAKE_CURRENT_SOURCE_DIR}/mixo/mixo_ots_access.c ${CMAKE_CURRENT_SOURCE_DIR}/mixo/mixo_at_cmd.c + ${CMAKE_CURRENT_SOURCE_DIR}/mixo/mixo_hal.c + ${CMAKE_CURRENT_SOURCE_DIR}/mixo/mixo_service.c ) set(PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/mixo diff --git a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.c b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.c new file mode 100644 index 000000000..e4d7dcebb --- /dev/null +++ b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.c @@ -0,0 +1,151 @@ +#include "at_cmd_api.h" +#include "pm_control.h" +#include "rotary_encoder_def.h" +#include "debug_print.h" +#include "mixo_ots_driver.h" +#include "custom_utils.h" +#include "pinctrl_porting.h" +#include "mixo_service.h" + +#define MIXO_INT_PIN S_AGPIO_L0 +#define INT_MODE 1 +#define TIMER_MODE 0 + +static uint8_t g_mixo_test_started = 0; +encoder_callback g_encoder_callback = NULL; + +void mixo_int_callback(pin_t pin, uintptr_t param) +{ + PRINT("mixo_int_callback %d 0x%X\n",pin,param); + uapi_gpio_clear_interrupt(pin); + // uapi_pin_set_ie(MIXO_INT_PIN,HAL_PIO_IE_DISABLE); + mixo_start(); // 启动定时器 +} + +void mixo_check(void) +{ + // if(mixo_get_check_mode() == TIMER_MODE) + mixo_ots_timer_callback(); + // else if(mixo_get_check_mode() == INT_MODE) + // { + // mixo_stop(); // 关闭定时器 + // // uapi_pin_set_ie(MIXO_INT_PIN,HAL_PIO_IE_ENBALE); + // } +} + + +void mixo_suspend(void) +{ + mixo_ots_enter_suspend_mode(1); +} + +void mixo_resume(void) +{ + mixo_ots_enter_suspend_mode(0); +} + + +uint32_t mixo_init(void) +{ + if(mixo_ots_init() != ERRCODE_SUCC) + return ERRCODE_FAIL; + + return ERRCODE_SUCC; +} + +static ext_errno mixo_encoder_init(void *attr) +{ + re_print("mixo_encoder_init\r\n"); + return EXT_ERR_SUCCESS; +} +static ext_errno mixo_encoder_deinit(void) +{ + re_print("mixo_encoder_deinit\r\n"); + return EXT_ERR_SUCCESS; +} +static ext_errno mixo_encoder_get_encoderinfo(uint8_t *data, uint8_t data_len) +{; + if (data_len != sizeof(re_input_event_info)) + return EXT_ERR_NOT_SUPPORT; + re_input_event_info *encoder_info = (re_input_event_info*)data; + int16_t diff = mixo_get_crown_result(); + int16_t stand_still = mixo_get_stand_still(); + // re_print("mixo_encoder_get_encoderinfo diff %d stand_still %d\n",diff,stand_still); + if (stand_still == 1 ) + { + encoder_info->re_event = MC_RE_COVER; + }else { + encoder_info->re_event = MC_RE_MOVE; + } + encoder_info->re_event_info.x_axis[0] = diff; + encoder_info->re_event_info.y_axis[0] = diff; + encoder_info->re_event_info.z_axis[0] = diff; + encoder_info->finger_id = 0 ; + encoder_info->point_num = 0 ; + encoder_info->tv_usec = (uint32_t)uapi_tcxo_get_ms(); + //re_print("mixo_encoder_get_encoderinfo %s rotate %d\r\n",encoder_info->re_event == MC_RE_SLIDE_UP?"MC_RE_SLIDE_UP":"MC_RE_SLIDE_DOWN",diff); + + return EXT_ERR_SUCCESS; +} +static ext_errno mixo_encoder_suspend(void) +{ + re_print("mixo_encoder_suspend\r\n"); + return EXT_ERR_SUCCESS; +} +static ext_errno mixo_encoder_resume(void) +{ + re_print("mixo_encoder_resume\r\n"); + mixo_start(); + return EXT_ERR_SUCCESS; +} +static ext_errno mixo_encoder_sleep(void) +{ + re_print("mixo_encoder_sleep\r\n"); + mixo_stop(); + return EXT_ERR_SUCCESS; +} +static ext_errno mixo_encoder_reset(void) +{ + re_print("mixo_encoder_reset\r\n"); + return EXT_ERR_SUCCESS; +} +static ext_errno mixo_encoder_bus_init(void *private_data) +{ + return EXT_ERR_SUCCESS; +} +static ext_errno mixo_register_callback(void *peri_data, encoder_callback func) +{ + re_print("mixo_register_callback\r\n"); + g_encoder_callback = func; + return EXT_ERR_SUCCESS; +} +static ext_errno mixo_unregister_callback(void *peri_data) +{ + re_print("mixo_unregister_callback\r\n"); + g_encoder_callback = NULL; + return EXT_ERR_SUCCESS; +} + +encoder_peripheral_api g_mixo_api = { + .encoder_init = mixo_encoder_init, + .encoder_deinit = mixo_encoder_deinit, + .encoder_get_encoderinfo = mixo_encoder_get_encoderinfo, + .encoder_suspend = mixo_encoder_suspend, + .encoder_resume = mixo_encoder_resume, + .encoder_sleep = mixo_encoder_sleep, + .encoder_reset = mixo_encoder_reset, + .encoder_bus_init = mixo_encoder_bus_init, + .register_callback = mixo_register_callback, + .unregister_callback = mixo_unregister_callback, +}; + + +void *rotary_encoder_get_mixo_api(void) +{ + return ((void *)&g_mixo_api); +} + +void *rotary_encoder_get_mixo_peri_attr(void) +{ + return ((void *)NULL); +} \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.h b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.h new file mode 100644 index 000000000..e48f5146d --- /dev/null +++ b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_hal.h @@ -0,0 +1,47 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-12-23 15:11:25 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-28 16:52:46 + * @FilePath: /sdk615/code/sdk/zhihui/drivers/rotary_encoder/hx3508/hx3508_hal.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE; + */ +/** + * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n + * + * Description: Provides at cmd register func \n + * Author: @CompanyNameTag \n + * History: \n + * 2022-07-20, Create file. \n + */ +#ifndef MIXO_HAL_H +#define MIXO_HAL_H + +#include +#include +#include "errcode.h" +#include "soc_osal.h" +#include "rotary_encoder_def.h" +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +void *rotary_encoder_get_mixo_api(void); +void *rotary_encoder_get_mixo_peri_attr(void); + +uint32_t mixo_init(void); + +void mixo_check(void); + +void mixo_suspend(void); +void mixo_resume(void); + +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif diff --git a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.c b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.c index 21e6ed824..34c2068dd 100644 --- a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.c +++ b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.c @@ -1,10 +1,10 @@ #include "mixo_ots_driver.h" - #include #include - #include "mixo_ots_access.h" #include "cmsis_os2.h" +#include "debug_print.h" +#include "mixo_hal.h" #ifndef ABS #define ABS(x) ((x) > 0 ? (x) : -(x)) @@ -16,17 +16,59 @@ static int dx_sum = 0; -static bool ots_timer_running = false; //ots定时器是否运行标志 +static uint16_t timer_cnt = 0; + +static int16_t ots_result = 0;//ots结果 +static int16_t stand_still = 1; //静止标志 1 静止,0 转动 + +static uint8_t int_mode = 0; -static osTimerId_t g_ots_timer = NULL; +extern encoder_callback g_encoder_callback; -static void ots_timer_callback(void) +static void put_crown_result(int16_t x) +{ + if(abs(x)<=1 ) + { + return; + } + if(abs(x)>=8 ) + { + ots_result += x/8; //大于4的值除以4, 代表角度, 单位0.5° + } + else + { + if(x>0) + { + ots_result+=1; //2~4 默认一个单位, 0.5° + } + else + { + ots_result-=1; //2~4 默认一个单位, 0.5° + } + } + + if (g_encoder_callback != NULL) + g_encoder_callback(); +} + +static void report_zero_data_for_start_stop_flag(void) +{ + ots_result = 0; + + if (g_encoder_callback != NULL) + g_encoder_callback(); +} + +void mixo_ots_timer_callback(void) { uint8_t mot_status = 0x00; mixo_ots_get_mot_status(&mot_status); + // printf("mot_status:0x%x\n",mot_status); if ((mot_status & 0x80) == 0x80) { + timer_cnt = 0; + int_mode = 0; // Get raw datas raw_data_t raw_data; mixo_ots_get_raw_data(&raw_data); @@ -34,35 +76,46 @@ static void ots_timer_callback(void) // Output raw data // printf("%ld,%d,%d,%d,%d\r\n", timestamp, raw_data.dx, raw_data.dy, mot_status, dx_sum); - } -} + // PRINT("%d,%d,%d,%d\r\n",raw_data.dx, raw_data.dy, mot_status, dx_sum); -void mixo_ots_start(void) -{ - if(ots_timer_running == false && g_ots_timer) - { - osTimerStart(g_ots_timer,10); - ots_timer_running = true; - } -} + // ots_result = raw_data.dx; -void mixo_ots_stop(void) -{ - if(ots_timer_running == true && g_ots_timer) + if (stand_still == 1) + { + //上次是静止,上报状态改变 + report_zero_data_for_start_stop_flag(); + } + stand_still = 0; + + put_crown_result(raw_data.dx); + + // if (g_encoder_callback != NULL) + // g_encoder_callback(); + + } + else { - osTimerStop(g_ots_timer); - ots_timer_running = false; + // timer_cnt++; + // if (timer_cnt == 20) // 20*10 = // 200ms:200ms内sensor没有检测到表冠转动就会关闭定时器重新开启中断响应 + // { + // printf("mixo enter int mode\n"); + // /** + // * 此处注意 mixo_ots_forced_clear_int + // * 必须放在 external_int_init 之前去做 + // * 否则可能造成功耗异常的问题 + // */ + // mixo_ots_forced_clear_int(); // 强制拉高MOT脚 + // int_mode = 1; + // } + if (stand_still == 0) + { + //上次是转动,上报状态改变 + report_zero_data_for_start_stop_flag(); + } + stand_still = 1; } } -void mixo_ots_timer_init(void) -{ - g_ots_timer = osTimerNew((osTimerFunc_t)ots_timer_callback, osTimerPeriodic, NULL, NULL); - - if(!g_ots_timer) - PRINT("g_ots_timer init failed \n"); -} - /** * @brief 接收1byte数据 @@ -142,7 +195,7 @@ int mixo_ots_get_raw_data(raw_data_t* raw_data) // If overflowed, clear out the data if ((ABS(raw_data->dx) == 2047) || (ABS(raw_data->dy) == 2047)) { - printf("dy/dx overflowed."); + // printf("dy/dx overflowed."); mixo_ots_reg_read(0x02, &tmp); mixo_ots_reg_read(0x02, &tmp); @@ -246,10 +299,13 @@ int callisto_2x_init(void) return ret; } - +static uint8_t mixo_installized = 0; int mixo_ots_init(void) { + if(mixo_installized) + return 0; + int rc = 0; uint8_t HardWareId = 0; @@ -269,11 +325,13 @@ int mixo_ots_init(void) break; default: printf("OTS Sensor Not Support!\n"); + rc = -1; break; } if(rc == 0) { + mixo_installized = 1; printf("mixo_ots_init succed !!! \n"); } else @@ -283,3 +341,36 @@ int mixo_ots_init(void) return rc; } +int16_t mixo_get_stand_still(void) +{ + return stand_still; +} + +void mixo_clean_result(void) +{ + ots_result = 0; +} + + +int16_t mixo_get_crown_result(void) +{ + int16_t resulttemp; + resulttemp=ots_result; + ots_result = 0; + return resulttemp; +} + +uint8_t mixo_get_check_mode(void) +{ + return int_mode; +} + + +void mixo_get_chip_id(uint16_t *id) +{ + mixo_ots_enter_suspend_mode(0); + uint8_t chip_id[2] = {0}; + mixo_ots_reg_read(0x00, &chip_id[0]); // Read chip-id high byte + mixo_ots_reg_read(0x01, &chip_id[1]); // Read chip-id low byte + *id = (chip_id[0] & 0XFF) << 8 | (chip_id[1] & 0XFF); +} \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.h b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.h index 5093bb2ee..9bfa28928 100644 --- a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.h +++ b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.h @@ -1,3 +1,11 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2025-01-04 10:53:54 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-28 16:51:32 + * @FilePath: /sdk615/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_ots_driver.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ /* * Copyright (c) 2019 MixoSense Technology Ltd . * @@ -26,4 +34,14 @@ int mixo_ots_get_raw_data(raw_data_t* raw_data); void mixo_ots_forced_clear_int(void); void mixo_ots_enter_suspend_mode(uint8_t true_or_false); +void mixo_ots_start(void); +void mixo_ots_stop(void); + +int16_t mixo_get_stand_still(void); +int16_t mixo_get_crown_result(void); +void mixo_ots_timer_callback(void); +void mixo_clean_result(void); +uint8_t mixo_get_check_mode(void); +void mixo_get_chip_id(uint16_t *id); + #endif //_MXS_DRIVER_H_ diff --git a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.c b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.c new file mode 100644 index 000000000..ad62a5b46 --- /dev/null +++ b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.c @@ -0,0 +1,157 @@ + +#include "debug_print.h" +#include "soc_osal.h" +#include "tcxo.h" +#include "irmalloc.h" +#include "errcode.h" +#include "common_def.h" +#include "tcxo.h" +#include "input_app.h" +#include "cmsis_os2.h" +#include "custom_utils.h" +#include "mixo_hal.h" +#include "mixo_service.h" +#include "pinctrl_porting.h" + +// #include "custom_runtime.h" +/*** + * 其他cmd在Header里定义,对外开放 +*/ +#define MIXO_SERVICE_CMD_TIMER_CHECK 0x11 + +#define MIXO_SERVICE_TIMER_CHECK_MS 20 + +static bool g_mixo_service_initialled = false; + +static bool g_mixo_sensor_exist = false; + +static unsigned long g_app_queue= 0xFFFFFFFF; + +static bool mixo_service_timer_running = false; //ots定时器是否运行标志 + +static osTimerId_t g_mixo_service_timer = NULL; + +void do_mixo_service_check_msg(int cmd); + +static void mixo_service_timer_callback(void) +{ + do_mixo_service_check_msg(MIXO_SERVICE_CMD_TIMER_CHECK); +} + +void mixo_service_timer_start(void) +{ + if(mixo_service_timer_running == false && g_mixo_service_timer) + { + mixo_resume(); + osTimerStart(g_mixo_service_timer,MIXO_SERVICE_TIMER_CHECK_MS); + mixo_service_timer_running = true; + } +} + +void mixo_service_timer_stop(void) +{ + if(mixo_service_timer_running == true && g_mixo_service_timer) + { + mixo_suspend(); + // mixo_clean_result(); + osTimerStop(g_mixo_service_timer); + mixo_service_timer_running = false; + } +} + +void mixo_start(void) +{ + do_mixo_service_check_msg(MIXO_SERVICE_CMD_START_CHECK); +} + +void mixo_stop(void) +{ + do_mixo_service_check_msg(MIXO_SERVICE_CMD_STOP_CHECK); +} + + +void do_mixo_service_check_msg(int cmd) +{ + int ret; + if (g_mixo_sensor_exist == false) + return ; + common_notify_mail_t mail = {0}; + mail.comm.app = cmd; + ret = osal_msg_queue_write_copy(g_app_queue, (void *)&mail, + sizeof(common_notify_mail_t), 0); + if (ret != OSAL_SUCCESS) { + PRINT("Error mixo Check MSG 0x%02X send failed! err=0x%x! \r\n",cmd, ret); + } + +} + +static void mixo_service_check_task(void const *arg) +{ + unused(arg); + int32_t ret; + common_notify_mail_t mail; + uint32_t msgsize = (uint32_t)sizeof(common_notify_mail_t); + while (1) { + ret = osal_msg_queue_read_copy(g_app_queue, (void *)&mail, &msgsize, + OSAL_MSGQ_WAIT_FOREVER); + if (ret != OSAL_SUCCESS) { + continue; + } + + if (mail.comm.app == MIXO_SERVICE_CMD_TIMER_CHECK) { + mixo_check(); + }else if (mail.comm.app == MIXO_SERVICE_CMD_START_CHECK){ + mixo_service_timer_start(); + }else if (mail.comm.app == MIXO_SERVICE_CMD_STOP_CHECK){ + mixo_service_timer_stop(); + } + + + } +} +void create_mixo_queue(void) +{ + + if (osal_msg_queue_create("mixo_service_queue", APP_BOARD_MSG_COUNT, &g_app_queue, + 0, sizeof(common_notify_mail_t)) != ERRCODE_SUCC) { + PRINT("[mixo][service] app create mail fail\n"); + } +} + +#define MIXO_BOARD_TASK_SIZE 0x1000 +errcode_t uapi_mixo_service_init(void) +{ + PRINT("uapi_mixo_service_init !\r\n"); + + if(mixo_init() != ERRCODE_SUCC) + { + //TODO 设置光电编码器检测是否存在标识 + PRINT("mixo not found!\r\n"); + return ERRCODE_FAIL; + } + g_mixo_sensor_exist = true; + + app_task_definition_t taskcfg={0}; + taskcfg.create_queue_handle = create_mixo_queue; + taskcfg.attr.name="mixo_service"; + taskcfg.attr.priority = osPriorityNormal1; + taskcfg.attr.stack_size = MIXO_BOARD_TASK_SIZE; + taskcfg.func = mixo_service_check_task; + taskcfg.use_mem = USE_EXTEND_MEM; + + errcode_t ret=uapi_create_osThread_custom(&taskcfg); + if(ret != ERRCODE_SUCC) + { + PRINT("create mixo_service failed %d!\r\n",ret); + return ERRCODE_FAIL; + } + + // mixo_init(); + + g_mixo_service_timer = osTimerNew((osTimerFunc_t)mixo_service_timer_callback, osTimerPeriodic, NULL, NULL); + + mixo_start(); + + return ERRCODE_SUCC; +} + diff --git a/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.h b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.h new file mode 100644 index 000000000..98b91d0ac --- /dev/null +++ b/code/sdk/zhihui/drivers/rotary_encoder/mixo/mixo_service.h @@ -0,0 +1,45 @@ +/* + * @Author: penglei 1624952103@qq.com + * @Date: 2024-12-23 15:12:01 + * @LastEditors: penglei 1624952103@qq.com + * @LastEditTime: 2025-07-28 16:55:36 + * @FilePath: /sdk615/code/sdk/zhihui/drivers/mixo/service/mixo_service.h + * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE + */ +/** + * Copyright (c) @CompanyNameMagicTag 2022-2022. All rights reserved. \n + * + * Description: Test adc header \n + * Author: @CompanyNameTag \n + * History: \n + * 2022-08-16, Create file. \n + */ + +#ifndef MIXO_SERVICE_H__ +#define MIXO_SERVICE_H__ + +#ifdef __cplusplus +#if __cplusplus +extern "C" { +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#include "stdint.h" +#include "errcode.h" +#include "platform_core.h" + +#define MIXO_SERVICE_CMD_START_CHECK 0x12 +#define MIXO_SERVICE_CMD_STOP_CHECK 0x13 + +errcode_t uapi_mixo_service_init(void); +void uapi_mixo_service_deinit(void); +void do_mixo_service_check_msg(int cmd); +void mixo_start(void); +void mixo_stop(void); +#ifdef __cplusplus +#if __cplusplus +} +#endif /* __cplusplus */ +#endif /* __cplusplus */ + +#endif \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/rotary_encoder/rotary_encoder_drv.c b/code/sdk/zhihui/drivers/rotary_encoder/rotary_encoder_drv.c index 6d1e53190..d729f2895 100644 --- a/code/sdk/zhihui/drivers/rotary_encoder/rotary_encoder_drv.c +++ b/code/sdk/zhihui/drivers/rotary_encoder/rotary_encoder_drv.c @@ -13,17 +13,12 @@ #include "rotary_encoder_def.h" #include "input_app.h" -#ifdef ROTARYENCODER_HX3507 +#ifdef ROTARYENCODER_MIXO +#include "mixo_hal.h" +#elif defined ROTARYENCODER_HX3507 #include "hx3507_hal.h" #endif -#ifdef ROTARYENCODER_HX3508 -#include "hx3508_hal.h" -#endif - -#ifdef ROTARYENCODER_U8 -#include "crown_hal.h" -#endif // #if defined(TPTYPE_TMA525B) // #include "tma525b_drv1.h" // #include "tma525b_ctrl.h" @@ -425,12 +420,9 @@ uint32_t re_init(void) #ifdef ROTARYENCODER_HX3507 g_encoder_drv.private_data = rotary_encoder_get_hx3507_peri_attr(); g_encoder_drv.encoder_api = rotary_encoder_get_hx3507_api(); -#elif defined ROTARYENCODER_HX3508 - g_encoder_drv.private_data = rotary_encoder_get_hx3508_peri_attr(); - g_encoder_drv.encoder_api = rotary_encoder_get_hx3508_api(); -#elif defined ROTARYENCODER_U8 - g_encoder_drv.private_data = rotary_encoder_get_crown_peri_attr(); - g_encoder_drv.encoder_api = rotary_encoder_get_crown_api(); +#elif defined ROTARYENCODER_MIXO + g_encoder_drv.private_data = rotary_encoder_get_mixo_peri_attr(); + g_encoder_drv.encoder_api = rotary_encoder_get_mixo_api(); #endif g_encoder_drv.ops = &g_re_status_ops; redd = rotary_encoder_get_driver_data(); @@ -471,10 +463,8 @@ void rotary_encoder_suspend(void) /**灭屏,关闭Encoder*/ #ifdef ROTARYENCODER_HX3507 encoder_ptr = rotary_encoder_get_hx3507_api(); -#elif defined ROTARYENCODER_HX3508 - encoder_ptr = rotary_encoder_get_hx3508_api(); -#elif defined ROTARYENCODER_U8 - encoder_ptr = rotary_encoder_get_crown_api(); +#elif defined ROTARYENCODER_MIXO + encoder_ptr = rotary_encoder_get_mixo_api(); #endif if(encoder_ptr == NULL) return; @@ -488,10 +478,8 @@ void rotary_encoder_resume(void) #ifdef ROTARYENCODER_HX3507 /**亮屏,恢复Encoder工作*/ encoder_ptr = (encoder_peripheral_api*)rotary_encoder_get_hx3507_api(); -#elif defined ROTARYENCODER_HX3508 - encoder_ptr = (encoder_peripheral_api*)rotary_encoder_get_hx3508_api(); -#elif defined ROTARYENCODER_U8 - encoder_ptr = (encoder_peripheral_api*)rotary_encoder_get_crown_api(); +#elif defined ROTARYENCODER_MIXO + encoder_ptr = (encoder_peripheral_api*)rotary_encoder_get_mixo_api(); #endif if(encoder_ptr == NULL) return; @@ -518,4 +506,13 @@ void rotary_encoder_restart(void) // uapi_i2c_master_init(TOUCH_I2C_BUS, 400000, I2C_SPEED_MODE_FS); /* 400000: 400KHz */ re_err("rotary_encoder_restart ----------succ!!!\n"); +} + +void rotary_get_chip_id(uint16_t *id) +{ +#ifdef ROTARYENCODER_HX3507 + crown_read_id(id); +#elif defined ROTARYENCODER_MIXO + mixo_get_chip_id(id); +#endif } \ No newline at end of file diff --git a/code/sdk/zhihui/drivers/rotary_encoder/rotary_encoder_drv.h b/code/sdk/zhihui/drivers/rotary_encoder/rotary_encoder_drv.h index 3a37a05fd..ba50d8c61 100644 --- a/code/sdk/zhihui/drivers/rotary_encoder/rotary_encoder_drv.h +++ b/code/sdk/zhihui/drivers/rotary_encoder/rotary_encoder_drv.h @@ -11,6 +11,14 @@ #include "soc_osal.h" #include "rotary_encoder_queue1.h" +#ifdef ROTARYENCODER_HX3507 +#define ROTARY_CHIP_ID 0x30 +#elif defined ROTARYENCODER_MIXO +#define ROTARY_CHIP_ID 0x585b +#else +#define ROTARY_CHIP_ID 0 +#endif + struct re_driver_data { osal_task *task_handle; osal_event event; @@ -29,5 +37,6 @@ struct re_ops { ext_errno rotary_encoder_module_init(void); ext_errno rotary_encoder_module_deinit(void); ext_errno encoder_info_process(void); +void rotary_get_chip_id(uint16_t *id); #endif \ No newline at end of file diff --git a/code/sdk/zhihui/services/battery/service/battery_driver.cpp b/code/sdk/zhihui/services/battery/service/battery_driver.cpp index 31fca19dc..9baeccaa9 100644 --- a/code/sdk/zhihui/services/battery/service/battery_driver.cpp +++ b/code/sdk/zhihui/services/battery/service/battery_driver.cpp @@ -805,7 +805,7 @@ bool batteryservice_get_voltage_by_channel(float *voltage, uint8_t channel) #define GPIO_PIN_CHARGE_STAT S_AGPIO_L29 void disable_charge(void) { -#if defined(BOARD_FD230) || defined(BOARD_W9) +#if defined(BOARD_FD230) || defined(BOARD_W9) || defined(BOARD_N9) // PRINT("disable_charge\r\n"); uapi_pin_set_mode(GPIO_PIN_ENABLE_CHARGE, (pin_mode_t)HAL_PIO_FUNC_GPIO); uapi_gpio_set_dir(GPIO_PIN_ENABLE_CHARGE, GPIO_DIRECTION_OUTPUT); @@ -818,7 +818,7 @@ void disable_charge(void) void enable_charge(void) { -#if defined(BOARD_FD230) || defined(BOARD_W9) +#if defined(BOARD_FD230) || defined(BOARD_W9) || defined(BOARD_N9) // PRINT("enable_charge\r\n"); uapi_pin_set_mode(GPIO_PIN_ENABLE_CHARGE, (pin_mode_t)HAL_PIO_FUNC_GPIO); uapi_gpio_set_dir(GPIO_PIN_ENABLE_CHARGE, GPIO_DIRECTION_OUTPUT); @@ -832,7 +832,7 @@ void enable_charge(void) void enable_02c(void) { -#if defined(BOARD_FD230) || defined(BOARD_W9) +#if defined(BOARD_FD230) || defined(BOARD_W9) || defined(BOARD_N9) // PRINT("enable_charge_02c\r\n"); uapi_pin_set_mode(GPIO_PIN_ENABLE_CHARGE_0_2C, (pin_mode_t)HAL_PIO_FUNC_GPIO); uapi_gpio_set_dir(GPIO_PIN_ENABLE_CHARGE_0_2C, GPIO_DIRECTION_OUTPUT); @@ -852,7 +852,7 @@ uint8_t get_02c_value(void) } void disable_02c(void) { -#if defined(BOARD_FD230) || defined(BOARD_W9) +#if defined(BOARD_FD230) || defined(BOARD_W9) || defined(BOARD_N9) // PRINT("disable_charge_02c\r\n"); uapi_pin_set_mode(GPIO_PIN_ENABLE_CHARGE_0_2C, (pin_mode_t)HAL_PIO_FUNC_GPIO); uapi_gpio_set_dir(GPIO_PIN_ENABLE_CHARGE_0_2C, GPIO_DIRECTION_OUTPUT); diff --git a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp index 2019a9e75..b92fcd044 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/bleInstruct.cpp @@ -24,7 +24,12 @@ #include "dirent.h" #include "custom_utils.h" -// #include "cywee_hal.h" +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_hal.h" +#include "cywee_data.h" +#endif + + // #include "font/base_font.h" // #include "uicomponents/UIComponents.h" @@ -391,7 +396,7 @@ void install_Register_dial( char * name,uint16_t id) void delete_before_file(uint8_t type) { - #ifdef CYWEE_SPORT +#ifdef SUPPORT_CYWEE_SERVICE time_t currtime; struct tm *timeinfo; time(&currtime); @@ -515,7 +520,7 @@ void delete_before_file(uint8_t type) char * ble_sywee_history(uint8_t day,uint16_t *len ,uint8_t type) { - #ifdef CYWEE_SPORT +#ifdef SUPPORT_CYWEE_SERVICE char path_[64]={0}; char timeday[12] = {0}; uapi_get_YYMMDD_Time_extend(timeday, '_',day); diff --git a/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp b/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp index 5551e854c..e7518122f 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/ble_congfig_adapt.cpp @@ -11,7 +11,9 @@ #include "ui_service.h" #include "custom_utils.h" - +#ifdef SUPPORT_CYWEE_SERVICE +#include "cywee_service.h" +#endif void set_ota_upgrade_(void) { @@ -204,7 +206,7 @@ void set_user_data_(msg_user_info_t *data) if(data->distance) p_ConfigModel->set_condigData_Int(OHOS::ConfigModel::CONFIGMODEL_ITEM_SPORTS_GOAL_DISTANCE,data->distance); -#ifdef CYWEE_SPORT +#ifdef SUPPORT_CYWEE_SERVICE do_cywee_service_check_msg(CYWEE_SERVICE_CMD_SET_USER_INFO, NULL); #endif diff --git a/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp b/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp index 2e9c9dad1..17f039e2a 100644 --- a/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp +++ b/code/sdk/zhihui/services/ble_service/blemoder/bleinstruct_sample.cpp @@ -723,13 +723,13 @@ char * dir_to_json_buf_malloc_(uint8_t type) uint8_t ble_AT_add_nap_data(uint16_t time) { - OHOS::NAP_T data; - data.total_time=time; - uint32_t creationTime; - int ret =uapi_get_timestampe_ss(&creationTime); - data.fall_asleep_timestamp=creationTime-60*60; - data.wake_up_timestamp=creationTime; - set_nap_data(&data); + // OHOS::SLEEP_T data; + // data.total_time=time; + // uint32_t creationTime; + // int ret =uapi_get_timestampe_ss(&creationTime); + // data.fall_asleep_timestamp=creationTime-60*60; + // data.wake_up_timestamp=creationTime; + // set_nap_data(&data); } uint8_t ble_get_sleep_data(uint32_t file_size,uint8_t day_,uint8_t *data) diff --git a/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c b/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c index fe67e5dbb..f1b5a4131 100644 --- a/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c +++ b/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-17 14:31:08 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-07-14 15:28:33 + * @LastEditTime: 2025-07-28 16:50:17 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -19,16 +19,19 @@ #include "app_common_api.h" #include "lcd_private.h" #include "app_at_process.h" +#include "cywee_hal.h" #ifdef SUPPORT_PPG_SERVICE #include "ppg_service.h" +#include "ppg_hal.h" #endif + #include "button_porting.h" #ifdef SUPPORT_CAT1_SERVICE #include "cat1_ctl.h" #include "cat1_server.h" #endif -#ifdef SUPPORT_PPG_SERVICE +#ifdef PPG_HX3695 #include "hx3695.h" #include "hx3695_hrs_agc.h" #include "hx3695_spo2_agc.h" @@ -46,10 +49,7 @@ #endif #include "battery_service.h" -#ifdef SUPPORT_CYWEE_SERVICE #include "cywee_service.h" -#include "cywee_hal.h" -#endif #include "broadcast_feature.h" #ifdef SUPPORT_TCPIP #include "lwip/api_shell.h" @@ -62,12 +62,10 @@ #include "lqbp_service.h" #include "lqbp002ta.h" #endif -#ifdef ENABLE_HP4507 +#ifdef ENABLE_HP4570 #include "hp4570.h" #endif -#ifdef PPG_VC9202 -#include "vc9202_user.h" -#endif + #ifdef SUPPORT_GNSS #include "gnss_ctl.h" #include "NMEA0183.h" @@ -78,6 +76,14 @@ static gps_data_t send_gps_data = {0}; #include "bp_ble_service.h" #endif +#ifdef ENABLE_GYRO +#include "gyro_service.h" +#include "gyro_hal.h" +#endif + +#include "touch_screen_drv.h" +#include "rotary_encoder_drv.h" + #pragma pack(1) typedef struct factorytest_cmd_header_t { @@ -105,8 +111,7 @@ static osTimerId_t g_ble_acc_timer = NULL; static int aging_time = 0; static uint8_t pwr_button_result = 0; -static uint8_t func_button_result = 0; -static uint8_t func2_button_result = 0; +static uint8_t func_button_result = 1; errcode_t factorytest_protocol_replymsg(uint8_t mode, uint8_t submode,uint8_t testitem, uint8_t *input_data,uint16_t input_len) @@ -167,19 +172,6 @@ static void func_button_callback_long_press_2s(void) func_button_result = 2; } -static void func2_button_callback_press(void) -{ - func2_button_result = 1; -} -static void func2_button_callback_click_2(void) -{ - func2_button_result = 3; -} -static void func2_button_callback_long_press_2s(void) -{ - func2_button_result = 2; -} - void ble_vibrator_check_timer_callback(void) { // uapi_vibrationModeSet(3); @@ -304,8 +296,8 @@ void aging_task(void) // /*********************TP 老化测试*****************************/ //读TP ID uint16_t tp_id; - touch_getid(&tp_id); - if(tp_id != 0x6456) + touch_get_chip_id(&tp_id); + if(tp_id != TP_CHIP_ID) { aging_t.tp_error++; aging_t.fail_num++; @@ -314,22 +306,18 @@ void aging_task(void) /*********************表冠 老化测试*****************************/ //读crown ID -#ifdef ROTARYENCODER_HX3507 - PRINT("crown_read_reg : %X \n",crown_read_reg(0x00)); - if(!(crown_read_reg(0x00) == 0x30)) + uint16_t crown_id = 0; + rotary_get_chip_id(&crown_id); + if(crown_id != ROTARY_CHIP_ID) { aging_t.crown_error++; aging_t.fail_num++; } -#endif PRINT("表冠 失败次数 : %d \r\n",aging_t.crown_error); /*********************充电 老化测试*****************************/ - bool state; - state = uapi_get_charger_plug_status(); - PRINT("充电 uapi_get_charger_plug_status() : %d \r\n",uapi_get_charger_plug_status()); - if(!uapi_get_charger_plug_status()) + if(!get_charge_stat()) { aging_t.charge_error++; aging_t.fail_num++; @@ -355,7 +343,7 @@ void aging_task(void) custom_VibratorFunc_int(4); LOS_Msleep(4000); // uapi_get_timestampe_ss(&age_time); - PRINT("current_time - enter_time[%d]\n",current_time - enter_time); + // PRINT("current_time - enter_time[%d]\n",current_time - enter_time); }while(current_time - enter_time <= 2 * 60); PRINT("马达失败次数 : %d \r\n",aging_t.motor_error); @@ -388,7 +376,7 @@ void aging_task(void) LOS_Msleep(2000); uapi_check_spk(0); aging_t.speaker_error = 0; - PRINT("current_time - enter_time[%d]\n",current_time - enter_time); + // PRINT("current_time - enter_time[%d]\n",current_time - enter_time); }while(current_time - enter_time <= 2 * 60); PRINT("spk失败次数 : %d \r\n",aging_t.speaker_error); /*********************ppg 老化测试*****************************/ @@ -406,24 +394,23 @@ void aging_task(void) return; } uapi_get_timestampe_ss(¤t_time); + + uint32_t green = 0; + uint32_t red = 0; + uint32_t ir = 0; + #ifdef SUPPORT_PPG_SERVICE - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SINGLE_CHECK_MODE_TEST); -#endif - LOS_Msleep(200); - #ifdef SUPPORT_PPG_SERVICE - FT_RESULTS_t ft_result = hx3695_factroy_test(SINGLE_CHECK_TEST); - #endif -#ifdef SUPPORT_PPG_SERVICE + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST); + LOS_Msleep(2000); + ppg_get_leaklight_data(&green,&red,&ir); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); #endif - #ifdef SUPPORT_PPG_SERVICE - PRINT("ft_result.gr_data_final : %d , ft_result.red_data_final : %d , ft_result.ir_data_final : %d\r\n",ft_result.gr_data_final,ft_result.red_data_final,ft_result.ir_data_final); - if(!(ft_result.gr_data_final && ft_result.red_data_final && ft_result.ir_data_final)) + PRINT("green : %d , red : %d , ir : %d\r\n",green,red,ir); + if(!green && !red && !ir) { aging_t.ppg_error++; aging_t.fail_num++; } - #endif PRINT("current_time - enter_time[%d]\n",current_time - enter_time); }while(current_time - enter_time <= 2 * 60); @@ -445,19 +432,21 @@ void aging_task(void) return; } uapi_get_timestampe_ss(¤t_time); +#ifdef SUPPORT_CYWEE_SERVICE cywee_get_gsensor_data(1,&g); +#endif if(g.x == 0 && g.y == 0 && g.z == 0) { aging_t.gsensor_error++; aging_t.fail_num++; } LOS_Msleep(1000); - PRINT("current_time - enter_time[%d]\n",current_time - enter_time); + // PRINT("current_time - enter_time[%d]\n",current_time - enter_time); }while(current_time - enter_time <= 2 * 60); PRINT("gsensor失败次数 : %d \r\n",aging_t.gsensor_error); /*********************磁力计 老化测试*****************************/ - float fAzimuth = 0; + float fAzimuth,fPitch,fRoll; total_time = 2 * 60; enter_time = 0; @@ -472,15 +461,19 @@ void aging_task(void) return; } uapi_get_timestampe_ss(¤t_time); - // mmc5603_getdata(&fAzimuth); + do_mag_service_check_msg(MAG_SERVICE_CMD_START_CHECK); + LOS_Msleep(1000); +#ifdef SUPPORT_MAG_SERVICE fAzimuth = mag_get_fAzimuth(); +#endif + do_mag_service_check_msg(MAG_SERVICE_CMD_STOP_CHECK); if(fAzimuth < 0) { aging_t.mag_error++; aging_t.fail_num++; } LOS_Msleep(1000); - PRINT("current_time - enter_time[%d]\n",current_time - enter_time); + // PRINT("current_time - enter_time[%d]\n",current_time - enter_time); }while(current_time - enter_time <= 2 * 60); PRINT("磁力计失败次数 : %d \r\n",aging_t.mag_error); @@ -553,31 +546,18 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t factorytest_mode_flag = 1; -#ifdef FD230 ChargerEventPublish(TOPIC_EVENT_CHARGE_UNPLUG,0); //进入产测模式 关闭充电弹窗 uapi_dev_runtime_set_factory_test_status(1); //设置产测模式runtime svr_ble_adv_factory_test_start_param(); //设置蓝牙广播 避免出现连接问题 - - // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_SET_FACTORY_BLE_ADV,NULL,0); -#endif + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_COMMON, BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE, 0x01, &send_data, 1); -#ifdef FD230 uapi_hfp_connect_(); - // uint8_t cmd = BR_HFP_CONNECT; - - // cmd = BR_A2DP_CONNECT; - // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&cmd,sizeof(cmd)); - LOS_Msleep(500); - - // cmd = BR_A2DP_CONNECT; - // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_BR_CONNECT,&cmd,sizeof(cmd)); uapi_a2dp_snk_connect_(); -#endif } else if (testitem == 0x02) { @@ -642,19 +622,21 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t if(id != 0x44) send_data[1] |= 1 << 1; - uint8_t mmc_id; + unsigned char mmc_id; #ifdef SUPPORT_MAG_SERVICE - mmc_id = mag_get_chip_id(); + mmc_id = mag_get_chip_id(); #endif if(mmc_id != 0x10) send_data[1] |= 2 << 4; - touch_getid(&tp_id); + touch_get_chip_id(&tp_id); + PRINT("touch_getid : %2X \r\n",tp_id); - if(tp_id != 0x6456) + if(tp_id != TP_CHIP_ID) send_data[1] |= 1 << 4; - - // uapi_ppg_get_id(&id); +#ifdef SUPPORT_PPG_SERVICE + id = ppg_get_chip_id(); +#endif if(id != 0x65) send_data[1] |= 1 << 3; @@ -740,10 +722,8 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t { uint8_t send_data = 0x00; - #ifdef SUPPORT_PPG_SERVICE send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST); - #endif uapi_set4GCapability(false); @@ -756,9 +736,7 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t { uint8_t send_data = 0x00; - #ifdef SUPPORT_CYWEE_SERVICE do_cywee_service_check_msg(CYWEE_SERVICE_CMD_STOP_ACC,NULL); - #endif stop_custom_ble_service(); LOS_Msleep(50); uapi_set4GCapability(false); @@ -887,7 +865,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint if(g_ble_vibrator_timer != NULL) { osTimerStop(g_ble_vibrator_timer); - // osTimerDelete(g_ble_vibrator_timer); } factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_VIBRATOR, @@ -905,7 +882,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint pwr_button_result = 0; func_button_result = 0; - func2_button_result = 0; + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, 0x01, @@ -988,34 +965,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint &send_data, 1); } - else if(testitem == 0x08) - { - //开启功能键2测试 - uint8_t send_data = 0; - - uapi_button_unregister_event_cb(BUTTON2_CLICKUP_2); - uapi_button_unregister_event_cb(BUTTON2_LONGPRESS_2S); - - uapi_button_register_event_cb(func2_button_callback_press, BUTTON2_CLICKUP); - uapi_button_register_event_cb(func2_button_callback_click_2, BUTTON2_CLICKUP_2); - uapi_button_register_event_cb(func2_button_callback_long_press_2s, BUTTON2_LONGPRESS_2S); - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, - 0x08, - &send_data, - 1); - } else if(testitem == 0x09) - { - //查询功能键2测试结果 - uint8_t send_data = func2_button_result; - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_KEY, - 0x09, - &send_data, - 1); - } break; @@ -1094,10 +1043,12 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //查询老化标志 uint8_t send_data[3] = {0}; + do_custom_fileoperate_service_check_msg(CUSTOM_FILEOPERATE_MSG_TYPE_AGING_DATA_READ, NULL, 0); + LOS_Msleep(500); - send_data[1] = aging_t.flag; + send_data[1] = aging_result_t.flag; - if(aging_t.fail_num != 0) + if(aging_result_t.fail_num != 0) { send_data[2] = 0x01; } @@ -1324,7 +1275,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //获取TP_ID uint16_t id = 0; uint8_t tp_id[3]; - touch_getid(&id); + + touch_get_chip_id(&id); tp_id[0] = 0; tp_id[1] = id >> 8; @@ -1379,7 +1331,9 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //获取原始数据 int16_t x,y; - // get_tp_info(&x,&y); +#ifdef TPTYPE_FT6X46 + get_tp_info(&x,&y); +#endif uint8_t databuf[5] = {0}; databuf[1] = (uint8_t)((x & 0XFF00) >> 8); @@ -1468,7 +1422,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint if(testitem == 0x01) { //获取 ppg_id - uint16_t ppg_id; + uint8_t ppg_id; #ifdef SUPPORT_PPG_SERVICE ppg_id = ppg_get_chip_id(); #endif @@ -1477,7 +1431,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, 0x01, &ppg_id, - 2); + 1); } else if(testitem == 0x02) { @@ -1493,32 +1447,44 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 1); } else if(testitem == 0x03) { - //打开心率检测 -#ifdef SUPPORT_PPG_SERVICE - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SINGLE_CHECK_MODE_TEST); -#elif defined PPG_VC9202 - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_TEST); -#endif - LOS_Msleep(500); + //获取绿灯数据 uint8_t databuf[4] = {0}; -#ifdef SUPPORT_PPG_SERVICE +#ifdef BOARD_FD230 +#ifdef PPG_HX3695 + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SINGLE_CHECK_MODE_TEST); + LOS_Msleep(2000); FT_RESULTS_t ft_result = hx3695_factroy_test(SINGLE_CHECK_TEST); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); + databuf[0] = (uint8_t)((ft_result.gr_data_final & 0xFF000000) >> 24); databuf[1] = (uint8_t)((ft_result.gr_data_final & 0x00FF0000) >> 16); databuf[2] = (uint8_t)((ft_result.gr_data_final & 0x0000FF00) >> 8); databuf[3] = (uint8_t)((ft_result.gr_data_final & 0x000000FF) >> 0); -#elif defined PPG_VC9202 - uint32_t ppg_data = vc9202_get_hr_ppg_data(); - PRINT("ppg_data : %d \n",ppg_data); - databuf[0] = (uint8_t)((ppg_data & 0xFF000000) >> 24); - databuf[1] = (uint8_t)((ppg_data & 0x00FF0000) >> 16); - databuf[2] = (uint8_t)((ppg_data & 0x0000FF00) >> 8); - databuf[3] = (uint8_t)((ppg_data & 0x000000FF) >> 0); + + PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, + 0x03, + databuf, + 4); +#endif +#elif defined BOARD_N9 + int32_t data = 0; +#ifdef SUPPORT_PPG_SERVICE + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_TEST); + LOS_Msleep(2000); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); + data = ppg_get_factory_data(); #endif + PRINT("%d\r\n",data); - #ifdef SUPPORT_PPG_SERVICE - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); - #endif + + databuf[0] = (uint8_t)((data & 0xFF000000) >> 24); + databuf[1] = (uint8_t)((data & 0x00FF0000) >> 16); + databuf[2] = (uint8_t)((data & 0x0000FF00) >> 8); + databuf[3] = (uint8_t)((data & 0x000000FF) >> 0); +#endif PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); @@ -1530,55 +1496,50 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x04) { - //打开血氧检测 -#ifdef SUPPORT_PPG_SERVICE + uint8_t databuf[4] = {0}; +#ifdef BOARD_FD230 +#ifdef PPG_HX3695 send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SINGLE_CHECK_MODE_TEST); -#elif defined PPG_VC9202 - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST); -#endif LOS_Msleep(500); - uint8_t databuf[8] = {0}; -#ifdef SUPPORT_PPG_SERVICE FT_RESULTS_t ft_result = hx3695_factroy_test(SINGLE_CHECK_TEST); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); + databuf[0] = (uint8_t)((ft_result.red_data_final & 0xFF000000) >> 24); databuf[1] = (uint8_t)((ft_result.red_data_final & 0x00FF0000) >> 16); databuf[2] = (uint8_t)((ft_result.red_data_final & 0x0000FF00) >> 8); databuf[3] = (uint8_t)((ft_result.red_data_final & 0x000000FF) >> 0); -#elif defined PPG_VC9202 - uint32_t red_data = 0; - uint32_t ir_data = 9; - vc9202_get_spo2_ppg_data(&ir_data,&red_data); - PRINT("ir_data : %d ,red_data : %d \n",ir_data,red_data); - databuf[0] = (uint8_t)((ir_data & 0xFF000000) >> 24); - databuf[1] = (uint8_t)((ir_data & 0x00FF0000) >> 16); - databuf[2] = (uint8_t)((ir_data & 0x0000FF00) >> 8); - databuf[3] = (uint8_t)((ir_data & 0x000000FF) >> 0); - - databuf[4] = (uint8_t)((red_data & 0xFF000000) >> 24); - databuf[5] = (uint8_t)((red_data & 0x00FF0000) >> 16); - databuf[6] = (uint8_t)((red_data & 0x0000FF00) >> 8); - databuf[7] = (uint8_t)((red_data & 0x000000FF) >> 0); #endif - #ifdef SUPPORT_PPG_SERVICE +#elif defined BOARD_N9 + //获取红灯数据 + int32_t data = 0; +#ifdef SUPPORT_PPG_SERVICE + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST); + LOS_Msleep(2000); send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); - #endif + data = ppg_get_factory_data(); +#endif + PRINT("%d\r\n",data); + + + databuf[0] = (uint8_t)((data & 0xFF000000) >> 24); + databuf[1] = (uint8_t)((data & 0x00FF0000) >> 16); + databuf[2] = (uint8_t)((data & 0x0000FF00) >> 8); + databuf[3] = (uint8_t)((data & 0x000000FF) >> 0); +#endif PRINT("%2X %2X %2X %2X \r\n",databuf[0],databuf[1],databuf[2],databuf[3]); - PRINT("%2X %2X %2X %2X \r\n",databuf[4],databuf[5],databuf[6],databuf[7]); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, 0x04, databuf, - sizeof(databuf)); + 4); } else if(testitem == 0x05) { +#ifdef PPG_HX3695 //灰卡测试 - #ifdef SUPPORT_PPG_SERVICE send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST); - #endif - LOS_Msleep(500); -#ifdef SUPPORT_PPG_SERVICE + LOS_Msleep(2000); uint8_t databuf[12] = {0}; FT_RESULTS_t ft_result = hx3695_factroy_test(GRAY_CARD_TEST); databuf[0] = (uint8_t)((ft_result.gr_data_final & 0xFF000000) >> 24); @@ -1601,31 +1562,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 0x05, databuf, 12); -#elif defined PPG_VC9202 - uint8_t databuf[8] = {0}; - uint32_t apre_val = 0; - uint32_t aps_val = 9; - vc9202_get_graycard_data(&apre_val,&aps_val); - PRINT("apre_val : %d ,aps_val : %d \n",apre_val,aps_val); - databuf[0] = (uint8_t)((apre_val & 0xFF000000) >> 24); - databuf[1] = (uint8_t)((apre_val & 0x00FF0000) >> 16); - databuf[2] = (uint8_t)((apre_val & 0x0000FF00) >> 8); - databuf[3] = (uint8_t)((apre_val & 0x000000FF) >> 0); - - databuf[4] = (uint8_t)((aps_val & 0xFF000000) >> 24); - databuf[5] = (uint8_t)((aps_val & 0x00FF0000) >> 16); - databuf[6] = (uint8_t)((aps_val & 0x0000FF00) >> 8); - databuf[7] = (uint8_t)((aps_val & 0x000000FF) >> 0); - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, - 0x05, - databuf, - 8); -#endif - #ifdef SUPPORT_PPG_SERVICE send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); - #endif +#endif // PRINT("%2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X\r\n", // databuf[0],databuf[1],databuf[2],databuf[3], // databuf[4],databuf[5],databuf[6],databuf[7], @@ -1636,52 +1574,33 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x06) { //漏光测试 - #ifdef SUPPORT_PPG_SERVICE - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST); - #endif - LOS_Msleep(500); uint8_t databuf[12] = {0}; + + uint32_t green = 0; + uint32_t red = 0; + uint32_t ir = 0; + #ifdef SUPPORT_PPG_SERVICE - FT_RESULTS_t ft_result = hx3695_factroy_test(LEAK_LIGHT_TEST); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST); + LOS_Msleep(2000); + ppg_get_leaklight_data(&green,&red,&ir); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); +#endif + databuf[0] = (uint8_t)((green & 0xFF000000) >> 24); + databuf[1] = (uint8_t)((green & 0x00FF0000) >> 16); + databuf[2] = (uint8_t)((green & 0x0000FF00) >> 8); + databuf[3] = (uint8_t)((green & 0x000000FF) >> 0); - databuf[0] = (uint8_t)((ft_result.gr_data_final & 0xFF000000) >> 24); - databuf[1] = (uint8_t)((ft_result.gr_data_final & 0x00FF0000) >> 16); - databuf[2] = (uint8_t)((ft_result.gr_data_final & 0x0000FF00) >> 8); - databuf[3] = (uint8_t)((ft_result.gr_data_final & 0x000000FF) >> 0); + databuf[4] = (uint8_t)((red & 0xFF000000) >> 24); + databuf[5] = (uint8_t)((red & 0x00FF0000) >> 16); + databuf[6] = (uint8_t)((red & 0x0000FF00) >> 8); + databuf[7] = (uint8_t)((red & 0x000000FF) >> 0); - databuf[4] = (uint8_t)((ft_result.red_data_final & 0xFF000000) >> 24); - databuf[5] = (uint8_t)((ft_result.red_data_final & 0x00FF0000) >> 16); - databuf[6] = (uint8_t)((ft_result.red_data_final & 0x0000FF00) >> 8); - databuf[7] = (uint8_t)((ft_result.red_data_final & 0x000000FF) >> 0); + databuf[8] = (uint8_t)((ir & 0xFF000000) >> 24); + databuf[9] = (uint8_t)((ir & 0x00FF0000) >> 16); + databuf[10] = (uint8_t)((ir & 0x0000FF00) >> 8); + databuf[11] = (uint8_t)((ir & 0x000000FF) >> 0); - databuf[8] = (uint8_t)((ft_result.ir_data_final & 0xFF000000) >> 24); - databuf[9] = (uint8_t)((ft_result.ir_data_final & 0x00FF0000) >> 16); - databuf[10] = (uint8_t)((ft_result.ir_data_final & 0x0000FF00) >> 8); - databuf[11] = (uint8_t)((ft_result.ir_data_final & 0x000000FF) >> 0); -#elif defined PPG_VC9202 - uint32_t led_cur = 0; - uint32_t apre_val = 0; - uint32_t aps_val = 9; - vc9202_get_leaklight_data(&led_cur,&apre_val,&aps_val); - PRINT("led_cur : %d ,apre_val : %d ,aps_val : %d \n",led_cur,apre_val,aps_val); - databuf[0] = (uint8_t)((led_cur & 0xFF000000) >> 24); - databuf[1] = (uint8_t)((led_cur & 0x00FF0000) >> 16); - databuf[2] = (uint8_t)((led_cur & 0x0000FF00) >> 8); - databuf[3] = (uint8_t)((led_cur & 0x000000FF) >> 0); - - databuf[4] = (uint8_t)((apre_val & 0xFF000000) >> 24); - databuf[5] = (uint8_t)((apre_val & 0x00FF0000) >> 16); - databuf[6] = (uint8_t)((apre_val & 0x0000FF00) >> 8); - databuf[7] = (uint8_t)((apre_val & 0x000000FF) >> 0); - - databuf[8] = (uint8_t)((aps_val & 0xFF000000) >> 24); - databuf[9] = (uint8_t)((aps_val & 0x00FF0000) >> 16); - databuf[10] = (uint8_t)((aps_val & 0x0000FF00) >> 8); - databuf[11] = (uint8_t)((aps_val & 0x000000FF) >> 0); -#endif - #ifdef SUPPORT_PPG_SERVICE - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); - #endif // PRINT("%2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X\r\n", // databuf[0],databuf[1],databuf[2],databuf[3], @@ -1703,7 +1622,9 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //获取mmc5603 ID unsigned char chip_id; - mmc5603_getid(&chip_id); +#ifdef SUPPORT_MAG_SERVICE + chip_id = mag_get_chip_id(); +#endif factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_COMPASS, @@ -1714,48 +1635,59 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x02) { //地磁sensor测试 - float fAzimuth = 0; + float fAzimuth,fPitch,fRoll; + do_mag_service_check_msg(MAG_SERVICE_CMD_START_CHECK); - LOS_Msleep(500); - // mmc5603_getdata(&fAzimuth); + LOS_Msleep(1000); +#ifdef SUPPORT_MAG_SERVICE fAzimuth = mag_get_fAzimuth(); +#endif do_mag_service_check_msg(MAG_SERVICE_CMD_STOP_CHECK); +#ifdef BOARD_FD230 + + uint8_t databuf[6] = {0}; + + databuf[0] = (uint8_t)(((uint32_t)fAzimuth & 0xFF00) >> 8); + databuf[1] = (uint8_t)((uint32_t)fAzimuth & 0x00FF); + + databuf[2] = (uint8_t)(((uint32_t)fPitch & 0xFF00) >> 8); + databuf[3] = (uint8_t)((uint32_t)fPitch & 0x00FF); + + databuf[4] = (uint8_t)(((uint32_t)fRoll & 0xFF00) >> 8); + databuf[5] = (uint8_t)((uint32_t)fRoll & 0x00FF); + + PRINT("%2X %2X %2X %2X %2X %2X\r\n",databuf[0],databuf[1],databuf[2],databuf[3],databuf[4],databuf[5]); + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_COMPASS, + 0x02, + databuf, + 6); + +#elif defined BOARD_N9 uint8_t databuf[2] = {0}; databuf[0] = (uint8_t)(((uint32_t)fAzimuth & 0xFF00) >> 8); databuf[1] = (uint8_t)((uint32_t)fAzimuth & 0x00FF); - // PRINT("%2X %2X %2X %2X %2X %2X\r\n",databuf[0],databuf[1],databuf[2],databuf[3],databuf[4],databuf[5]); + PRINT("%2X %2X\r\n",databuf[0],databuf[1]); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_COMPASS, 0x02, databuf, - sizeof(databuf)); + 2); +#endif } break; case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_PM: - if(testitem == 0x01) - { - //获取充电IC ID - uint8_t chip_id = 0; -#ifdef ENABLE_HP4507 - chip_id = hp4507_get_id(); - PRINT("chip id = 0x%x\n",chip_id); -#endif - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_PM, - 0x01, - &chip_id, - 1); - } - else if(testitem == 0x02) + if(testitem == 0x02) { //获取充电状态 bool state; - state = get_charge_stat(); + state = uapi_get_charger_plug_status(); uint8_t send_data[2] = {0}; send_data[1] = state; factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, @@ -1767,12 +1699,12 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x03) { //获取电量 - float voltage; - uint8_t power = battery_get_voltage(&voltage); - + uint8_t power; + battery_getvolpower(&power); + uint8_t send_data[3] = {0}; send_data[2] = power & 0XFF; - PRINT("power : %d \n",power); + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_PM, 0x03, @@ -1783,13 +1715,13 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //获取电压 float voltage; uint16_t vol; - battery_get_voltage(&voltage); + battery_getvoltage(&voltage); uint8_t send_data[3] = {0}; vol = voltage * 1000; send_data[1] = (vol >> 8) ; send_data[2] = vol; - PRINT("vol : %d \n",vol); + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_PM, 0x04, @@ -1807,29 +1739,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 1); LOS_Mdelay(100); uapi_poweroff_device(); - } else if(testitem == 0x06) - { - //切换vbus供电测电流 - uint8_t send_data = 0x00; -#ifdef ENABLE_HP4507 - hp45xxx_init(HP4570C9); - hp45xxx_set_batfet_dis(true); - // hp45xxx_set_ceb_en(true); - hp45xxx_set_hiz_en(false); - LOS_Mdelay(50); - if (hp45xxx_read_status_vbus_pg()) - PRINT("VBUS is in Power Good state\n"); - else - PRINT("VBUS is not in Power Good state\n"); - -#endif - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_PM, - 0x06, - &send_data, - 1); } - break; @@ -1917,6 +1827,11 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //查看sim卡插入状态 uint8_t send_data = 0; send_data = uapi_dev_runtime_get_cat1_simstat(); + if(!send_data) + { + LOS_Msleep(1000); + send_data = uapi_dev_runtime_get_cat1_simstat(); + } factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_CAT1, 0x03, @@ -1949,6 +1864,13 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //查看iMei号 char* imei = uapi_dev_runtime_get_cat1_imei(); + uint8_t retry = 0; + while(strlen(imei) == 0 && retry < 3) + { + retry++; + LOS_Msleep(2000); + imei = uapi_dev_runtime_get_cat1_imei(); + } PRINT("imei : %s \r\n",imei); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, @@ -2148,7 +2070,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint uint8_t send_data= 0; // uapi_start_audio_test(30); uapi_microhone_switch(1); - // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_START_MIC,NULL,0); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, 0x01, @@ -2161,7 +2082,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint uint8_t send_data= 0; // uapi_stop_audio_test(); uapi_microhone_switch(0); - // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_STOP_MIC,NULL,0); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, 0x02, @@ -2173,7 +2093,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //播放录音 uint8_t send_data= 0; uapi_check_mic(1); - // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_START_CHECK_MIC,NULL,0); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, 0x03, @@ -2184,7 +2103,6 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //停止播放 uint8_t send_data= 0; uapi_check_mic(0); - // do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_STOP_CHECK_MIC,NULL,0); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, 0x04, @@ -2199,129 +2117,20 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 0x05, &send_data, 1); - } else if(testitem == 0x06) - { - //播放扫频文件 - uint8_t send_data = 0; - uapi_check_spk(2); - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, - 0x06, - &send_data, - 1); - } else if(testitem == 0x07) - { - //删除扫频文件 - uint8_t send_data = uapi_delete_files("/user/music/20-20KHZ.mp3"); - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, - 0x07, - &send_data, - 1); } - else if (testitem == 0x08) - { - uint8_t send_data = 0x00; - - send_data = factorytest_upload_mic_file(); - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, - 0x08, - &send_data, - 1); - } - - -// else if (testitem == 0x08) -// { -// uint8_t send_data = 0x00; -// #ifdef FD230 -// uapi_hfp_connect_(); -// LOS_Msleep(500); -// uapi_a2dp_snk_connect_(); -// #endif -// factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, -// BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, -// 0x03, -// &send_data, -// 1); -// } - - break; - - case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_LQBP: - - if (testitem == 0x01) + if (testitem == 0x06) { uint8_t send_data = 0x00; -#ifdef ENABLE_LQBP002TA - send_data = lqbp002ta_get_id(); - PRINT("send_data : 0x%x \n",send_data); -#endif + uapi_hfp_connect_(); + LOS_Msleep(500); + uapi_a2dp_snk_connect_(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_LQBP, - 0x01, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, + 0x03, &send_data, 1); - } else if(testitem == 0x02) - { - //获取温度 - uint8_t databuf[4] = {0}; - float temp = 0; -#ifdef ENABLE_LQBP002TA - do_lqbp_service_check_msg(LQBP_SERVICE_CMD_START_CHECK); - LOS_Msleep(100); - temp = lqbp002ta_get_temp(); - do_lqbp_service_check_msg(LQBP_SERVICE_CMD_STOP_CHECK); -#endif - PRINT("temp : %f\n",temp); - - int integer_part = (int)temp; - - int decimal_part = (int)((temp - integer_part) * 100); - - PRINT("integer_part : %d , decimal_part : %d\n",integer_part,decimal_part); - - databuf[0] = (uint8_t)((integer_part >> 8) & 0xFF); - databuf[1] = (uint8_t)(integer_part & 0xFF); - - databuf[2] = (uint8_t)((decimal_part >> 8) & 0xFF); - databuf[3] = (uint8_t)(decimal_part & 0xFF); - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_LQBP, - 0x02, - databuf, - sizeof(databuf)); - } else if(testitem == 0x03) - { - //获取气压 - uint8_t databuf[4] = {0}; - int pressure = 0; -#ifdef ENABLE_LQBP002TA - do_lqbp_service_check_msg(LQBP_SERVICE_CMD_START_CHECK); - LOS_Msleep(100); - pressure = (int)lqbp002ta_get_pressure(); - do_lqbp_service_check_msg(LQBP_SERVICE_CMD_STOP_CHECK); -#endif - PRINT("pressure : %d\n",pressure); - - // memcpy(databuf, &pressure, sizeof(pressure)); - databuf[0] = (uint8_t)((pressure & 0xFF000000) >> 24); - databuf[1] = (uint8_t)((pressure & 0x00FF0000) >> 16); - databuf[2] = (uint8_t)((pressure & 0x0000FF00) >> 8); - databuf[3] = (uint8_t)((pressure & 0x000000FF) >> 0); - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_LQBP, - 0x03, - databuf, - sizeof(databuf)); } - - break; - case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_GPS: if (testitem == 0x01) @@ -2335,7 +2144,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint gnss_start(); LOS_Msleep(100); do{ - gps_data_t *gps_data = getGPSGlobaldata(); + gps_data_t *gps_data = getPGPSGlobaldata(); if(gps_data == NULL) { PRINT("gps_data == NULL \n"); @@ -2359,8 +2168,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint memset_s(time,sizeof(time),0,sizeof(time)); sprintf_s(time,sizeof(time),"%d",send_data); strcat_s(tmp,sizeof(tmp),time); - // PRINT("send_gps_data.status : %d time : %d\n",send_gps_data.status,send_data); - // PRINT("tmp : %s size : %d\n",tmp,strlen(tmp)); + PRINT("send_gps_data.status : %d time : %d\n",send_gps_data.status,send_data); + PRINT("tmp : %s size : %d\n",tmp,strlen(tmp)); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_GPS, 0x01, @@ -2402,6 +2211,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } break; + break; default: printf(""); @@ -2440,7 +2250,7 @@ errcode_t factorytest_protocol_decode(uint8_t *buf, uint16_t event_size) printf("crc16 0x%04X vs 0x%04X\n",crc16,crc16_2); - if( crc16 == crc16_2) //校验通过,开始正式解析 + // if( crc16 == crc16_2) //校验通过,开始正式解析 { if(factorytest_mode_flag == 0 && header.submod != BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE) return ERRCODE_FAIL; @@ -2472,15 +2282,12 @@ errcode_t factorytest_protocol_decode(uint8_t *buf, uint16_t event_size) } - } - else if(header.header == BLE_TEST_BN02_HEADER) + }else if(header.header == BLE_TEST_BN02_HEADER) { #ifdef ENABLE_BN02 bn02_parse_frame(buf,event_size); #endif - } - else - { + }else{ printf("crc error!\r\n"); return ERRCODE_FAIL; } diff --git a/code/sdk/zhihui/services/gnss/driver/common/interface/board_interface/board_porting/tiot_board_pin_port.h b/code/sdk/zhihui/services/gnss/driver/common/interface/board_interface/board_porting/tiot_board_pin_port.h index 1a3570652..4d849083e 100644 --- a/code/sdk/zhihui/services/gnss/driver/common/interface/board_interface/board_porting/tiot_board_pin_port.h +++ b/code/sdk/zhihui/services/gnss/driver/common/interface/board_interface/board_porting/tiot_board_pin_port.h @@ -41,7 +41,7 @@ extern "C" { #define TIOT_PIN_UART_RTS S_MGPIO21 #define TIOT_PINMUX HAL_PIO_FUNC_UART1 -#elif defined(BOARD_L22) || defined(BOARD_W9) +#elif defined(BOARD_L22) || defined(BOARD_W9) || defined(BOARD_N9) #define TIOT_UART_PORT UART_BUS_1 #define TIOT_PIN_WAKEUP_HOST_NUM S_AGPIO_L15 /* 用于唤醒HOST. */ #define TIOT_PIN_WAKEUP_GNSS_NUM S_HGPIO0 /* 用于 唤醒GNSS. */ diff --git a/code/sdk/zhihui/services/gnss/src/gnss_ctl.c b/code/sdk/zhihui/services/gnss/src/gnss_ctl.c index ce8914b57..b0fe28fd8 100644 --- a/code/sdk/zhihui/services/gnss/src/gnss_ctl.c +++ b/code/sdk/zhihui/services/gnss/src/gnss_ctl.c @@ -62,7 +62,7 @@ S_AGPIO_L28 GPS_1V8 PRINT("GPS_PWREN set_value S_AGPIO_L30 GPIO_LEVEL_HIGH ret %d\n",ret); -#elif defined (BOARD_L22) || defined (BOARD_W9) +#elif defined (BOARD_L22) || defined (BOARD_W9) || defined(BOARD_N9) ret=uapi_gpio_set_dir(S_AGPIO_L16,GPIO_DIRECTION_OUTPUT); PRINT("set_dir S_AGPIO_L16,GPIO_DIRECTION_OUTPUT ret %d\n",ret); @@ -127,7 +127,7 @@ S_AGPIO_L28 GPS_1V8 PRINT("GPS_PWRON set_value S_AGPIO_L30 GPIO_LEVEL_LOW ret %d\n",ret); -#elif defined (BOARD_L22) || defined (BOARD_W9) +#elif defined (BOARD_L22) || defined (BOARD_W9) || defined(BOARD_N9) ret=uapi_gpio_set_dir(S_AGPIO_L16,GPIO_DIRECTION_OUTPUT); PRINT("set_dir S_AGPIO_L16,GPIO_DIRECTION_OUTPUT ret %d\n",ret); diff --git a/code/sdk/zhihui/utils/custom_fileoperate_service.c b/code/sdk/zhihui/utils/custom_fileoperate_service.c index 9362b3473..b5fc9956a 100644 --- a/code/sdk/zhihui/utils/custom_fileoperate_service.c +++ b/code/sdk/zhihui/utils/custom_fileoperate_service.c @@ -178,16 +178,16 @@ static void custom_fileoperate_service_check_task(void const *arg) break; case CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPDATA_READ: #ifdef SUPPORT_CYWEE_SERVICE - custom_read_sleep_data(); + // custom_read_sleep_data(); #endif break; case CUSTOM_FILEOPERATE_MSG_TYPE_NAPDATA_READ: #ifdef SUPPORT_CYWEE_SERVICE - custom_read_nap_data(); + // custom_read_nap_data(); #endif break; case CUSTOM_FILEOPERATE_MSG_TYPE_SLEEPMODLE_UPDATE: - custom_sleep_model_updata(); + // custom_sleep_model_updata(); break; case CUSTOM_FILEOPERATE_MSG_TYPE_MMCDATA_SAVE: // mmc5603_savePara_infile(); @@ -226,7 +226,7 @@ static void custom_fileoperate_service_check_task(void const *arg) case CUSTOM_FILEOPERATE_MSG_TYPE_WEAR_DATA_READ: #ifdef SUPPORT_CYWEE_SERVICE - custom_read_wear_data(); + // custom_read_wear_data(); #endif break; diff --git a/code/sdk/zhihui/utils/custom_utils.c b/code/sdk/zhihui/utils/custom_utils.c index 56e4891f2..0829d14d9 100644 --- a/code/sdk/zhihui/utils/custom_utils.c +++ b/code/sdk/zhihui/utils/custom_utils.c @@ -2830,9 +2830,9 @@ void uapi_cywee_reset_daily_data(void) //cywee时间更新 void uapi_cywee_time_sync(void) { - #ifdef CYWEE_SPORT +#ifdef SUPPORT_CYWEE_SERVICE do_cywee_service_check_msg(CYWEE_SERVICE_CMD_TIME_SYNC,NULL); - #endif +#endif } void uapi_cywee_get_id(uint8_t *id)