capwheel2  2.0.0.0
capwheel2.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 CAPWHEEL2_H
36 #define CAPWHEEL2_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_i2c_master.h"
41 
42 
43 // -------------------------------------------------------------- PUBLIC MACROS
53 #define CAPWHEEL2_MAP_MIKROBUS( cfg, mikrobus ) \
54  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
55  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
56  cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
57 
63 #define CAPWHEEL2_RETVAL uint8_t
64 
65 #define CAPWHEEL2_OK 0x00
66 #define CAPWHEEL2_INIT_ERROR 0xFF
67 
73 #define CAPWHEEL2_DEVICE_ADDRESS 0x44
74 
80 #define CAPWHEEL2_DEVICE_INFO 0x00
81 #define CAPWHEEL2_SYS_FLAGS 0x01
82 #define CAPWHEEL2_COORDINATES 0x02
83 #define CAPWHEEL2_TOUCH_BYTES 0x03
84 #define CAPWHEEL2_COUNTS 0x04
85 #define CAPWHEEL2_LTA 0x05
86 #define CAPWHEEL2_DELTAS 0x06
87 #define CAPWHEEL2_MULTIPLIERS 0x07
88 #define CAPWHEEL2_COMPENSATION 0x08
89 #define CAPWHEEL2_PROX_SETTINGS 0x09
90 #define CAPWHEEL2_THRESHOLDS 0x0A
91 #define CAPWHEEL2_TIMINGS_AND_TARGETS 0x0B
92 #define CAPWHEEL2_GESTURE_TIMERS 0x0C
93 #define CAPWHEEL2_ACTIVE_CHANNELS 0x0D
94 
100 #define CAPWHEEL2_TAP_MASK 0x20
101 #define CAPWHEEL2_TOUCH_MASK 0x02
102 #define CAPWHEEL2_PROX_MASK 0x01
103  // End group macro
106 // --------------------------------------------------------------- PUBLIC TYPES
115 typedef struct
116 {
117  // Input pins
118 
119  digital_in_t rdy;
120 
121  // Modules
122 
123  i2c_master_t i2c;
124 
125  // ctx variable
126 
127  hal_i2c_address_t slave_address;
128 
129 } capwheel2_t;
130 
134 typedef struct
135 {
136  // Communication gpio pins
137 
138  pin_name_t scl;
139  pin_name_t sda;
140 
141  // Additional gpio pins
142 
143  pin_name_t rdy;
144 
145  // static variable
146 
147  hal_i2c_speed_t i2c_speed;
148  hal_i2c_address_t i2c_address;
149 
151  // End types group
153 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
154 
160 #ifdef __cplusplus
161 extern "C"{
162 #endif
163 
173 
182 
191 uint8_t capwheel2_default_cfg ( capwheel2_t *ctx );
192 
203 void capwheel2_i2c_write_no_wait ( capwheel2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
204 
216 void capwheel2_i2c_read_no_wait ( capwheel2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
217 
226 uint8_t capwheel2_int_get ( capwheel2_t *ctx );
227 
236 uint8_t capwheel2_wait_for_rdy ( capwheel2_t *ctx );
237 
250 uint8_t capwheel2_i2c_read_wait ( capwheel2_t *ctx, uint8_t register_address, uint8_t * read_buffer, uint8_t n_bytes );
251 
264 uint8_t capwheel2_i2c_write_wait ( capwheel2_t *ctx, uint8_t register_address, uint8_t * register_values, uint8_t n_bytes );
265 
266 
267 #ifdef __cplusplus
268 }
269 #endif
270 #endif // _CAPWHEEL2_H_
271  // End public_function group
274 
275 // ------------------------------------------------------------------------- END
capwheel2_int_get
uint8_t capwheel2_int_get(capwheel2_t *ctx)
Getingg state of INT pin.
capwheel2_init
CAPWHEEL2_RETVAL capwheel2_init(capwheel2_t *ctx, capwheel2_cfg_t *cfg)
Initialization function.
capwheel2_default_cfg
uint8_t capwheel2_default_cfg(capwheel2_t *ctx)
Click Default Configuration function.
capwheel2_cfg_t
Click configuration structure definition.
Definition: capwheel2.h:134
capwheel2_i2c_read_no_wait
void capwheel2_i2c_read_no_wait(capwheel2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Read function.
capwheel2_t::slave_address
hal_i2c_address_t slave_address
Definition: capwheel2.h:127
capwheel2_cfg_t::i2c_speed
hal_i2c_speed_t i2c_speed
Definition: capwheel2.h:147
capwheel2_i2c_write_no_wait
void capwheel2_i2c_write_no_wait(capwheel2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len)
Write function.
capwheel2_t
Click ctx object definition.
Definition: capwheel2.h:115
capwheel2_cfg_t::rdy
pin_name_t rdy
Definition: capwheel2.h:143
capwheel2_t::i2c
i2c_master_t i2c
Definition: capwheel2.h:123
capwheel2_wait_for_rdy
uint8_t capwheel2_wait_for_rdy(capwheel2_t *ctx)
Waiting for RDY (INT) pin.
CAPWHEEL2_RETVAL
#define CAPWHEEL2_RETVAL
Definition: capwheel2.h:63
capwheel2_cfg_t::i2c_address
hal_i2c_address_t i2c_address
Definition: capwheel2.h:148
capwheel2_cfg_t::scl
pin_name_t scl
Definition: capwheel2.h:138
capwheel2_i2c_read_wait
uint8_t capwheel2_i2c_read_wait(capwheel2_t *ctx, uint8_t register_address, uint8_t *read_buffer, uint8_t n_bytes)
Read wait function.
capwheel2_i2c_write_wait
uint8_t capwheel2_i2c_write_wait(capwheel2_t *ctx, uint8_t register_address, uint8_t *register_values, uint8_t n_bytes)
Write wait function.
capwheel2_cfg_t::sda
pin_name_t sda
Definition: capwheel2.h:139
capwheel2_cfg_setup
void capwheel2_cfg_setup(capwheel2_cfg_t *cfg)
Config Object Initialization function.
capwheel2_t::rdy
digital_in_t rdy
Definition: capwheel2.h:119