16 #ifndef SI117x_DRIVER_H 17 #define SI117x_DRIVER_H 24 #include "si117x_types.h" 25 #include "si117xdrv_config.h" 29 #define ECODE_SI117XDRV_OK 0 30 #define ECODE_SI117XDRV_QUEUE_FULL -1 31 #define ECODE_SI117XDRV_QUEUE_EMPTY -2 32 #define ECODE_SI117XDRV_ALL_QUEUES_USED -3 33 #define ECODE_SI117XDRV_PARAM_ERROR -4 34 #define ECODE_SI117XDRV_QUEUE_SIZE_ERROR -5 35 #define ECODE_SI117XDRV_RUNNING -6 36 #define ECODE_SI117XDRV_NOT_RUNNING -7 37 #define ECODE_SI117XDRV_ALL_CB_USED -8 38 #define ECODE_SI117XDRV_UNINITIALIZED -9 44 #define SI117XDRV_UNINITIALIZED_QUEUE_ID 0xffff 57 #define SI117XDRV_PPG_24BIT_SAMPLE_SIZE_BYTES 21 70 #define SI117XDRV_PPG_SAMPLE_SIZE_BYTES 13 80 #define SI117XDRV_ECG_SAMPLE_SIZE_BYTES 9 90 #define SI117XDRV_ECG_LD_SAMPLE_SIZE_BYTES 9 100 #define SI117XDRV_BIOZ_SAMPLE_SIZE_BYTES 9 124 #define SI117XDRV_TASK_PPG1_EN (1<<0) 125 #define SI117XDRV_TASK_PPG2_EN (1<<1) 126 #define SI117XDRV_TASK_PPG3_EN (1<<2) 127 #define SI117XDRV_TASK_PPG4_EN (1<<3) 128 #define SI117XDRV_TASK_BIOZ1_AC_EN (1<<4) 129 #define SI117XDRV_TASK_BIOZ_DC_EN (1<<5) 130 #define SI117XDRV_TASK_ECG_EN (1<<6) 131 #define SI117XDRV_TASK_ECG_LD_EN (1<<7) 133 #define SI117XDRV_IRQ_EN_FIFO (1<<0) 134 #define SI117XDRV_IRQ_EN_PPG1 (1<<1) 135 #define SI117XDRV_IRQ_EN_WD (1<<2) 136 #define SI117XDRV_IRQ_EN_LD (1<<3) 159 #define SI117XDRV_DEFAULT_GLOBAL_CFG \ 170 MSPolarHighLowHigh, \ 180 uint8_t ecg_measconfig;
181 uint8_t ecg_adcconfig;
182 uint8_t ecg_feconfig;
187 uint8_t ecg_threshold;
188 uint8_t ecg_ldconfig;
189 uint8_t ecg_ld_freq_sel;
193 #define SI117XDRV_DEFAULT_ECG_CFG \ 200 #define SI117XDRV_DEFAULT_ECG_LD_CFG \ 209 uint8_t ppg_led1_config;
210 uint8_t ppg_led2_config;
211 uint8_t ppg_led3_config;
212 uint8_t ppg_led4_config;
214 uint8_t ppg_measconfig;
215 uint8_t ppg_adcconfig;
219 #define SI117XDRV_DEFAULT_PPG_CHANNEL_CFG \ 232 uint8_t ppg4_threshold;
237 #define SI117XDRV_DEFAULT_PPG_CFG \ 239 {SI117XDRV_DEFAULT_PPG_CHANNEL_CFG, \ 240 SI117XDRV_DEFAULT_PPG_CHANNEL_CFG, \ 241 SI117XDRV_DEFAULT_PPG_CHANNEL_CFG, \ 242 SI117XDRV_DEFAULT_PPG_CHANNEL_CFG} \ 314 Si117x_Ecode_t
SI117XDRV_StartLegacyPPG (SI117XDRV_DeviceSelect_t device, uint8_t ppg_meascount, uint16_t measrate) ;
329 Si117x_Ecode_t
SI117XDRV_GetPartInfo (SI117XDRV_DeviceSelect_t device, uint8_t *
id, uint8_t *rev, uint8_t *mfr_id, uint8_t *pkg_led_cfg);
348 Si117x_Ecode_t
SI117XDRV_InitAPI (SI117XDRV_DeviceSelect_t device, HANDLE deviceHandle);
357 Si117x_Ecode_t
SI117XDRV_ProcessFifoData(SI117XDRV_DeviceSelect_t device, uint8_t *fifoData, uint16_t fifo_length, uint16_t timestamp, uint16_t irqSequence);
365 #endif //SI117x_DRIVER_H int32_t ppg3
ppg3 sample data
uint32_t SI117XDRV_DataQueueID_t
Queue ID.
Si117x_Ecode_t SI117XDRV_AllocateECGDataQueue(SI117XDRV_DataQueueID_t *id, SI117XDRV_ECGSample_t *queueBuffer, int16_t queueSizeInBytes)
Allocate a fifo queue for ECG data.
uint32_t ecgldSampleRateus
desired ECG LD sample rate us
uint16_t sequence
irq sequence number
Si117x_Ecode_t SI117XDRV_Reset(SI117XDRV_DeviceSelect_t device)
Resets the Si117x.
uint16_t timestamp
irq timestamp
uint32_t biozSampleRateus
desired bioz sample rate in us
SI117XDRV_SampleSize_t ecgSampleSize
ecg sample size setting
Si117x_Ecode_t SI117XDRV_ClearWristDetection(SI117XDRV_DeviceSelect_t device)
wrist detection algorithm
Si117x_Ecode_t SI117XDRV_InitPPG(SI117XDRV_DeviceSelect_t device, SI117XDRV_PPGCfg_t *ppgCfg)
Configure PPG parameters.
uint16_t sequence
irq sequence number
uint16_t timestamp
irq timestamp
Si117x_Ecode_t SI117XDRV_LeadDetection(SI117XDRV_DeviceSelect_t device, bool *leadDetectStatus)
Lead detection algorithm.
Si117x_Ecode_t SI117XDRV_ProcessWDInterrupt(SI117XDRV_DeviceSelect_t device)
wrist detection interrupt handler
SI117XDRV_MSPolar_t
MS pin polarity setting.
Si117x_Ecode_t SI117XDRV_InitECG(SI117XDRV_DeviceSelect_t device, SI117XDRV_ECGCfg_t *ecgCfg)
Configure ECG parameters.
uint16_t sequence
irq sequence number
int16_t ppg1
ppg1 sample data
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_SetECGTaskEnable(SI117XDRV_DeviceSelect_t device, uint8_t ecgTask)
Configure ECG tasks.
Si117x_Ecode_t SI117XDRV_PPG1IntConfig(SI117XDRV_DeviceSelect_t device, bool enable)
Enable/disable PPG interrupt.
Si117x_Ecode_t SI117XDRV_WDIntConfig(SI117XDRV_DeviceSelect_t device, bool enable)
Enable/disable wrist detection interrupt.
Si117x_Ecode_t SI117XDRV_RegisterPreStartCallback(SI117XDRV_DeviceSelect_t device, SI117XDRV_Callback_t callback, void *user)
Register a pre start callback.
Si117x_Ecode_t SI117XDRV_ProcessFifoData(SI117XDRV_DeviceSelect_t device, uint8_t *fifoData, uint16_t fifo_length, uint16_t timestamp, uint16_t irqSequence)
FIFO interrupt handler.
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
Si117x_Ecode_t SI117XDRV_StopLegacyPPG(SI117XDRV_DeviceSelect_t device)
Stop legacy PPG mode (restores ECG & BIOZ tasks as previously set)
Si117x_Ecode_t SI117XDRV_Start(SI117XDRV_DeviceSelect_t device)
Start running measurements with the current configuration.
Si117x_Ecode_t SI117XDRV_RegisterPreFifoFlushCallback(SI117XDRV_DeviceSelect_t device, SI117XDRV_Callback_t callback, void *user)
Register a pre fifo flush callback.
Si117x_Ecode_t SI117XDRV_InitGlobal(SI117XDRV_DeviceSelect_t device, SI117XDRV_GlobalCfg_t *globalCfg)
Configure global Si117x settings.
Si117x global configuration.
SI117XDRV_SampleSize_t biozSampleSize
bioz sample size setting
Si117x_Ecode_t SI117XDRV_WristDetection(SI117XDRV_DeviceSelect_t device, bool *wristDetectStatus)
wrist detection algorithm
Si117XDRV ECG configuration.
Si117x_Ecode_t SI117XDRV_LDIntConfig(SI117XDRV_DeviceSelect_t device, bool enable)
Enable/disable lead detection interrupt.
Si117x_Ecode_t SI117XDRV_DequeuePPGSampleData(SI117XDRV_DataQueueID_t id, SI117XDRV_PPGSample_t *sample)
Remove a 16bit PPG sample from the queue.
uint16_t timestamp
irq timestamp
Si117x_Ecode_t SI117XDRV_InitECGLD(SI117XDRV_DeviceSelect_t device, SI117XDRV_ECGLDCfg_t *ecgldCfg)
Configure ECG LD parameters.
uint16_t timestamp
irq timestamp
uint8_t syncMessage
sync message received
SI117XDRV_SampleSize_t ppgSampleSize
ppg sample size setting
Si117x_Ecode_t SI117XDRV_RegisterPostFifoFlushCallback(SI117XDRV_DeviceSelect_t device, SI117XDRV_Callback_t callback, void *user)
Register a post fifo flush callback.
int32_t ppg1
ppg1 sample data
int16_t ppg2
ppg2 sample data
Si117x_Ecode_t SI117XDRV_FifoIntConfig(SI117XDRV_DeviceSelect_t device, bool enable)
Enable/disable fifo interrupt.
uint32_t ppgSampleRateus
desired PPG sample rate in us
Si117x_Ecode_t SI117XDRV_Dequeue24bPPGSampleData(SI117XDRV_DataQueueID_t id, SI117XDRV_PPG24bSample_t *sample)
Remove a PPG sample from the queue.
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.
SI117XDRV_SampleSize_t
Sample size settings.
bool fifo_self_test
enable fifo self test mode
int32_t bioz
bioz sample data
Si117x_Ecode_t SI117XDRV_FifoFlush(SI117XDRV_DeviceSelect_t device)
Flushes the Si117x fifo.
int32_t ppg4
ppg4 sample data
int32_t Si117x_Ecode_t
SI117XDRV error code.
Si117x_Ecode_t SI117XDRV_AllocateECGLDDataQueue(SI117XDRV_DataQueueID_t *id, SI117XDRV_ECGLDSample_t *queueBuffer, int16_t queueSizeInBytes)
Allocate a fifo queue for ECG data.
PPG 16bit sample data typedef. Use this data type to save memory.
int16_t ppg4
ppg4 sample data
Si117x_Ecode_t SI117XDRV_InitAPI(SI117XDRV_DeviceSelect_t device, HANDLE deviceHandle)
Initializes API memory and device handle.
uint8_t irq_enable
irq enable setting
Si117x_Ecode_t SI117XDRV_DequeueECGSampleData(SI117XDRV_DataQueueID_t id, SI117XDRV_ECGSample_t *sample)
Remove an ECG sample from the queue.
SI117XDRV_SynchMode_t synch_mode
sync mode
Si117XDRV ECG LD configuration.
bool fifo_disable
disable fifo
uint8_t syncMessage
sync message received
int32_t ecg
ecg sample data
uint8_t taskEnable
task enable
Si117x_Ecode_t SI117XDRV_SetPPGTaskEnable(SI117XDRV_DeviceSelect_t device, uint8_t ppgTasks)
Configure PPG tasks.
uint16_t SI117XDRV_NumSamplesInQueue(SI117XDRV_DataQueueID_t id)
Get number of samples in the queue.
uint16_t sequence
irq sequence number
uint8_t syncMessage
sync message received
uint8_t syncMessage
sync message received
uint16_t sequence
irq sequence number
int16_t ppg3
ppg3 sample data
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.
Si117x_Ecode_t SI117XDRV_Allocate24bPPGDataQueue(SI117XDRV_DataQueueID_t *id, SI117XDRV_PPG24bSample_t *queueBuffer, int16_t queueSizeInBytes)
Allocate a fifo queue for PPG data.
SI117XDRV_SynchMode_t
Sync configuration settings.
Si117x_Ecode_t SI117XDRV_Stop(SI117XDRV_DeviceSelect_t device)
Stop running measurements in the Si117x.
void(* SI117XDRV_AccelCallback_t)(SI117XDRV_DeviceSelect_t device, uint16_t ppgCount, void *user)
Typedef for accel sync DLE message received event.
uint16_t timestamp
irq timestamp
Si117x_Ecode_t SI117XDRV_GetFifoIntLevel(SI117XDRV_DeviceSelect_t device, uint16_t *fifo_int_level)
Returns the current fifo interrupt level the Si117x.
Si117x_Ecode_t SI117XDRV_InitializeSi117xFifoStateMachine(SI117XDRV_DeviceSelect_t device)
Initializes the FIFO processing state machine.
uint32_t accelSyncRateus
accel synchronization period in us
Si117x_Ecode_t SI117XDRV_RegisterAccelSyncCallback(SI117XDRV_DeviceSelect_t device, SI117XDRV_AccelCallback_t callback, void *user)
Register an accelerometer sync message callback.
uint32_t ecgSampleRateus
desired ECG sample rate in us
Si117x_Ecode_t SI117XDRV_DequeueECGLDSampleData(SI117XDRV_DataQueueID_t id, SI117XDRV_ECGLDSample_t *sample)
Remove an ECG LD sample from the queue.
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...
Si117x_Ecode_t SI117XDRV_FreeDataQueue(SI117XDRV_DataQueueID_t id)
De-allocate a fifo queue.
uint16_t fifo_int_level
fifo interrupt level
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
Si117XDRV one PPG channel configuration.
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...
Si117x_Ecode_t SI117XDRV_ClearQueue(SI117XDRV_DataQueueID_t id)
Empty a fifo queue.
Si117XDRV PPG configuration.
uint8_t ppg_sw_avg
ppg sw avg setting