42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
66#define SPECTRAL2_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
70 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
77#define SPECTRAL2_RETVAL uint8_t
79#define SPECTRAL2_OK 0x00
80#define SPECTRAL2_INIT_ERROR 0xFF
88#define SPECTRAL2_SOFT_RESET 0x01 << 6
89#define SPECTRAL2_NORMAL_OPERATION 0x00 << 6
90#define SPECTRAL2_INT_ENABLE 0x01 << 5
91#define SPECTRAL2_INT_DISABLE 0x00 << 5
92#define SPECTRAL2_GAIN_1X 0x00 << 4
93#define SPECTRAL2_GAIN_3_7X 0x01 << 4
94#define SPECTRAL2_GAIN_16X 0x02 << 4
95#define SPECTRAL2_GAIN_64X 0x03 << 4
96#define SPECTRAL2_MODE_0 0x00 << 2
97#define SPECTRAL2_MODE_1 0x01 << 2
98#define SPECTRAL2_MODE_2 0x02 << 2
99#define SPECTRAL2_MODE_3 0x03 << 2
107#define SPECTRAL2_LED_DRV_CURRENT_12_5mA 0x00 << 4
108#define SPECTRAL2_LED_DRV_CURRENT_25mA 0x01 << 4
109#define SPECTRAL2_LED_DRV_CURRENT_50mA 0x02 << 4
110#define SPECTRAL2_LED_DRV_CURRENT_100mA 0x03 << 4
111#define SPECTRAL2_LED_DRV_ENABLE 0x01 << 2
112#define SPECTRAL2_LED_DRV_DISABLE 0x00 << 2
113#define SPECTRAL2_LED_IND_CURRENT_1mA 0x00 << 1
114#define SPECTRAL2_LED_IND_CURRENT_2mA 0x01 << 1
115#define SPECTRAL2_LED_IND_CURRENT_4mA 0x02 << 1
116#define SPECTRAL2_LED_IND_CURRENT_8mA 0x03 << 1
117#define SPECTRAL2_LED_IND_ENABLE 0x01
118#define SPECTRAL2_LED_IND_DISABLE 0x00
125#define SPECTRAL2_CALIBRATED_DATA_V 0x14
126#define SPECTRAL2_CALIBRATED_DATA_B 0x18
127#define SPECTRAL2_CALIBRATED_DATA_G 0x1C
128#define SPECTRAL2_CALIBRATED_DATA_Y 0x20
129#define SPECTRAL2_CALIBRATED_DATA_O 0x24
130#define SPECTRAL2_CALIBRATED_DATA_R 0x28
138#define SPECTRAL2_DATA_V 0x08
139#define SPECTRAL2_DATA_B 0x0A
140#define SPECTRAL2_DATA_G 0x0C
141#define SPECTRAL2_DATA_Y 0x0E
142#define SPECTRAL2_DATA_O 0x10
143#define SPECTRAL2_DATA_R 0x12
#define SPECTRAL2_RETVAL
Definition spectral2.h:77
void spectral2_generic_write(spectral2_t *ctx, uint8_t reg, uint8_t data_buf)
Generic write function.
void spectral2_default_cfg(spectral2_t *ctx)
Click Default Configuration function.
uint8_t spectral2_generic_read(spectral2_t *ctx, uint8_t reg)
Generic read function.
void spectral2_set_integration_time(spectral2_t *ctx, uint8_t cur_time)
Integration time function.
void spectral2_reset(spectral2_t *ctx)
Reset function.
void spectral2_led_control(spectral2_t *ctx, uint8_t led_data)
Led ctrl and setting function.
int32_t spectral2_get_calibrated_data(spectral2_t *ctx, uint8_t data_reg)
Reads calibrated data function.
void spectral2_cfg_setup(spectral2_cfg_t *cfg)
Config Object Initialization function.
int16_t spectral2_get_data(spectral2_t *ctx, uint8_t data_reg)
Read data function.
uint8_t spectral2_get_temperature(spectral2_t *ctx)
Read temperature function.
SPECTRAL2_RETVAL spectral2_init(spectral2_t *ctx, spectral2_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition spectral2.h:180
uint32_t i2c_speed
Definition spectral2.h:193
pin_name_t scl
Definition spectral2.h:183
pin_name_t int_pin
Definition spectral2.h:189
pin_name_t sda
Definition spectral2.h:184
pin_name_t rst
Definition spectral2.h:188
uint8_t i2c_address
Definition spectral2.h:194
Click ctx object definition.
Definition spectral2.h:157
digital_in_t int_pin
Definition spectral2.h:164
i2c_master_t i2c
Definition spectral2.h:168
digital_out_t rst
Definition spectral2.h:160
uint8_t slave_address
Definition spectral2.h:172