-
Notifications
You must be signed in to change notification settings - Fork 0
/
si114x_algorithm.h
95 lines (79 loc) · 3.42 KB
/
si114x_algorithm.h
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
/**************************************************************************//**
* @file
* @brief Swipe algorithm for Si114x
* @version 3.20.9
******************************************************************************
* @section License
* <b>(C) Copyright 2014 Silicon Labs, http://www.silabs.com</b>
*******************************************************************************
*
* This file is licensensed under the Silabs License Agreement. See the file
* "Silabs_License_Agreement.txt" for details. Before using this software for
* any purpose, you must agree to the terms of that agreement.
*
******************************************************************************/
#ifndef __SI114X_ALGORITHM_H
#define __SI114X_ALGORITHM_H
#include "em_device.h"
#include "si114x_functions.h"
#ifdef __cplusplus
extern "C" {
#endif
/***************************************************************************//**
* @addtogroup Drivers
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup Si114x
* @{
******************************************************************************/
/*******************************************************************************
******************************* DEFINES ***********************************
******************************************************************************/
/** I2C device address for Si1147 on weather station board. */
#define SI1147_ADDR 0xc0
/*******************************************************************************
******************************* STRUCTS ***********************************
******************************************************************************/
/** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
/** Interrupt Sample */
typedef struct
{
u32 timestamp; /* Timestamp to record */
u16 vis; /* VIS */
u16 ir; /* IR */
u16 ps1; /* PS1 */
u16 ps2; /* PS2 */
u16 ps3; /* PS3 */
u16 aux; /* AUX */
} Si114x_Sample_TypeDef;
/** @endcond */
/*******************************************************************************
******************************** ENUMS ************************************
******************************************************************************/
/** Si114x gestures */
typedef enum
{
NONE,
UP,
DOWN,
LEFT,
RIGHT,
TAP
} gesture_t;
/*******************************************************************************
***************************** PROTOTYPES **********************************
******************************************************************************/
gesture_t Si1147_NewSample(I2C_TypeDef *i2c, uint8_t addr, uint32_t timestamp);
gesture_t Si1147_NewPosSample(I2C_TypeDef *i2c, uint8_t addr, uint32_t timestamp, int *dist);
int Si1147_ConfigureDetection(I2C_TypeDef *i2c, uint8_t addr, int slow);
int Si1147_SetInterruptOutputEnable(I2C_TypeDef *i2c, uint8_t addr, int enable);
int Si1147_GetInterruptOutputEnable(I2C_TypeDef *i2c, uint8_t addr, int *enable);
int Si1147_Detect_Device(I2C_TypeDef *i2c, uint8_t addr);
int Si1147_MeasureUVAndObjectPresent(I2C_TypeDef *i2c, uint8_t addr, uint16_t *uvIndex, int* objectDetect);
/** @} (end addtogroup Drivers) */
/** @} (end addtogroup Si114x) */
#ifdef __cplusplus
}
#endif
#endif /* #define SI114X_ALGORITHM_H */