EFM32 Happy Gecko Software Documentation  efm32hg-doc-5.1.2
si114x_algorithm.h
Go to the documentation of this file.
1 /**************************************************************************/
17 #ifndef __SI114X_ALGORITHM_H
18 #define __SI114X_ALGORITHM_H
19 
20 #include "em_device.h"
21 #include "si114x_functions.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /***************************************************************************/
32 /***************************************************************************/
37 /*******************************************************************************
38  ******************************* DEFINES ***********************************
39  ******************************************************************************/
41 #define SI1147_ADDR 0xc0
42 
43 /*******************************************************************************
44  ******************************* STRUCTS ***********************************
45  ******************************************************************************/
46 
50 typedef struct
51 {
52  u32 timestamp; /* Timestamp to record */
53  u16 vis; /* VIS */
54  u16 ir; /* IR */
55  u16 ps1; /* PS1 */
56  u16 ps2; /* PS2 */
57  u16 ps3; /* PS3 */
58  u16 aux; /* AUX */
59 } Si114x_Sample_TypeDef;
60 
63 /*******************************************************************************
64  ******************************** ENUMS ************************************
65  ******************************************************************************/
67 typedef enum
68 {
69  NONE,
70  UP,
71  DOWN,
72  LEFT,
73  RIGHT,
74  TAP
75 } gesture_t;
76 
77 /*******************************************************************************
78  ***************************** PROTOTYPES **********************************
79  ******************************************************************************/
80 gesture_t Si1147_NewSample(I2C_TypeDef *i2c, uint8_t addr, uint32_t timestamp);
81 int Si1147_ConfigureDetection(I2C_TypeDef *i2c, uint8_t addr, int slow);
82 int Si1147_SetInterruptOutputEnable(I2C_TypeDef *i2c, uint8_t addr, int enable);
83 int Si1147_GetInterruptOutputEnable(I2C_TypeDef *i2c, uint8_t addr, int *enable);
84 int Si1147_Detect_Device(I2C_TypeDef *i2c, uint8_t addr);
85 int Si1147_MeasureUVAndObjectPresent(I2C_TypeDef *i2c, uint8_t addr, uint16_t *uvIndex, int* objectDetect);
86 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* #define SI114X_ALGORITHM_H */
Si114x function prototypes, structure and bit definitions.
unsigned short int u16
Definition: bmp280.h:283
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
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.
unsigned int u32
Definition: bmp280.h:284
int Si1147_GetInterruptOutputEnable(I2C_TypeDef *i2c, uint8_t addr, int *enable)
Get the enable status of the Si1147 interrupt pin.
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 i...
int Si1147_SetInterruptOutputEnable(I2C_TypeDef *i2c, uint8_t addr, int enable)
Enables or disables the Si1147 interrupt pin.
int Si1147_ConfigureDetection(I2C_TypeDef *i2c, uint8_t addr, int slow)
Initializes and configures the Si1147 sensor.
int Si1147_Detect_Device(I2C_TypeDef *i2c, uint8_t addr)
Detects whether Si1147 is on the i2c bus.
gesture_t