22 #include "si117xdrv_config.h" 23 #include "si117x_functions.h" 27 #define MEASCOUNT_LSB 20000 //20khz or 50us 28 #define MEASRATE_MIN 3 29 #define MEASRATE_MAX 0xffff 30 #define MEASCOUNT_MAX 0xff 71 uint16_t fifo_int_level;
74 uint8_t input_freq_sel;
79 uint8_t ecg_meascount;
80 uint8_t ecg_measconfig;
81 uint8_t ecg_adcconfig;
83 uint8_t ecg_threshold;
84 uint8_t ecg_ld_meascount;
90 uint8_t bioz_control1;
91 uint8_t bioz_control2;
92 uint8_t bioz_fe_gain1;
93 uint8_t bioz_fe_gain2;
99 uint8_t ppg_led1_config;
100 uint8_t ppg_led2_config;
101 uint8_t ppg_led3_config;
102 uint8_t ppg_led4_config;
104 uint8_t ppg_measconfig;
105 uint8_t ppg_adcconfig;
110 uint8_t ppg_meascount;
111 uint8_t ppg4_threshold;
119 uint8_t bioz_meascount;
120 uint8_t bioz_dc_value;
134 uint8_t hrmOversamplingRatio;
138 uint16_t savedMeasrate;
139 uint8_t savedPPG_meascount;
140 uint8_t savedECG_meascount;
156 static bool leadDetectionFlag [SI117XDRV_MAX_NUM_DEVICES];
157 static bool wristDetectionFlag [SI117XDRV_MAX_NUM_DEVICES];
158 static bool leadDetect[SI117XDRV_MAX_NUM_DEVICES];
160 static int initFlag[SI117XDRV_MAX_NUM_DEVICES] = { 0 };
168 for (i=0;i<SI117XDRV_MAX_NUM_CALLBACKS;i++)
170 if (callbacks[device].accelSyncRecvCallbacks[i].allocated)
172 callbacks[device].accelSyncRecvCallbacks[i].
callback(device,ppg_count,callbacks[device].accelSyncRecvCallbacks[i].user);
180 for (i=0;i<SI117XDRV_MAX_NUM_CALLBACKS;i++)
182 if (callbacks[device].preStartCallbacks[i].allocated)
184 callbacks[device].preStartCallbacks[i].
callback(device,callbacks[device].preStartCallbacks[i].user);
192 for (i=0;i<SI117XDRV_MAX_NUM_CALLBACKS;i++)
194 if (callbacks[device].postStartCallbacks[i].allocated)
196 callbacks[device].postStartCallbacks[i].
callback(device,callbacks[device].postStartCallbacks[i].user);
203 for (i=0;i<SI117XDRV_MAX_NUM_CALLBACKS;i++)
205 if (callbacks[device].preFifoFlushCallbacks[i].allocated)
207 callbacks[device].preFifoFlushCallbacks[i].
callback(device,callbacks[device].preFifoFlushCallbacks[i].user);
214 for (i=0;i<SI117XDRV_MAX_NUM_CALLBACKS;i++)
216 if (callbacks[device].postFifoFlushCallbacks[i].allocated)
218 callbacks[device].postFifoFlushCallbacks[i].
callback(device,callbacks[device].postFifoFlushCallbacks[i].user);
233 preFifoFlushCallbacks(device);
234 Si117xFlushFIFO(devices[device].deviceHandle);
235 postFifoFlushCallbacks(device);
254 if (initFlag[device] != 1)
258 devices[device].deviceStatus.running =
false;
259 devices[device].deviceStatus.savedTasks = 0;
260 devices[device].deviceStatus.hrmOversamplingRatio = 1;
261 devices[device].deviceStatus.partNumber = 0x70;
262 devices[device].deviceCfg.globalCfg.fifo_int_level = 0x100;
263 devices[device].deviceCfg.globalCfg.meas_cntl = 0x4;
264 devices[device].deviceCfg.globalCfg.measrate = 0x320;
265 devices[device].deviceCfg.globalCfg.synch_config = 0;
266 devices[device].deviceCfg.globalCfg.input_freq_sel = 0;
267 devices[device].deviceCfg.globalCfg.
taskEnable = 0;
268 devices[device].deviceCfg.ppgCfg.ppg4_threshold = 0;
269 devices[device].deviceCfg.ppgCfg.ppg_meascount = 1;
270 devices[device].deviceCfg.globalCfg.irq_enable = 0;
273 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_mode = 0xf;
274 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_adcconfig = 0x30;
275 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_led1_config = 0;
276 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_led2_config = 0;
277 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_led3_config = 0;
278 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_led4_config = 0;
279 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_measconfig = 3;
281 devices[device].deviceCfg.ecgCfg.ecg_adcconfig = 0x8;
282 devices[device].deviceCfg.ecgCfg.ecg_feconfig = 0;
283 devices[device].deviceCfg.ecgCfg.ecg_ld_meascount = 0;
284 devices[device].deviceCfg.ecgCfg.ecg_ldconfig = 0;
285 devices[device].deviceCfg.ecgCfg.ecg_measconfig = 0;
286 devices[device].deviceCfg.ecgCfg.ecg_meascount = 0;
287 devices[device].deviceCfg.ecgCfg.ecg_threshold = 0;
288 devices[device].deviceCfg.biozCfg.bioz_dc_value = 0;
289 devices[device].deviceCfg.biozCfg.bioz_meascount = 0;
292 devices[device].deviceCfg.biozCfg.biozConfig[i].bioz_control1 = 0;
293 devices[device].deviceCfg.biozCfg.biozConfig[i].bioz_control2 = 0;
294 devices[device].deviceCfg.biozCfg.biozConfig[i].bioz_fe_gain1 = 0;
295 devices[device].deviceCfg.biozCfg.biozConfig[i].bioz_fe_gain2 = 0;
296 devices[device].deviceCfg.biozCfg.biozConfig[i].bioz_fe_mux = 0;
299 leadDetect[device] =
false;
300 leadDetectionFlag[device]=
false;
301 wristDetectionFlag[device]=
false;
302 retval = Si117xReset(devices[device].deviceHandle);
303 retval += Si117xWriteToRegister(devices[device].deviceHandle, REG_HW_KEY, 0x00);
304 Si117xReadFromRegister (devices[device].deviceHandle, REG_HW_KEY);
305 devices[device].deviceStatus.partNumber = Si117xReadFromRegister (devices[device].deviceHandle, REG_PART_ID);
324 if (initFlag[device] != 1)
328 *
id = devices[device].deviceStatus.partNumber;
329 *rev = Si117xReadFromRegister (devices[device].deviceHandle, REG_REV_ID);
330 *mfr_id = Si117xReadFromRegister (devices[device].deviceHandle, REG_MFR_ID) >> 5;
331 *pkg_led_cfg = Si117xReadFromRegister (devices[device].deviceHandle, REG_MFR_ID) & 0x1F;
348 *fifo_int_level = devices[device].deviceCfg.globalCfg.fifo_int_level;
365 if (initFlag[device] != 1)
369 if (devices[device].deviceStatus.running)
373 devices[device].deviceCfg.ecgCfg.ecg_adcconfig = ecgCfg->ecg_adcconfig;
374 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_ADCCONFIG,ecgCfg->ecg_adcconfig);
375 devices[device].deviceCfg.ecgCfg.ecg_measconfig = ecgCfg->ecg_measconfig;
376 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_MEASCONFIG,ecgCfg->ecg_measconfig);
377 devices[device].deviceCfg.ecgCfg.ecg_feconfig = ecgCfg->ecg_feconfig;
378 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_FECONFIG,ecgCfg->ecg_feconfig);
395 if (initFlag[device] != 1)
399 if (devices[device].deviceStatus.running)
403 devices[device].deviceCfg.ecgCfg.ecg_threshold = ecgCfg->ecg_threshold;
404 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_THRESHOLD,ecgCfg->ecg_threshold);
405 devices[device].deviceCfg.ecgCfg.ecg_ldconfig = ecgCfg->ecg_ldconfig;
406 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_LDCONFIG,ecgCfg->ecg_ldconfig);
407 devices[device].deviceCfg.globalCfg.input_freq_sel = (ecgCfg->ecg_ld_freq_sel<<4) | (devices[device].deviceCfg.globalCfg.input_freq_sel&0xf);
408 Si117xParamSet(devices[device].deviceHandle,PARAM_INPUT_FREQ_SEL,devices[device].deviceCfg.globalCfg.input_freq_sel);
425 if (initFlag[device] != 1)
429 if (devices[device].deviceStatus.running)
433 devices[device].deviceCfg.ppgCfg.ppg4_threshold = ppgCfg->ppg4_threshold;
434 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG4_THRESHOLD,ppgCfg->ppg4_threshold);
437 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_adcconfig = ppgCfg->ppgCfg[i].ppg_adcconfig;
438 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG1_ADCCONFIG+i*PPG_OFFSET,ppgCfg->ppgCfg[i].ppg_adcconfig);
439 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_measconfig = ppgCfg->ppgCfg[i].ppg_measconfig;
440 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG1_MEASCONFIG+i*PPG_OFFSET,ppgCfg->ppgCfg[i].ppg_measconfig);
441 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_mode = ppgCfg->ppgCfg[i].ppg_mode;
442 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG1_MODE+i*PPG_OFFSET,ppgCfg->ppgCfg[i].ppg_mode);
443 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_led1_config = ppgCfg->ppgCfg[i].ppg_led1_config;
444 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG1_LED1_CONFIG+i*PPG_OFFSET,ppgCfg->ppgCfg[i].ppg_led1_config);
445 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_led2_config = ppgCfg->ppgCfg[i].ppg_led2_config;
446 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG1_LED2_CONFIG+i*PPG_OFFSET,ppgCfg->ppgCfg[i].ppg_led2_config);
447 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_led3_config = ppgCfg->ppgCfg[i].ppg_led3_config;
448 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG1_LED3_CONFIG+i*PPG_OFFSET,ppgCfg->ppgCfg[i].ppg_led3_config);
449 devices[device].deviceCfg.ppgCfg.ppgCfg[i].ppg_led4_config = ppgCfg->ppgCfg[i].ppg_led4_config;
450 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG1_LED4_CONFIG+i*PPG_OFFSET,ppgCfg->ppgCfg[i].ppg_led4_config);
469 if (initFlag[device] != 1)
473 if (devices[device].deviceStatus.running)
477 devices[device].deviceCfg.globalCfg.
taskEnable = devices[device].deviceCfg.globalCfg.
taskEnable&0xf0;
478 devices[device].deviceCfg.globalCfg.
taskEnable |= ppgTasks&0xf;
479 retval = Si117xParamSet(devices[device].deviceHandle,PARAM_TASK_ENABLE,devices[device].deviceCfg.globalCfg.taskEnable);
498 if (initFlag[device] != 1)
502 if (devices[device].deviceStatus.running)
506 devices[device].deviceCfg.globalCfg.
taskEnable = devices[device].deviceCfg.globalCfg.
taskEnable&0x3F;
507 devices[device].deviceCfg.globalCfg.
taskEnable |= ecgTasks&0xc0;
508 retval = Si117xParamSet(devices[device].deviceHandle,PARAM_TASK_ENABLE,devices[device].deviceCfg.globalCfg.taskEnable);
526 if (initFlag[device] != 1)
530 devices[device].deviceCfg.globalCfg.irq_enable = devices[device].deviceCfg.globalCfg.irq_enable & ~(0x1);
533 devices[device].deviceCfg.globalCfg.irq_enable |= 0x1;
553 if (initFlag[device] != 1)
557 devices[device].deviceCfg.globalCfg.irq_enable = devices[device].deviceCfg.globalCfg.irq_enable & ~(0x2);
560 devices[device].deviceCfg.globalCfg.irq_enable |= 0x2;
580 if (initFlag[device] != 1)
584 devices[device].deviceCfg.globalCfg.irq_enable = devices[device].deviceCfg.globalCfg.irq_enable & ~(0x8);
587 devices[device].deviceCfg.globalCfg.irq_enable |= 0x8;
607 if (initFlag[device] != 1)
611 devices[device].deviceCfg.globalCfg.irq_enable = devices[device].deviceCfg.globalCfg.irq_enable & ~(0x4);
614 devices[device].deviceCfg.globalCfg.irq_enable |= 0x4;
639 if (initFlag[device] != 1)
643 if (devices[device].deviceStatus.running)
648 devices[device].deviceStatus.savedTasks = devices[device].deviceCfg.globalCfg.
taskEnable;
649 devices[device].deviceStatus.irqSave = devices[device].deviceCfg.globalCfg.irq_enable;
650 devices[device].deviceStatus.savedMeasrate = devices[device].deviceCfg.globalCfg.measrate;
651 devices[device].deviceStatus.savedPPG_meascount = devices[device].deviceCfg.ppgCfg.ppg_meascount;
653 devices[device].deviceCfg.globalCfg.
taskEnable = devices[device].deviceCfg.globalCfg.
taskEnable & 0xf;
655 Si117xParamSet(devices[device].deviceHandle,PARAM_TASK_ENABLE,devices[device].deviceCfg.globalCfg.taskEnable);
658 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG_MEASCOUNT,ppg_meascount);
659 Si117xParamSet(devices[device].deviceHandle, PARAM_MEASRATE_L, (measrate & 0xff));
660 Si117xParamSet(devices[device].deviceHandle, PARAM_MEASRATE_H, (measrate & 0xff00)>>8);
662 preStartCallbacks(device);
666 Si117xStart(devices[device].deviceHandle);
667 devices[device].deviceStatus.running =
true;
668 postStartCallbacks(device);
686 if (initFlag[device] != 1)
690 if (devices[device].deviceStatus.running ==
false)
695 devices[device].deviceCfg.globalCfg.
taskEnable = devices[device].deviceStatus.savedTasks;
696 devices[device].deviceCfg.globalCfg.irq_enable = devices[device].deviceStatus.irqSave;
697 devices[device].deviceCfg.globalCfg.measrate = devices[device].deviceStatus.savedMeasrate;
698 devices[device].deviceCfg.ppgCfg.ppg_meascount = devices[device].deviceStatus.savedPPG_meascount;
701 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG_MEASCOUNT,devices[device].deviceStatus.savedPPG_meascount);
702 Si117xParamSet(devices[device].deviceHandle, PARAM_MEASRATE_L, (devices[device].deviceStatus.savedMeasrate & 0xff));
703 Si117xParamSet(devices[device].deviceHandle, PARAM_MEASRATE_H, (devices[device].deviceStatus.savedMeasrate & 0xff00)>>8);
704 Si117xParamSet(devices[device].deviceHandle,PARAM_TASK_ENABLE,devices[device].deviceStatus.savedTasks);
705 retval = Si117xWriteToRegister (devices[device].deviceHandle, REG_IRQ_ENABLE, 0);
706 devices[device].deviceStatus.running =
false;
721 if (initFlag[device] != 1)
725 if (devices[device].deviceStatus.running ==
false)
729 Si117xStop(devices[device].deviceHandle,0);
731 Si117xWriteToRegister (devices[device].deviceHandle, REG_IRQ_ENABLE,0);
732 devices[device].deviceStatus.running =
false;
747 if (initFlag[device] != 1)
751 if (devices[device].deviceStatus.running)
755 preStartCallbacks(device);
757 Si117xWriteToRegister (devices[device].deviceHandle, REG_IRQ_ENABLE, devices[device].deviceCfg.globalCfg.irq_enable);
759 Si117xStart(devices[device].deviceHandle);
760 devices[device].deviceStatus.running =
true;
761 postStartCallbacks(device);
766 static bool findMeasRate (uint16_t freqDivider, uint16_t *measrate, uint8_t *meascount, uint32_t accelSyncus)
772 *measrate = freqDivider;
777 static uint16_t gcd2 (uint16_t n1, uint16_t n2)
781 for(i=3; i <= n1 && i <= n2; ++i)
784 if(n1%i==0 && n2%i==0)
791 static uint16_t gcd3 (uint16_t n1, uint16_t n2, uint16_t n3)
795 for(i=3; i <= n1 && i <= n2 && i <= n3; ++i)
798 if(n1%i==0 && n2%i==0 && n3%i==0)
805 static bool findTwoMeasCount (uint16_t freqDivider1, uint16_t freqDivider2, uint16_t *measrate, uint8_t *meascount1, uint8_t *meascount2, uint32_t accelSyncus)
810 if (freqDivider1 == freqDivider2)
814 *measrate = freqDivider1;
819 *measrate = gcd2(freqDivider1, freqDivider2);
822 for (j=0;j<MEASCOUNT_MAX;j++)
824 for (k=0;k<MEASCOUNT_MAX;k++)
826 if ((((*measrate)*j) == freqDivider1) && (((*measrate)*k) == freqDivider2))
838 static bool findThreeMeasCount (uint16_t freqDivider1, uint16_t freqDivider2, uint16_t freqDivider3, uint16_t *measrate, uint8_t *meascount1, uint8_t *meascount2, uint8_t *meascount3, uint32_t accelSyncus)
844 if (freqDivider1 == freqDivider2 == freqDivider3)
849 *measrate = freqDivider1;
854 *measrate = gcd3(freqDivider1, freqDivider2,freqDivider3);
856 for (j=0;j<MEASCOUNT_MAX;j++)
858 for (k=0;k<MEASCOUNT_MAX;k++)
860 for (m=0;m<MEASCOUNT_MAX;m++)
862 if ((((*measrate)*j) == freqDivider1) && (((*measrate)*k) == freqDivider2)&& (((*measrate)*m) == freqDivider3))
889 uint16_t measrate, fifo_int_level;
890 uint16_t freqDivider;
891 uint16_t freqDivider2;
892 uint16_t freqDivider3;
893 uint16_t bytesPerSample;
894 uint8_t ppg_meascount, ecg_meascount, bioz_meascount, ecgld_meascount;
896 if (initFlag[device] != 1)
900 if (devices[device].deviceStatus.running)
904 devices[device].deviceCfg.globalCfg.synch_config = globalCfg->
synch_mode | (globalCfg->
ms_polar<<4);
905 Si117xParamSet(devices[device].deviceHandle,PARAM_SYNCH_CONFIG,devices[device].deviceCfg.globalCfg.synch_config);
907 Si117xParamSet(devices[device].deviceHandle,PARAM_MEAS_CNTL,devices[device].deviceCfg.globalCfg.meas_cntl);
909 Si117xParamSet(devices[device].deviceHandle,PARAM_TASK_ENABLE,devices[device].deviceCfg.globalCfg.taskEnable);
910 devices[device].deviceCfg.globalCfg.irq_enable = globalCfg->
irq_enable;
921 if (findMeasRate(freqDivider,&measrate,&bioz_meascount, globalCfg->
accelSyncRateus)!=
true)
925 devices[device].deviceCfg.globalCfg.measrate = measrate;
926 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_H,measrate>>8);
927 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_L,measrate&0xff);
928 devices[device].deviceCfg.biozCfg.bioz_meascount = bioz_meascount;
929 Si117xParamSet(devices[device].deviceHandle,PARAM_BIOZ_MEASCOUNT,bioz_meascount);
933 devices[device].deviceStatus.hrmOversamplingRatio = 40000 / globalCfg->
ppgSampleRateus;
942 if (findThreeMeasCount (freqDivider, freqDivider2, freqDivider3, &measrate, &ecg_meascount, &ecgld_meascount,&ppg_meascount, globalCfg->
accelSyncRateus)!=
true)
946 devices[device].deviceCfg.globalCfg.measrate = measrate;
947 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_H,measrate>>8);
948 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_L,measrate&0xff);
949 devices[device].deviceCfg.ecgCfg.ecg_meascount = ecg_meascount;
950 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_MEASCOUNT,ecg_meascount);
951 devices[device].deviceCfg.ecgCfg.ecg_ld_meascount = ecgld_meascount;
952 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_LD_MEASCOUNT,ecgld_meascount);
953 devices[device].deviceCfg.ppgCfg.ppg_meascount = ppg_meascount;
954 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG_MEASCOUNT,ppg_meascount);
959 if (findTwoMeasCount(freqDivider,freqDivider3,&measrate,&ecg_meascount,&ppg_meascount, globalCfg->
accelSyncRateus)!=
true)
963 devices[device].deviceCfg.globalCfg.measrate = measrate;
964 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_H,measrate>>8);
965 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_L,measrate&0xff);
966 devices[device].deviceCfg.ecgCfg.ecg_meascount = ecg_meascount;
967 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_MEASCOUNT,ecg_meascount);
968 devices[device].deviceCfg.ppgCfg.ppg_meascount = ppg_meascount;
969 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG_MEASCOUNT,ppg_meascount);
974 if (findTwoMeasCount(freqDivider,freqDivider3,&measrate,&ecgld_meascount,&ppg_meascount, globalCfg->
accelSyncRateus)!=
true)
978 devices[device].deviceCfg.globalCfg.measrate = measrate;
979 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_H,measrate>>8);
980 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_L,measrate&0xff);
981 devices[device].deviceCfg.ecgCfg.ecg_ld_meascount = ecgld_meascount;
982 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_LD_MEASCOUNT,ecgld_meascount);
983 devices[device].deviceCfg.ppgCfg.ppg_meascount = ppg_meascount;
984 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG_MEASCOUNT,ppg_meascount);
991 if (findMeasRate(freqDivider,&measrate,&ppg_meascount, globalCfg->
accelSyncRateus)!=
true)
995 devices[device].deviceCfg.globalCfg.measrate = measrate;
996 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_H,measrate>>8);
997 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_L,measrate&0xff);
998 devices[device].deviceCfg.ppgCfg.ppg_meascount = ppg_meascount;
999 Si117xParamSet(devices[device].deviceHandle,PARAM_PPG_MEASCOUNT,ppg_meascount);
1009 if (findTwoMeasCount (freqDivider, freqDivider2, &measrate, &ecg_meascount, &ecgld_meascount, globalCfg->
accelSyncRateus)!=
true)
1013 devices[device].deviceCfg.globalCfg.measrate = measrate;
1014 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_H,measrate>>8);
1015 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_L,measrate&0xff);
1016 devices[device].deviceCfg.ecgCfg.ecg_meascount = ecg_meascount;
1017 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_MEASCOUNT,ecg_meascount);
1018 devices[device].deviceCfg.ecgCfg.ecg_ld_meascount = ecgld_meascount;
1019 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_LD_MEASCOUNT,ecgld_meascount);
1024 if (findMeasRate(freqDivider,&measrate,&ecg_meascount, globalCfg->
accelSyncRateus)!=
true)
1028 devices[device].deviceCfg.globalCfg.measrate = measrate;
1029 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_H,measrate>>8);
1030 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_L,measrate&0xff);
1031 devices[device].deviceCfg.ecgCfg.ecg_meascount = ecg_meascount;
1032 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_MEASCOUNT,ecg_meascount);
1037 if (findMeasRate(freqDivider,&measrate,&ecgld_meascount, globalCfg->
accelSyncRateus)!=
true)
1041 devices[device].deviceCfg.globalCfg.measrate = measrate;
1042 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_H,measrate>>8);
1043 Si117xParamSet(devices[device].deviceHandle,PARAM_MEASRATE_L,measrate&0xff);
1044 devices[device].deviceCfg.ecgCfg.ecg_ld_meascount = ecgld_meascount;
1045 Si117xParamSet(devices[device].deviceHandle,PARAM_ECG_LD_MEASCOUNT,ecgld_meascount);
1049 devices[device].deviceCfg.globalCfg.fifo_int_level = globalCfg->
fifo_int_level;
1050 Si117xParamSet(devices[device].deviceHandle,PARAM_FIFO_INT_LEVEL_H,globalCfg->
fifo_int_level>>8);
1051 Si117xParamSet(devices[device].deviceHandle,PARAM_FIFO_INT_LEVEL_L,globalCfg->
fifo_int_level&0xff);
1070 devices[device].deviceHandle = deviceHandle;
1071 for (i=0;i<SI117XDRV_MAX_NUM_CALLBACKS;i++)
1073 callbacks[device].preStartCallbacks[ i ].
allocated =
false;
1074 callbacks[device].postStartCallbacks[ i ].
allocated =
false;
1075 callbacks[device].preFifoFlushCallbacks[ i ].
allocated =
false;
1076 callbacks[device].postFifoFlushCallbacks[ i ].
allocated =
false;
1078 leadDetect[device] =
false;
1079 leadDetectionFlag[device]=
false;
1080 wristDetectionFlag[device]=
false;
1081 initFlag[device] = 1;
1104 while ( ( i < SI117XDRV_MAX_NUM_CALLBACKS ) && ( callbacks[device].accelSyncRecvCallbacks[ i ].allocated ) ) {
1109 if ( i == SI117XDRV_MAX_NUM_CALLBACKS ) {
1112 callbacks[device].accelSyncRecvCallbacks[ i ].
allocated =
true;
1113 callbacks[device].accelSyncRecvCallbacks[ i ].
callback = callback;
1114 callbacks[device].accelSyncRecvCallbacks[ i ].
user = user;
1138 while ( ( i < SI117XDRV_MAX_NUM_CALLBACKS ) && ( callbacks[device].preStartCallbacks[ i ].allocated ) ) {
1143 if ( i == SI117XDRV_MAX_NUM_CALLBACKS ) {
1146 callbacks[device].preStartCallbacks[ i ].
allocated =
true;
1147 callbacks[device].preStartCallbacks[ i ].
callback = callback;
1148 callbacks[device].preStartCallbacks[ i ].
user = user;
1172 while ( ( i < SI117XDRV_MAX_NUM_CALLBACKS ) && ( callbacks[device].postStartCallbacks[ i ].allocated ) ) {
1177 if ( i == SI117XDRV_MAX_NUM_CALLBACKS ) {
1180 callbacks[device].postStartCallbacks[ i ].
allocated =
true;
1181 callbacks[device].postStartCallbacks[ i ].
callback = callback;
1182 callbacks[device].postStartCallbacks[ i ].
user = user;
1206 while ( ( i < SI117XDRV_MAX_NUM_CALLBACKS ) && ( callbacks[device].preFifoFlushCallbacks[ i ].allocated ) ) {
1211 if ( i == SI117XDRV_MAX_NUM_CALLBACKS ) {
1214 callbacks[device].preFifoFlushCallbacks[ i ].
allocated =
true;
1215 callbacks[device].preFifoFlushCallbacks[ i ].
callback = callback;
1216 callbacks[device].preFifoFlushCallbacks[ i ].
user = user;
1239 while ( ( i < SI117XDRV_MAX_NUM_CALLBACKS ) && ( callbacks[device].postFifoFlushCallbacks[ i ].allocated ) ) {
1244 if ( i == SI117XDRV_MAX_NUM_CALLBACKS ) {
1247 callbacks[device].postFifoFlushCallbacks[ i ].
allocated =
true;
1248 callbacks[device].postFifoFlushCallbacks[ i ].
callback = callback;
1249 callbacks[device].postFifoFlushCallbacks[ i ].
user = user;
1286 int8_t *inputBuffer,
1289 int8_t *buffer, uint16_t size);
1311 while ( ( i < SI117XDRV_MAX_DATA_QUEUES ) && ( queues[ i ].allocated ) ) {
1316 if ( i == SI117XDRV_MAX_DATA_QUEUES ) {
1321 queues[ i ].allocated =
true;
1322 queues[ i ].ppg =
false;
1323 queues[ i ].ppg16 =
true;
1324 queues[ i ].ecg =
false;
1325 queues[ i ].ecgld =
false;
1326 queues[ i ].queue.
head = 0;
1327 queues[ i ].queue.
tail = 0;
1328 queues[ i ].queue.
used = 0;
1329 queues[ i ].queue.
size = queueSizeInBytes;
1330 queues[ i ].queue.
fifo = (int8_t*)queueBuffer;
1362 while ( ( i < SI117XDRV_MAX_DATA_QUEUES ) && ( queues[ i ].allocated ) ) {
1367 if ( i == SI117XDRV_MAX_DATA_QUEUES ) {
1372 queues[ i ].allocated =
true;
1373 queues[ i ].ppg =
true;
1374 queues[ i ].ppg16 =
false;
1375 queues[ i ].ecg =
false;
1376 queues[ i ].ecgld =
false;
1377 queues[ i ].queue.
head = 0;
1378 queues[ i ].queue.
tail = 0;
1379 queues[ i ].queue.
used = 0;
1380 queues[ i ].queue.
size = queueSizeInBytes;
1381 queues[ i ].queue.
fifo = (int8_t*)queueBuffer;
1414 while ( ( i < SI117XDRV_MAX_DATA_QUEUES ) && ( queues[ i ].allocated ) ) {
1419 if ( i == SI117XDRV_MAX_DATA_QUEUES ) {
1424 queues[ i ].allocated =
true;
1425 queues[ i ].ppg =
false;
1426 queues[ i ].ecg =
true;
1427 queues[ i ].ppg16 =
false;
1428 queues[ i ].ecgld =
false;
1429 queues[ i ].queue.
head = 0;
1430 queues[ i ].queue.
tail = 0;
1431 queues[ i ].queue.
used = 0;
1432 queues[ i ].queue.
size = queueSizeInBytes;
1433 queues[ i ].queue.
fifo = (int8_t*)queueBuffer;
1466 while ( ( i < SI117XDRV_MAX_DATA_QUEUES ) && ( queues[ i ].allocated ) ) {
1471 if ( i == SI117XDRV_MAX_DATA_QUEUES ) {
1476 queues[ i ].allocated =
true;
1477 queues[ i ].ppg =
false;
1478 queues[ i ].ecg =
false;
1479 queues[ i ].ecgld =
true;
1480 queues[ i ].ppg16 =
false;
1481 queues[ i ].queue.
head = 0;
1482 queues[ i ].queue.
tail = 0;
1483 queues[ i ].queue.
used = 0;
1484 queues[ i ].queue.
size = queueSizeInBytes;
1485 queues[ i ].queue.
fifo = (int8_t*)queueBuffer;
1512 if (
id >= SI117XDRV_MAX_DATA_QUEUES ) {
1517 queues[ id ].allocated =
false;
1554 int8_t *inputBuffer,
1558 for(i=0; i<size; i++)
1560 queue->
fifo[queue->
head] = inputBuffer[i];
1565 queue->
used += size;
1567 if (i == queue->
head)
1569 queue->
tail += size;
1570 queue->
used -= size;
1582 int8_t *buffer, uint16_t size)
1586 if (queue->
used < size) {
1591 for(i=0; i<size; i++)
1593 buffer[i] = queue->
fifo[queue->
tail];
1599 queue->
used -= size;
1623 if (
id > SI117XDRV_MAX_DATA_QUEUES)
1635 int8_t *buf = buffer;
1639 for (i=0; i< SI117XDRV_MAX_DATA_QUEUES; i++)
1641 if (queues[ i ].allocated && queues[ i ].ppg16)
1644 *(uint16_t*)(buf) = sample->
sequence;
1650 *(int16_t*)(buf) = sample->
ppg1;
1652 *(int16_t*)(buf) = sample->
ppg2;
1654 *(int16_t*)(buf) = sample->
ppg3;
1656 *(int16_t*)(buf) = sample->
ppg4;
1673 int8_t *buf = buffer;
1677 for (i=0; i< SI117XDRV_MAX_DATA_QUEUES; i++)
1679 if (queues[ i ].allocated && queues[ i ].ppg)
1682 *(uint16_t*)(buf) = sample->
sequence;
1688 *(int32_t*)(buf) = sample->
ppg1;
1690 *(int32_t*)(buf) = sample->
ppg2;
1692 *(int32_t*)(buf) = sample->
ppg3;
1694 *(int32_t*)(buf) = sample->
ppg4;
1722 int8_t *buf = buffer;
1724 sample->
sequence = *(uint16_t*)(buf);
1730 sample->
ppg1 = *(int32_t*)(buf);
1732 sample->
ppg2 = *(int32_t*)(buf);
1734 sample->
ppg3 = *(int32_t*)(buf);
1736 sample->
ppg4 = *(int32_t*)(buf);
1756 int8_t *buf = buffer;
1758 sample->
sequence = *(uint16_t*)(buf);
1764 sample->
ppg1 = *(int16_t*)(buf);
1766 sample->
ppg2 = *(int16_t*)(buf);
1768 sample->
ppg3 = *(int16_t*)(buf);
1770 sample->
ppg4 = *(int16_t*)(buf);
1782 int8_t *buf = buffer;
1786 for (i=0; i< SI117XDRV_MAX_DATA_QUEUES; i++)
1788 if (queues[ i ].allocated && queues[i].ecg)
1790 *(uint16_t*)(buf) = sample->
sequence;
1796 *(int32_t*)(buf) = sample->
ecg;
1813 int8_t *buf = buffer;
1817 for (i=0; i< SI117XDRV_MAX_DATA_QUEUES; i++)
1819 if (queues[ i ].allocated && queues[i].ecgld)
1821 *(uint16_t*)(buf) = sample->
sequence;
1827 *(uint8_t*)(buf) = sample->
data[0];
1829 *(uint8_t*)(buf) = sample->
data[1];
1831 *(uint8_t*)(buf) = sample->
data[2];
1833 *(uint8_t*)(buf) = sample->
data[3];
1858 int8_t *buf = buffer;
1860 sample->
sequence = *(uint16_t*)(buf);
1866 sample->
data[0] = *(uint8_t*)(buf);
1868 sample->
data[1] = *(uint8_t*)(buf);
1870 sample->
data[2] = *(uint8_t*)(buf);
1872 sample->
data[3] = *(uint8_t*)(buf);
1890 int8_t *buf = buffer;
1892 sample->
sequence = *(uint16_t*)(buf);
1898 sample->
ecg = *(int32_t*)(buf);
1940 retval = Si117xParamRead(devices[device].deviceHandle, PARAM_ECG_LDCONFIG);
1941 if (leadDetectionFlag[device] && retval >= 0)
1943 value = (uint8_t)retval;
1948 devices[device].deviceCfg.ecgCfg.ecg_ldconfig &= ~0x80;
1949 Si117xParamSet(devices[device].deviceHandle, PARAM_ECG_LDCONFIG, (value & 0x7F));
1950 leadDetect[device] =
true;
1955 devices[device].deviceCfg.ecgCfg.ecg_ldconfig |= 0x80;
1956 Si117xParamSet(devices[device].deviceHandle, PARAM_ECG_LDCONFIG, (value | 0x80));
1957 leadDetect[device] =
false;
1959 leadDetectionFlag[device] =
false;
1961 *leadDetectStatus = leadDetect[device];
1979 *wristDetectStatus = wristDetectionFlag[device];
1996 wristDetectionFlag[device] =
false;
2011 leadDetectionFlag[device] =
true;
2026 wristDetectionFlag[device] =
true;
2037 SI117x_FIFO_STATE_PPG1_HI=0,
2038 SI117x_FIFO_STATE_PPG1_MID=1,
2039 SI117x_FIFO_STATE_PPG1_LO=2,
2040 SI117x_FIFO_STATE_PPG2_HI=3,
2041 SI117x_FIFO_STATE_PPG2_MID=4,
2042 SI117x_FIFO_STATE_PPG2_LO=5,
2043 SI117x_FIFO_STATE_PPG3_HI=6,
2044 SI117x_FIFO_STATE_PPG3_MID=7,
2045 SI117x_FIFO_STATE_PPG3_LO=8,
2046 SI117x_FIFO_STATE_PPG4_HI=9,
2047 SI117x_FIFO_STATE_PPG4_MID=10,
2048 SI117x_FIFO_STATE_PPG4_LO=11,
2049 SI117x_FIFO_STATE_BIOZ1_HI = 12,
2050 SI117x_FIFO_STATE_BIOZ1_MID = 13,
2051 SI117x_FIFO_STATE_BIOZ1_LO = 14,
2052 SI117x_FIFO_STATE_BIOZ2_HI = 15,
2053 SI117x_FIFO_STATE_BIOZ2_MID = 16,
2054 SI117x_FIFO_STATE_BIOZ2_LO = 17,
2055 SI117x_FIFO_STATE_ECG_HI=18,
2056 SI117x_FIFO_STATE_ECG_MID=19,
2057 SI117x_FIFO_STATE_ECG_LO=20,
2058 SI117x_FIFO_STATE_ECG_LD_BYTE1=21,
2059 SI117x_FIFO_STATE_ECG_LD_BYTE2=22,
2060 SI117x_FIFO_STATE_ECG_LD_BYTE3=23,
2061 SI117x_FIFO_STATE_ECG_LD_BYTE4=24,
2062 SI117x_FIFO_STATE_UNKNOWN = 0xff
2069 int32_t ppg_value[4];
2071 int32_t bioz_value[2];
2072 uint8_t ecg_ld_value[4];
2077 #define SI117X_FIFO_DEFAULT_FIFO_STATE {SI117x_FIFO_STATE_UNKNOWN,1,0,0,0,0,0,0,0} 2083 static bool Unprocessed_DLE_S=
false;
2085 static uint8_t found_DLE_S=0, DLE_S_tag;
2087 typedef enum si117xFifoStateTaskComplete
2089 SI117x_TASK_NOT_COMPLETE,
2090 SI117x_TASK_COMPLETE_PPG,
2091 SI117x_TASK_COMPLETE_BIOZ,
2092 SI117x_TASK_COMPLETE_ECG,
2093 SI117x_TASK_COMPLETE_ECG_LD
2094 }si117xFifoStateTaskComplete_t;
2105 static uint16_t ppg1_sample_count[SI117XDRV_MAX_NUM_DEVICES];
2106 static uint16_t ppg2_sample_count[SI117XDRV_MAX_NUM_DEVICES];
2107 static uint16_t ppg3_sample_count[SI117XDRV_MAX_NUM_DEVICES];
2108 static uint16_t ppg4_sample_count[SI117XDRV_MAX_NUM_DEVICES];
2112 static uint16_t ppg_count;
2116 ppg1_sample_count[device]=0;
2117 ppg2_sample_count[device]=0;
2118 ppg3_sample_count[device]=0;
2119 ppg4_sample_count[device]=0;
2134 fifoStateMachine->fifoState = SI117x_FIFO_STATE_UNKNOWN;
2135 fifoStateMachine->isMsb = 1;
2136 fifoStateMachine->ppg_value[0] = 0;
2137 fifoStateMachine->ppg_value[1] = 0;
2138 fifoStateMachine->ppg_value[2] = 0;
2139 fifoStateMachine->ppg_value[3] = 0;
2140 fifoStateMachine->bioz_value[0] = 0;
2141 fifoStateMachine->bioz_value[1] = 0;
2142 fifoStateMachine->ecg_value = 0;
2144 resetSynchSampleCounters(device);
2173 if ( fifoData[j]==0x10 && fifoData[j+1]==
'P' )
2175 if ( fifoData[j]==0x10 && fifoData[j+1]==
'A' )
2177 if (fifoData[j]== 0x10 && fifoData[j+1]== 0x10)
2179 ppg[i] = 256 *fifoData[j] + fifoData[j+1];
2185 sample.
ppg1 = ppg[0];
2186 sample.
ppg2 = ppg[1];
2187 sample.
ppg3 = ppg[2];
2188 sample.
ppg4 = ppg[3];
2201 void setFifoProcessingValues(
int oversampling, uint8_t meas_cntl, uint8_t taskEnable, uint8_t ppg_measconfig0, uint8_t ppg_measconfig1, uint8_t ppg_measconfig2, uint8_t ppg_measconfig3 )
2204 devices[0].deviceCfg.globalCfg.
taskEnable = taskEnable;
2205 devices[0].deviceCfg.globalCfg.meas_cntl = meas_cntl;
2206 devices[0].deviceStatus.hrmOversamplingRatio = oversampling;
2207 devices[0].deviceCfg.ppgCfg.ppgCfg[0].ppg_measconfig = ppg_measconfig0;
2208 devices[0].deviceCfg.ppgCfg.ppgCfg[1].ppg_measconfig = ppg_measconfig1;
2209 devices[0].deviceCfg.ppgCfg.ppgCfg[2].ppg_measconfig = ppg_measconfig2;
2210 devices[0].deviceCfg.ppgCfg.ppgCfg[3].ppg_measconfig = ppg_measconfig3;
2234 uint8_t *record_ptr;
2236 si117xFifoStateTaskComplete_t task_complete;
2244 configuration = &(devices[device].deviceCfg.globalCfg);
2245 ppgCfg = &(devices[device].deviceCfg.ppgCfg);
2246 record_ptr = &(*record);
2248 for (i = 0; i < fifo_length; i += 1)
2250 data_byte = record_ptr[i];
2255 if (data_byte != 0x10)
2261 DLE_S_tag = record_ptr[i];
2269 goto Take_DLE_as_data;
2272 if (Unprocessed_DLE_S ==
true)
2274 Unprocessed_DLE_S =
false;
2276 DLE_S_tag = data_byte;
2281 if ((data_byte == 0x10) && fifoStateMachine->isMsb && (i <= fifo_length-2))
2285 data_byte = record_ptr[i];
2287 if (data_byte ==
'S')
2289 if (i == fifo_length-1)
2291 Unprocessed_DLE_S =
true;
2297 DLE_S_tag = record_ptr[i];
2301 if (data_byte != 0x10)
2307 else if ((data_byte == 0x10) && fifoStateMachine->isMsb)
2315 switch (fifoStateMachine->fifoState)
2317 case SI117x_FIFO_STATE_PPG1_HI:
2318 fifoStateMachine->ppg_value[0] = (data_byte << 16) & 0xFF0000;
2320 case SI117x_FIFO_STATE_PPG1_MID:
2321 fifoStateMachine->ppg_value[0] |= (data_byte << 8) & 0x00FF00;
2322 ppg1_sample_count[device]++;
2324 case SI117x_FIFO_STATE_PPG1_LO:
2325 fifoStateMachine->ppg_value[0] |= data_byte & 0x0000FF;
2327 case SI117x_FIFO_STATE_PPG2_HI:
2328 fifoStateMachine->ppg_value[1] = (data_byte << 16) & 0xFF0000;
2330 case SI117x_FIFO_STATE_PPG2_MID:
2331 fifoStateMachine->ppg_value[1] |= (data_byte << 8) & 0x00FF00;
2332 ppg2_sample_count[device]++;
2334 case SI117x_FIFO_STATE_PPG2_LO:
2335 fifoStateMachine->ppg_value[1] |= data_byte & 0x0000FF;
2337 case SI117x_FIFO_STATE_PPG3_HI:
2338 fifoStateMachine->ppg_value[2] = (data_byte << 16) & 0xFF0000;
2340 case SI117x_FIFO_STATE_PPG3_MID:
2341 fifoStateMachine->ppg_value[2] |= (data_byte << 8) & 0x00FF00;
2342 ppg3_sample_count[device]++;
2344 case SI117x_FIFO_STATE_PPG3_LO:
2345 fifoStateMachine->ppg_value[2] |= data_byte & 0x0000FF;
2347 case SI117x_FIFO_STATE_PPG4_HI:
2348 fifoStateMachine->ppg_value[3] = (data_byte << 16) & 0xFF0000;
2350 case SI117x_FIFO_STATE_PPG4_MID:
2351 fifoStateMachine->ppg_value[3] |= (data_byte << 8) & 0x00FF00;
2352 ppg4_sample_count[device]++;
2354 case SI117x_FIFO_STATE_PPG4_LO:
2355 fifoStateMachine->ppg_value[3] |= data_byte & 0x0000FF;
2357 case SI117x_FIFO_STATE_BIOZ1_HI:
2358 fifoStateMachine->bioz_value[0] = (data_byte << 16) & 0xFF0000;
2360 case SI117x_FIFO_STATE_BIOZ1_MID:
2361 fifoStateMachine->bioz_value[0] |= (data_byte << 8) & 0x00FF00;
2363 case SI117x_FIFO_STATE_BIOZ1_LO:
2364 fifoStateMachine->bioz_value[0] |= data_byte & 0x0000FF;
2366 case SI117x_FIFO_STATE_BIOZ2_HI:
2367 fifoStateMachine->bioz_value[1] = (data_byte << 16) & 0xFF0000;
2369 case SI117x_FIFO_STATE_BIOZ2_MID:
2370 fifoStateMachine->bioz_value[1] |= (data_byte << 8) & 0x00FF00;
2372 case SI117x_FIFO_STATE_BIOZ2_LO:
2373 fifoStateMachine->bioz_value[1] |= data_byte & 0x0000FF;
2375 case SI117x_FIFO_STATE_ECG_HI:
2376 fifoStateMachine->ecg_value = (data_byte << 16) & 0xFF0000;
2378 case SI117x_FIFO_STATE_ECG_MID:
2379 fifoStateMachine->ecg_value |= (data_byte << 8) & 0x00FF00;
2381 case SI117x_FIFO_STATE_ECG_LO:
2382 fifoStateMachine->ecg_value |= data_byte & 0x0000FF;
2384 case SI117x_FIFO_STATE_ECG_LD_BYTE1:
2385 fifoStateMachine->ecg_ld_value[0] = data_byte;
2387 case SI117x_FIFO_STATE_ECG_LD_BYTE2:
2388 fifoStateMachine->ecg_ld_value[1] = data_byte;
2390 case SI117x_FIFO_STATE_ECG_LD_BYTE3:
2391 fifoStateMachine->ecg_ld_value[2] = data_byte;
2393 case SI117x_FIFO_STATE_ECG_LD_BYTE4:
2394 fifoStateMachine->ecg_ld_value[3] = data_byte;
2396 case SI117x_FIFO_STATE_UNKNOWN:
2402 if (task_complete == SI117x_TASK_COMPLETE_ECG)
2408 sampleECG.
ecg = fifoStateMachine->ecg_value;
2410 fifoStateMachine->ecg_value =0;
2412 if (task_complete == SI117x_TASK_COMPLETE_ECG_LD)
2415 sampleECGLD.
sequence = irqSequence;
2418 sampleECGLD.
data[0] = fifoStateMachine->ecg_ld_value[0];
2419 sampleECGLD.
data[1] = fifoStateMachine->ecg_ld_value[1];
2420 sampleECGLD.
data[2] = fifoStateMachine->ecg_ld_value[2];
2421 sampleECGLD.
data[3] = fifoStateMachine->ecg_ld_value[3];
2423 fifoStateMachine->ecg_ld_value[0] =0;
2424 fifoStateMachine->ecg_ld_value[1] =0;
2425 fifoStateMachine->ecg_ld_value[2] =0;
2426 fifoStateMachine->ecg_ld_value[3] =0;
2428 if (task_complete == SI117x_TASK_COMPLETE_PPG)
2433 for (j = 0; j < 4; j++)
2435 if ((ppgCfg->ppgCfg[j].ppg_measconfig & 0x10) != 0)
2437 mask = (uint32_t)0x8000 << (8 * (configuration->meas_cntl & 0x01));
2438 if (fifoStateMachine->ppg_value[j] & mask)
2439 fifoStateMachine->ppg_value[j] |= 0xFFFF0000 << (8 * (configuration->meas_cntl & 0x01));
2446 sample.
ppg1 = fifoStateMachine->ppg_value[0];
2447 sample.
ppg2 = fifoStateMachine->ppg_value[1];
2448 sample.
ppg3 = fifoStateMachine->ppg_value[2];
2449 sample.
ppg4 = fifoStateMachine->ppg_value[3];
2450 if (found_DLE_S==
true)
2465 fifoStateMachine->ppg_value[0] = 0;
2466 fifoStateMachine->ppg_value[1] = 0;
2467 fifoStateMachine->ppg_value[2] = 0;
2468 fifoStateMachine->ppg_value[3] = 0;
2485 configuration = &(devices[device].deviceCfg.globalCfg);
2487 *taskComplete = SI117x_TASK_NOT_COMPLETE;
2488 fifoStateMachine->isMsb = 1;
2489 uint16_t oversampling = devices[device].deviceStatus.hrmOversamplingRatio;
2492 switch (dleDataByte)
2496 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG1_HI : SI117x_FIFO_STATE_PPG1_MID;
2498 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG2_HI : SI117x_FIFO_STATE_PPG2_MID;
2500 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG3_HI : SI117x_FIFO_STATE_PPG3_MID;
2502 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG4_HI : SI117x_FIFO_STATE_PPG4_MID;
2504 fifoStateMachine->fifoState = SI117x_FIFO_STATE_UNKNOWN;
2508 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x4) ? SI117x_FIFO_STATE_ECG_HI : SI117x_FIFO_STATE_ECG_MID;
2510 fifoStateMachine->fifoState = SI117x_FIFO_STATE_UNKNOWN;
2514 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x2) ? SI117x_FIFO_STATE_BIOZ1_HI : SI117x_FIFO_STATE_BIOZ1_MID;
2516 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x2) ? SI117x_FIFO_STATE_BIOZ2_HI : SI117x_FIFO_STATE_BIOZ2_MID;
2518 fifoStateMachine->fifoState = SI117x_FIFO_STATE_UNKNOWN;
2524 ppg_count = ppg1_sample_count[device];
2525 ppg1_sample_count[device] = 0; }
2527 ppg_count = ppg2_sample_count[device];
2528 ppg2_sample_count[device] = 0; }
2530 ppg_count = ppg3_sample_count[device];
2531 ppg3_sample_count[device] = 0; }
2533 ppg_count = ppg4_sample_count[device];
2534 ppg4_sample_count[device] = 0; }
2538 if (oversampling == 8)
2539 ppg_count = (ppg_count + 4) >> 3;
2540 if (oversampling == 4)
2541 ppg_count = (ppg_count + 2) >> 2;
2542 if (oversampling == 2)
2543 ppg_count = (ppg_count + 1) >> 1;
2555 fifoStateMachine->fifoState = SI117x_FIFO_STATE_ECG_LD_BYTE1;
2565 switch (fifoStateMachine->fifoState)
2567 case SI117x_FIFO_STATE_PPG1_HI:
case SI117x_FIFO_STATE_PPG1_MID:
2568 case SI117x_FIFO_STATE_PPG2_HI:
case SI117x_FIFO_STATE_PPG2_MID:
2569 case SI117x_FIFO_STATE_PPG3_HI:
case SI117x_FIFO_STATE_PPG3_MID:
2570 case SI117x_FIFO_STATE_PPG4_HI:
case SI117x_FIFO_STATE_PPG4_MID:
2571 case SI117x_FIFO_STATE_BIOZ1_HI:
case SI117x_FIFO_STATE_BIOZ1_MID:
2572 case SI117x_FIFO_STATE_BIOZ2_HI:
case SI117x_FIFO_STATE_BIOZ2_MID:
2573 case SI117x_FIFO_STATE_ECG_HI:
case SI117x_FIFO_STATE_ECG_MID:
2574 case SI117x_FIFO_STATE_ECG_LD_BYTE1:
case SI117x_FIFO_STATE_ECG_LD_BYTE2:
2575 case SI117x_FIFO_STATE_ECG_LD_BYTE3:
2576 fifoStateMachine->fifoState = (
si117xFifoState_t)(fifoStateMachine->fifoState + 1);
2577 fifoStateMachine->isMsb = 0;
2579 case SI117x_FIFO_STATE_ECG_LD_BYTE4:
2580 fifoStateMachine->fifoState = SI117x_FIFO_STATE_ECG_LD_BYTE1;
2581 *taskComplete = SI117x_TASK_COMPLETE_ECG_LD;
2583 case SI117x_FIFO_STATE_PPG1_LO:
2585 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG2_HI : SI117x_FIFO_STATE_PPG2_MID;
2587 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG3_HI : SI117x_FIFO_STATE_PPG3_MID;
2589 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG4_HI : SI117x_FIFO_STATE_PPG4_MID;
2592 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG1_HI : SI117x_FIFO_STATE_PPG1_MID;
2593 *taskComplete = SI117x_TASK_COMPLETE_PPG;
2596 case SI117x_FIFO_STATE_PPG2_LO:
2598 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG3_HI : SI117x_FIFO_STATE_PPG3_MID;
2600 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG4_HI : SI117x_FIFO_STATE_PPG4_MID;
2603 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG1_HI : SI117x_FIFO_STATE_PPG1_MID;
2604 *taskComplete = SI117x_TASK_COMPLETE_PPG;
2608 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG2_HI : SI117x_FIFO_STATE_PPG2_MID;
2609 *taskComplete = SI117x_TASK_COMPLETE_PPG;
2612 case SI117x_FIFO_STATE_PPG3_LO:
2614 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG4_HI : SI117x_FIFO_STATE_PPG4_MID;
2617 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG1_HI : SI117x_FIFO_STATE_PPG1_MID;
2618 *taskComplete = SI117x_TASK_COMPLETE_PPG;
2622 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG2_HI : SI117x_FIFO_STATE_PPG2_MID;
2623 *taskComplete = SI117x_TASK_COMPLETE_PPG;
2627 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG3_HI : SI117x_FIFO_STATE_PPG3_MID;
2628 *taskComplete = SI117x_TASK_COMPLETE_PPG;
2632 case SI117x_FIFO_STATE_PPG4_LO:
2634 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG1_HI : SI117x_FIFO_STATE_PPG1_MID;
2636 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG2_HI : SI117x_FIFO_STATE_PPG2_MID;
2638 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG3_HI : SI117x_FIFO_STATE_PPG3_MID;
2640 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x1) ? SI117x_FIFO_STATE_PPG4_HI : SI117x_FIFO_STATE_PPG4_MID;
2641 *taskComplete = SI117x_TASK_COMPLETE_PPG;
2643 case SI117x_FIFO_STATE_BIOZ1_LO:
2645 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x2) ? SI117x_FIFO_STATE_BIOZ2_HI : SI117x_FIFO_STATE_BIOZ2_MID;
2648 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x2) ? SI117x_FIFO_STATE_BIOZ1_HI : SI117x_FIFO_STATE_BIOZ1_MID;
2649 *taskComplete = SI117x_TASK_COMPLETE_BIOZ;
2652 case SI117x_FIFO_STATE_BIOZ2_LO:
2654 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x2) ? SI117x_FIFO_STATE_BIOZ1_HI : SI117x_FIFO_STATE_BIOZ1_MID;
2656 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x2) ? SI117x_FIFO_STATE_BIOZ2_HI : SI117x_FIFO_STATE_BIOZ2_MID;
2657 *taskComplete = SI117x_TASK_COMPLETE_BIOZ;
2659 case SI117x_FIFO_STATE_ECG_LO:
2660 fifoStateMachine->fifoState = (configuration->meas_cntl & 0x4) ? SI117x_FIFO_STATE_ECG_HI : SI117x_FIFO_STATE_ECG_MID;
2661 *taskComplete = SI117x_TASK_COMPLETE_ECG;
2663 case SI117x_FIFO_STATE_UNKNOWN:
2668 if (fifoStateMachine->fifoState == SI117x_FIFO_STATE_UNKNOWN)
2669 fifoStateMachine->isMsb = 0;
Si117x_Ecode_t SI117XDRV_FifoIntConfig(SI117XDRV_DeviceSelect_t device, bool enable)
Enable/disable fifo interrupt.
int32_t ppg3
ppg3 sample data
Si117x_Ecode_t SI117XDRV_SetECGTaskEnable(SI117XDRV_DeviceSelect_t device, uint8_t ecgTasks)
Configure ECG tasks.
uint32_t SI117XDRV_DataQueueID_t
Queue ID.
Si117x_Ecode_t SI117XDRV_GetFifoIntLevel(SI117XDRV_DeviceSelect_t device, uint16_t *fifo_int_level)
Returns the current fifo interrupt level the Si117x.
uint32_t ecgldSampleRateus
desired ECG LD sample rate us
uint16_t sequence
irq sequence number
void * user
User supplied data.
uint16_t timestamp
irq timestamp
static Si117x_Ecode_t SI117XDRV_EnqueueBIOZSampleData(SI117XDRV_BIOZSample_t *sample)
Enqueue Si117x bioz sample data.
uint32_t biozSampleRateus
desired bioz sample rate in us
volatile uint16_t tail
Index of where to enqueue next byte.
SI117XDRV_SampleSize_t ecgSampleSize
ecg sample size setting
uint16_t sequence
irq sequence number
Si117x_Ecode_t SI117XDRV_StartLegacyPPG(SI117XDRV_DeviceSelect_t device, uint8_t ppg_meascount, uint16_t measrate)
Start legacy PPG mode (ECG & BIOZ will be disabled before start) This function overwrites some config...
uint16_t timestamp
irq timestamp
Si117x_Ecode_t SI117XDRV_DequeuePPGSampleData(SI117XDRV_DataQueueID_t id, SI117XDRV_PPGSample_t *sample)
Remove a 16bit PPG sample from the queue.
General callback function datatype.
static Si117x_Ecode_t SI117XDRV_EnqueueECGLDSampleData(SI117XDRV_ECGLDSample_t *sample)
Enqueue Si117x ECG LD sample data.
uint8_t data[4]
ecg ld sample data
Si117x_Ecode_t SI117XDRV_Start(SI117XDRV_DeviceSelect_t device)
Start running measurements with the current configuration.
#define SI117XDRV_PPG_24BIT_SAMPLE_SIZE_BYTES
PPG sample size in bytes.
uint16_t sequence
irq sequence number
int16_t ppg1
ppg1 sample data
#define SI117XDRV_ECG_SAMPLE_SIZE_BYTES
ECG sample size in bytes.
Si117x_Ecode_t SI117XDRV_DequeueECGSampleData(SI117XDRV_DataQueueID_t id, SI117XDRV_ECGSample_t *sample)
Remove an ECG sample from the queue.
#define ECODE_SI117XDRV_ALL_CB_USED
All callbacks used.
Si117x_Ecode_t SI117XDRV_ProcessPPGInterrupt(SI117XDRV_DeviceSelect_t device, uint8_t *fifoData, uint16_t timestamp, uint16_t irqSequence)
PPG1 interrupt handler.
Si117x_Ecode_t SI117XDRV_Stop(SI117XDRV_DeviceSelect_t device)
Stop running measurements in the Si117x.
Si117x_Ecode_t SI117XDRV_PPG1IntConfig(SI117XDRV_DeviceSelect_t device, bool enable)
Enable/disable PPG interrupt.
#define SI117XDRV_TASK_BIOZ_DC_EN
BIOZ DC task enable bit.
uint32_t SI117XDRV_DeviceSelect_t
Device ID.
uint8_t syncMessage
sync message received
int32_t ppg2
ppg2 sample data
SI117XDRV_MSPolar_t ms_polar
ms pin polarity
uint16_t size
Size of FIFO.
bool allocated
Flag to indicate callback data is set //todo: do we really need this allocated member? Can't we just say if callback == NULL then not allocated?
static uint16_t SI117XDRV_NumBytesInQueue(SI117XDRV_FifoQueue_t *queue)
Get number of bytes in queue.
Si117x global configuration.
Si117x_Ecode_t SI117XDRV_DequeueECGLDSampleData(SI117XDRV_DataQueueID_t id, SI117XDRV_ECGLDSample_t *sample)
Remove an ECG LD sample from the queue.
SI117XDRV_SampleSize_t biozSampleSize
bioz sample size setting
Si117x_Ecode_t SI117XDRV_InitECGLD(SI117XDRV_DeviceSelect_t device, SI117XDRV_ECGLDCfg_t *ecgCfg)
Configure ECG LD parameters.
Si117x_Ecode_t SI117XDRV_StopLegacyPPG(SI117XDRV_DeviceSelect_t device)
Stop legacy PPG mode (restores ECG & BIOZ tasks as previously set)
Si117x_Ecode_t SI117XDRV_ClearWristDetection(SI117XDRV_DeviceSelect_t device)
wrist detection algorithm
Si117XDRV ECG configuration.
Si117x_Ecode_t SI117XDRV_DequeueBIOZSampleData(SI117XDRV_DataQueueID_t id, SI117XDRV_BIOZSample_t *sample)
Dequeue Si117x bioz sample data.
static Si117x_Ecode_t SI117XDRV_EnqueuePPG16bSampleData(SI117XDRV_PPGSample_t *sample)
Enqueue Si117x 16 bit PPG sample data.
#define ECODE_SI117XDRV_PARAM_ERROR
Invalid parameter.
Si117x_Ecode_t SI117XDRV_InitGlobal(SI117XDRV_DeviceSelect_t device, SI117XDRV_GlobalCfg_t *globalCfg)
Configure global Si117x settings.
Si117x_Ecode_t SI117XDRV_LeadDetection(SI117XDRV_DeviceSelect_t device, bool *leadDetectStatus)
Lead detection algorithm.
uint16_t timestamp
irq timestamp
static Si117x_Ecode_t SI117XDRV_ClearRawQueue(SI117XDRV_FifoQueue_t *queue)
Empty queue.
uint16_t timestamp
irq timestamp
Si117x_Ecode_t SI117XDRV_InitECG(SI117XDRV_DeviceSelect_t device, SI117XDRV_ECGCfg_t *ecgCfg)
Configure ECG parameters.
SI117XDRV_SampleSize_t ppgSampleSize
ppg sample size setting
static Si117x_Ecode_t SI117XDRV_EnqueueRawData(SI117XDRV_FifoQueue_t *queue, int8_t *inputBuffer, uint16_t size)
Enqueue Si117x raw data.
#define SI117XDRV_IRQ_EN_PPG1
Legacy PPG irq enable bit.
int32_t ppg1
ppg1 sample data
int16_t ppg2
ppg2 sample data
Raw data FIFO queue typedef.
uint32_t ppgSampleRateus
desired PPG sample rate in us
int8_t * fifo
Pointer to FIFO of queue data (allocated by user)
Si117x_Ecode_t SI117XDRV_RegisterPostFifoFlushCallback(SI117XDRV_DeviceSelect_t device, SI117XDRV_Callback_t callback, void *user)
Register a post fifo flush callback.
uint8_t taskEnable
The global task enable register.
Raw data FIFO queue typedef.
Si117x_Ecode_t SI117XDRV_InitializeSi117xFifoStateMachine(SI117XDRV_DeviceSelect_t device)
Initializes the FIFO processing state machine.
#define SI117XDRV_TASK_ECG_LD_EN
ECG LD task enable bit.
Si117x_Ecode_t SI117XDRV_FifoFlush(SI117XDRV_DeviceSelect_t device)
Flushes the Si117x fifo.
Si117x_Ecode_t SI117XDRV_RegisterAccelSyncCallback(SI117XDRV_DeviceSelect_t device, SI117XDRV_AccelCallback_t callback, void *user)
Register an accelerometer sync message callback.
bool fifo_self_test
enable fifo self test mode
Si117x_Ecode_t SI117XDRV_InitPPG(SI117XDRV_DeviceSelect_t device, SI117XDRV_PPGCfg_t *ppgCfg)
Configure PPG parameters.
uint16_t SI117XDRV_NumSamplesInQueue(SI117XDRV_DataQueueID_t id)
Get number of samples in the queue.
static bool Unprocessed_DLE
#define SI117XDRV_ECG_LD_SAMPLE_SIZE_BYTES
ECG LD sample size in bytes.
int32_t ppg4
ppg4 sample data
int32_t Si117x_Ecode_t
SI117XDRV error code.
Si117x_Ecode_t SI117XDRV_RegisterPostStartCallback(SI117XDRV_DeviceSelect_t device, SI117XDRV_Callback_t callback, void *user)
Register a post start callback.
Si117x_Ecode_t SI117XDRV_ProcessLDInterrupt(SI117XDRV_DeviceSelect_t device)
lead detection interrupt handler
Si117x_Ecode_t SI117XDRV_WristDetection(SI117XDRV_DeviceSelect_t device, bool *wristDetectStatus)
wrist detection algorithm
PPG 16bit sample data typedef. Use this data type to save memory.
int16_t ppg4
ppg4 sample data
#define SI117XDRV_TASK_PPG4_EN
PPG4 task enable bit.
Si117x_Ecode_t SI117XDRV_AllocatePPGDataQueue(SI117XDRV_DataQueueID_t *id, SI117XDRV_PPGSample_t *queueBuffer, int16_t queueSizeInBytes)
Allocate a fifo queue for 16 bit PPG data.
#define ECODE_SI117XDRV_ALL_QUEUES_USED
No more queues left.
uint8_t irq_enable
irq enable setting
static SI117XDRV_Device_t devices[SI117XDRV_MAX_NUM_DEVICES]
enum si117xFifoState si117xFifoState_t
Si117x_Ecode_t SI117XDRV_AllocateECGLDDataQueue(SI117XDRV_DataQueueID_t *id, SI117XDRV_ECGLDSample_t *queueBuffer, int16_t queueSizeInBytes)
Allocate a fifo queue for ECG data.
Si117x_Ecode_t SI117XDRV_ProcessFifoData(SI117XDRV_DeviceSelect_t device, uint8_t *record, uint16_t fifo_length, uint16_t timestamp, uint16_t irqSequence)
FIFO interrupt handler.
SI117XDRV_SynchMode_t synch_mode
sync mode
bool allocated
Flag to indicate callback data is set.
Si117x_Ecode_t SI117XDRV_InitAPI(SI117XDRV_DeviceSelect_t device, HANDLE deviceHandle)
Initializes API memory and device handle.
Si117XDRV ECG LD configuration.
Si117x_Ecode_t SI117XDRV_Allocate24bPPGDataQueue(SI117XDRV_DataQueueID_t *id, SI117XDRV_PPG24bSample_t *queueBuffer, int16_t queueSizeInBytes)
Allocate a fifo queue for PPG data.
void * user
User supplied data.
bool fifo_disable
disable fifo
uint8_t syncMessage
sync message received
Data structure containing all callback info.
int32_t ecg
ecg sample data
volatile uint16_t head
Index of next byte to get.
Si117x_Ecode_t SI117XDRV_Dequeue24bPPGSampleData(SI117XDRV_DataQueueID_t id, SI117XDRV_PPG24bSample_t *sample)
Remove a PPG sample from the queue.
#define ECODE_SI117XDRV_QUEUE_EMPTY
Fifo queue empty.
static void accelSyncCallbacks(SI117XDRV_DeviceSelect_t device, uint16_t ppg_count)
Call accel sync DLE received callback functions.
Accel sync DLE callback function datatype.
SI117XDRV_Callback_t callback
Callback function pointer.
Si117x_Ecode_t SI117XDRV_RegisterPreFifoFlushCallback(SI117XDRV_DeviceSelect_t device, SI117XDRV_Callback_t callback, void *user)
Register a pre fifo flush callback.
static Si117x_Ecode_t SI117XDRV_EnqueuePPG24bSampleData(SI117XDRV_PPG24bSample_t *sample)
Enqueue Si117x PPG sample data.
uint8_t taskEnable
task enable
#define ECODE_SI117XDRV_QUEUE_SIZE_ERROR
Invalid queue size.
#define ECODE_SI117XDRV_RUNNING
Si117x is already running.
static int16_t si117xFifoStateMachine_Next(SI117XDRV_DeviceSelect_t device, uint8_t isDle, uint8_t dleDataByte, si117xFifoStateTaskComplete_t *taskComplete)
#define ECODE_SI117XDRV_QUEUE_FULL
Fifo queue full.
#define SI117XDRV_TASK_ECG_EN
ECG task enable bit.
static Si117x_Ecode_t SI117XDRV_EnqueueECGSampleData(SI117XDRV_ECGSample_t *sample)
Enqueue Si117x ECG sample data.
Si117x_Ecode_t SI117XDRV_LDIntConfig(SI117XDRV_DeviceSelect_t device, bool enable)
Enable/disable lead detection interrupt.
Si117x_Ecode_t SI117XDRV_ClearQueue(SI117XDRV_DataQueueID_t id)
Empty a fifo queue.
uint8_t syncMessage
sync message received
volatile uint16_t used
Number of bytes queued.
uint8_t syncMessage
sync message received
uint16_t sequence
irq sequence number
int16_t ppg3
ppg3 sample data
SI117XDRV_AccelCallback_t callback
Callback function pointer.
Si117x_Ecode_t SI117XDRV_WDIntConfig(SI117XDRV_DeviceSelect_t device, bool enable)
Enable/disable wrist detection interrupt.
static Si117x_Ecode_t SI117XDRV_DequeueRawData(SI117XDRV_FifoQueue_t *queue, int8_t *buffer, uint16_t size)
Dequeue si117x raw data.
Si117x_Ecode_t SI117XDRV_Reset(SI117XDRV_DeviceSelect_t device)
Resets the Si117x.
#define SI117XDRV_IRQ_EN_FIFO
Fifo irq enable bit.
Si117x_Ecode_t SI117XDRV_GetPartInfo(SI117XDRV_DeviceSelect_t device, uint8_t *id, uint8_t *rev, uint8_t *mfr_id, uint8_t *pkg_led_cfg)
Returns the part number read from the Si117x.
#define SI117XDRV_TASK_PPG2_EN
PPG2 task enable bit.
void(* SI117XDRV_AccelCallback_t)(SI117XDRV_DeviceSelect_t device, uint16_t ppgCount, void *user)
Typedef for accel sync DLE message received event.
#define SI117XDRV_TASK_PPG1_EN
PPG1 task enable bit.
Si117x_Ecode_t SI117XDRV_SetPPGTaskEnable(SI117XDRV_DeviceSelect_t device, uint8_t ppgTasks)
Configure PPG tasks.
#define SI117XDRV_TASK_BIOZ1_AC_EN
BIOZ AC task enable bit.
Si117x_Ecode_t SI117XDRV_FreeDataQueue(SI117XDRV_DataQueueID_t id)
De-allocate a fifo queue.
#define ECODE_SI117XDRV_UNINITIALIZED
All callbacks used.
Si117x_Ecode_t SI117XDRV_AllocateECGDataQueue(SI117XDRV_DataQueueID_t *id, SI117XDRV_ECGSample_t *queueBuffer, int16_t queueSizeInBytes)
Allocate a fifo queue for ECG data.
#define SI117XDRV_TASK_PPG3_EN
PPG3 task enable bit.
uint32_t accelSyncRateus
accel synchronization period in us
Si117x_Ecode_t SI117XDRV_ProcessWDInterrupt(SI117XDRV_DeviceSelect_t device)
wrist detection interrupt handler
uint32_t ecgSampleRateus
desired ECG sample rate in us
void(* SI117XDRV_Callback_t)(SI117XDRV_DeviceSelect_t device, void *user)
Typedef for the user supplied callback function which is called when a specific event happens...
uint16_t fifo_int_level
fifo interrupt level
#define ECODE_SI117XDRV_OK
Success return value. //dlc: It is my opinion that these should be SI117XDRV_ECODE_....
#define SI117XDRV_PPG_SAMPLE_SIZE_BYTES
PPG 16 bit sample size in bytes.
Si117x_Ecode_t SI117XDRV_RegisterPreStartCallback(SI117XDRV_DeviceSelect_t device, SI117XDRV_Callback_t callback, void *user)
Register a pre start callback.
Si117XDRV PPG configuration.
uint8_t ppg_sw_avg
ppg sw avg setting
#define ECODE_SI117XDRV_NOT_RUNNING
Si117x is not running.