Go to the documentation of this file.
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_i2c_master.h"
59 #define PROXIMITY18_REG_PS_CONF12 0x03
60 #define PROXIMITY18_REG_PS_CONF3_MS 0x04
61 #define PROXIMITY18_REG_PS_CANC 0x05
62 #define PROXIMITY18_REG_PS_THDL 0x06
63 #define PROXIMITY18_REG_PS_THDH 0x07
64 #define PROXIMITY18_REG_PS1_DATA 0x08
65 #define PROXIMITY18_REG_PS2_DATA 0x09
66 #define PROXIMITY18_REG_PS3_DATA 0x0A
67 #define PROXIMITY18_REG_INT_FLAG 0x0D
68 #define PROXIMITY18_REG_ID 0x0E
86 #define PROXIMITY18_PS_CONF2_MPX_INT_EN_DIS 0x0000
87 #define PROXIMITY18_PS_CONF2_MPX_INT_EN_EN 0x8000
88 #define PROXIMITY18_PS_CONF2_MPX_INT_EN_MASK 0x8000
89 #define PROXIMITY18_PS_CONF2_MPX_MODE_DIS 0x0000
90 #define PROXIMITY18_PS_CONF2_MPX_MODE_EN 0x4000
91 #define PROXIMITY18_PS_CONF2_MPX_MODE_MASK 0x4000
92 #define PROXIMITY18_PS_CONF2_PS_GAIN_TWO_STEP 0x0000
93 #define PROXIMITY18_PS_CONF2_PS_GAIN_SINGLE_X8 0x2000
94 #define PROXIMITY18_PS_CONF2_PS_GAIN_SINGLE_X1 0x3000
95 #define PROXIMITY18_PS_CONF2_PS_GAIN_MASK 0x3000
96 #define PROXIMITY18_PS_CONF2_PS_HD_12BITS 0x0000
97 #define PROXIMITY18_PS_CONF2_PS_HD_16BITS 0x0800
98 #define PROXIMITY18_PS_CONF2_PS_HD_MASK 0x0800
99 #define PROXIMITY18_PS_CONF2_PS_NS_MASK 0x0400
100 #define PROXIMITY18_PS_CONF2_PS_INT_DIS 0x0000
101 #define PROXIMITY18_PS_CONF2_PS_INT_CLOSE 0x0100
102 #define PROXIMITY18_PS_CONF2_PS_INT_AWAY 0x0200
103 #define PROXIMITY18_PS_CONF2_PS_INT_CLOSE_AWAY 0x0300
104 #define PROXIMITY18_PS_CONF2_PS_INT_MASK 0x0300
105 #define PROXIMITY18_PS_CONF2_MASK 0xFF00
106 #define PROXIMITY18_PS_CONF1_PS_DUTY_1_OF_40 0x0000
107 #define PROXIMITY18_PS_CONF1_PS_DUTY_1_OF_80 0x0040
108 #define PROXIMITY18_PS_CONF1_PS_DUTY_1_OF_160 0x0080
109 #define PROXIMITY18_PS_CONF1_PS_DUTY_1_OF_320 0x00C0
110 #define PROXIMITY18_PS_CONF1_PS_DUTY_MASK 0x00C0
111 #define PROXIMITY18_PS_CONF1_PS_PERS_1 0x0000
112 #define PROXIMITY18_PS_CONF1_PS_PERS_2 0x0010
113 #define PROXIMITY18_PS_CONF1_PS_PERS_3 0x0020
114 #define PROXIMITY18_PS_CONF1_PS_PERS_4 0x0030
115 #define PROXIMITY18_PS_CONF1_PS_PERS_MASK 0x0030
116 #define PROXIMITY18_PS_CONF1_PS_IT_1T 0x0000
117 #define PROXIMITY18_PS_CONF1_PS_IT_1p5T 0x0002
118 #define PROXIMITY18_PS_CONF1_PS_IT_2T 0x0004
119 #define PROXIMITY18_PS_CONF1_PS_IT_2p5T 0x0006
120 #define PROXIMITY18_PS_CONF1_PS_IT_3T 0x0008
121 #define PROXIMITY18_PS_CONF1_PS_IT_3p5T 0x000A
122 #define PROXIMITY18_PS_CONF1_PS_IT_4T 0x000C
123 #define PROXIMITY18_PS_CONF1_PS_IT_8T 0x000E
124 #define PROXIMITY18_PS_CONF1_PS_IT_MASK 0x000E
125 #define PROXIMITY18_PS_CONF1_PS_SD_POWER_ON 0x0000
126 #define PROXIMITY18_PS_CONF1_PS_SD_SHUT_DOWN 0x0001
127 #define PROXIMITY18_PS_CONF1_PS_SD_MASK 0x0001
128 #define PROXIMITY18_PS_CONF1_MASK 0x00FF
134 #define PROXIMITY18_PS_MS_PS_SC_CUR_1X 0x0000
135 #define PROXIMITY18_PS_MS_PS_SC_CUR_2X 0x2000
136 #define PROXIMITY18_PS_MS_PS_SC_CUR_4X 0x4000
137 #define PROXIMITY18_PS_MS_PS_SC_CUR_8X 0x6000
138 #define PROXIMITY18_PS_MS_PS_SC_CUR_MASK 0x6000
139 #define PROXIMITY18_PS_MS_PS_SP_1X_CAP 0x0000
140 #define PROXIMITY18_PS_MS_PS_SP_1p5X_CAP 0x1000
141 #define PROXIMITY18_PS_MS_PS_SP_MASK 0x1000
142 #define PROXIMITY18_PS_MS_PS_SPO_00H 0x0000
143 #define PROXIMITY18_PS_MS_PS_SPO_FFH 0x0800
144 #define PROXIMITY18_PS_MS_PS_SPO_MASK 0x0800
145 #define PROXIMITY18_PS_MS_LED_I_50mA 0x0000
146 #define PROXIMITY18_PS_MS_LED_I_75mA 0x0100
147 #define PROXIMITY18_PS_MS_LED_I_100mA 0x0200
148 #define PROXIMITY18_PS_MS_LED_I_120mA 0x0300
149 #define PROXIMITY18_PS_MS_LED_I_140mA 0x0400
150 #define PROXIMITY18_PS_MS_LED_I_160mA 0x0500
151 #define PROXIMITY18_PS_MS_LED_I_180mA 0x0600
152 #define PROXIMITY18_PS_MS_LED_I_200mA 0x0700
153 #define PROXIMITY18_PS_MS_LED_I_MASK 0x0700
154 #define PROXIMITY18_PS_MS_MASK 0xFF00
155 #define PROXIMITY18_PS_CONF3_LED_I_LOW_DIS 0x0000
156 #define PROXIMITY18_PS_CONF3_LED_I_LOW_EN 0x0080
157 #define PROXIMITY18_PS_CONF3_LED_I_LOW_MASK 0x0080
158 #define PROXIMITY18_PS_CONF3_IRED_SELECT_IRED1 0x0000
159 #define PROXIMITY18_PS_CONF3_IRED_SELECT_IRED2 0x0020
160 #define PROXIMITY18_PS_CONF3_IRED_SELECT_IRED3 0x0040
161 #define PROXIMITY18_PS_CONF3_IRED_SELECT_MASK 0x0060
162 #define PROXIMITY18_PS_CONF3_PS_SMART_PERS_DIS 0x0000
163 #define PROXIMITY18_PS_CONF3_PS_SMART_PERS_EN 0x0010
164 #define PROXIMITY18_PS_CONF3_PS_SMART_PERS_MASK 0x0010
165 #define PROXIMITY18_PS_CONF3_PS_AF_DIS 0x0000
166 #define PROXIMITY18_PS_CONF3_PS_AF_EN 0x0008
167 #define PROXIMITY18_PS_CONF3_PS_AF_MASK 0x0008
168 #define PROXIMITY18_PS_CONF3_PS_TRIG_NO_TRIG 0x0000
169 #define PROXIMITY18_PS_CONF3_PS_TRIG_ONE_TIME 0x0004
170 #define PROXIMITY18_PS_CONF3_PS_TRIG_MASK 0x0004
171 #define PROXIMITY18_PS_CONF3_PS_MS_NORMAL 0x0000
172 #define PROXIMITY18_PS_CONF3_PS_MS_DET_LOGIC 0x0002
173 #define PROXIMITY18_PS_CONF3_PS_MS_MASK 0x0002
174 #define PROXIMITY18_PS_CONF3_PS_SC_EN_TURN_OFF 0x0000
175 #define PROXIMITY18_PS_CONF3_PS_SC_EN_TURN_ON 0x0001
176 #define PROXIMITY18_PS_CONF3_PS_SC_EN_MASK 0x0001
177 #define PROXIMITY18_PS_CONF3_MASK 0x00FF
183 #define PROXIMITY18_INT_FLAG_MPX_DATA_READY 0x8000
184 #define PROXIMITY18_INT_FLAG_PS_SP 0x4000
185 #define PROXIMITY18_INT_FLAG_PS_IF_CLOSE 0x0200
186 #define PROXIMITY18_INT_FLAG_PS_IF_AWAY 0x0100
187 #define PROXIMITY18_INT_FLAG_MASK 0xFF00
193 #define PROXIMITY18_DEVICE_ID 0x80
194 #define PROXIMITY18_DEVICE_ID_MASK 0xFF
200 #define PROXIMITY18_DATA_READY_TIMEOUT_MS 5000
207 #define PROXIMITY18_DEVICE_ADDRESS 0x41
225 #define PROXIMITY18_MAP_MIKROBUS( cfg, mikrobus ) \
226 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
227 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
228 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
416 #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:240
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:271
Proximity 18 Click configuration object.
Definition: proximity18.h:255
@ PROXIMITY18_ERROR
Definition: proximity18.h:273
@ PROXIMITY18_OK
Definition: proximity18.h:272
err_t proximity18_start_measurement(proximity18_t *ctx)
Proximity 18 start measurement function.
Proximity 18 Click context object.
Definition: proximity18.h:238
i2c_master_t i2c
Definition: proximity18.h:243
pin_name_t sda
Definition: proximity18.h:257
pin_name_t scl
Definition: proximity18.h:256
uint32_t i2c_speed
Definition: proximity18.h:261
uint8_t i2c_address
Definition: proximity18.h:262
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:259
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:246