41#ifdef PREINIT_SUPPORTED
45#ifdef MikroCCoreVersion
46 #if MikroCCoreVersion >= 1
51#include "drv_digital_in.h"
52#include "drv_i2c_master.h"
64#define AMBIENT2_CFG_RANGE_40_95_LX_MIN 0x0
65#define AMBIENT2_CFG_RANGE_81_9_LX 0x1000
66#define AMBIENT2_CFG_RANGE_163_8_LX 0x2000
67#define AMBIENT2_CFG_RANGE_327_6_LX 0x3000
68#define AMBIENT2_CFG_RANGE_655_2_LX 0x4000
69#define AMBIENT2_CFG_RANGE_1310_4_LX 0x5000
70#define AMBIENT2_CFG_RANGE_2620_8_LX 0x6000
71#define AMBIENT2_CFG_RANGE_5241_6_LX 0x7000
72#define AMBIENT2_CFG_RANGE_10483_2_LX 0x8000
73#define AMBIENT2_CFG_RANGE_20966_4_LX 0x9000
74#define AMBIENT2_CFG_RANGE_41932_8_LX 0xA000
75#define AMBIENT2_CFG_RANGE_83865_6_LX_MAX 0xB000
76#define AMBIENT2_CFG_RANGE_AUTO_SCALE 0xC000
83#define AMBIENT2_CFG_CONV_TIME_100MS 0x0
84#define AMBIENT2_CFG_CONV_TIME_800MS 0x800
91#define AMBIENT2_CFG_CONV_MODE_SHUTDOWN 0x0
92#define AMBIENT2_CFG_CONV_MODE_SINGLE_SHOT 0x200
93#define AMBIENT2_CFG_CONV_MODE_CONT_CONV 0x400
100#define AMBIENT2_CFG_LATCH_COMP_HYSTERESIS_STYLE 0x0
101#define AMBIENT2_CFG_LATCH_COMP_WINDOW_STYLE 0x10
108#define AMBIENT2_CFG_POL_INT_ACTIVE_LOW 0x0
109#define AMBIENT2_CFG_POL_INT_ACTIVE_HIGH 0x8
116#define AMBIENT2_CFG_MASK_EXPONENT 0x4
123#define AMBIENT2_CFG_FAULT_1_COUNT 0x0
124#define AMBIENT2_CFG_FAULT_2_COUNTS 0x1
125#define AMBIENT2_CFG_FAULT_4_COUNTS 0x2
126#define AMBIENT2_CFG_FAULT_8_COUNTS 0x3
133#define AMBIENT2_FLAG_MASK_OVERFLOW 0x100
134#define AMBIENT2_FLAG_MASK_CONV_READY 0x80
135#define AMBIENT2_FLAG_MASK_HIGH 0x40
136#define AMBIENT2_FLAG_MASK_LOW 0x20
143#define AMBIENT2_ID_MANUFACTURER 0x5449
144#define AMBIENT2_ID_DEVICE 0x3001
151#define AMBIENT2_MAP_MIKROBUS( cfg, mikrobus ) \
152 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
153 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
154 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
ambient2_err_t ambient2_init(ambient2_t *ctx, ambient2_cfg_t *cfg)
Click Initialization function.
void ambient2_cfg_setup(ambient2_cfg_t *cfg)
Configuration Object Setup function.
void ambient2_default_cfg(ambient2_t *ctx)
Click Default Configuration function.
void ambient2_generic_write(ambient2_t *ctx, ambient2_reg_addr_t reg_addr, ambient2_data_t data_in)
Generic Write function.
uint8_t ambient2_get_int(ambient2_t *ctx)
INT Pin Check function.
void ambient2_get_sens_results(ambient2_t *ctx)
Sensor Results Read function.
ambient2_data_t ambient2_generic_read(ambient2_t *ctx, ambient2_reg_addr_t reg_addr)
Generic Read function.
uint16_t ambient2_data_t
Click registers data type.
Definition ambient2.h:167
ambient2_reg_addr_t
Click register address selection.
Definition ambient2.h:196
ambient2_err_t
Click error code definition.
Definition ambient2.h:173
ambient_addr_t
Click I2C address selection.
Definition ambient2.h:184
@ AMBIENT2_REG_LOW_LIMIT
Definition ambient2.h:199
@ AMBIENT2_REG_MANUFACTURER_ID
Definition ambient2.h:201
@ AMBIENT2_REG_HIGH_LIMIT
Definition ambient2.h:200
@ AMBIENT2_REG_RESULT
Definition ambient2.h:197
@ AMBIENT2_REG_DEVICE_ID
Definition ambient2.h:202
@ AMBIENT2_REG_CONFIGURATION
Definition ambient2.h:198
@ AMBIENT2_OK
Definition ambient2.h:174
@ AMBIENT2_ERR_INIT_DRV
Definition ambient2.h:175
@ AMBIENT2_ERR_UNSUPPORTED_PIN
Definition ambient2.h:176
@ AMBIENT2_I2C_ADDRESS_VDD
Definition ambient2.h:186
@ AMBIENT2_I2C_ADDRESS_SCL
Definition ambient2.h:188
@ AMBIENT2_I2C_ADDRESS_GND
Definition ambient2.h:185
@ AMBIENT2_I2C_ADDRESS_SDA
Definition ambient2.h:187
Click configuration structure definition.
Definition ambient2.h:240
uint8_t i2c_addr
Definition ambient2.h:250
uint32_t i2c_speed
Definition ambient2.h:249
pin_name_t scl
Definition ambient2.h:242
pin_name_t int_pin
Definition ambient2.h:246
pin_name_t sda
Definition ambient2.h:243
Click sensor data definition.
Definition ambient2.h:210
float amb_light_lx
Definition ambient2.h:211
uint8_t amb_light_per
Definition ambient2.h:213
float amb_light_range
Definition ambient2.h:212
Click context object definition.
Definition ambient2.h:221
digital_in_t int_pin
Definition ambient2.h:223
i2c_master_t i2c
Definition ambient2.h:226
uint8_t slave_addr
Definition ambient2.h:229
ambient2_sens_data_t sens_data
Definition ambient2.h:232