captouch  2.0.0.0
captouch.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 CAPTOUCH_H
36 #define CAPTOUCH_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 
51 // -------------------------------------------------------------- PUBLIC MACROS
61 #define CAPTOUCH_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.mod = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
63  cfg.out = MIKROBUS( mikrobus, MIKROBUS_INT );
64 
70 #define CAPTOUCH_RETVAL uint8_t
71 
72 #define CAPTOUCH_OK 0x00
73 #define CAPTOUCH_INIT_ERROR 0xFF
74 
80 #define CAPTOUCH_FAST_MODE 1
81 #define CAPTOUCH_LOW_POWER_MODE 0
82  // End group macro
85 // --------------------------------------------------------------- PUBLIC TYPES
94 typedef struct
95 {
96  // Output pins
97 
98  digital_out_t mod;
99 
100  // Input pins
101 
102  digital_in_t out;
103 
104 } captouch_t;
105 
109 typedef struct
110 {
111  // Additional gpio pins
112 
113  pin_name_t mod;
114  pin_name_t out;
115 
117  // End types group
119 
120 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
121 
127 #ifdef __cplusplus
128 extern "C"{
129 #endif
130 
140 
149 
158 
165 void captouch_set_mode( captouch_t *ctx, uint8_t mode );
166 
174 
175 
176 #ifdef __cplusplus
177 }
178 #endif
179 #endif // _CAPTOUCH_H_
180  // End public_function group
183 
184 // ------------------------------------------------------------------------- END
CAPTOUCH_RETVAL
#define CAPTOUCH_RETVAL
Definition: captouch.h:70
captouch_t
Click ctx object definition.
Definition: captouch.h:95
captouch_cfg_t::out
pin_name_t out
Definition: captouch.h:114
captouch_t::out
digital_in_t out
Definition: captouch.h:102
captouch_cfg_t::mod
pin_name_t mod
Definition: captouch.h:113
captouch_cfg_t
Click configuration structure definition.
Definition: captouch.h:110
captouch_default_cfg
void captouch_default_cfg(captouch_t *ctx)
Click Default Configuration function.
captouch_init
CAPTOUCH_RETVAL captouch_init(captouch_t *ctx, captouch_cfg_t *cfg)
Initialization function.
captouch_set_mode
void captouch_set_mode(captouch_t *ctx, uint8_t mode)
Select mode.
captouch_cfg_setup
void captouch_cfg_setup(captouch_cfg_t *cfg)
Config Object Initialization function.
captouch_t::mod
digital_out_t mod
Definition: captouch.h:98
captouch_get_touch
uint8_t captouch_get_touch(captouch_t *ctx)
Get touch state.