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 AMBIENT21_REG_ENABLE 0x00
74#define AMBIENT21_REG_CONFIG 0x01
75#define AMBIENT21_REG_AILTL 0x04
76#define AMBIENT21_REG_AILTH 0x05
77#define AMBIENT21_REG_AIHTL 0x06
78#define AMBIENT21_REG_AIHTH 0x07
79#define AMBIENT21_REG_NPAILTL 0x08
80#define AMBIENT21_REG_NPAILTH 0x09
81#define AMBIENT21_REG_NPAIHTL 0x0A
82#define AMBIENT21_REG_NPAIHTH 0x0B
83#define AMBIENT21_REG_PERSIST 0x0C
84#define AMBIENT21_REG_PID 0x11
85#define AMBIENT21_REG_ID 0x12
86#define AMBIENT21_REG_STATUS 0x13
87#define AMBIENT21_REG_C0DATAL 0x14
88#define AMBIENT21_REG_C0DATAH 0x15
89#define AMBIENT21_REG_C1DATAL 0x16
90#define AMBIENT21_REG_C1DATAH 0x17
108#define AMBIENT21_CMD_NORMAL_OP 0xA0
109#define AMBIENT21_CMD_SPEC_FUNC 0xE0
110#define AMBIENT21_SF_INT_SET 0x04
111#define AMBIENT21_SF_CLEAR_ALS_INT 0x06
112#define AMBIENT21_SF_CLEAR_ALS_NOPERS_INT 0x07
113#define AMBIENT21_SF_CLEAR_NOPERS_INT 0x0A
114#define AMBIENT21_ADDR_SF_MASK 0x1F
120#define AMBIENT21_ENABLE_NPIEN 0x80
121#define AMBIENT21_ENABLE_SAI 0x40
122#define AMBIENT21_ENABLE_AIEN 0x10
123#define AMBIENT21_ENABLE_AEN 0x02
124#define AMBIENT21_ENABLE_PON 0x01
130#define AMBIENT21_CONFIG_SRESET 0x80
131#define AMBIENT21_CONFIG_AGAIN_LOW 0x00
132#define AMBIENT21_CONFIG_AGAIN_MID 0x10
133#define AMBIENT21_CONFIG_AGAIN_HIGH 0x20
134#define AMBIENT21_CONFIG_AGAIN_MAX 0x30
135#define AMBIENT21_CONFIG_AGAIN_MASK 0x30
136#define AMBIENT21_CONFIG_ATIME_100MS 0x00
137#define AMBIENT21_CONFIG_ATIME_200MS 0x01
138#define AMBIENT21_CONFIG_ATIME_300MS 0x02
139#define AMBIENT21_CONFIG_ATIME_400MS 0x03
140#define AMBIENT21_CONFIG_ATIME_500MS 0x04
141#define AMBIENT21_CONFIG_ATIME_600MS 0x05
142#define AMBIENT21_CONFIG_ATIME_MASK 0x07
148#define AMBIENT21_PERSIST_EVERY 0x00
149#define AMBIENT21_PERSIST_ANY 0x01
150#define AMBIENT21_PERSIST_2 0x02
151#define AMBIENT21_PERSIST_3 0x03
152#define AMBIENT21_PERSIST_5 0x04
153#define AMBIENT21_PERSIST_10 0x05
154#define AMBIENT21_PERSIST_15 0x06
155#define AMBIENT21_PERSIST_20 0x07
156#define AMBIENT21_PERSIST_25 0x08
157#define AMBIENT21_PERSIST_30 0x09
158#define AMBIENT21_PERSIST_35 0x0A
159#define AMBIENT21_PERSIST_40 0x0B
160#define AMBIENT21_PERSIST_45 0x0C
161#define AMBIENT21_PERSIST_50 0x0D
162#define AMBIENT21_PERSIST_55 0x0E
163#define AMBIENT21_PERSIST_60 0x0F
164#define AMBIENT21_PERSIST_MASK 0x0F
170#define AMBIENT21_STATUS_NPINTR 0x20
171#define AMBIENT21_STATUS_AINT 0x10
172#define AMBIENT21_STATUS_AVALID 0x01
178#define AMBIENT21_DEVICE_ID 0x50
184#define AMBIENT21_AGAIN_LOW 0x00
185#define AMBIENT21_AGAIN_MID 0x01
186#define AMBIENT21_AGAIN_HIGH 0x02
187#define AMBIENT21_AGAIN_MAX 0x03
188#define AMBIENT21_ATIME_100MS 0x00
189#define AMBIENT21_ATIME_200MS 0x01
190#define AMBIENT21_ATIME_300MS 0x02
191#define AMBIENT21_ATIME_400MS 0x03
192#define AMBIENT21_ATIME_500MS 0x04
193#define AMBIENT21_ATIME_600MS 0x05
199#define AMBIENT21_GAIN_0 1.0f
200#define AMBIENT21_GAIN_1 25.0f
201#define AMBIENT21_GAIN_2 428.0f
202#define AMBIENT21_GAIN_3 9876.0f
203#define AMBIENT21_TIME_RES 100.0f
204#define AMBIENT21_LUX_GDF 900.0f
205#define AMBIENT21_LUX_COEF 1.0f
212#define AMBIENT21_DEVICE_ADDRESS 0x29
230#define AMBIENT21_MAP_MIKROBUS( cfg, mikrobus ) \
231 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
232 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
233 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
ambient21_return_value_t
Ambient 21 Click return value data.
Definition ambient21.h:280
@ AMBIENT21_ERROR
Definition ambient21.h:282
@ AMBIENT21_OK
Definition ambient21.h:281
err_t ambient21_set_config(ambient21_t *ctx, uint8_t again, uint8_t atime)
Ambient 21 set config function.
err_t ambient21_init(ambient21_t *ctx, ambient21_cfg_t *cfg)
Ambient 21 initialization function.
err_t ambient21_read_register(ambient21_t *ctx, uint8_t reg, uint8_t *data_out)
Ambient 21 read register function.
err_t ambient21_measure_light_level(ambient21_t *ctx, uint16_t *lux)
Ambient 21 measure light level function.
err_t ambient21_check_communication(ambient21_t *ctx)
Ambient 21 check communication function.
void ambient21_cfg_setup(ambient21_cfg_t *cfg)
Ambient 21 configuration object setup function.
err_t ambient21_write_spec_func(ambient21_t *ctx, uint8_t spec_func)
Ambient 21 write spec func function.
err_t ambient21_generic_read(ambient21_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
Ambient 21 I2C reading function.
uint8_t ambient21_get_int_pin(ambient21_t *ctx)
Ambient 21 get int pin function.
err_t ambient21_generic_write(ambient21_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
Ambient 21 I2C writing function.
err_t ambient21_default_cfg(ambient21_t *ctx)
Ambient 21 default configuration function.
err_t ambient21_read_raw_data(ambient21_t *ctx, uint16_t *ch_0, uint16_t *ch_1)
Ambient 21 read raw data function.
err_t ambient21_write_register(ambient21_t *ctx, uint8_t reg, uint8_t data_in)
Ambient 21 write register function.
err_t ambient21_clear_interrupts(ambient21_t *ctx)
Ambient 21 clear interrupts function.
Ambient 21 Click configuration object.
Definition ambient21.h:264
uint32_t i2c_speed
Definition ambient21.h:270
pin_name_t scl
Definition ambient21.h:265
pin_name_t int_pin
Definition ambient21.h:268
pin_name_t sda
Definition ambient21.h:266
uint8_t i2c_address
Definition ambient21.h:271
Ambient 21 Click context object.
Definition ambient21.h:243
digital_in_t int_pin
Definition ambient21.h:245
i2c_master_t i2c
Definition ambient21.h:248
uint8_t slave_address
Definition ambient21.h:251
float atime_ms
Definition ambient21.h:253
float cpl
Definition ambient21.h:255
float again
Definition ambient21.h:254