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"
67#define PROXIMITY7_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
69 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
70 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
77#define PROXIMITY7_RETVAL uint8_t
79#define PROXIMITY7_OK 0x00
80#define PROXIMITY7_INIT_ERROR 0xFF
87#define PROXIMITY7_DEVICE_ADDRESS 0x39
94#define PROXIMITY7_REPEATED_BYTE 0x80
95#define PROXIMITY7_AUTO_INCREMENT 0xA0
96#define PROXIMITY7_RESERVED 0xC0
97#define PROXIMITY7_SPECIAL_FUNCTION 0xE0
104#define PROXIMITY7_NO_ACTION 0x00
105#define PROXIMITY7_PROXIMITY_INT_PIN_CLEAR 0x05
106#define PROXIMITY7_ALS_INT_PIN_CLEAR 0x06
107#define PROXIMITY7_PROXIMITY_AND_ALS_INT_PIN_CLEAR 0x07
114#define PROXIMITY7_ENABLE 0x00
115#define PROXIMITY7_ALS_ADC_TIME 0x01
116#define PROXIMITY7_PROXIMITY_ADC_TIME 0x02
117#define PROXIMITY7_WAIT_TIME 0x03
118#define PROXIMITY7_LOW_ALS_INT_PIN_THRESHOLD_LOW 0x04
119#define PROXIMITY7_LOW_ALS_INT_PIN_THRESHOLD_HIGH 0x05
120#define PROXIMITY7_HIGH_ALS_INT_PIN_THRESHOLD_LOW 0x06
121#define PROXIMITY7_HIGH_ALS_INT_PIN_THRESHOLD_HIGH 0x07
122#define PROXIMITY7_LOW_PROXIMITY_INT_PIN_THRESHOLD_LOW 0x08
123#define PROXIMITY7_LOW_PROXIMITY_INT_PIN_THRESHOLD_HIGH 0x09
124#define PROXIMITY7_HIGH_PROXIMITY_INT_PIN_THRESHOLD_LOW 0x0A
125#define PROXIMITY7_HIGH_PROXIMITY_INT_PIN_THRESHOLD_HIGH 0x0B
126#define PROXIMITY7_INT_PIN_PERSISTANCE_FILTERS 0x0C
127#define PROXIMITY7_CONFIGURATION 0x0D
128#define PROXIMITY7_PROXIMITY_PULSE_COUNT 0x0E
129#define PROXIMITY7_GAIN_CONTROL 0x0F
130#define PROXIMITY7_ID 0x12
131#define PROXIMITY7_STATUS 0x13
132#define PROXIMITY7_CH0_ADC_DATA_LOW 0x14
133#define PROXIMITY7_CH0_ADC_DATA_HIGH 0x15
134#define PROXIMITY7_CH1_ADC_DATA_LOW 0x16
135#define PROXIMITY7_CH1_ADC_DATA_HIGH 0x17
136#define PROXIMITY7_PROXIMITY_ADC_DATA_LOW 0x18
137#define PROXIMITY7_PROXIMITY_ADC_DATA_HIGH 0x19
138#define PROXIMITY7_PROXIMITY_OFFSET 0x1E
145#define PROXIMITY7_SLEEP_AFTER_INT_PIN 0x40
146#define PROXIMITY7_PROXIMITY_INT_PIN_MASK 0x20
147#define PROXIMITY7_ALS_INT_PIN_MASK 0x10
148#define PROXIMITY7_WAIT_ENA 0x08
149#define PROXIMITY7_PROXIMITY_ENA 0x04
150#define PROXIMITY7_ALS_ENA 0x02
151#define PROXIMITY7_POWER_ON 0x01
158#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_EVERY 0x00
159#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_1 0x10
160#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_2 0x20
161#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_3 0x30
162#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_4 0x40
163#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_5 0x50
164#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_6 0x60
165#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_7 0x70
166#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_8 0x80
167#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_9 0x90
168#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_10 0xA0
169#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_11 0xB0
170#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_12 0xC0
171#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_13 0xD0
172#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_14 0xE0
173#define PROXIMITY7_PPERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_15 0xF0
175#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_EVERY 0x00
176#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_1 0x01
177#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_2 0x02
178#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_3 0x03
179#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_5 0x04
180#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_10 0x05
181#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_15 0x06
182#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_20 0x07
183#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_25 0x08
184#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_30 0x09
185#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_35 0x0A
186#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_40 0x0B
187#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_45 0x0C
188#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_50 0x0D
189#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_55 0x0E
190#define PROXIMITY7_APERS_CONSECUTIVE_VALUES_OUT_OF_RANGE_60 0x0F
197#define PROXIMITY7_ALS_GAIN_LEVEL 0x04
198#define PROXIMITY7_WAIT_LONG 0x02
199#define PROXIMITY7_PROXIMITY_DRIVE_LEVEL 0x01
206#define PROXIMITY7_LED_DRIVE_100mA 0x00
207#define PROXIMITY7_LED_DRIVE_50mA 0x40
208#define PROXIMITY7_LED_DRIVE_25mA 0x80
209#define PROXIMITY7_LED_DRIVE_12p5mA 0xC0
210#define PROXIMITY7_PROXIMITY_DIODE_CH1 0x20
211#define PROXIMITY7_PROXIMITY_GAIN_1x 0x00
212#define PROXIMITY7_PROXIMITY_GAIN_2x 0x04
213#define PROXIMITY7_PROXIMITY_GAIN_4x 0x08
214#define PROXIMITY7_PROXIMITY_GAIN_8x 0x0C
215#define PROXIMITY7_ALS_GAIN_1x 0x00
216#define PROXIMITY7_ALS_GAIN_8x 0x01
217#define PROXIMITY7_ALS_GAIN_16x 0x02
218#define PROXIMITY7_ALS_GAIN_120x 0x03
225#define PROXIMITY7_PROXIMITY_SATURATION_MASK 0x40
226#define PROXIMITY7_PROXIMITY_INT_PINERRUPT_MASK 0x20
227#define PROXIMITY7_ALS_INT_PINERRUPT_MASK 0x10
228#define PROXIMITY7_PROXIMITY_VALID_MASK 0x02
229#define PROXIMITY7_ALS_VALID_MASK 0x01
236#define PROXIMITY7_NEGATIVE 0x00
237#define PROXIMITY7_POSITIVE 0x80
void proximity7_set_int_persistance(proximity7_t *ctx, uint16_t proximity_int_persistence, uint16_t als_int_persistence)
Setting int_pinerrupt persistance.
uint8_t proximity7_set_als_integration_time(proximity7_t *ctx, float integration_time)
Setting ALS int_pinegration time.
void proximity7_generic_write(proximity7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic write function.
uint16_t proximity7_get_proximity_data(proximity7_t *ctx)
Getting proximity measurement data.
uint16_t proximity7_get_als_data_ch0(proximity7_t *ctx)
Getting channel measurement data.
uint16_t proximity7_get_als_data_ch1(proximity7_t *ctx)
Getting channel 1 measurement data.
float proximity7_get_lux_level(proximity7_t *ctx)
Calculating LUX level.
uint8_t proximity7_set_proximity_integration_time(proximity7_t *ctx, float integration_time)
Setting proximity int_pinegration time.
void proximity7_generic_read(proximity7_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Generic read function.
void proximity7_set_constants(proximity7_t *ctx, proximity7_const_t *set_const_data)
Generic read function.
uint8_t proximity7_init(proximity7_t *ctx, proximity7_cfg_t *cfg)
Initialization function.
uint8_t proximity7_get_int_pin(proximity7_t *ctx)
Checking INT_pin pin status.
void proximity7_cfg_setup(proximity7_cfg_t *cfg)
Config Object Initialization function.
void proximity7_set_low_alsCh0_threshold(proximity7_t *ctx, uint16_t low_als_ch0_threshold)
Setting low ALS Ch0 threshold value.
void proximity7_set_low_proximity_threshold(proximity7_t *ctx, uint16_t low_proximity_threshold)
Setting low proximity threshold.
void proximity7_set_high_alsCh0_threshold(proximity7_t *ctx, uint16_t high_als_ch0_threshold)
Setting high ALS Ch0 threshold value.
uint8_t proximity7_set_wait_time(proximity7_t *ctx, float wait_time)
Setting wait time.
void proximity7_default_cfg(proximity7_t *ctx)
Click Default Configuration function.
void proximity7_set_proximity_pulse_count(proximity7_t *ctx, uint8_t proximity_pulse_count)
Setting proximity pulse count.
uint8_t proximity7_set_proximity_offset(proximity7_t *ctx, uint8_t proximity_offset_sign, uint8_t proximity_offset_magnitude)
Setting proximity offset.
void proximity7_set_high_proximity_threshold(proximity7_t *ctx, uint16_t high_proximity_threshold)
Setting high proximity threshold.
Click configuration structure definition.
Definition proximity7.h:285
proximity7_const_t dev_const
Definition proximity7.h:301
uint32_t i2c_speed
Definition proximity7.h:298
pin_name_t scl
Definition proximity7.h:288
pin_name_t int_pin
Definition proximity7.h:294
pin_name_t sda
Definition proximity7.h:289
uint8_t i2c_address
Definition proximity7.h:299
Definition proximity7.h:273
float const_c
Definition proximity7.h:276
float const_b
Definition proximity7.h:275
float const_d
Definition proximity7.h:277
float glass_attenuation
Definition proximity7.h:274
float device_factor
Definition proximity7.h:278
Click ctx object definition.
Definition proximity7.h:251
float const_c
Definition proximity7.h:266
float const_b
Definition proximity7.h:265
float const_d
Definition proximity7.h:267
float glass_attenuation
Definition proximity7.h:264
digital_in_t int_pin
Definition proximity7.h:254
i2c_master_t i2c
Definition proximity7.h:258
float device_factor
Definition proximity7.h:268
uint8_t slave_address
Definition proximity7.h:262