spectrometer2 2.0.0.0
spectrometer2.h File Reference

This file contains API for Spectrometer 2 Click Driver. More...

#include "drv_digital_out.h"
#include "drv_digital_in.h"
#include "drv_i2c_master.h"

Go to the source code of this file.

Data Structures

struct  spectrometer2_t
 Spectrometer 2 Click context object. More...
 
struct  spectrometer2_cfg_t
 Spectrometer 2 Click configuration object. More...
 
struct  spectrometer2_als_channels_t
 Spectrometer 2 ALS channels data object. More...
 
struct  spectrometer2_hsl_t
 Spectrometer 2 HSL color data object. More...
 

Macros

#define SPECTROMETER2_REG_DEVICE_ID   0x00
 Spectrometer 2 register map.
 
#define SPECTROMETER2_REG_REVISION_ID   0x01
 
#define SPECTROMETER2_REG_INTERRUPT_CTRL   0x02
 
#define SPECTROMETER2_REG_ALS_CTRL   0x03
 
#define SPECTROMETER2_REG_ALS_PERIOD   0x04
 
#define SPECTROMETER2_REG_ALS_CH1_DATA_H   0x06
 
#define SPECTROMETER2_REG_ALS_CH1_DATA_M   0x07
 
#define SPECTROMETER2_REG_ALS_CH1_DATA_L   0x08
 
#define SPECTROMETER2_REG_ALS_CH2_DATA_H   0x0A
 
#define SPECTROMETER2_REG_ALS_CH2_DATA_M   0x0B
 
#define SPECTROMETER2_REG_ALS_CH2_DATA_L   0x0C
 
#define SPECTROMETER2_REG_ALS_CH3_DATA_H   0x0E
 
#define SPECTROMETER2_REG_ALS_CH3_DATA_M   0x0F
 
#define SPECTROMETER2_REG_ALS_CH3_DATA_L   0x10
 
#define SPECTROMETER2_REG_ALS_CH4_DATA_H   0x12
 
#define SPECTROMETER2_REG_ALS_CH4_DATA_M   0x13
 
#define SPECTROMETER2_REG_ALS_CH4_DATA_L   0x14
 
#define SPECTROMETER2_REG_ALS_CH5_DATA_H   0x16
 
#define SPECTROMETER2_REG_ALS_CH5_DATA_M   0x17
 
#define SPECTROMETER2_REG_ALS_CH5_DATA_L   0x18
 
#define SPECTROMETER2_REG_ALS_CH6_DATA_H   0x1A
 
#define SPECTROMETER2_REG_ALS_CH6_DATA_M   0x1B
 
#define SPECTROMETER2_REG_ALS_CH6_DATA_L   0x1C
 
#define SPECTROMETER2_REG_ALS_EXPOSURE_M   0x1D
 
#define SPECTROMETER2_REG_ALS_EXPOSURE_L   0x1E
 
#define SPECTROMETER2_REG_ALS_GAIN_CH1   0x25
 
#define SPECTROMETER2_REG_ALS_GAIN_CH2   0x26
 
#define SPECTROMETER2_REG_ALS_GAIN_CH3   0x27
 
#define SPECTROMETER2_REG_ALS_GAIN_CH4   0x28
 
#define SPECTROMETER2_REG_ALS_GAIN_CH5   0x29
 
#define SPECTROMETER2_REG_ALS_GAIN_CH6   0x2A
 
#define SPECTROMETER2_REG_CHANNEL6_ENABLE   0x2D
 
#define SPECTROMETER2_REG_ALS_CHANNEL_ENABLE   0x2E
 
#define SPECTROMETER2_REG_AC_MODE_CTRL   0x31
 
#define SPECTROMETER2_REG_PEDESTAL_VALUE   0x32
 
#define SPECTROMETER2_REG_SDA_DRV_CFG   0x3C
 
#define SPECTROMETER2_REG_GPIO1_DRV_CFG   0x41
 
#define SPECTROMETER2_INTR_STATUS   0x02
 Spectrometer 2 INTERRUPT_CTRL register settings.
 
#define SPECTROMETER2_CLR_INTR_SET   0x01
 
#define SPECTROMETER2_CLR_INTR_CLEAR   0x00
 
#define SPECTROMETER2_EXPOSURE_TIME_MS_MAX   1638.4
 Spectrometer 2 ALS_EXPOSURE register settings.
 
#define SPECTROMETER2_EXPOSURE_TIME_MS_DEFAULT   160.0
 
#define SPECTROMETER2_EXPOSURE_TIME_MS_MIN   1.6
 
#define SPECTROMETER2_EXPOSURE_TIME_MS_LSB   1.6
 
#define SPECTROMETER2_EXPOSURE_TIME_RES   0x03FF
 
#define SPECTROMETER2_IM_PERIOD_MS_MAX   5227.5
 Spectrometer 2 ALS_PERIOD register settings.
 
#define SPECTROMETER2_IM_PERIOD_MS_DEFAULT   200.0
 
#define SPECTROMETER2_IM_PERIOD_MS_MIN   0.0
 
#define SPECTROMETER2_IM_PERIOD_MS_LSB   20.5
 
#define SPECTROMETER2_IM_PERIOD_RES   0xFF
 
#define SPECTROMETER2_AGAIN_66p6X   0x01
 Spectrometer 2 ALS_GAIN_CHx register settings.
 
#define SPECTROMETER2_AGAIN_50X   0x02
 
#define SPECTROMETER2_AGAIN_33X   0x03
 
#define SPECTROMETER2_AGAIN_25X   0x04
 
#define SPECTROMETER2_AGAIN_16X   0x05
 
#define SPECTROMETER2_AGAIN_10X   0x06
 
#define SPECTROMETER2_AGAIN_7p1X   0x07
 
#define SPECTROMETER2_AGAIN_5X   0x08
 
#define SPECTROMETER2_AGAIN_3p33X   0x09
 
#define SPECTROMETER2_AGAIN_2p5X   0x0A
 
#define SPECTROMETER2_AGAIN_1p67X   0x0B
 
#define SPECTROMETER2_AGAIN_1p25X   0x0C
 
#define SPECTROMETER2_AGAIN_1X   0x0D
 
#define SPECTROMETER2_AGAIN_0p83X   0x0E
 
#define SPECTROMETER2_AGAIN_0p71X   0x0F
 
#define SPECTROMETER2_AGAIN_BIT_MASK   0x0F
 
#define SPECTROMETER2_CHANNEL6_DISABLE   0x00
 Spectrometer 2 CHANNEL6_ENABLE register settings.
 
#define SPECTROMETER2_CHANNEL6_ENABLE   0x01
 
#define SPECTROMETER2_NO_CHANNEL_ENABLED   0x00
 Spectrometer 2 ALS_CHANNEL_ENABLE register settings.
 
#define SPECTROMETER2_CHANNEL1_ENABLE   0x01
 
#define SPECTROMETER2_CHANNEL2_ENABLE   0x02
 
#define SPECTROMETER2_CHANNEL3_ENABLE   0x04
 
#define SPECTROMETER2_CHANNEL4_ENABLE   0x08
 
#define SPECTROMETER2_CHANNEL5_ENABLE   0x10
 
#define SPECTROMETER2_ALL_CHANNELS_ENABLE   0x1F
 
#define SPECTROMETER2_ALS_MODE_SINGLE   0x00
 Spectrometer 2 ALS_CTRL register settings.
 
#define SPECTROMETER2_ALS_MODE_CONTINUOUS   0x06
 
#define SPECTROMETER2_ALS_STOP   0x00
 
#define SPECTROMETER2_ALS_START   0x01
 
#define SPECTROMETER2_UNKNOWN_COLOR   0
 Spectrometer 2 color flags.
 
#define SPECTROMETER2_RED_COLOR   1
 
#define SPECTROMETER2_YELLOW_COLOR   2
 
#define SPECTROMETER2_GREEN_COLOR   3
 
#define SPECTROMETER2_CYAN_COLOR   4
 
#define SPECTROMETER2_BLUE_COLOR   5
 
#define SPECTROMETER2_MAGENTA_COLOR   6
 
#define SPECTROMETER2_WHITE_COLOR   7
 
#define SPECTROMETER2_BLACK_COLOR   8
 
#define SPECTROMETER2_WHITE_COLOR_LIGHTNESS   95
 Spectrometer 2 color from HSL thresholds.
 
#define SPECTROMETER2_BLACK_COLOR_LIGHTNESS   5
 
#define SPECTROMETER2_YELLOW_COLOR_HUE_ANGLE   30
 
#define SPECTROMETER2_GREEN_COLOR_HUE_ANGLE   90
 
#define SPECTROMETER2_CYAN_COLOR_HUE_ANGLE   150
 
#define SPECTROMETER2_BLUE_COLOR_HUE_ANGLE   210
 
#define SPECTROMETER2_MAGENTA_COLOR_HUE_ANGLE   270
 
#define SPECTROMETER2_RED_COLOR_HUE_ANGLE   330
 
#define SPECTROMETER2_HSL_HUE_RESOLUTION   360
 Spectrometer 2 RGB to HSL calculation values.
 
#define SPECTROMETER2_HSL_SATURATION_RESOLUTION   100
 
#define SPECTROMETER2_HSL_LIGHTNESS_RESOLUTION   100
 
#define SPECTROMETER2_DEVICE_ID   0x70
 Spectrometer 2 device ID value.
 
#define SPECTROMETER2_DEVICE_ADDRESS   0x20
 Spectrometer 2 device address setting.
 
#define SPECTROMETER2_MAP_MIKROBUS(cfg, mikrobus)
 MikroBUS pin mapping.
 

Enumerations

enum  spectrometer2_return_value_t { SPECTROMETER2_OK = 0 , SPECTROMETER2_ERROR = -1 }
 Spectrometer 2 Click return value data. More...
 

Functions

void spectrometer2_cfg_setup (spectrometer2_cfg_t *cfg)
 Spectrometer 2 configuration object setup function.
 
err_t spectrometer2_init (spectrometer2_t *ctx, spectrometer2_cfg_t *cfg)
 Spectrometer 2 initialization function.
 
err_t spectrometer2_default_cfg (spectrometer2_t *ctx)
 Spectrometer 2 default configuration function.
 
err_t spectrometer2_generic_write (spectrometer2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
 Spectrometer 2 I2C writing function.
 
err_t spectrometer2_generic_read (spectrometer2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
 Spectrometer 2 I2C reading function.
 
err_t spectrometer2_write_register (spectrometer2_t *ctx, uint8_t reg, uint8_t data_in)
 Spectrometer 2 write register function.
 
err_t spectrometer2_read_register (spectrometer2_t *ctx, uint8_t reg, uint8_t *data_out)
 Spectrometer 2 read register function.
 
err_t spectrometer2_check_communication (spectrometer2_t *ctx)
 Spectrometer 2 check communication function.
 
uint8_t spectrometer2_get_int_pin (spectrometer2_t *ctx)
 Spectrometer 2 get int pin function.
 
uint8_t spectrometer2_get_an_pin (spectrometer2_t *ctx)
 Spectrometer 2 get an pin function.
 
err_t spectrometer2_get_data (spectrometer2_t *ctx, spectrometer2_als_channels_t *als_channels)
 Spectrometer 2 get data function.
 
err_t spectrometer2_clear_interrupt (spectrometer2_t *ctx)
 Spectrometer 2 clear interrupt function.
 
err_t spectrometer2_set_exposure_time (spectrometer2_t *ctx, float exp_time)
 Spectrometer 2 set exposure time function.
 
err_t spectrometer2_set_inter_measurement_period (spectrometer2_t *ctx, float im_period)
 Spectrometer 2 set inter measurement period function.
 
uint8_t spectrometer2_get_color (spectrometer2_hsl_t *hsl)
 Spectrometer 2 get color function.
 
void spectrometer2_rgbc_to_hsl (spectrometer2_als_channels_t *rgbc, spectrometer2_hsl_t *hsl)
 Spectrometer 2 rgbc to hsl function.
 

Detailed Description

This file contains API for Spectrometer 2 Click Driver.

Enumeration Type Documentation

◆ spectrometer2_return_value_t

Spectrometer 2 Click return value data.

Predefined enum values for driver return values.

Enumerator
SPECTROMETER2_OK 
SPECTROMETER2_ERROR