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"
66#define AMBIENT9_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
76#define AMBIENT9_RETVAL uint8_t
78#define AMBIENT9_OK 0x00
79#define AMBIENT9_INIT_ERROR 0xFF
82#define AMBIENT9_SLAVE_ADDR 0x53
84#define AMBIENT9_REG_MAIN_CTRL 0x00
85#define AMBIENT9_REG_PS_LED 0x01
86#define AMBIENT9_REG_PS_PULSES 0x02
87#define AMBIENT9_REG_PS_MEAS_RATE 0x03
88#define AMBIENT9_REG_ALS_MEAS_RATE 0x04
89#define AMBIENT9_REG_ALS_GAIN 0x05
90#define AMBIENT9_REG_PART_ID 0x06
91#define AMBIENT9_REG_MAIN_STATUS 0x07
92#define AMBIENT9_REG_PS_DATA_0 0x08
93#define AMBIENT9_REG_PS_DATA_1 0x09
94#define AMBIENT9_REG_LS_CLEAR_DATA_0 0x0A
95#define AMBIENT9_REG_LS_CLEAR_DATA_1 0x0B
96#define AMBIENT9_REG_LS_CLEAR_DATA_2 0x0C
97#define AMBIENT9_REG_ALS_DATA_0 0x0D
98#define AMBIENT9_REG_ALS_DATA_1 0x0E
99#define AMBIENT9_REG_ALS_DATA_2 0x0F
100#define AMBIENT9_REG_INT_CFG 0x19
101#define AMBIENT9_REG_INT_PST 0x1A
102#define AMBIENT9_REG_PS_THRES_UP_0 0x1B
103#define AMBIENT9_REG_PS_THRES_UP_1 0x1C
104#define AMBIENT9_REG_PS_THRES_LOW_0 0x1D
105#define AMBIENT9_REG_PS_THRES_LOW_1 0x1E
106#define AMBIENT9_REG_PS_CAN_DIG_0 0x1F
107#define AMBIENT9_REG_PS_CAN_DIG_1 0x20
108#define AMBIENT9_REG_PS_CAN_ANA_DURATION 0x21
109#define AMBIENT9_REG_PS_CAN_ANA_CURRENT 0x22
110#define AMBIENT9_REG_PS_AV_HYST 0x23
111#define AMBIENT9_REG_ALS_THRES_UP_0 0x24
112#define AMBIENT9_REG_ALS_THRES_UP_1 0x25
113#define AMBIENT9_REG_ALS_THRES_UP_2 0x26
114#define AMBIENT9_REG_ALS_THRES_LOW_0 0x27
115#define AMBIENT9_REG_ALS_THRES_LOW_1 0x28
116#define AMBIENT9_REG_ALS_THRES_LOW_2 0x29
117#define AMBIENT9_REG_ALS_THRES_VAR 0x2A
119#define AMBIENT9_PART_ID_VAL 0x03
120#define AMBIENT9_POWER_ON 0x20
122#define AMBIENT9_ALS 0xAA
123#define AMBIENT9_PROXY 0xBB
#define AMBIENT9_RETVAL
Definition ambient9.h:76
void ambient9_generic_write(ambient9_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t ambient9_get_int_status(ambient9_t *ctx)
Generic function for getting int pin status.
uint32_t ambient9_als_data(ambient9_t *ctx)
Generic function for reading ALS data from sensor.
uint16_t ambient9_proxy_data(ambient9_t *ctx)
Generic function for reading proximity data from sensor.
void ambient9_enable_data(ambient9_t *ctx, uint8_t als_ps)
Function for enabeling sensor for ALS or proximity.
void ambient9_generic_read(ambient9_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
AMBIENT9_RETVAL ambient9_init(ambient9_t *ctx, ambient9_cfg_t *cfg)
Initialization function.
void ambient9_cfg_setup(ambient9_cfg_t *cfg)
Config Object Initialization function.
Click configuration structure definition.
Definition ambient9.h:155
uint32_t i2c_speed
Definition ambient9.h:167
pin_name_t scl
Definition ambient9.h:158
pin_name_t int_pin
Definition ambient9.h:163
pin_name_t sda
Definition ambient9.h:159
uint8_t i2c_address
Definition ambient9.h:168
Click ctx object definition.
Definition ambient9.h:136
digital_in_t int_pin
Definition ambient9.h:139
i2c_master_t i2c
Definition ambient9.h:143
uint8_t slave_address
Definition ambient9.h:147