si114x_algorithm.c File Reference

Configures and calculates gestures from Si1147.

License

Copyright 2018 Silicon Laboratories Inc. www.silabs.com

The licensor of this software is Silicon Laboratories Inc. Your use of this software is governed by the terms of Silicon Labs Master Software License Agreement (MSLA) available at www.silabs.com/about-us/legal/master-software-license-agreement. This software is distributed to you in Source Code format and is governed by the sections of the MSLA applicable to Source Code.

Definition in file si114x_algorithm.c.

#include "si114x_algorithm.h"
#include "si114x_functions.h"
#include "si1147_i2c.h"

Macros

#define GESTURE_IRQ   (IE_ALS_EVRYSAMPLE | IE_PS1_EVRYSAMPLE | IE_PS2_EVRYSAMPLE | IE_PS3_EVRYSAMPLE)
 
#define GESTURE_TASKLIST   0x7
 
#define HOVER_TASKLIST   0x1
 
#define LED1I   0xb
 
#define LED2I   0xb
 
#define LED3I   0xb
 
#define MEASRATE_FAST   320
 
#define MEASRATE_SLOW   32000
 
#define PS_HOVER_THRESHOLD   295
 
#define PS_THRESHOLD   275
 
#define SI1147_DEVICE_ID   0x47
 
#define UV_IRQ_EN   IE_ALS_EVRYSAMPLE
 
#define UV_TASKLIST   0x80
 

Functions

static gesture_t ProcessSi1147Samples (Si114x_Sample_TypeDef *samples)
 Implements the algorithm for detecting gestures on the sensor STK. Should be called with new sample data every time an interrupt is received.
 
static void readPSData (HANDLE si114x_handle, Si114x_Sample_TypeDef *sample)
 Reads the PS measurement data from the Si1147.
 
int Si1147_ConfigureDetection (I2C_TypeDef *i2c, uint8_t addr, int lowpower)
 Initializes and configures the Si1147 sensor.
 
int Si1147_Detect_Device (I2C_TypeDef *i2c, uint8_t addr)
 Detects whether Si1147 is on the i2c bus.
 
int Si1147_GetInterruptOutputEnable (I2C_TypeDef *i2c, uint8_t addr, int *enable)
 Get the enable status of the Si1147 interrupt pin.
 
int Si1147_MeasureUVAndObjectPresent (I2C_TypeDef *i2c, uint8_t addr, uint16_t *uvIndex, int *objectDetect)
 Reads the UV measurement data and checks for object in proximity to the Si1147.
 
gesture_t Si1147_NewSample (I2C_TypeDef *i2c, uint8_t addr, uint32_t timestamp)
 Reads new measurement data and processes a new sample. This function should be called every time an interrupt for a new sample is received.
 
int Si1147_SetInterruptOutputEnable (I2C_TypeDef *i2c, uint8_t addr, int enable)
 Enables or disables the Si1147 interrupt pin.
 

Variables

static si114x_i2c_t * si114x_handle = &si114x_i2c
 
static si114x_i2c_t si114x_i2c
 

Function Documentation

static gesture_t ProcessSi1147Samples ( Si114x_Sample_TypeDef *  samples)
static

Implements the algorithm for detecting gestures on the sensor STK. Should be called with new sample data every time an interrupt is received.

Parameters
[in]samplesNew sample data received from the sensor.
Returns
Returns the type of gesture detected (as defined by gesture_t).

Definition at line 224 of file si114x_algorithm.c.

Referenced by Si1147_NewSample().

static void readPSData ( HANDLE  si114x_handle,
Si114x_Sample_TypeDef *  sample 
)
static

Reads the PS measurement data from the Si1147.

Parameters
[in]si114x_handleContains i2c peripheral information. See definition of si114x_i2c_t.
[out]sampleThe sample data read from the sensor.

Definition at line 174 of file si114x_algorithm.c.

References Si114xReadFromRegister().

Referenced by Si1147_NewSample().