isl29125.h
Go to the documentation of this file.
1 /*
2  * Copyright 2015 Ludwig Knüpfer
3  * Copyright 2017 HAW Hamburg
4  *
5  * This file is subject to the terms and conditions of the GNU Lesser
6  * General Public License v2.1. See the file LICENSE in the top level
7  * directory for more details.
8  */
9 
48 #ifndef ISL29125_H
49 #define ISL29125_H
50 
51 #include <stdint.h>
52 
53 #include "periph/i2c.h"
54 #include "periph/gpio.h"
55 #include "color.h"
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
64 typedef struct {
65  float red;
66  float green;
67  float blue;
69 
74 typedef enum {
78  ISL29125_MODE_R = 0x02,
79  ISL29125_MODE_G = 0x01,
80  ISL29125_MODE_B = 0x03,
84 
88 typedef enum {
92 
97 typedef enum {
101 
105 typedef struct {
107  gpio_t gpio;
112 
116 typedef struct {
118 } isl29125_t;
119 
123 typedef enum {
129 
133 typedef enum {
139 
143 typedef enum {
147 
157 int isl29125_init(isl29125_t *dev, const isl29125_params_t *params);
158 
174 int isl29125_init_int(isl29125_t *dev, isl29125_interrupt_status_t interrupt_status,
175  isl29125_interrupt_persist_t interrupt_persist,
176  isl29125_interrupt_conven_t interrupt_conven,
177  uint16_t lower_threshold, uint16_t higher_threshold,
178  gpio_cb_t cb, void *arg);
179 
186 void isl29125_read_rgb_lux(const isl29125_t *dev, isl29125_rgb_t *dest);
187 
194 void isl29125_read_rgb_color(const isl29125_t *dev, color_rgb_t *dest);
195 
202 void isl29125_set_mode(const isl29125_t *dev, isl29125_mode_t mode);
203 
211 int isl29125_read_irq_status(const isl29125_t *dev);
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif /* ISL29125_H */
218 
isl29125_interrupt_status_t
isl29125_interrupt_status_t
Configuration-3 Register 0x03 B1:0.
Definition: isl29125.h:123
ISL29125_MODE_B
@ ISL29125_MODE_B
blue conversion only
Definition: isl29125.h:80
isl29125_t::params
isl29125_params_t params
device parameters
Definition: isl29125.h:117
isl29125_params_t::range
isl29125_range_t range
measurement range
Definition: isl29125.h:108
isl29125_read_irq_status
int isl29125_read_irq_status(const isl29125_t *dev)
Read isl29125 interrupt status.
isl29125_init
int isl29125_init(isl29125_t *dev, const isl29125_params_t *params)
Initialize a new ISL29125 device.
ISL29125_INTERRUPT_PERSIST_4
@ ISL29125_INTERRUPT_PERSIST_4
Int.
Definition: isl29125.h:136
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
ISL29125_INTERRUPT_CONV_DIS
@ ISL29125_INTERRUPT_CONV_DIS
RGB Conversion done to ~INT Control disable.
Definition: isl29125.h:144
ISL29125_INTERRUPT_PERSIST_2
@ ISL29125_INTERRUPT_PERSIST_2
Int.
Definition: isl29125.h:135
ISL29125_INTERRUPT_PERSIST_8
@ ISL29125_INTERRUPT_PERSIST_8
Int.
Definition: isl29125.h:137
isl29125_rgb_t::red
float red
red lux value
Definition: isl29125.h:65
isl29125_params_t::i2c
i2c_t i2c
I2C device the sensor is connected to.
Definition: isl29125.h:106
isl29125_rgb_t::green
float green
green lux value
Definition: isl29125.h:66
isl29125_range_t
isl29125_range_t
Supported RGB sensing range values of the ISL29125 sensor.
Definition: isl29125.h:88
ISL29125_INTERRUPT_STATUS_GREEN
@ ISL29125_INTERRUPT_STATUS_GREEN
GREEN interrupt.
Definition: isl29125.h:125
isl29125_init_int
int isl29125_init_int(isl29125_t *dev, isl29125_interrupt_status_t interrupt_status, isl29125_interrupt_persist_t interrupt_persist, isl29125_interrupt_conven_t interrupt_conven, uint16_t lower_threshold, uint16_t higher_threshold, gpio_cb_t cb, void *arg)
Initialize interrupts.
isl29125_t
Device descriptor for ISL29125 sensors.
Definition: isl29125.h:116
ISL29125_RANGE_375
@ ISL29125_RANGE_375
range: 5.7m - 375 lux
Definition: isl29125.h:89
isl29125_read_rgb_lux
void isl29125_read_rgb_lux(const isl29125_t *dev, isl29125_rgb_t *dest)
Read RGB values from device.
ISL29125_MODE_RG
@ ISL29125_MODE_RG
red and green conversion only
Definition: isl29125.h:81
ISL29125_MODE_RGB
@ ISL29125_MODE_RGB
RGB conversion.
Definition: isl29125.h:77
ISL29125_INTERRUPT_STATUS_NONE
@ ISL29125_INTERRUPT_STATUS_NONE
No interrupt.
Definition: isl29125.h:124
ISL29125_MODE_GB
@ ISL29125_MODE_GB
green and blue conversion only
Definition: isl29125.h:82
isl29125_params_t::gpio
gpio_t gpio
GPIO pin for interrupt/sync mode.
Definition: isl29125.h:107
ISL29125_INTERRUPT_PERSIST_1
@ ISL29125_INTERRUPT_PERSIST_1
Int.
Definition: isl29125.h:134
isl29125_params_t::mode
isl29125_mode_t mode
AD conversion mode.
Definition: isl29125.h:109
isl29125_rgb_t
Data type for storing lux RGB sensor readings.
Definition: isl29125.h:64
ISL29125_MODE_G
@ ISL29125_MODE_G
green conversion only
Definition: isl29125.h:79
isl29125_mode_t
isl29125_mode_t
Supported operation modes of the ISL29125 sensor's AD conversion.
Definition: isl29125.h:74
gpio_cb_t
void(* gpio_cb_t)(void *arg)
Signature of event callback functions triggered from interrupts.
Definition: gpio.h:146
ISL29125_MODE_STANDBY
@ ISL29125_MODE_STANDBY
AD conversion not performed.
Definition: isl29125.h:76
isl29125_rgb_t::blue
float blue
blue lux value
Definition: isl29125.h:67
isl29125_set_mode
void isl29125_set_mode(const isl29125_t *dev, isl29125_mode_t mode)
Set the device's operation mode.
isl29125_interrupt_persist_t
isl29125_interrupt_persist_t
Configuration-3 Register 0x03 B3:2.
Definition: isl29125.h:133
ISL29125_RESOLUTION_12
@ ISL29125_RESOLUTION_12
resolution: 12 bit
Definition: isl29125.h:98
ISL29125_INTERRUPT_STATUS_RED
@ ISL29125_INTERRUPT_STATUS_RED
RED interrupt.
Definition: isl29125.h:126
gpio.h
Low-level GPIO peripheral driver interface definitions.
isl29125_params_t
Device parameters for ISL29125 sensors.
Definition: isl29125.h:105
isl29125_read_rgb_color
void isl29125_read_rgb_color(const isl29125_t *dev, color_rgb_t *dest)
Read color values from device.
isl29125_resolution_t
isl29125_resolution_t
Supported color resolutions of the ISL29125 sensor's AD conversion.
Definition: isl29125.h:97
ISL29125_MODE_DOWN
@ ISL29125_MODE_DOWN
ADC powered down.
Definition: isl29125.h:75
color.h
Headers for the color handling module.
ISL29125_INTERRUPT_CONV_EN
@ ISL29125_INTERRUPT_CONV_EN
RGB Conversion done to ~INT Control enable.
Definition: isl29125.h:145
isl29125_params_t::res
isl29125_resolution_t res
AD conversion resolution.
Definition: isl29125.h:110
ISL29125_RESOLUTION_16
@ ISL29125_RESOLUTION_16
resolution: 16 bit
Definition: isl29125.h:99
ISL29125_MODE_R
@ ISL29125_MODE_R
red conversion only
Definition: isl29125.h:78
color_rgb_t
Data-structure describing a RGB color.
Definition: color.h:35
ISL29125_INTERRUPT_STATUS_BLUE
@ ISL29125_INTERRUPT_STATUS_BLUE
BLUE interrupt.
Definition: isl29125.h:127
ISL29125_RANGE_10K
@ ISL29125_RANGE_10K
range: 0.152 - 10,000 lux
Definition: isl29125.h:90
isl29125_interrupt_conven_t
isl29125_interrupt_conven_t
Configuration-3 Register 0x03 B4.
Definition: isl29125.h:143
i2c.h
Low-level I2C peripheral driver interface definition.