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 AMBIENT17_REG_ENABLE 0x00
74#define AMBIENT17_REG_ATIME 0x01
75#define AMBIENT17_REG_WTIME 0x03
76#define AMBIENT17_REG_AILTL 0x04
77#define AMBIENT17_REG_AILTH 0x05
78#define AMBIENT17_REG_AIHTL 0x06
79#define AMBIENT17_REG_AIHTH 0x07
80#define AMBIENT17_REG_PERS 0x0C
81#define AMBIENT17_REG_CONFIG 0x0D
82#define AMBIENT17_REG_CONTROL 0x0F
83#define AMBIENT17_REG_ID 0x12
84#define AMBIENT17_REG_STATUS 0x13
85#define AMBIENT17_REG_C0DATA 0x14
86#define AMBIENT17_REG_C0DATAH 0x15
87#define AMBIENT17_REG_C1DATA 0x16
88#define AMBIENT17_REG_C1DATAH 0x17
106#define AMBIENT17_CMD_BIT 0x80
107#define AMBIENT17_TYPE_REPEATED 0x00
108#define AMBIENT17_TYPE_AUTO_INC 0x20
109#define AMBIENT17_TYPE_SPEC_FUNC 0x60
110#define AMBIENT17_SPEC_FUNC_INT_CLEAR 0x06
116#define AMBIENT17_ENABLE_SLEEP_AFTER_INT 0x40
117#define AMBIENT17_ENABLE_ALS_INT 0x10
118#define AMBIENT17_ENABLE_WAIT 0x08
119#define AMBIENT17_ENABLE_ALS 0x02
120#define AMBIENT17_ENABLE_OSC 0x01
126#define AMBIENT17_STATUS_AINT 0x10
127#define AMBIENT17_STATUS_AVALID 0x01
133#define AMBIENT17_ATIME_MAX 699.88
134#define AMBIENT17_ATIME_MIN 2.73
135#define AMBIENT17_ATIME_STEP 2.73
136#define AMBIENT17_DEFAULT_ATIME 200.0
142#define AMBIENT17_WTIME_MAX 699.88
143#define AMBIENT17_WTIME_MIN 2.73
144#define AMBIENT17_WTIME_STEP 2.73
145#define AMBIENT17_DEFAULT_WTIME 200.0
151#define AMBIENT17_AGAIN_1X 0x00
152#define AMBIENT17_AGAIN_8X 0x01
153#define AMBIENT17_AGAIN_16X 0x02
154#define AMBIENT17_AGAIN_120X 0x03
160#define AMBIENT17_CH0_COFF0 1.0
161#define AMBIENT17_CH1_COFF0 1.87
162#define AMBIENT17_CH0_COFF1 0.63
163#define AMBIENT17_CH1_COFF1 1.0
164#define AMBIENT17_GA_VALUE 1.0
165#define AMBIENT17_GA_MULTIPLIER 60.0
171#define AMBIENT17_DEVICE_ID 0x34
178#define AMBIENT17_DEVICE_ADDRESS 0x39
196#define AMBIENT17_MAP_MIKROBUS( cfg, mikrobus ) \
197 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
198 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
199 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
ambient17_return_value_t
Ambient 17 Click return value data.
Definition ambient17.h:246
@ AMBIENT17_OK
Definition ambient17.h:247
@ AMBIENT17_ERROR
Definition ambient17.h:248
err_t ambient17_generic_write(ambient17_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Ambient 17 I2C writing function.
err_t ambient17_clear_interrupts(ambient17_t *ctx)
Ambient 17 clear interrupts function.
err_t ambient17_set_atime(ambient17_t *ctx, float atime_ms)
Ambient 17 set atime function.
err_t ambient17_read_register(ambient17_t *ctx, uint8_t reg, uint8_t *data_out)
Ambient 17 read register function.
err_t ambient17_init(ambient17_t *ctx, ambient17_cfg_t *cfg)
Ambient 17 initialization function.
err_t ambient17_default_cfg(ambient17_t *ctx)
Ambient 17 default configuration function.
err_t ambient17_set_wtime(ambient17_t *ctx, float wtime_ms)
Ambient 17 set wtime function.
uint8_t ambient17_get_int_pin(ambient17_t *ctx)
Ambient 17 get INT pin function.
void ambient17_cfg_setup(ambient17_cfg_t *cfg)
Ambient 17 configuration object setup function.
err_t ambient17_generic_read(ambient17_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Ambient 17 I2C reading function.
err_t ambient17_check_communication(ambient17_t *ctx)
Ambient 17 check communication function.
err_t ambient17_read_raw_data(ambient17_t *ctx, uint16_t *ch_0, uint16_t *ch_1)
Ambient 17 read raw data function.
err_t ambient17_measure_light_level(ambient17_t *ctx, uint16_t *lux)
Ambient 17 measure light level function.
err_t ambient17_write_register(ambient17_t *ctx, uint8_t reg, uint8_t data_in)
Ambient 17 write register function.
err_t ambient17_set_again(ambient17_t *ctx, uint8_t again)
Ambient 17 set again function.
Ambient 17 Click configuration object.
Definition ambient17.h:230
uint32_t i2c_speed
Definition ambient17.h:236
pin_name_t scl
Definition ambient17.h:231
pin_name_t int_pin
Definition ambient17.h:234
pin_name_t sda
Definition ambient17.h:232
uint8_t i2c_address
Definition ambient17.h:237
Ambient 17 Click context object.
Definition ambient17.h:209
uint8_t again
Definition ambient17.h:220
digital_in_t int_pin
Definition ambient17.h:211
i2c_master_t i2c
Definition ambient17.h:214
uint8_t slave_address
Definition ambient17.h:217
float atime_ms
Definition ambient17.h:219
float cpl
Definition ambient17.h:221