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 PROXIMITY17_REG_ENABLE 0x80
74#define PROXIMITY17_REG_PRATE 0x82
75#define PROXIMITY17_REG_PILTL 0x88
76#define PROXIMITY17_REG_PILTH 0x89
77#define PROXIMITY17_REG_PIHTL 0x8A
78#define PROXIMITY17_REG_PIHTH 0x8B
79#define PROXIMITY17_REG_PERS 0x8C
80#define PROXIMITY17_REG_CFG0 0x8D
81#define PROXIMITY17_REG_PCFG0 0x8E
82#define PROXIMITY17_REG_PCFG1 0x8F
83#define PROXIMITY17_REG_REVID 0x91
84#define PROXIMITY17_REG_ID 0x92
85#define PROXIMITY17_REG_STATUS 0x9B
86#define PROXIMITY17_REG_PDATAL 0x9C
87#define PROXIMITY17_REG_PDATAH 0x9D
88#define PROXIMITY17_REG_REVID2 0xA6
89#define PROXIMITY17_REG_SOFTRST 0xA8
90#define PROXIMITY17_REG_PWTIME 0xA9
91#define PROXIMITY17_REG_CFG8 0xAA
92#define PROXIMITY17_REG_CFG3 0xAB
93#define PROXIMITY17_REG_CFG6 0xAE
94#define PROXIMITY17_REG_PFILTER 0xB3
95#define PROXIMITY17_REG_POFFSETL 0xC0
96#define PROXIMITY17_REG_POFFSETH 0xC1
97#define PROXIMITY17_REG_CALIB 0xD7
98#define PROXIMITY17_REG_CALIBCFG 0xD9
99#define PROXIMITY17_REG_CALIBSTAT 0xDC
100#define PROXIMITY17_REG_INTENAB 0xDD
101#define PROXIMITY17_REG_FAC_L 0xE5
102#define PROXIMITY17_REG_FAC_H 0xE6
103#define PROXIMITY17_REG_TEST9 0xF9
121#define PROXIMITY17_ENABLE_PWEN 0x10
122#define PROXIMITY17_ENABLE_PEN 0x04
123#define PROXIMITY17_ENABLE_PON 0x01
129#define PROXIMITY17_SOFT_RESET 0x01
135#define PROXIMITY17_PGAIN_1X 0x00
136#define PROXIMITY17_PGAIN_2X 0x40
137#define PROXIMITY17_PGAIN_4X 0x80
138#define PROXIMITY17_PGAIN_8X 0xC0
139#define PROXIMITY17_PPULSE_MIN 0x00
140#define PROXIMITY17_PPULSE_DEFAULT 0x0F
141#define PROXIMITY17_PPULSE_MAX 0x3F
147#define PROXIMITY17_PPULSE_LEN_1US 0x00
148#define PROXIMITY17_PPULSE_LEN_2US 0x20
149#define PROXIMITY17_PPULSE_LEN_4US 0x40
150#define PROXIMITY17_PPULSE_LEN_8US 0x60
151#define PROXIMITY17_PPULSE_LEN_12US 0x80
152#define PROXIMITY17_PPULSE_LEN_16US 0xA0
153#define PROXIMITY17_PPULSE_LEN_24US 0xC0
154#define PROXIMITY17_PPULSE_LEN_32US 0xE0
155#define PROXIMITY17_PLDRIVE_2mA 0x00
156#define PROXIMITY17_PLDRIVE_3mA 0x01
157#define PROXIMITY17_PLDRIVE_4mA 0x02
158#define PROXIMITY17_PLDRIVE_5mA 0x03
159#define PROXIMITY17_PLDRIVE_6mA 0x04
160#define PROXIMITY17_PLDRIVE_7mA 0x05
161#define PROXIMITY17_PLDRIVE_8mA 0x06
162#define PROXIMITY17_PLDRIVE_9mA 0x07
163#define PROXIMITY17_PLDRIVE_10mA 0x08
169#define PROXIMITY17_PDSELECT_NO_PDIODE 0x00
170#define PROXIMITY17_PDSELECT_FAR_PDIODE 0x01
171#define PROXIMITY17_PDSELECT_NEAR_PDIODE 0x02
172#define PROXIMITY17_PDSELECT_BOTH_PDIODE 0x03
178#define PROXIMITY17_STATUS_PHIGH 0x80
179#define PROXIMITY17_STATUS_PLOW 0x40
180#define PROXIMITY17_STATUS_PSAT 0x20
181#define PROXIMITY17_STATUS_PINT 0x10
182#define PROXIMITY17_STATUS_CINT 0x08
183#define PROXIMITY17_STATUS_ZINT 0x04
184#define PROXIMITY17_STATUS_PSAT_REFLECTIVE 0x02
185#define PROXIMITY17_STATUS_PSAT_AMBIENT 0x01
186#define PROXIMITY17_STATUS_CLEAR_ALL 0xFF
192#define PROXIMITY17_INTENAB_PIM 0x20
193#define PROXIMITY17_INTENAB_PIEN 0x10
194#define PROXIMITY17_INTENAB_PSIEN 0x08
195#define PROXIMITY17_INTENAB_CIEN 0x04
196#define PROXIMITY17_INTENAB_ZIEN 0x02
197#define PROXIMITY17_INTENAB_DISABLE 0x00
203#define PROXIMITY17_CALAVG 0x80
204#define PROXIMITY17_ELECTRICAL_CALIB 0x20
205#define PROXIMITY17_CALPRATE 0x10
206#define PROXIMITY17_START_OFFSET_CAL 0x01
212#define PROXIMITY17_BINSRCH_TARGET_3 0x00
213#define PROXIMITY17_BINSRCH_TARGET_7 0x20
214#define PROXIMITY17_BINSRCH_TARGET_15 0x40
215#define PROXIMITY17_BINSRCH_TARGET_31 0x60
216#define PROXIMITY17_BINSRCH_TARGET_63 0x80
217#define PROXIMITY17_BINSRCH_TARGET_127 0xA0
218#define PROXIMITY17_BINSRCH_TARGET_255 0xC0
219#define PROXIMITY17_BINSRCH_TARGET_511 0xE0
220#define PROXIMITY17_CALIBCFG_RESERVED 0x10
221#define PROXIMITY17_AUTO_OFFSET_ADJ 0x08
222#define PROXIMITY17_PROX_AVG_DISABLE 0x00
223#define PROXIMITY17_PROX_AVG_2 0x01
224#define PROXIMITY17_PROX_AVG_4 0x02
225#define PROXIMITY17_PROX_AVG_8 0x03
226#define PROXIMITY17_PROX_AVG_16 0x04
227#define PROXIMITY17_PROX_AVG_32 0x05
228#define PROXIMITY17_PROX_AVG_64 0x06
229#define PROXIMITY17_PROX_AVG_128 0x07
235#define PROXIMITY17_OFFSET_ADJUSTED 0x04
236#define PROXIMITY17_CALIB_FINISHED 0x01
242#define PROXIMITY17_APC_ENABLE 0x3F
243#define PROXIMITY17_APC_DISABLE 0x7F
249#define PROXIMITY17_DEVICE_ID 0x44
256#define PROXIMITY17_DEVICE_ADDRESS 0x39
274#define PROXIMITY17_MAP_MIKROBUS( cfg, mikrobus ) \
275 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
276 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
277 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
err_t proximity17_read_proximity(proximity17_t *ctx, uint16_t *prox_data)
Proximity 17 read proximity function.
err_t proximity17_check_communication(proximity17_t *ctx)
Proximity 17 check communication function.
err_t proximity17_read_register(proximity17_t *ctx, uint8_t reg, uint8_t *data_out)
Proximity 17 read register function.
err_t proximity17_write_register(proximity17_t *ctx, uint8_t reg, uint8_t data_in)
Proximity 17 write register function.
void proximity17_cfg_setup(proximity17_cfg_t *cfg)
Proximity 17 configuration object setup function.
err_t proximity17_default_cfg(proximity17_t *ctx)
Proximity 17 default configuration function.
err_t proximity17_init(proximity17_t *ctx, proximity17_cfg_t *cfg)
Proximity 17 initialization function.
uint8_t proximity17_get_int_pin(proximity17_t *ctx)
Proximity 17 get int pin function.
err_t proximity17_soft_reset(proximity17_t *ctx)
Proximity 17 soft reset function.
err_t proximity17_generic_read(proximity17_t *ctx, uint8_t reg, uint8_t *rx_buf, uint8_t rx_len)
Proximity 17 I2C reading function.
err_t proximity17_generic_write(proximity17_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len)
Proximity 17 I2C writing function.
proximity17_return_value_t
Proximity 17 Click return value data.
Definition proximity17.h:320
@ PROXIMITY17_ERROR
Definition proximity17.h:322
@ PROXIMITY17_OK
Definition proximity17.h:321
Proximity 17 Click configuration object.
Definition proximity17.h:304
uint32_t i2c_speed
Definition proximity17.h:310
pin_name_t scl
Definition proximity17.h:305
pin_name_t int_pin
Definition proximity17.h:308
pin_name_t sda
Definition proximity17.h:306
uint8_t i2c_address
Definition proximity17.h:311
Proximity 17 Click context object.
Definition proximity17.h:287
digital_in_t int_pin
Definition proximity17.h:289
i2c_master_t i2c
Definition proximity17.h:292
uint8_t slave_address
Definition proximity17.h:295