Go to the documentation of this file.
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
53 #define ILLUMINANCE_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
63 #define ILLUMINANCE_RETVAL uint8_t
65 #define ILLUMINANCE_OK 0x00
66 #define ILLUMINANCE_INIT_ERROR 0xFF
73 #define ILLUMINANCE_TSL2561_I2C_ADDR_LOW 0x29
74 #define ILLUMINANCE_TSL2561_I2C_ADDR_FLOAT 0x39
75 #define ILLUMINANCE_TSL2561_I2C_ADDR_HIGH 0x49
82 #define ILLUMINANCE_TSL2561_REGISTER_CONTROL 0x00
83 #define ILLUMINANCE_TSL2561_REGISTER_TIMING 0x01
84 #define ILLUMINANCE_TSL2561_REGISTER_THRESHHOLDL_LOW 0x02
85 #define ILLUMINANCE_TSL2561_REGISTER_THRESHHOLDL_HIGH 0x03
86 #define ILLUMINANCE_TSL2561_REGISTER_THRESHHOLDH_LOW 0x04
87 #define ILLUMINANCE_TSL2561_REGISTER_THRESHHOLDH_HIGH 0x05
88 #define ILLUMINANCE_TSL2561_REGISTER_INTERRUPT 0x06
89 #define ILLUMINANCE_TSL2561_REGISTER_CRC 0x08
90 #define ILLUMINANCE_TSL2561_REGISTER_ID 0x0A
91 #define ILLUMINANCE_TSL2561_REGISTER_CHAN0_LOW 0x0C
92 #define ILLUMINANCE_TSL2561_REGISTER_CHAN0_HIGH 0x0D
93 #define ILLUMINANCE_TSL2561_REGISTER_CHAN1_LOW 0x0E
94 #define ILLUMINANCE_TSL2561_REGISTER_CHAN1_HIGH 0x0F
101 #define ILLUMINANCE_TSL2561_INTEGRATIONTIME_13MS 0x00
102 #define ILLUMINANCE_TSL2561_INTEGRATIONTIME_101MS 0x01
103 #define ILLUMINANCE_TSL2561_INTEGRATIONTIME_402MS 0x02
104 #define ILLUMINANCE_TSL2561_GAIN_0X 0x00
105 #define ILLUMINANCE_TSL2561_GAIN_16X 0x10
106 #define ILLUMINANCE_TSL2561_COMMAND_BIT 0x80
107 #define ILLUMINANCE_TSL2561_CLEAR_BIT 0x40
108 #define ILLUMINANCE_TSL2561_WORD_BIT 0x20
109 #define ILLUMINANCE_TSL2561_BLOCK_BIT 0x10
110 #define ILLUMINANCE_TSL2561_CONTROL_POWERON 0x03
111 #define ILLUMINANCE_TSL2561_CONTROL_POWEROFF 0x00
112 #define ILLUMINANCE_TSL2561_CHSCALE_TINT0 0x7517
113 #define ILLUMINANCE_TSL2561_CHSCALE_TINT1 0x0FE7
114 #define ILLUMINANCE_TSL2561_LUX_SCALE 14
115 #define ILLUMINANCE_TSL2561_RATIO_SCALE 9
116 #define ILLUMINANCE_TSL2561_CH_SCALE 10
123 #define ILLUMINANCE_TSL2561_K1T 0x0040
124 #define ILLUMINANCE_TSL2561_B1T 0x01f2
125 #define ILLUMINANCE_TSL2561_M1T 0x01be
126 #define ILLUMINANCE_TSL2561_K2T 0x0080
127 #define ILLUMINANCE_TSL2561_B2T 0x0214
128 #define ILLUMINANCE_TSL2561_M2T 0x02d1
129 #define ILLUMINANCE_TSL2561_K3T 0x00c0
130 #define ILLUMINANCE_TSL2561_B3T 0x023f
131 #define ILLUMINANCE_TSL2561_M3T 0x037b
132 #define ILLUMINANCE_TSL2561_K4T 0x0100
133 #define ILLUMINANCE_TSL2561_B4T 0x0270
134 #define ILLUMINANCE_TSL2561_M4T 0x03fe
135 #define ILLUMINANCE_TSL2561_K5T 0x0138
136 #define ILLUMINANCE_TSL2561_B5T 0x016f
137 #define ILLUMINANCE_TSL2561_M5T 0x01fc
138 #define ILLUMINANCE_TSL2561_K6T 0x019a
139 #define ILLUMINANCE_TSL2561_B6T 0x00d2
140 #define ILLUMINANCE_TSL2561_M6T 0x00fb
141 #define ILLUMINANCE_TSL2561_K7T 0x029a
142 #define ILLUMINANCE_TSL2561_B7T 0x0018
143 #define ILLUMINANCE_TSL2561_M7T 0x0012
144 #define ILLUMINANCE_TSL2561_K8T 0x029a
145 #define ILLUMINANCE_TSL2561_B8T 0x0000
146 #define ILLUMINANCE_TSL2561_M8T 0x0000
330 #endif // _ILLUMINANCE_H_
pin_name_t sda
Definition: illuminance.h:185
digital_in_t int_pin
Definition: illuminance.h:165
void illuminance_default_cfg(illuminance_t *ctx)
Click Default Configuration function.
uint8_t illuminance_get_interrupt(illuminance_t *ctx)
Get interrupt pin status.
uint16_t illuminance_calculate_lux(uint16_t value_gain, uint16_t value_int, uint16_t ch0, uint16_t ch1)
Calculate lux value.
void illuminance_cfg_setup(illuminance_cfg_t *cfg)
Config Object Initialization function.
uint8_t illuminance_read_data(illuminance_t *ctx, uint8_t addr)
Generic read data function.
void illuminance_get_result(illuminance_t *ctx, uint16_t *value_ch0, uint16_t *value_ch1)
Get Visible & Infrared value.
void illuminance_generic_read(illuminance_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void illuminance_generic_write(illuminance_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t slave_address
Definition: illuminance.h:173
void illuminance_write_data(illuminance_t *ctx, uint8_t address, uint8_t write_command)
Generic write data function.
uint8_t i2c_address
Definition: illuminance.h:194
pin_name_t int_pin
Definition: illuminance.h:189
#define ILLUMINANCE_RETVAL
Definition: illuminance.h:63
i2c_master_t i2c
Definition: illuminance.h:169
ILLUMINANCE_RETVAL illuminance_init(illuminance_t *ctx, illuminance_cfg_t *cfg)
Initialization function.
pin_name_t scl
Definition: illuminance.h:184
Click ctx object definition.
Definition: illuminance.h:160
Click configuration structure definition.
Definition: illuminance.h:180
uint32_t i2c_speed
Definition: illuminance.h:193