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"
67#define AMBIENT8_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
76#define AMBIENT8_RETVAL uint8_t
78#define AMBIENT8_OK 0x00
79#define AMBIENT8_INIT_ERROR 0xFF
85#define AMBIENT8_DEVICE_ADDRESS 0x29
92#define AMBIENT8_ALS_CONTROL 0x80
93#define AMBIENT8_ALS_MEASUREMENT_RATE 0x85
94#define AMBIENT8_PART_ID 0x86
95#define AMBIENT8_MANUFACTURER_ID 0x87
96#define AMBIENT8_ALS_DATA_CH1_0 0x88
97#define AMBIENT8_ALS_DATA_CH1_1 0x89
98#define AMBIENT8_ALS_DATA_CH0_0 0x8A
99#define AMBIENT8_ALS_DATA_CH0_1 0x8B
100#define AMBIENT8_ALS_STATUS 0x8C
107#define AMBIENT8_ALS_GAIN_1X 0x00
108#define AMBIENT8_ALS_GAIN_2X 0x04
109#define AMBIENT8_ALS_GAIN_4X 0x08
110#define AMBIENT8_ALS_GAIN_8X 0x0C
111#define AMBIENT8_ALS_GAIN_48X 0x18
112#define AMBIENT8_ALS_GAIN_96X 0x1C
113#define AMBIENT8_SW_RESET 0x02
114#define AMBIENT8_ALS_MODE_STANDBY 0x00
115#define AMBIENT8_ALS_MODE_ACTIVE 0x01
122#define AMBIENT8_ALS_INTEGRATION_TIME_100ms 0x00
123#define AMBIENT8_ALS_INTEGRATION_TIME_50ms 0x08
124#define AMBIENT8_ALS_INTEGRATION_TIME_200ms 0x10
125#define AMBIENT8_ALS_INTEGRATION_TIME_400ms 0x18
126#define AMBIENT8_ALS_INTEGRATION_TIME_150ms 0x20
127#define AMBIENT8_ALS_INTEGRATION_TIME_250ms 0x28
128#define AMBIENT8_ALS_INTEGRATION_TIME_300ms 0x30
129#define AMBIENT8_ALS_INTEGRATION_TIME_350ms 0x38
130#define AMBIENT8_ALS_MEASUREMENT_RATE_50 0x00
131#define AMBIENT8_ALS_MEASUREMENT_RATE_100 0x01
132#define AMBIENT8_ALS_MEASUREMENT_RATE_200 0x02
133#define AMBIENT8_ALS_MEASUREMENT_RATE_500 0x03
134#define AMBIENT8_ALS_MEASUREMENT_RATE_1000 0x04
135#define AMBIENT8_ALS_MEASUREMENT_RATE_2000 0x07
256 uint16_t* als_data_ch0);
275 float window_factor,
float IR_factor );
#define AMBIENT8_RETVAL
Definition ambient8.h:76
AMBIENT8_RETVAL ambient8_init(ambient8_t *ctx, ambient8_cfg_t *cfg)
Initialization function.
void ambient8_get_register(ambient8_t *ctx, uint8_t reg_addr, uint8_t *data_buf, uint8_t n_bytes)
Reading register value(s).
void ambient8_cfg_setup(ambient8_cfg_t *cfg)
Config Object Initialization function.
void ambient8_set_register(ambient8_t *ctx, uint8_t *write_buf, uint8_t n_bytes)
Writing to device registers.
void ambient8_set_constants(ambient8_t *ctx)
Setting constants for lux level calculation.
AMBIENT8_RETVAL ambient8_get_als_data(ambient8_t *ctx, uint16_t *als_data_ch1, uint16_t *als_data_ch0)
Reading ALS data.
AMBIENT8_RETVAL ambient8_get_lux_level(ambient8_t *ctx, float *lux_level, float window_factor, float IR_factor)
Calculating lux level.
Click configuration structure definition.
Definition ambient8.h:164
uint32_t i2c_speed
Definition ambient8.h:172
pin_name_t scl
Definition ambient8.h:167
pin_name_t sda
Definition ambient8.h:168
uint8_t i2c_address
Definition ambient8.h:173
Click ctx object definition.
Definition ambient8.h:148
i2c_master_t i2c
Definition ambient8.h:152
uint8_t slave_address
Definition ambient8.h:156