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 
42 #ifdef PREINIT_SUPPORTED
43 #include "preinit.h"
44 #endif
45 
46 #ifdef MikroCCoreVersion
47  #if MikroCCoreVersion >= 1
48  #include "delays.h"
49  #endif
50 #endif
51 
52 #include "drv_digital_out.h"
53 #include "drv_digital_in.h"
54 
55 // -------------------------------------------------------------- PUBLIC MACROS
65 #define C2X2KEY_MAP_MIKROBUS( cfg, mikrobus ) \
66  cfg.t1o = MIKROBUS( mikrobus, MIKROBUS_AN ); \
67  cfg.t2o = MIKROBUS( mikrobus, MIKROBUS_RST ); \
68  cfg.t3o = MIKROBUS( mikrobus, MIKROBUS_CS ); \
69  cfg.t4o = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
70  cfg.tint = MIKROBUS( mikrobus, MIKROBUS_INT )
71 
77 #define C2X2KEY_RETVAL uint8_t
78 
79 #define C2X2KEY_OK 0x00
80 #define C2X2KEY_INIT_ERROR 0xFF
81  // End group macro
84 
85 // --------------------------------------------------------------- PUBLIC TYPES
94 typedef struct
95 {
96  // Input pins
97 
98  digital_in_t t1o;
99  digital_in_t t2o;
100  digital_in_t t3o;
101  digital_in_t t4o;
102  digital_in_t tint;
103 
104 } c2x2key_t;
105 
109 typedef struct
110 {
111  // Additional gpio pins
112 
113  pin_name_t t1o;
114  pin_name_t t2o;
115  pin_name_t t3o;
116  pin_name_t t4o;
117  pin_name_t tint;
118 
119 } c2x2key_cfg_t;
120  // End types group
122 
123 // ------------------------------------------------------------------ CONSTANTS // End constants group
131 
132 // ------------------------------------------------------------------ VARIABLES // End variable group
140 
141 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
142 
148 #ifdef __cplusplus
149 extern "C"{
150 #endif
151 
161 
170 
179 
191 uint8_t c2x2key_t1_state ( c2x2key_t *ctx );
192 
204 uint8_t c2x2key_t2_state ( c2x2key_t *ctx );
205 
217 uint8_t c2x2key_t3_state ( c2x2key_t *ctx );
218 
230 uint8_t c2x2key_t4_state ( c2x2key_t *ctx );
231 
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 #endif // _C2X2KEY_H_
249  // End public_function group
252 
253 // ------------------------------------------------------------------------- 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:95
c2x2key_t::t1o
digital_in_t t1o
Definition: c2x2key.h:98
c2x2key_cfg_t::tint
pin_name_t tint
Definition: c2x2key.h:117
C2X2KEY_RETVAL
#define C2X2KEY_RETVAL
Definition: c2x2key.h:77
c2x2key_cfg_t::t4o
pin_name_t t4o
Definition: c2x2key.h:116
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:102
c2x2key_t::t3o
digital_in_t t3o
Definition: c2x2key.h:100
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:99
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:110
c2x2key_t::t4o
digital_in_t t4o
Definition: c2x2key.h:101
c2x2key_cfg_t::t1o
pin_name_t t1o
Definition: c2x2key.h:113
c2x2key_cfg_t::t3o
pin_name_t t3o
Definition: c2x2key.h:115
c2x2key_cfg_t::t2o
pin_name_t t2o
Definition: c2x2key.h:114