capwheel2  2.0.0.0
capwheel2.h
Go to the documentation of this file.
1 /*
2  * MikroSDK - MikroE Software Development Kit
3  * Copyright© 2020 MikroElektronika d.o.o.
4  *
5  * Permission is hereby granted, free of charge, to any person
6  * obtaining a copy of this software and associated documentation
7  * files (the "Software"), to deal in the Software without restriction,
8  * including without limitation the rights to use, copy, modify, merge,
9  * publish, distribute, sublicense, and/or sell copies of the Software,
10  * and to permit persons to whom the Software is furnished to do so,
11  * subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be
14  * included in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22  * OR OTHER DEALINGS IN THE SOFTWARE.
23  */
24 
33 // ----------------------------------------------------------------------------
34 
35 #ifndef CAPWHEEL2_H
36 #define CAPWHEEL2_H
37 
38 #include "mikrosdk_version.h"
39 
40 #ifdef __GNUC__
41 #if mikroSDK_GET_VERSION < 20800ul
42 #include "rcu_delays.h"
43 #else
44 #include "delays.h"
45 #endif
46 #endif
47 
48 #include "drv_digital_out.h"
49 #include "drv_digital_in.h"
50 #include "drv_i2c_master.h"
51 
52 
53 // -------------------------------------------------------------- PUBLIC MACROS
63 #define CAPWHEEL2_MAP_MIKROBUS( cfg, mikrobus ) \
64  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
65  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
66  cfg.rdy = MIKROBUS( mikrobus, MIKROBUS_INT )
67 
73 #define CAPWHEEL2_RETVAL uint8_t
74 
75 #define CAPWHEEL2_OK 0x00
76 #define CAPWHEEL2_INIT_ERROR 0xFF
77 
83 #define CAPWHEEL2_DEVICE_ADDRESS 0x44
84 
90 #define CAPWHEEL2_DEVICE_INFO 0x00
91 #define CAPWHEEL2_SYS_FLAGS 0x01
92 #define CAPWHEEL2_COORDINATES 0x02
93 #define CAPWHEEL2_TOUCH_BYTES 0x03
94 #define CAPWHEEL2_COUNTS 0x04
95 #define CAPWHEEL2_LTA 0x05
96 #define CAPWHEEL2_DELTAS 0x06
97 #define CAPWHEEL2_MULTIPLIERS 0x07
98 #define CAPWHEEL2_COMPENSATION 0x08
99 #define CAPWHEEL2_PROX_SETTINGS 0x09
100 #define CAPWHEEL2_THRESHOLDS 0x0A
101 #define CAPWHEEL2_TIMINGS_AND_TARGETS 0x0B
102 #define CAPWHEEL2_GESTURE_TIMERS 0x0C
103 #define CAPWHEEL2_ACTIVE_CHANNELS 0x0D
104 
110 #define CAPWHEEL2_TAP_MASK 0x20
111 #define CAPWHEEL2_TOUCH_MASK 0x02
112 #define CAPWHEEL2_PROX_MASK 0x01
113  // End group macro
116 // --------------------------------------------------------------- PUBLIC TYPES
125 typedef struct
126 {
127  // Input pins
128 
129  digital_in_t rdy;
130 
131  // Modules
132 
133  i2c_master_t i2c;
134 
135  // ctx variable
136 
137  uint8_t slave_address;
138 
139 } capwheel2_t;
140 
144 typedef struct
145 {
146  // Communication gpio pins
147 
148  pin_name_t scl;
149  pin_name_t sda;
150 
151  // Additional gpio pins
152 
153  pin_name_t rdy;
154 
155  // static variable
156 
157  uint32_t i2c_speed;
158  uint8_t i2c_address;
159 
161  // End types group
163 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
164 
170 #ifdef __cplusplus
171 extern "C"{
172 #endif
173 
183 
192 
202 
213 void capwheel2_i2c_write_no_wait ( capwheel2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
214 
226 void capwheel2_i2c_read_no_wait ( capwheel2_t *ctx, uint8_t reg, uint8_t *data_buf, uint8_t len );
227 
237 
247 
260 uint8_t capwheel2_i2c_read_wait ( capwheel2_t *ctx, uint8_t register_address, uint8_t * read_buffer, uint8_t n_bytes );
261 
274 uint8_t capwheel2_i2c_write_wait ( capwheel2_t *ctx, uint8_t register_address, uint8_t * register_values, uint8_t n_bytes );
275 
276 
277 #ifdef __cplusplus
278 }
279 #endif
280 #endif // _CAPWHEEL2_H_
281  // End public_function group
284 
285 // ------------------------------------------------------------------------- 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:145
capwheel2_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: capwheel2.h:157
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_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:126
capwheel2_cfg_t::rdy
pin_name_t rdy
Definition: capwheel2.h:153
capwheel2_t::i2c
i2c_master_t i2c
Definition: capwheel2.h:133
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:73
capwheel2_t::slave_address
uint8_t slave_address
Definition: capwheel2.h:137
capwheel2_cfg_t::scl
pin_name_t scl
Definition: capwheel2.h:148
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_cfg_t::i2c_address
uint8_t i2c_address
Definition: capwheel2.h:158
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:149
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:129