Loading...
Searching...
No Matches
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
9#pragma once
10
32
33#include "periph/i2c.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
50
54typedef enum {
55 SI1133_SENS_SMALL_IR = 1u << 0,
56 SI1133_SENS_MEDIUM_IR = 1u << 1,
57 SI1133_SENS_LARGE_IR = 1u << 2,
58 SI1133_SENS_WHITE = 1u << 3,
59 SI1133_SENS_LARGE_WHITE = 1u << 4,
60 SI1133_SENS_UV = 1u << 5,
61 SI1133_SENS_DEEP_UV = 1u << 6,
63
99
103typedef struct {
112 uint8_t address;
114
118typedef struct {
119 /* Initialization parameters */
121 uint8_t address;
122 /* Internal members */
123 uint8_t cmd_counter;
124 uint8_t num_channels;
126} si1133_t;
127
137
152 const si1133_channel_t *channels,
153 uint32_t num_channels);
154
175 si1133_sensor_t sensor_mask,
176 uint8_t sample_time_log,
177 uint8_t sw_gain);
178
202 uint32_t num_channels);
203
204#ifdef __cplusplus
205}
206#endif
207
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:144
si1133_sensor_t
Sensor (photodiode combination) in the Si1133 package.
Definition si1133.h:54
si1133_ret_code_t
Driver error return codes.
Definition si1133.h:42
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:45
@ SI1133_OK
No error.
Definition si1133.h:43
@ SI1133_ERR_PARAMS
Invalid parameters.
Definition si1133.h:44
@ SI1133_ERR_LOGIC
Device communication logic error.
Definition si1133.h:46
@ SI1133_ERR_NODEV
No SI1133 device detected.
Definition si1133.h:47
@ SI1133_ERR_OVERFLOW
ADC overflow when sampling.
Definition si1133.h:48
Low-level I2C peripheral driver interface definition.
Channel configuration the Si1133 sensor.
Definition si1133.h:94
uint8_t sample_time_log
Log2 of sampling time, 0 to 14.
Definition si1133.h:95
si1133_sensor_t sensor
Sensor to sample.
Definition si1133.h:97
uint8_t sw_gain
Software gain, 0 to 7.
Definition si1133.h:96
Device initialization parameters.
Definition si1133.h:103
uint8_t address
sensor address.
Definition si1133.h:112
i2c_t i2c_dev
I2C bus the sensor is connected to.
Definition si1133.h:104
Device descriptor for the Si1133 sensor.
Definition si1133.h:118
uint8_t cmd_counter
Si1133 command counter.
Definition si1133.h:123
si1133_channel_t channel[6]
Channel configuration.
Definition si1133.h:125
uint8_t address
sensor address
Definition si1133.h:121
uint8_t num_channels
Number of configured channels.
Definition si1133.h:124
i2c_t i2c_dev
I2C bus the sensor is connected to.
Definition si1133.h:120