42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_in.h"
53#include "drv_i2c_master.h"
65#define PROXIMITY2_MAP_MIKROBUS( cfg, mikrobus ) \
66 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
67 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
68 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
75#define PROXIMITY2_RETVAL uint8_t
77#define PROXIMITY2_OK 0x00
78#define PROXIMITY2_INIT_ERROR 0xFF
85#define PROXIMITY2_I2C_SLAVE_ADDR 0x4A
92#define PROXIMITY2_REG_INTER_STAT 0x00
93#define PROXIMITY2_REG_MAIN_CONFIG 0x01
94#define PROXIMITY2_REG_RECEIVE_CONFIG 0x02
95#define PROXIMITY2_REG_TRANSMIT_CONFIG 0x03
96#define PROXIMITY2_REG_ALS_HI_BY 0x04
97#define PROXIMITY2_REG_ALS_LO_BY 0x05
98#define PROXIMITY2_REG_PROX 0x16
99#define PROXIMITY2_REG_ALS_UPTRSH_H 0x06
100#define PROXIMITY2_REG_ALS_UPTRSH_L 0x07
101#define PROXIMITY2_REG_ALS_LOTRSH_H 0x08
102#define PROXIMITY2_REG_ALS_LOTRSH_L 0x09
103#define PROXIMITY2_REG_TRSH_PERS_TIM 0x0A
104#define PROXIMITY2_REG_PROX_TRSH_IND 0x0B
105#define PROXIMITY2_REG_PROX_TRSH 0x0C
106#define PROXIMITY2_REG_GREEN_GAIN 0x0F
107#define PROXIMITY2_REG_IR_GAIN 0x10
114#define PROXIMITY2_RECE_CONFIG_ALSPGA_0_03125 0x00
115#define PROXIMITY2_RECE_CONFIG_ALSPGA_0_125 0x01
116#define PROXIMITY2_RECE_CONFIG_ALSPGA_0_5 0x02
117#define PROXIMITY2_RECE_CONFIG_ALSPGA_4 0x03
118#define PROXIMITY2_RECE_CONFIG_DEFAULT 0xF1
119#define PROXIMITY2_MAIN_CONFIG_STDWN 0x00
120#define PROXIMITY2_MAIN_CONFIG_DEFAULT 0x13
121#define PROXIMITY2_MAIN_CONFIG_ALS_G_IR 0x04
122#define PROXIMITY2_MAIN_CONFIG_ALS_G 0x08
123#define PROXIMITY2_MAIN_CONFIG_ALS_IR 0x0C
124#define PROXIMITY2_MAIN_CONFIG_ALS_PROX 0x10
125#define PROXIMITY2_MAIN_CONFIG_PROX_ONLY 0x14
126#define PROXIMITY2_RECE_CONFIG_ALSTIM_14 0x00
127#define PROXIMITY2_RECE_CONFIG_ALSTIM_12 0x01
128#define PROXIMITY2_RECE_CONFIG_ALSTIM_10 0x02
129#define PROXIMITY2_RECE_CONFIG_ALSTIM_8 0x03
136#define PROXIMITY2_LED_DRV_DISABLE 0x00
137#define PROXIMITY2_LED_DRV_CURRENT_10_MA 0x01
138#define PROXIMITY2_LED_DRV_CURRENT_20_MA 0x02
139#define PROXIMITY2_LED_DRV_CURRENT_30_MA 0x03
140#define PROXIMITY2_LED_DRV_CURRENT_40_MA 0x04
141#define PROXIMITY2_LED_DRV_CURRENT_50_MA 0x05
142#define PROXIMITY2_LED_DRV_CURRENT_60_MA 0x06
143#define PROXIMITY2_LED_DRV_CURRENT_70_MA 0x07
144#define PROXIMITY2_LED_DRV_CURRENT_80_MA 0x0C
145#define PROXIMITY2_LED_DRV_CURRENT_90_MA 0x0D
146#define PROXIMITY2_LED_DRV_CURRENT_100_MA 0x0E
147#define PROXIMITY2_LED_DRV_CURRENT_110_MA 0x0F
154#define PROXIMITY2_INTERRUPT_TRIGGERS_1 0x00
155#define PROXIMITY2_INTERRUPT_TRIGGERS_2 0x01
156#define PROXIMITY2_INTERRUPT_TRIGGERS_4 0x02
157#define PROXIMITY2_INTERRUPT_TRIGGERS_16 0x03
164#define PROXIMITY2_PROXI_AVG_VAL 0x7F
165#define PROXIMITY2_PROXI_MAX_VAL 0xFF
166#define PROXIMITY2_PROXI_SENSITIVITY 5
#define PROXIMITY2_RETVAL
Definition proximity2.h:75
void proximity2_generic_read(proximity2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void proximity2_cfg_setup(proximity2_cfg_t *cfg)
Config Object Initialization function.
uint16_t proximity2_read_als(proximity2_t *ctx)
Read ALS Data Registers function.
void proximity2_generic_write(proximity2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint8_t proximity2_read_prox(proximity2_t *ctx)
Read PROX Data Register function.
uint8_t proximity2_get_int_pin_status(proximity2_t *ctx)
Get int pin status.
void proximity2_default_cfg(proximity2_t *ctx)
Click Default Configuration function.
PROXIMITY2_RETVAL proximity2_init(proximity2_t *ctx, proximity2_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition proximity2.h:199
uint32_t i2c_speed
Definition proximity2.h:211
pin_name_t scl
Definition proximity2.h:202
pin_name_t int_pin
Definition proximity2.h:207
pin_name_t sda
Definition proximity2.h:203
uint8_t i2c_address
Definition proximity2.h:212
Click ctx object definition.
Definition proximity2.h:180
digital_in_t int_pin
Definition proximity2.h:183
i2c_master_t i2c
Definition proximity2.h:187
uint8_t slave_address
Definition proximity2.h:191