c2x2key  2.0.0.0
c2x2key.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 C2X2KEY_H
36 #define C2X2KEY_H
37 
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 
41 // -------------------------------------------------------------- PUBLIC MACROS
51 #define C2X2KEY_MAP_MIKROBUS( cfg, mikrobus ) \
52  cfg.t1o = MIKROBUS( mikrobus, MIKROBUS_AN ); \
53  cfg.t2o = MIKROBUS( mikrobus, MIKROBUS_RST ); \
54  cfg.t3o = MIKROBUS( mikrobus, MIKROBUS_CS ); \
55  cfg.t4o = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
56  cfg.tint = MIKROBUS( mikrobus, MIKROBUS_INT )
57 
63 #define C2X2KEY_RETVAL uint8_t
64 
65 #define C2X2KEY_OK 0x00
66 #define C2X2KEY_INIT_ERROR 0xFF
67  // End group macro
70 
71 // --------------------------------------------------------------- PUBLIC TYPES
80 typedef struct
81 {
82  // Input pins
83 
84  digital_in_t t1o;
85  digital_in_t t2o;
86  digital_in_t t3o;
87  digital_in_t t4o;
88  digital_in_t tint;
89 
90 } c2x2key_t;
91 
95 typedef struct
96 {
97  // Additional gpio pins
98 
99  pin_name_t t1o;
100  pin_name_t t2o;
101  pin_name_t t3o;
102  pin_name_t t4o;
103  pin_name_t tint;
104 
105 } c2x2key_cfg_t;
106  // End types group
108 
109 // ------------------------------------------------------------------ CONSTANTS // End constants group
117 
118 // ------------------------------------------------------------------ VARIABLES // End variable group
126 
127 // ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
128 
134 #ifdef __cplusplus
135 extern "C"{
136 #endif
137 
146 void c2x2key_cfg_setup ( c2x2key_cfg_t *cfg );
147 
156 
164 void c2x2key_default_cfg ( c2x2key_t *ctx );
165 
177 uint8_t c2x2key_t1_state ( c2x2key_t *ctx );
178 
190 uint8_t c2x2key_t2_state ( c2x2key_t *ctx );
191 
203 uint8_t c2x2key_t3_state ( c2x2key_t *ctx );
204 
216 uint8_t c2x2key_t4_state ( c2x2key_t *ctx );
217 
229 uint8_t c2x2key_taster_pressed ( c2x2key_t *ctx );
230 
231 #ifdef __cplusplus
232 }
233 #endif
234 #endif // _C2X2KEY_H_
235  // End public_function group
238 
239 // ------------------------------------------------------------------------- END
void c2x2key_default_cfg(c2x2key_t *ctx)
Click Default Configuration function.
uint8_t c2x2key_t1_state(c2x2key_t *ctx)
Taster 1 state function.
Click configuration structure definition.
Definition: c2x2key.h:95
#define C2X2KEY_RETVAL
Definition: c2x2key.h:63
pin_name_t t2o
Definition: c2x2key.h:100
void c2x2key_cfg_setup(c2x2key_cfg_t *cfg)
Config Object Initialization function.
pin_name_t t4o
Definition: c2x2key.h:102
uint8_t c2x2key_t2_state(c2x2key_t *ctx)
Taster 2 state function.
uint8_t c2x2key_t3_state(c2x2key_t *ctx)
Taster 3 state function.
digital_in_t t1o
Definition: c2x2key.h:84
digital_in_t t2o
Definition: c2x2key.h:85
digital_in_t t3o
Definition: c2x2key.h:86
pin_name_t t1o
Definition: c2x2key.h:99
C2X2KEY_RETVAL c2x2key_init(c2x2key_t *ctx, c2x2key_cfg_t *cfg)
Initialization function.
uint8_t c2x2key_t4_state(c2x2key_t *ctx)
Taster 4 state function.
digital_in_t tint
Definition: c2x2key.h:88
digital_in_t t4o
Definition: c2x2key.h:87
uint8_t c2x2key_taster_pressed(c2x2key_t *ctx)
Taster Pressed function.
Click ctx object definition.
Definition: c2x2key.h:80
pin_name_t t3o
Definition: c2x2key.h:101
pin_name_t tint
Definition: c2x2key.h:103