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