proxfusion  2.0.0.0
proxfusion.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright (c) 2019, MikroElektronika - www.mikroe.com
4  * All rights reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to deal
8  * in the Software without restriction, including without limitation the rights
9  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  * copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in
14  * all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef PROXFUSION_H
36 #define PROXFUSION_H
37 
38 #include "drv_digital_in.h"
39 #include "drv_i2c_master.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define PROXFUSION_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
53  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
54  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT );
55 
61 #define PROXFUSION_RETVAL uint8_t
62 
63 #define PROXFUSION_OK 0x00
64 #define PROXFUSION_INIT_ERROR 0xFF
65 
71 #define PROXFUSION_REG_PR_NUMBER 0x00
72 #define PROXFUSION_REG_SW_NUMBER 0x01
73 #define PROXFUSION_REG_HW_NUMBER 0x02
74 
80 #define PROXFUSION_PR_OK 0x41
81 #define PROXFUSION_SW_IQS620_OK 0x04
82 #define PROXFUSION_SW_IQS620A_OK 0x08
83 #define PROXFUSION_HW_OK 0x82
84 
90 #define PROXFUSION_FREG_SYSTEM 0x10
91 #define PROXFUSION_FREG_GLOBAL_EVENTS 0x11
92 #define PROXFUSION_FREG_UI 0x12
93 #define PROXFUSION_FREG_SAR_HYSTERESIS_UI 0x13
94 #define PROXFUSION_FREG_HALL_EFFECT_UI 0x16
95 #define PROXFUSION_FREG_TEMP_UI 0x19
96 
102 #define PROXFUSION_REG_OUT_HYSTERESIS 0x1514
103 #define PROXFUSION_REG_OUT_HALL_EFFECT 0x1817
104 #define PROXFUSION_REG_OUT_TEMP 0x1A
105 
111 #define PROXFUSION_REG_CH_0_LSB 0x20
112 #define PROXFUSION_REG_CH_0_MSB 0x21
113 #define PROXFUSION_REG_CH_1_LSB 0x22
114 #define PROXFUSION_REG_CH_1_MSB 0x23
115 #define PROXFUSION_REG_CH_2_LSB 0x24
116 #define PROXFUSION_REG_CH_2_MSB 0x25
117 #define PROXFUSION_REG_CH_3_LSB 0x26
118 #define PROXFUSION_REG_CH_3_MSB 0x27
119 #define PROXFUSION_REG_CH_4_LSB 0x28
120 #define PROXFUSION_REG_CH_4_MSB 0x29
121 #define PROXFUSION_REG_CH_5_LSB 0x2A
122 #define PROXFUSION_REG_CH_5_MSB 0x2B
123 
129 #define PROXFUSION_REG_LTA_CH_0_LSB 0x30
130 #define PROXFUSION_REG_LTA_CH_0_MSB 0x31
131 #define PROXFUSION_REG_LTA_CH_1_LSB 0x32
132 #define PROXFUSION_REG_LTA_CH_1_MSB 0x33
133 #define PROXFUSION_REG_LTA_CH_2_LSB 0x34
134 #define PROXFUSION_REG_LTA_CH_2_MSB 0x35
135 
141 #define PROXFUSION_REG_SETTINGS_0_0 0x40
142 #define PROXFUSION_REG_SETTINGS_0_1 0x41
143 #define PROXFUSION_REG_SETTINGS_0_2 0x42
144 #define PROXFUSION_REG_SETTINGS_1_0 0x43
145 #define PROXFUSION_REG_SETTINGS_1_1 0x44
146 #define PROXFUSION_REG_SETTINGS_1_2 0x45
147 #define PROXFUSION_REG_SETTINGS_2_0 0x46
148 #define PROXFUSION_REG_SETTINGS_2_1 0x47
149 #define PROXFUSION_REG_SETTINGS_2_2 0x48
150 #define PROXFUSION_REG_SETTINGS_3_0 0x49
151 #define PROXFUSION_REG_SETTINGS_3_1 0x4A
152 #define PROXFUSION_REG_SETTINGS_3_2 0x4B
153 
159 #define PROXFUSION_REG_SETTINGS_4 0x50
160 #define PROXFUSION_REG_SETTINGS_5 0x51
161 #define PROXFUSION_REG_COMPENSATION_CH_0 0x52
162 #define PROXFUSION_REG_COMPENSATION_CH_1 0x53
163 #define PROXFUSION_REG_COMPENSATION_CH_2 0x54
164 #define PROXFUSION_REG_MULTIPLIERS_CH_0 0x55
165 #define PROXFUSION_REG_MULTIPLIERS_CH_1 0x56
166 #define PROXFUSION_REG_MULTIPLIERS_CH_2 0x57
167 
173 #define PROXFUSION_REG_PROX_CH_0 0x60
174 #define PROXFUSION_REG_TOUCH_CH_0 0x61
175 #define PROXFUSION_REG_PROX_CH_1 0x62
176 #define PROXFUSION_REG_TOUCH_CH_1 0x63
177 #define PROXFUSION_REG_PROX_CH_2 0x64
178 #define PROXFUSION_REG_TOUCH_CH_2 0x65
179 #define PROXFUSION_REG_UI_HALY_TIME 0x66
180 
186 #define PROXFUSION_REG_SAR_SETTINGS_CH0 0x70
187 #define PROXFUSION_REG_SAR_SETTINGS_CH1 0x71
188 #define PROXFUSION_REG_QRD_THRESHOLD 0x72
189 #define PROXFUSION_REG_FILTER_HALT_THRESHOLD 0x73
190 #define PROXFUSION_REG_PROX_THRESHOLD 0x74
191 
197 #define PROXFUSION_REG_HYS_UI_SETTINGS 0x80
198 #define PROXFUSION_REG_HYS_FILTER_THRESHOLD 0x81
199 #define PROXFUSION_REG_HYS_PROX_THRESHOLD 0x82
200 #define PROXFUSION_REG_HYS_TOUCH_THRESHOLD 0x83
201 
207 #define PROXFUSION_REG_HALL_SETTINGS_0 0x90
208 #define PROXFUSION_REG_HALL_SETTINGS_1 0x91
209 #define PROXFUSION_REG_HALL_COMPENSATION_4_5 0x92
210 #define PROXFUSION_REG_HALL_MULTIPLIERS_4_5 0x93
211 
217 #define PROXFUSION_REG_HALL_SWITCH_UI 0xA0
218 #define PROXFUSION_REG_HALL_SWITCH_PROX 0xA1
219 #define PROXFUSION_REG_HALL_SWITCH_TOUCH 0xA2
220 
226 #define PROXFUSION_REG_TEMP_UI_SETTINGS 0xC0
227 #define PROXFUSION_REG_TEMP_MULTIPLIERS_3 0xC1
228 #define PROXFUSION_REG_TEMP_DATA_0 0xC2
229 #define PROXFUSION_REG_TEMP_DATA_1 0xC3
230 #define PROXFUSION_REG_TEMP_OFFSET 0xC4
231 
237 #define PROXFUSION_REG_I2C_SETTINGS 0xDA
238 
244 #define PROXFUSION_SYSTEM_RESET (0x02 << 6)
245 #define PROXFUSION_SYSTEM_ATI_RESET (0x02)
246 #define PROXFUSION_EVENT_MODE_0 (0x00 << 5)
247 #define PROXFUSION_EVENT_MODE_1 (0x01 << 5)
248 #define PROXFUSION_CLOCK_16MHz (0x00 << 4)
249 #define PROXFUSION_CLOCK_4MHz (0x01 << 4)
250 #define PROXFUSION_ATI_DESABLED (0x00 << 3)
251 #define PROXFUSION_ATI_ENABLED (0x01 << 3)
252 #define PROXFUSION_ATI_BAND_1_8 (0x00 << 3)
253 #define PROXFUSION_ATI_BAND_1_16 (0x01 << 3)
254 
260 #define PROXFUSION_MASK_SAR_ACTIVE 0x80
261 #define PROXFUSION_MASK_PMU_EVENT 0x40
262 #define PROXFUSION_MASK_SYS_EVENT 0x20
263 #define PROXFUSION_MASK_TEMP_EVENT 0x10
264 #define PROXFUSION_MASK_HYSTERESIS_EVENT 0x08
265 #define PROXFUSION_MASK_HALL_EVENT 0x04
266 #define PROXFUSION_MASK_SAR_EVENT 0x02
267 #define PROXFUSION_MASK_PROX_SENSE_EVENT 0x01
268 
274 #define PROXFUSION_SLAVE_ADDRESS 0x44
275  // End group macro
278 // --------------------------------------------------------------- PUBLIC TYPES
287 typedef struct
288 {
289  // Input pins
290 
291  digital_in_t int_pin;
292 
293  // Modules
294 
295  i2c_master_t i2c;
296 
297  // ctx variable
298 
299  hal_i2c_address_t slave_address;
300 
301 } proxfusion_t;
302 
306 typedef struct
307 {
308  // Communication gpio pins
309 
310  pin_name_t scl;
311  pin_name_t sda;
312 
313  // Additional gpio pins
314 
315  pin_name_t int_pin;
316 
317  // static variable
318 
319  hal_i2c_speed_t i2c_speed;
320  hal_i2c_address_t i2c_address;
321 
323  // End types group
325 
326 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
327 
333 #ifdef __cplusplus
334 extern "C"{
335 #endif
336 
346 
354 uint8_t proxfusion_init ( proxfusion_t *ctx, proxfusion_cfg_t *cfg );
355 
376 
387 void proxfusion_generic_write ( proxfusion_t *ctx, uint8_t reg, uint8_t *data_buffer, uint8_t len );
388 
399 void proxfusion_generic_read ( proxfusion_t *ctx, uint8_t reg, uint8_t *data_buffer, uint8_t len );
400 
409 
417 uint8_t proxfusion_get_touch ( proxfusion_t *ctx );
418 
434 void proxfusion_set_system_reg ( proxfusion_t *ctx, uint8_t cfg );
435 
452 void proxfusion_set_event_reg ( proxfusion_t *ctx, uint8_t cfg );
453 
454 #ifdef __cplusplus
455 }
456 #endif
457 #endif // _PROXFUSION_H_
458  // End public_function group
461 
462 // ------------------------------------------------------------------------- END
proxfusion_cfg_t::scl
pin_name_t scl
Definition: proxfusion.h:310
proxfusion_cfg_t::i2c_speed
hal_i2c_speed_t i2c_speed
Definition: proxfusion.h:319
proxfusion_cfg_setup
void proxfusion_cfg_setup(proxfusion_cfg_t *cfg)
Config Object Initialization function.
proxfusion_cfg_t::int_pin
pin_name_t int_pin
Definition: proxfusion.h:315
proxfusion_generic_write
void proxfusion_generic_write(proxfusion_t *ctx, uint8_t reg, uint8_t *data_buffer, uint8_t len)
Generic write function.
proxfusion_set_event_reg
void proxfusion_set_event_reg(proxfusion_t *ctx, uint8_t cfg)
Selecting events.
proxfusion_t::int_pin
digital_in_t int_pin
Definition: proxfusion.h:291
proxfusion_get_touch
uint8_t proxfusion_get_touch(proxfusion_t *ctx)
Touch event.
proxfusion_t::slave_address
hal_i2c_address_t slave_address
Definition: proxfusion.h:299
proxfusion_generic_read
void proxfusion_generic_read(proxfusion_t *ctx, uint8_t reg, uint8_t *data_buffer, uint8_t len)
Generic read function.
proxfusion_init
uint8_t proxfusion_init(proxfusion_t *ctx, proxfusion_cfg_t *cfg)
Initialization function.
proxfusion_get_temperature
float proxfusion_get_temperature(proxfusion_t *ctx)
Temperature data.
proxfusion_cfg_t
Click configuration structure definition.
Definition: proxfusion.h:306
proxfusion_t::i2c
i2c_master_t i2c
Definition: proxfusion.h:295
proxfusion_cfg_t::sda
pin_name_t sda
Definition: proxfusion.h:311
proxfusion_t
Click ctx object definition.
Definition: proxfusion.h:287
proxfusion_set_system_reg
void proxfusion_set_system_reg(proxfusion_t *ctx, uint8_t cfg)
Sets system register.
proxfusion_default_cfg
void proxfusion_default_cfg(proxfusion_t *ctx)
Click Default Configuration function.
proxfusion_cfg_t::i2c_address
hal_i2c_address_t i2c_address
Definition: proxfusion.h:320