39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
73#define AMBIENT19_REG_SYSM_CTRL 0x00
74#define AMBIENT19_REG_INT_CTRL 0x01
75#define AMBIENT19_REG_INT_FLAG 0x02
76#define AMBIENT19_REG_WAIT_TIME 0x03
77#define AMBIENT19_REG_ALS_GAIN 0x04
78#define AMBIENT19_REG_ALS_TIME 0x05
79#define AMBIENT19_REG_LED_CTRL 0x06
80#define AMBIENT19_REG_PS_GAIN 0x07
81#define AMBIENT19_REG_PS_PULSE 0x08
82#define AMBIENT19_REG_PS_TIME 0x09
83#define AMBIENT19_REG_PERSISTENCE 0x0B
84#define AMBIENT19_REG_ALS_THRES_LL 0x0C
85#define AMBIENT19_REG_ALS_THRES_LH 0x0D
86#define AMBIENT19_REG_ALS_THRES_HL 0x0E
87#define AMBIENT19_REG_ALS_THRES_HH 0x0F
88#define AMBIENT19_REG_PS_THRES_LL 0x10
89#define AMBIENT19_REG_PS_THRES_LH 0x11
90#define AMBIENT19_REG_PS_THRES_HL 0x12
91#define AMBIENT19_REG_PS_THRES_HH 0x13
92#define AMBIENT19_REG_PS_OFFSET_L 0x14
93#define AMBIENT19_REG_PS_OFFSET_H 0x15
94#define AMBIENT19_REG_INT_SOURCE 0x16
95#define AMBIENT19_REG_ERROR_FLAG 0x17
96#define AMBIENT19_REG_PS_DATA_L 0x18
97#define AMBIENT19_REG_PS_DATA_H 0x19
98#define AMBIENT19_REG_IR_DATA_L 0x1A
99#define AMBIENT19_REG_IR_DATA_H 0x1B
100#define AMBIENT19_REG_CH0_DATA_L 0x1C
101#define AMBIENT19_REG_CH0_DATA_H 0x1D
102#define AMBIENT19_REG_CH1_DATA_L 0x1E
103#define AMBIENT19_REG_CH1_DATA_H 0x1F
104#define AMBIENT19_REG_PNO_LB 0xBC
105#define AMBIENT19_REG_PNO_HB 0xBD
123#define AMBIENT19_SYSM_CTRL_SWRST 0x80
124#define AMBIENT19_SYSM_EN_WAIT 0x40
125#define AMBIENT19_SYSM_EN_PS 0x02
126#define AMBIENT19_SYSM_EN_ALS 0x01
132#define AMBIENT19_INT_CTRL_PS_INT_MODE 0x80
133#define AMBIENT19_INT_CTRL_SINT_MODE 0x40
134#define AMBIENT19_INT_CTRL_PS_SYNC 0x20
135#define AMBIENT19_INT_CTRL_ALS_SYNC 0x10
136#define AMBIENT19_INT_CTRL_EN_PINT 0x02
137#define AMBIENT19_INT_CTRL_EN_AINT 0x01
143#define AMBIENT19_INT_FLAG_INT_POR 0x80
144#define AMBIENT19_INT_FLAG_DATA_FLAG 0x40
145#define AMBIENT19_INT_FLAG_OBJ 0x20
146#define AMBIENT19_INT_FLAG_INT_PS 0x02
147#define AMBIENT19_INT_FLAG_INT_ALS 0x01
153#define AMBIENT19_WAIT_TIME_MAX 1280.0
154#define AMBIENT19_WAIT_TIME_MIN 5.0
155#define AMBIENT19_WAIT_TIME_STEP 5.0
156#define AMBIENT19_WAIT_TIME_DEFAULT 100.0
162#define AMBIENT19_ALS_GAIN_1X 0x00
163#define AMBIENT19_ALS_GAIN_4X 0x01
164#define AMBIENT19_ALS_GAIN_8X 0x02
165#define AMBIENT19_ALS_GAIN_32X 0x03
166#define AMBIENT19_ALS_GAIN_96X 0x04
172#define AMBIENT19_ALS_TIME_MAX 674.888
173#define AMBIENT19_ALS_TIME_MIN 5.513
174#define AMBIENT19_ALS_TIME_STEP 2.625
175#define AMBIENT19_ALS_TIME_DEFAULT 400.0
181#define AMBIENT19_LED_CTRL_IRDR_SEL_50mA 0x00
182#define AMBIENT19_LED_CTRL_IRDR_SEL_100mA 0x40
183#define AMBIENT19_LED_CTRL_IRDR_SEL_150mA 0x80
184#define AMBIENT19_LED_CTRL_IRDR_SEL_200mA 0xC0
185#define AMBIENT19_LED_CTRL_IRDR_SEL_BIT_MASK 0xC0
186#define AMBIENT19_LED_CTRL_ITW_PS_MAX 875.213
187#define AMBIENT19_LED_CTRL_ITW_PS_MIN 13.675
188#define AMBIENT19_LED_CTRL_ITW_PS_STEP 13.675
189#define AMBIENT19_LED_CTRL_ITW_PS_BIT_MASK 0x3F
195#define AMBIENT19_PS_GAIN_1X 0x00
196#define AMBIENT19_PS_GAIN_2X 0x01
197#define AMBIENT19_PS_GAIN_4X 0x02
198#define AMBIENT19_PS_GAIN_8X 0x03
204#define AMBIENT19_PS_TIME_MAX_COUNT_4095 0x0F
210#define AMBIENT19_PERSISTANCE_EVERY_ALS_CONV 0x00
216#define AMBIENT19_INT_SOURCE_CH0_DATA 0x00
217#define AMBIENT19_INT_SOURCE_CH1_DATA 0x01
223#define AMBIENT19_LUX_K1 0.52
224#define AMBIENT19_LUX_K2 0.94
225#define AMBIENT19_LUX_K3 1.12
231#define AMBIENT19_PRODUCT_NUM_LOW 0x14
232#define AMBIENT19_PRODUCT_NUM_HIGH 0x16
239#define AMBIENT19_DEVICE_ADDRESS 0x38
257#define AMBIENT19_MAP_MIKROBUS( cfg, mikrobus ) \
258 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
259 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
260 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
ambient19_return_value_t
Ambient 19 Click return value data.
Definition ambient19.h:306
@ AMBIENT19_ERROR
Definition ambient19.h:308
@ AMBIENT19_OK
Definition ambient19.h:307
err_t ambient19_read_raw_proximity(ambient19_t *ctx, uint16_t *ps_data, uint16_t *ir_data)
Ambient 19 read raw proximity function.
err_t ambient19_set_als_time(ambient19_t *ctx, float als_time_ms)
Ambient 19 set als time function.
err_t ambient19_set_als_gain(ambient19_t *ctx, uint8_t als_gain)
Ambient 19 set als gain function.
err_t ambient19_measure_light_level(ambient19_t *ctx, uint16_t *lux)
Ambient 19 measure light level function.
err_t ambient19_init(ambient19_t *ctx, ambient19_cfg_t *cfg)
Ambient 19 initialization function.
err_t ambient19_write_register(ambient19_t *ctx, uint8_t reg, uint8_t data_in)
Ambient 19 write register function.
err_t ambient19_generic_write(ambient19_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Ambient 19 I2C writing function.
uint8_t ambient19_get_int_pin(ambient19_t *ctx)
Ambient 19 get INT pin function.
err_t ambient19_read_raw_als(ambient19_t *ctx, uint16_t *ch_0, uint16_t *ch_1)
Ambient 19 read raw als function.
err_t ambient19_default_cfg(ambient19_t *ctx)
Ambient 19 default configuration function.
err_t ambient19_check_communication(ambient19_t *ctx)
Ambient 19 check communication function.
err_t ambient19_clear_interrupts(ambient19_t *ctx)
Ambient 19 clear interrupts function.
err_t ambient19_set_wait_time(ambient19_t *ctx, float wait_time_ms)
Ambient 19 set wait time function.
err_t ambient19_read_register(ambient19_t *ctx, uint8_t reg, uint8_t *data_out)
Ambient 19 read register function.
void ambient19_cfg_setup(ambient19_cfg_t *cfg)
Ambient 19 configuration object setup function.
err_t ambient19_generic_read(ambient19_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Ambient 19 I2C reading function.
Ambient 19 Click configuration object.
Definition ambient19.h:290
uint32_t i2c_speed
Definition ambient19.h:296
pin_name_t scl
Definition ambient19.h:291
pin_name_t int_pin
Definition ambient19.h:294
pin_name_t sda
Definition ambient19.h:292
uint8_t i2c_address
Definition ambient19.h:297
Ambient 19 Click context object.
Definition ambient19.h:270
uint8_t pga_als
Definition ambient19.h:280
digital_in_t int_pin
Definition ambient19.h:272
i2c_master_t i2c
Definition ambient19.h:275
uint8_t alsconv
Definition ambient19.h:281
uint8_t slave_address
Definition ambient19.h:278