si1133.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 iosabi
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser General
5  * Public License v2.1. See the file LICENSE in the top level directory for more
6  * details.
7  */
8 
31 #ifndef SI1133_H
32 #define SI1133_H
33 
34 #include "periph/i2c.h"
35 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
43 typedef enum {
44  SI1133_OK = 0,
51 
55 typedef enum {
56  SI1133_SENS_SMALL_IR = 1u << 0,
57  SI1133_SENS_MEDIUM_IR = 1u << 1,
58  SI1133_SENS_LARGE_IR = 1u << 2,
59  SI1133_SENS_WHITE = 1u << 3,
60  SI1133_SENS_LARGE_WHITE = 1u << 4,
61  SI1133_SENS_UV = 1u << 5,
62  SI1133_SENS_DEEP_UV = 1u << 6,
64 
95 typedef struct {
96  uint8_t sample_time_log;
97  uint8_t sw_gain;
100 
104 typedef struct {
113  uint8_t address;
115 
119 typedef struct {
120  /* Initialization parameters */
122  uint8_t address;
123  /* Internal members */
124  uint8_t cmd_counter;
125  uint8_t num_channels;
126  si1133_channel_t channel[6];
127 } si1133_t;
128 
138 
153  const si1133_channel_t *channels,
154  uint32_t num_channels);
155 
176  si1133_sensor_t sensor_mask,
177  uint8_t sample_time_log,
178  uint8_t sw_gain);
179 
203  uint32_t num_channels);
204 
205 #ifdef __cplusplus
206 }
207 #endif
208 
209 #endif /* SI1133_H */
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition: i2c.h:145
si1133_sensor_t
Sensor (photodiode combination) in the Si1133 package.
Definition: si1133.h:55
si1133_ret_code_t
Driver error return codes.
Definition: si1133.h:43
si1133_ret_code_t si1133_configure_channels(si1133_t *dev, const si1133_channel_t *channels, uint32_t num_channels)
Configure the capture channels.
si1133_ret_code_t si1133_easy_configure(si1133_t *dev, si1133_sensor_t sensor_mask, uint8_t sample_time_log, uint8_t sw_gain)
Convenience function to configure all capture channels.
si1133_ret_code_t si1133_capture_sensors(si1133_t *dev, int32_t *values, uint32_t num_channels)
Perform a one-time blocking sample of the configured channels.
si1133_ret_code_t si1133_init(si1133_t *dev, const si1133_params_t *params)
Initialize the given Si1133 device.
@ SI1133_ERR_I2C
I2C communication error.
Definition: si1133.h:46
@ SI1133_OK
No error.
Definition: si1133.h:44
@ SI1133_ERR_PARAMS
Invalid parameters.
Definition: si1133.h:45
@ SI1133_ERR_LOGIC
Device communication logic error.
Definition: si1133.h:47
@ SI1133_ERR_NODEV
No SI1133 device detected.
Definition: si1133.h:48
@ SI1133_ERR_OVERFLOW
ADC overflow when sampling.
Definition: si1133.h:49
Low-level I2C peripheral driver interface definition.
Channel configuration the Si1133 sensor.
Definition: si1133.h:95
uint8_t sample_time_log
Log2 of sampling time, 0 to 14.
Definition: si1133.h:96
si1133_sensor_t sensor
Sensor to sample.
Definition: si1133.h:98
uint8_t sw_gain
Software gain, 0 to 7.
Definition: si1133.h:97
Device initialization parameters.
Definition: si1133.h:104
uint8_t address
sensor address.
Definition: si1133.h:113
i2c_t i2c_dev
I2C bus the sensor is connected to.
Definition: si1133.h:105
Device descriptor for the Si1133 sensor.
Definition: si1133.h:119
uint8_t cmd_counter
Si1133 command counter.
Definition: si1133.h:124
uint8_t address
sensor address
Definition: si1133.h:122
uint8_t num_channels
Number of configured channels.
Definition: si1133.h:125
i2c_t i2c_dev
I2C bus the sensor is connected to.
Definition: si1133.h:121