RocketLogger  1.1
tsl4531.h
Go to the documentation of this file.
1 
31 #ifndef SENSOR_TSL4531_H_
32 #define SENSOR_TSL4531_H_
33 
34 #include <errno.h>
35 #include <math.h>
36 #include <stdint.h>
37 #include <stdio.h>
38 #include <unistd.h>
39 
40 #include <fcntl.h>
41 #include <linux/i2c-dev.h>
42 #include <sys/ioctl.h>
43 #include <sys/stat.h>
44 #include <sys/types.h>
45 
46 #include "../log.h"
47 #include "../types.h"
48 
49 #define TSL4531_I2C_ADDRESS_LEFT 0x29
50 #define TSL4531_I2C_ADDRESS_RIGHT 0x28
51 
52 #define TSL4531_I2C_ADDRESSES \
53  { (TSL4531_I2C_ADDRESS_LEFT), (TSL4531_I2C_ADDRESS_RIGHT) }
54 
55 #define TSL4531_CHANNEL_DEFAULT 0
56 
57 // register definitions
58 #define TSL4531_ID 162
59 
60 #define TSL4531_COMMAND 0x80
61 
62 #define TSL4531_REG_CONTROL 0x00
63 #define TSL4531_REG_CONFIG 0x01
64 #define TSL4531_REG_DATALOW 0x04
65 #define TSL4531_REG_DATAHIGH 0x05
66 #define TSL4531_REG_ID 0x0A
67 
68 #define TSL4531_SAMPLE_OFF 0x00
69 #define TSL4531_SAMPLE_SINGLE 0x2
70 #define TSL4531_SAMPLE_CONTINUOUS 0x03
71 
72 #define TSL4531_HIGH_POWER 0x08
73 #define TSL4531_LOW_POWER 0x00
74 
75 #define TSL4531_INT_TIME_100 0x02
76 #define TSL4531_INT_TIME_200 0x01
77 #define TSL4531_INT_TIME_400 0x00
78 
79 #define TSL4531_MULT_100 4
80 #define TSL4531_MULT_200 2
81 #define TSL4531_MULT_400 1
82 
91 };
92 #define TSL4531_RANGE_LOW_MAX 65000
93 #define TSL4531_RANGE_MEDIUM_MAX 130000
94 #define TSL4531_RANGE_HYSTERESIS 5000
95 
96 /*
97  * API FUNCTIONS
98  */
99 int TSL4531_init(int);
100 void TSL4531_close(int);
101 int TSL4531_read(int);
102 int32_t TSL4531_getValue(int, int);
103 
104 int TSL4531_setRange(int, int);
105 int TSL4531_getRange(int);
106 
107 /*
108  * Helper FUNCTIONS
109  */
110 int TSL4531_getID(void);
111 int TSL4531_setParameters(int);
112 int TSL4531_sendRange(int, int);
113 int TSL4531_getIndex(int);
114 
115 #endif /* SENSOR_TSL4531_H_ */
int32_t TSL4531_getValue(int, int)
Definition: tsl4531.c:165
int TSL4531_init(int)
Definition: tsl4531.c:51
TSL4531_range
Definition: tsl4531.h:86
int TSL4531_getIndex(int)
Definition: tsl4531.c:321
int TSL4531_setRange(int, int)
Definition: tsl4531.c:181
int TSL4531_sendRange(int, int)
Definition: tsl4531.c:260
int TSL4531_getRange(int)
Definition: tsl4531.c:200
int TSL4531_setParameters(int)
Definition: tsl4531.c:232
int TSL4531_getID(void)
Definition: tsl4531.c:215
void TSL4531_close(int)
Definition: tsl4531.c:87
int TSL4531_read(int)
Definition: tsl4531.c:96