Si1133 UV Index/Ambient Light Sensor with I2C

Device driver for the Si1133 sensor. More...

Detailed Description

Device driver for the Si1133 sensor.

The Si1133 is a UV Index Sensor and Ambient Light Sensor with I2C digital interface and programmable-event interrupt output.

The I2C protocol implemented in this driver is most similar in registers and commands to the Si115x family, like the SI1153, however the Si1133 supports UV index while the Si115x doesn't.

This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities as well.

Files

file  si1133.h
 Device driver interface for the Si1133 sensor.
 
file  si1133_internals.h
 Internal addresses, registers, constants for the Si1133 sensors family.
 
file  si1133_params.h
 Default configuration for SI1133.
 

Data Structures

struct  si1133_channel_t
 Channel configuration the Si1133 sensor. More...
 
struct  si1133_params_t
 Device initialization parameters. More...
 
struct  si1133_t
 Device descriptor for the Si1133 sensor. More...
 

Enumerations

enum  si1133_ret_code_t {
  SI1133_OK = 0, SI1133_ERR_PARAMS = -1, SI1133_ERR_I2C = -2, SI1133_ERR_LOGIC = -3,
  SI1133_ERR_NODEV = -4, SI1133_ERR_OVERFLOW = -5
}
 Driver error return codes. More...
 
enum  si1133_sensor_t {
  SI1133_SENS_SMALL_IR = 1u << 0, SI1133_SENS_MEDIUM_IR = 1u << 1, SI1133_SENS_LARGE_IR = 1u << 2, SI1133_SENS_WHITE = 1u << 3,
  SI1133_SENS_LARGE_WHITE = 1u << 4, SI1133_SENS_UV = 1u << 5, SI1133_SENS_DEEP_UV = 1u << 6
}
 Sensor (photodiode combination) in the Si1133 package.
 

Functions

si1133_ret_code_t si1133_init (si1133_t *dev, const si1133_params_t *params)
 Initialize the given Si1133 device. More...
 
si1133_ret_code_t si1133_configure_channels (si1133_t *dev, const si1133_channel_t *channels, uint32_t num_channels)
 Configure the capture channels. More...
 
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. More...
 
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. More...
 

Enumeration Type Documentation

◆ si1133_ret_code_t

Driver error return codes.

Enumerator
SI1133_OK 

No error.

SI1133_ERR_PARAMS 

Invalid parameters.

SI1133_ERR_I2C 

I2C communication error.

SI1133_ERR_LOGIC 

Device communication logic error.

SI1133_ERR_NODEV 

No SI1133 device detected.

SI1133_ERR_OVERFLOW 

ADC overflow when sampling.

Definition at line 43 of file si1133.h.

Function Documentation

◆ si1133_capture_sensors()

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.

Forces a one-time blocking sample of the sensors configured in the channels and returns the read values as signed 24-bit integers, sign extended to 32-bits. The number of channels sampled and configured sensor is set by the last call to si1133_configure_channels, however after sampling all of them only up to the first num_channels values will be returned by this function.

In case of ADC overflow, for example because there's too much light for the configured sensors the overflown sensor will read 0x7fffff and the function will return SI1133_ERR_OVERFLOW. In case of overflow, try configuring a smaller sensor, for example SI1133_SENS_MEDIUM_IR instead of SI1133_SENS_LARGE_IR, or reduce the sw_gain for the given sensor.

Parameters
[in]devDevice descriptor of Si1133 device to read from
[out]valuesPointer to the output value buffer.
[in]num_channelsMaximum number of channel values to return.
Returns
A si1133_ret_code_t error or status code.

◆ si1133_configure_channels()

si1133_ret_code_t si1133_configure_channels ( si1133_t dev,
const si1133_channel_t channels,
uint32_t  num_channels 
)

Configure the capture channels.

The Si1133 has up to 6 "channels" that can be configured to capture from the different sensors (photodiode combinations). See si1133_channel_t for a description of the channel configuration.

Parameters
[in]devDevice descriptor of Si1133 device to read from
[in]channelsArray of num_channels channel configuration.
[in]num_channelsNumber of configured channel passed in channels.
Returns
A si1133_ret_code_t error or status code.

◆ si1133_easy_configure()

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.

This function is a convenience function to configure one channel per selected sensor in the sensor_mask, up to the maximum number of channels, setting all channels to force-mode only with the same parameters. This is equivalent to a call to si1133_configure_channels with as many channels as bits set in the sensor_mask.

The channels are configured in increasing order of the si1133_sensor_t values.

Parameters
[in]devDevice descriptor of Si1133 device to read from
[in]sensor_maskCombination of up to 6 si1133_sensor_t values.
[in]sample_time_logLog2 of sampling time, 0 to 14. See si1133_channel_t for details.
[in]sw_gainSoftware gain, 0 to 7. See si1133_channel_t for details.

◆ si1133_init()

si1133_ret_code_t si1133_init ( si1133_t dev,
const si1133_params_t params 
)

Initialize the given Si1133 device.

Parameters
[out]devInitialized device descriptor of Si1133 device
[in]paramsInitialization parameters
Returns
A si1133_ret_code_t error or status code.