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 AMBIENT15_REG_CONTROL 0x00
74#define AMBIENT15_REG_TIMING 0x01
75#define AMBIENT15_REG_INTERRUPT 0x02
76#define AMBIENT15_REG_THL_LOW 0x03
77#define AMBIENT15_REG_THL_HIGH 0x04
78#define AMBIENT15_REG_THH_LOW 0x05
79#define AMBIENT15_REG_THH_HIGH 0x06
80#define AMBIENT15_REG_ANALOG 0x07
81#define AMBIENT15_REG_ID 0x12
82#define AMBIENT15_REG_DATA0_LOW 0x14
83#define AMBIENT15_REG_DATA0_HIGH 0x15
84#define AMBIENT15_REG_DATA1_LOW 0x16
85#define AMBIENT15_REG_DATA1_HIGH 0x17
86#define AMBIENT15_REG_TIMER_LOW 0x18
87#define AMBIENT15_REG_TIMER_HIGH 0x19
88#define AMBIENT15_REG_ID2 0x1E
106#define AMBIENT15_CMD_BIT 0x80
107#define AMBIENT15_TRANSACTION_REPEATED 0x00
108#define AMBIENT15_TRANSACTION_AUTO_INC 0x20
109#define AMBIENT15_TRANSACTION_SPEC_FUNC 0x60
110#define AMBIENT15_SPEC_FUNC_INT_CLEAR 0x01
111#define AMBIENT15_SPEC_FUNC_STOP_MAN_INT 0x02
112#define AMBIENT15_SPEC_FUNC_START_MAN_INT 0x03
118#define AMBIENT15_CONTROL_ADC_INTR 0x20
119#define AMBIENT15_CONTROL_ADC_VALID 0x10
120#define AMBIENT15_CONTROL_ADC_ENABLE 0x02
121#define AMBIENT15_CONTROL_POWER_ON 0x01
127#define AMBIENT15_ATIME_MAX 688.5
128#define AMBIENT15_ATIME_MIN 2.7
129#define AMBIENT15_ATIME_STEP 2.7
130#define AMBIENT15_DEFAULT_ATIME 200.0
136#define AMBIENT15_ENABLE_INTERRUPT 0x10
142#define AMBIENT15_GAIN_1X 0x00
143#define AMBIENT15_GAIN_8X 0x01
144#define AMBIENT15_GAIN_16X 0x02
145#define AMBIENT15_GAIN_111X 0x03
151#define AMBIENT15_ID_PARTNO 0x90
152#define AMBIENT15_ID2 0x80
158#define AMBIENT15_CH0_COFF0 1000ul
159#define AMBIENT15_CH1_COFF0 2160ul
160#define AMBIENT15_CH0_COFF1 950ul
161#define AMBIENT15_CH1_COFF1 1110ul
168#define AMBIENT15_SET_DEV_ADDR_GND 0x29
169#define AMBIENT15_SET_DEV_ADDR_FLOAT 0x39
170#define AMBIENT15_SET_DEV_ADDR_VCC 0x49
188#define AMBIENT15_MAP_MIKROBUS( cfg, mikrobus ) \
189 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
190 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
191 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
ambient15_return_value_t
Ambient 15 Click return value data.
Definition ambient15.h:237
@ AMBIENT15_OK
Definition ambient15.h:238
@ AMBIENT15_ERROR
Definition ambient15.h:239
err_t ambient15_write_register(ambient15_t *ctx, uint8_t reg, uint8_t data_in)
Ambient 15 write register function.
uint8_t ambient15_get_int_pin(ambient15_t *ctx)
Ambient 15 get int pin function.
err_t ambient15_default_cfg(ambient15_t *ctx)
Ambient 15 default configuration function.
err_t ambient15_generic_read(ambient15_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Ambient 15 I2C reading function.
err_t ambient15_read_raw_data(ambient15_t *ctx, uint16_t *ch_0, uint16_t *ch_1)
Ambient 15 read raw data function.
err_t ambient15_init(ambient15_t *ctx, ambient15_cfg_t *cfg)
Ambient 15 initialization function.
err_t ambient15_check_communication(ambient15_t *ctx)
Ambient 15 check communication function.
err_t ambient15_read_register(ambient15_t *ctx, uint8_t reg, uint8_t *data_out)
Ambient 15 read register function.
err_t ambient15_set_gain(ambient15_t *ctx, uint8_t gain)
Ambient 15 set gain function.
err_t ambient15_generic_write(ambient15_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Ambient 15 I2C writing function.
void ambient15_cfg_setup(ambient15_cfg_t *cfg)
Ambient 15 configuration object setup function.
err_t ambient15_set_atime(ambient15_t *ctx, float atime_ms)
Ambient 15 set atime function.
err_t ambient15_measure_light_level(ambient15_t *ctx, uint16_t *lux)
Ambient 15 measure light level function.
Ambient 15 Click configuration object.
Definition ambient15.h:221
uint32_t i2c_speed
Definition ambient15.h:227
pin_name_t scl
Definition ambient15.h:222
pin_name_t int_pin
Definition ambient15.h:225
pin_name_t sda
Definition ambient15.h:223
uint8_t i2c_address
Definition ambient15.h:228
Ambient 15 Click context object.
Definition ambient15.h:201
uint8_t gain
Definition ambient15.h:212
digital_in_t int_pin
Definition ambient15.h:203
i2c_master_t i2c
Definition ambient15.h:206
uint8_t slave_address
Definition ambient15.h:209
float atime_ms
Definition ambient15.h:211