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 PROXIMITY_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 PROXIMITY_RETVAL uint8_t
78#define PROXIMITY_OK 0x00
79#define PROXIMITY_INIT_ERROR 0xFF
86#define PROXIMITY_SLAVE_ADDR 0x13
87#define PROXIMITY_REGISTER_COMMAND 0x80
88#define PROXIMITY_REGISTER_ID 0x81
89#define PROXIMITY_REGISTER_PROX_RATE 0x82
90#define PROXIMITY_REGISTER_PROX_CURRENT 0x83
91#define PROXIMITY_REGISTER_AMBI_PARAMETER 0x84
92#define PROXIMITY_REGISTER_AMBI_VALUE 0x85
93#define PROXIMITY_REGISTER_PROX_VALUE 0x87
94#define PROXIMITY_REGISTER_INTERRUPT_CONTROL 0x89
95#define PROXIMITY_REGISTER_INTERRUPT_LOW_THRES 0x8a
96#define PROXIMITY_REGISTER_INTERRUPT_HIGH_THRES 0x8c
97#define PROXIMITY_REGISTER_INTERRUPT_STATUS 0x8e
98#define PROXIMITY_REGISTER_PROX_TIMING 0xf9
99#define PROXIMITY_REGISTER_AMBI_IR_LIGHT_LEVEL 0x90
106#define PROXIMITY_COMMAND_ALL_DISABLE 0x00
107#define PROXIMITY_COMMAND_SELFTIMED_MODE_ENABLE 0x01
108#define PROXIMITY_COMMAND_PROX_ENABLE 0x02
109#define PROXIMITY_COMMAND_AMBI_ENABLE 0x04
110#define PROXIMITY_COMMAND_PROX_ON_DEMAND 0x08
111#define PROXIMITY_COMMAND_AMBI_ON_DEMAND 0x10
112#define PROXIMITY_COMMAND_MASK_PROX_DATA_READY 0x20
113#define PROXIMITY_COMMAND_MASK_AMBI_DATA_READY 0x40
114#define PROXIMITY_COMMAND_MASK_LOCK 0x80
121#define PROXIMITY_PRODUCT_MASK_REVISION_ID 0x0f
122#define PROXIMITY_PRODUCT_MASK_PRODUCT_ID 0xf0
129#define PROXIMITY_MEASUREMENT_RATE_2 0x00
130#define PROXIMITY_MEASUREMENT_RATE_4 0x01
131#define PROXIMITY_MEASUREMENT_RATE_8 0x02
132#define PROXIMITY_MEASUREMENT_RATE_16 0x03
133#define PROXIMITY_MEASUREMENT_RATE_31 0x04
134#define PROXIMITY_MEASUREMENT_RATE_62 0x05
135#define PROXIMITY_MEASUREMENT_RATE_125 0x06
136#define PROXIMITY_MEASUREMENT_RATE_250 0x07
137#define PROXIMITY_MASK_MEASUREMENT_RATE 0x07
144#define PROXIMITY_MASK_LED_CURRENT 0x3f
145#define PROXIMITY_MASK_FUSE_PROG_ID 0xc0
152#define PROXIMITY_AMBI_PARA_AVERAGE_1 0x00
153#define PROXIMITY_AMBI_PARA_AVERAGE_2 0x01
154#define PROXIMITY_AMBI_PARA_AVERAGE_4 0x02
155#define PROXIMITY_AMBI_PARA_AVERAGE_8 0x03
156#define PROXIMITY_AMBI_PARA_AVERAGE_16 0x04
157#define PROXIMITY_AMBI_PARA_AVERAGE_32 0x05
158#define PROXIMITY_AMBI_PARA_AVERAGE_64 0x06
159#define PROXIMITY_AMBI_PARA_AVERAGE_128 0x07
160#define PROXIMITY_AMBI_MASK_PARA_AVERAGE 0x07
161#define PROXIMITY_AMBI_PARA_AUTO_OFFSET_ENABLE 0x08
162#define PROXIMITY_AMBI_MASK_PARA_AUTO_OFFSET 0x08
163#define PROXIMITY_AMBI_PARA_MEAS_RATE_1 0x00
164#define PROXIMITY_AMBI_PARA_MEAS_RATE_2 0x10
165#define PROXIMITY_AMBI_PARA_MEAS_RATE_3 0x20
166#define PROXIMITY_AMBI_PARA_MEAS_RATE_4 0x30
167#define PROXIMITY_AMBI_PARA_MEAS_RATE_5 0x40
168#define PROXIMITY_AMBI_PARA_MEAS_RATE_6 0x50
169#define PROXIMITY_AMBI_PARA_MEAS_RATE_8 0x60
170#define PROXIMITY_AMBI_PARA_MEAS_RATE_10 0x70
171#define PROXIMITY_AMBI_MASK_PARA_MEAS_RATE 0x70
172#define PROXIMITY_AMBI_PARA_CONT_CONV_ENABLE 0x80
173#define PROXIMITY_AMBI_MASK_PARA_CONT_CONV 0x80
180#define PROXIMITY_INTERRUPT_THRES_SEL_PROX 0x00
181#define PROXIMITY_INTERRUPT_THRES_SEL_ALS 0x01
182#define PROXIMITY_INTERRUPT_THRES_ENABLE 0x02
183#define PROXIMITY_INTERRUPT_ALS_READY_ENABLE 0x04
184#define PROXIMITY_INTERRUPT_PROX_READY_ENABLE 0x08
185#define PROXIMITY_INTERRUPT_COUNT_EXCEED_1 0x00
186#define PROXIMITY_INTERRUPT_COUNT_EXCEED_2 0x20
187#define PROXIMITY_INTERRUPT_COUNT_EXCEED_4 0x40
188#define PROXIMITY_INTERRUPT_COUNT_EXCEED_8 0x60
189#define PROXIMITY_INTERRUPT_COUNT_EXCEED_16 0x80
190#define PROXIMITY_INTERRUPT_COUNT_EXCEED_32 0xa0
191#define PROXIMITY_INTERRUPT_COUNT_EXCEED_64 0xc0
192#define PROXIMITY_INTERRUPT_COUNT_EXCEED_128 0xe0
193#define PROXIMITY_INTERRUPT_MASK_COUNT_EXCEED 0xe0
194#define PROXIMITY_INTERRUPT_STATUS_THRES_HI 0x01
195#define PROXIMITY_INTERRUPT_STATUS_THRES_LO 0x02
196#define PROXIMITY_INTERRUPT_STATUS_ALS_READY 0x04
197#define PROXIMITY_INTERRUPT_STATUS_PROX_READY 0x08
198#define PROXIMITY_INTERRUPT_MASK_STATUS_THRES_HI 0x01
199#define PROXIMITY_INTERRUPT_MASK_THRES_LO 0x02
200#define PROXIMITY_INTERRUPT_MASK_ALS_READY 0x04
201#define PROXIMITY_INTERRUPT_MASK_PROX_READY 0x08
#define PROXIMITY_RETVAL
Definition proximity.h:76
void proximity_cfg_setup(proximity_cfg_t *cfg)
Config Object Initialization function.
void proximity_read_data(proximity_t *ctx, uint8_t r_addr, uint8_t *rcv_data, uint8_t n_len)
Functions for read data from register.
uint16_t proximity_read_ambient_light(proximity_t *ctx)
Functions for reads Ambient light.
void proximity_write_byte(proximity_t *ctx, uint8_t w_addr, uint8_t w_data)
Functions for write one byte in register.
void proximity_set_default_mode(proximity_t *ctx)
Functions for sets default mode.
void proximity_set_upper_threshold(proximity_t *ctx)
Functions for sets upper threshold.
void proximity_write_data(proximity_t *ctx, uint8_t w_addr, uint8_t *wr_data, uint8_t n_len)
Functions for write data.
PROXIMITY_RETVAL proximity_init(proximity_t *ctx, proximity_cfg_t *cfg)
Initialization function.
uint16_t proximity_read_prox_data(proximity_t *ctx)
Functions for reads Proximity data.
uint8_t proximity_read_byte(proximity_t *ctx, uint8_t r_addr)
Functions for read byte from register.
Click configuration structure definition.
Definition proximity.h:234
uint32_t i2c_speed
Definition proximity.h:246
pin_name_t scl
Definition proximity.h:237
pin_name_t int_pin
Definition proximity.h:242
pin_name_t sda
Definition proximity.h:238
uint8_t i2c_address
Definition proximity.h:247
Click ctx object definition.
Definition proximity.h:214
digital_in_t int_pin
Definition proximity.h:218
i2c_master_t i2c
Definition proximity.h:222
uint8_t slave_address
Definition proximity.h:226