c2x2key  2.0.0.0
c2x2key.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 C2X2KEY_H
36 #define C2X2KEY_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 C2X2KEY_MAP_MIKROBUS( cfg, mikrobus ) \
62  cfg.t1o = MIKROBUS( mikrobus, MIKROBUS_AN ); \
63  cfg.t2o = MIKROBUS( mikrobus, MIKROBUS_RST ); \
64  cfg.t3o = MIKROBUS( mikrobus, MIKROBUS_CS ); \
65  cfg.t4o = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
66  cfg.tint = MIKROBUS( mikrobus, MIKROBUS_INT )
67 
73 #define C2X2KEY_RETVAL uint8_t
74 
75 #define C2X2KEY_OK 0x00
76 #define C2X2KEY_INIT_ERROR 0xFF
77  // End group macro
80 
81 // --------------------------------------------------------------- PUBLIC TYPES
90 typedef struct
91 {
92  // Input pins
93 
94  digital_in_t t1o;
95  digital_in_t t2o;
96  digital_in_t t3o;
97  digital_in_t t4o;
98  digital_in_t tint;
99 
100 } c2x2key_t;
101 
105 typedef struct
106 {
107  // Additional gpio pins
108 
109  pin_name_t t1o;
110  pin_name_t t2o;
111  pin_name_t t3o;
112  pin_name_t t4o;
113  pin_name_t tint;
114 
115 } c2x2key_cfg_t;
116  // End types group
118 
119 // ------------------------------------------------------------------ CONSTANTS // End constants group
127 
128 // ------------------------------------------------------------------ VARIABLES // End variable group
136 
137 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
138 
144 #ifdef __cplusplus
145 extern "C"{
146 #endif
147 
157 
166 
175 
187 uint8_t c2x2key_t1_state ( c2x2key_t *ctx );
188 
200 uint8_t c2x2key_t2_state ( c2x2key_t *ctx );
201 
213 uint8_t c2x2key_t3_state ( c2x2key_t *ctx );
214 
226 uint8_t c2x2key_t4_state ( c2x2key_t *ctx );
227 
240 
241 #ifdef __cplusplus
242 }
243 #endif
244 #endif // _C2X2KEY_H_
245  // End public_function group
248 
249 // ------------------------------------------------------------------------- END
c2x2key_taster_pressed
uint8_t c2x2key_taster_pressed(c2x2key_t *ctx)
Taster Pressed function.
c2x2key_cfg_setup
void c2x2key_cfg_setup(c2x2key_cfg_t *cfg)
Config Object Initialization function.
c2x2key_default_cfg
void c2x2key_default_cfg(c2x2key_t *ctx)
Click Default Configuration function.
c2x2key_t3_state
uint8_t c2x2key_t3_state(c2x2key_t *ctx)
Taster 3 state function.
c2x2key_t1_state
uint8_t c2x2key_t1_state(c2x2key_t *ctx)
Taster 1 state function.
c2x2key_t
Click ctx object definition.
Definition: c2x2key.h:91
c2x2key_t::t1o
digital_in_t t1o
Definition: c2x2key.h:94
c2x2key_cfg_t::tint
pin_name_t tint
Definition: c2x2key.h:113
C2X2KEY_RETVAL
#define C2X2KEY_RETVAL
Definition: c2x2key.h:73
c2x2key_cfg_t::t4o
pin_name_t t4o
Definition: c2x2key.h:112
c2x2key_t4_state
uint8_t c2x2key_t4_state(c2x2key_t *ctx)
Taster 4 state function.
c2x2key_t::tint
digital_in_t tint
Definition: c2x2key.h:98
c2x2key_t::t3o
digital_in_t t3o
Definition: c2x2key.h:96
c2x2key_t2_state
uint8_t c2x2key_t2_state(c2x2key_t *ctx)
Taster 2 state function.
c2x2key_t::t2o
digital_in_t t2o
Definition: c2x2key.h:95
c2x2key_init
C2X2KEY_RETVAL c2x2key_init(c2x2key_t *ctx, c2x2key_cfg_t *cfg)
Initialization function.
c2x2key_cfg_t
Click configuration structure definition.
Definition: c2x2key.h:106
c2x2key_t::t4o
digital_in_t t4o
Definition: c2x2key.h:97
c2x2key_cfg_t::t1o
pin_name_t t1o
Definition: c2x2key.h:109
c2x2key_cfg_t::t3o
pin_name_t t3o
Definition: c2x2key.h:111
c2x2key_cfg_t::t2o
pin_name_t t2o
Definition: c2x2key.h:110