Go to the documentation of this file.
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 PROXIMITY18_REG_PS_CONF12 0x03
74 #define PROXIMITY18_REG_PS_CONF3_MS 0x04
75 #define PROXIMITY18_REG_PS_CANC 0x05
76 #define PROXIMITY18_REG_PS_THDL 0x06
77 #define PROXIMITY18_REG_PS_THDH 0x07
78 #define PROXIMITY18_REG_PS1_DATA 0x08
79 #define PROXIMITY18_REG_PS2_DATA 0x09
80 #define PROXIMITY18_REG_PS3_DATA 0x0A
81 #define PROXIMITY18_REG_INT_FLAG 0x0D
82 #define PROXIMITY18_REG_ID 0x0E
100 #define PROXIMITY18_PS_CONF2_MPX_INT_EN_DIS 0x0000
101 #define PROXIMITY18_PS_CONF2_MPX_INT_EN_EN 0x8000
102 #define PROXIMITY18_PS_CONF2_MPX_INT_EN_MASK 0x8000
103 #define PROXIMITY18_PS_CONF2_MPX_MODE_DIS 0x0000
104 #define PROXIMITY18_PS_CONF2_MPX_MODE_EN 0x4000
105 #define PROXIMITY18_PS_CONF2_MPX_MODE_MASK 0x4000
106 #define PROXIMITY18_PS_CONF2_PS_GAIN_TWO_STEP 0x0000
107 #define PROXIMITY18_PS_CONF2_PS_GAIN_SINGLE_X8 0x2000
108 #define PROXIMITY18_PS_CONF2_PS_GAIN_SINGLE_X1 0x3000
109 #define PROXIMITY18_PS_CONF2_PS_GAIN_MASK 0x3000
110 #define PROXIMITY18_PS_CONF2_PS_HD_12BITS 0x0000
111 #define PROXIMITY18_PS_CONF2_PS_HD_16BITS 0x0800
112 #define PROXIMITY18_PS_CONF2_PS_HD_MASK 0x0800
113 #define PROXIMITY18_PS_CONF2_PS_NS_MASK 0x0400
114 #define PROXIMITY18_PS_CONF2_PS_INT_DIS 0x0000
115 #define PROXIMITY18_PS_CONF2_PS_INT_CLOSE 0x0100
116 #define PROXIMITY18_PS_CONF2_PS_INT_AWAY 0x0200
117 #define PROXIMITY18_PS_CONF2_PS_INT_CLOSE_AWAY 0x0300
118 #define PROXIMITY18_PS_CONF2_PS_INT_MASK 0x0300
119 #define PROXIMITY18_PS_CONF2_MASK 0xFF00
120 #define PROXIMITY18_PS_CONF1_PS_DUTY_1_OF_40 0x0000
121 #define PROXIMITY18_PS_CONF1_PS_DUTY_1_OF_80 0x0040
122 #define PROXIMITY18_PS_CONF1_PS_DUTY_1_OF_160 0x0080
123 #define PROXIMITY18_PS_CONF1_PS_DUTY_1_OF_320 0x00C0
124 #define PROXIMITY18_PS_CONF1_PS_DUTY_MASK 0x00C0
125 #define PROXIMITY18_PS_CONF1_PS_PERS_1 0x0000
126 #define PROXIMITY18_PS_CONF1_PS_PERS_2 0x0010
127 #define PROXIMITY18_PS_CONF1_PS_PERS_3 0x0020
128 #define PROXIMITY18_PS_CONF1_PS_PERS_4 0x0030
129 #define PROXIMITY18_PS_CONF1_PS_PERS_MASK 0x0030
130 #define PROXIMITY18_PS_CONF1_PS_IT_1T 0x0000
131 #define PROXIMITY18_PS_CONF1_PS_IT_1p5T 0x0002
132 #define PROXIMITY18_PS_CONF1_PS_IT_2T 0x0004
133 #define PROXIMITY18_PS_CONF1_PS_IT_2p5T 0x0006
134 #define PROXIMITY18_PS_CONF1_PS_IT_3T 0x0008
135 #define PROXIMITY18_PS_CONF1_PS_IT_3p5T 0x000A
136 #define PROXIMITY18_PS_CONF1_PS_IT_4T 0x000C
137 #define PROXIMITY18_PS_CONF1_PS_IT_8T 0x000E
138 #define PROXIMITY18_PS_CONF1_PS_IT_MASK 0x000E
139 #define PROXIMITY18_PS_CONF1_PS_SD_POWER_ON 0x0000
140 #define PROXIMITY18_PS_CONF1_PS_SD_SHUT_DOWN 0x0001
141 #define PROXIMITY18_PS_CONF1_PS_SD_MASK 0x0001
142 #define PROXIMITY18_PS_CONF1_MASK 0x00FF
148 #define PROXIMITY18_PS_MS_PS_SC_CUR_1X 0x0000
149 #define PROXIMITY18_PS_MS_PS_SC_CUR_2X 0x2000
150 #define PROXIMITY18_PS_MS_PS_SC_CUR_4X 0x4000
151 #define PROXIMITY18_PS_MS_PS_SC_CUR_8X 0x6000
152 #define PROXIMITY18_PS_MS_PS_SC_CUR_MASK 0x6000
153 #define PROXIMITY18_PS_MS_PS_SP_1X_CAP 0x0000
154 #define PROXIMITY18_PS_MS_PS_SP_1p5X_CAP 0x1000
155 #define PROXIMITY18_PS_MS_PS_SP_MASK 0x1000
156 #define PROXIMITY18_PS_MS_PS_SPO_00H 0x0000
157 #define PROXIMITY18_PS_MS_PS_SPO_FFH 0x0800
158 #define PROXIMITY18_PS_MS_PS_SPO_MASK 0x0800
159 #define PROXIMITY18_PS_MS_LED_I_50mA 0x0000
160 #define PROXIMITY18_PS_MS_LED_I_75mA 0x0100
161 #define PROXIMITY18_PS_MS_LED_I_100mA 0x0200
162 #define PROXIMITY18_PS_MS_LED_I_120mA 0x0300
163 #define PROXIMITY18_PS_MS_LED_I_140mA 0x0400
164 #define PROXIMITY18_PS_MS_LED_I_160mA 0x0500
165 #define PROXIMITY18_PS_MS_LED_I_180mA 0x0600
166 #define PROXIMITY18_PS_MS_LED_I_200mA 0x0700
167 #define PROXIMITY18_PS_MS_LED_I_MASK 0x0700
168 #define PROXIMITY18_PS_MS_MASK 0xFF00
169 #define PROXIMITY18_PS_CONF3_LED_I_LOW_DIS 0x0000
170 #define PROXIMITY18_PS_CONF3_LED_I_LOW_EN 0x0080
171 #define PROXIMITY18_PS_CONF3_LED_I_LOW_MASK 0x0080
172 #define PROXIMITY18_PS_CONF3_IRED_SELECT_IRED1 0x0000
173 #define PROXIMITY18_PS_CONF3_IRED_SELECT_IRED2 0x0020
174 #define PROXIMITY18_PS_CONF3_IRED_SELECT_IRED3 0x0040
175 #define PROXIMITY18_PS_CONF3_IRED_SELECT_MASK 0x0060
176 #define PROXIMITY18_PS_CONF3_PS_SMART_PERS_DIS 0x0000
177 #define PROXIMITY18_PS_CONF3_PS_SMART_PERS_EN 0x0010
178 #define PROXIMITY18_PS_CONF3_PS_SMART_PERS_MASK 0x0010
179 #define PROXIMITY18_PS_CONF3_PS_AF_DIS 0x0000
180 #define PROXIMITY18_PS_CONF3_PS_AF_EN 0x0008
181 #define PROXIMITY18_PS_CONF3_PS_AF_MASK 0x0008
182 #define PROXIMITY18_PS_CONF3_PS_TRIG_NO_TRIG 0x0000
183 #define PROXIMITY18_PS_CONF3_PS_TRIG_ONE_TIME 0x0004
184 #define PROXIMITY18_PS_CONF3_PS_TRIG_MASK 0x0004
185 #define PROXIMITY18_PS_CONF3_PS_MS_NORMAL 0x0000
186 #define PROXIMITY18_PS_CONF3_PS_MS_DET_LOGIC 0x0002
187 #define PROXIMITY18_PS_CONF3_PS_MS_MASK 0x0002
188 #define PROXIMITY18_PS_CONF3_PS_SC_EN_TURN_OFF 0x0000
189 #define PROXIMITY18_PS_CONF3_PS_SC_EN_TURN_ON 0x0001
190 #define PROXIMITY18_PS_CONF3_PS_SC_EN_MASK 0x0001
191 #define PROXIMITY18_PS_CONF3_MASK 0x00FF
197 #define PROXIMITY18_INT_FLAG_MPX_DATA_READY 0x8000
198 #define PROXIMITY18_INT_FLAG_PS_SP 0x4000
199 #define PROXIMITY18_INT_FLAG_PS_IF_CLOSE 0x0200
200 #define PROXIMITY18_INT_FLAG_PS_IF_AWAY 0x0100
201 #define PROXIMITY18_INT_FLAG_MASK 0xFF00
207 #define PROXIMITY18_DEVICE_ID 0x80
208 #define PROXIMITY18_DEVICE_ID_MASK 0xFF
214 #define PROXIMITY18_DATA_READY_TIMEOUT_MS 5000
221 #define PROXIMITY18_DEVICE_ADDRESS 0x41
239 #define PROXIMITY18_MAP_MIKROBUS( cfg, mikrobus ) \
240 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
241 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
242 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
430 #endif // PROXIMITY18_H
err_t proximity18_wait_for_data_ready(proximity18_t *ctx)
Proximity 18 wait for data ready function.
digital_in_t int_pin
Definition: proximity18.h:254
err_t proximity18_read_register(proximity18_t *ctx, uint8_t reg, uint16_t *data_out)
Proximity 18 read register function.
err_t proximity18_check_communication(proximity18_t *ctx)
Proximity 18 check communication function.
proximity18_return_value_t
Proximity 18 Click return value data.
Definition: proximity18.h:285
Proximity 18 Click configuration object.
Definition: proximity18.h:269
@ PROXIMITY18_ERROR
Definition: proximity18.h:287
@ PROXIMITY18_OK
Definition: proximity18.h:286
err_t proximity18_start_measurement(proximity18_t *ctx)
Proximity 18 start measurement function.
Proximity 18 Click context object.
Definition: proximity18.h:252
i2c_master_t i2c
Definition: proximity18.h:257
pin_name_t sda
Definition: proximity18.h:271
pin_name_t scl
Definition: proximity18.h:270
uint32_t i2c_speed
Definition: proximity18.h:275
uint8_t i2c_address
Definition: proximity18.h:276
err_t proximity18_write_register(proximity18_t *ctx, uint8_t reg, uint16_t data_in)
Proximity 18 write register function.
err_t proximity18_read_proximity(proximity18_t *ctx, uint16_t *ps1_data, uint16_t *ps2_data, uint16_t *ps3_data)
Proximity 18 read proximity function.
pin_name_t int_pin
Definition: proximity18.h:273
uint8_t proximity18_get_int_pin(proximity18_t *ctx)
Proximity 18 get int pin function.
err_t proximity18_init(proximity18_t *ctx, proximity18_cfg_t *cfg)
Proximity 18 initialization function.
void proximity18_cfg_setup(proximity18_cfg_t *cfg)
Proximity 18 configuration object setup function.
err_t proximity18_default_cfg(proximity18_t *ctx)
Proximity 18 default configuration function.
uint8_t slave_address
Definition: proximity18.h:260