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 )
77#define C2X2KEY_RETVAL uint8_t
78
79#define C2X2KEY_OK 0x00
80#define C2X2KEY_INIT_ERROR 0xFF
83 // End group macro
84
85// --------------------------------------------------------------- PUBLIC TYPES
94typedef 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
109typedef 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
120
121 // End types group
122
123// ------------------------------------------------------------------ CONSTANTS
130 // End constants group
131
132// ------------------------------------------------------------------ VARIABLES
139 // End variable group
140
141// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
142
148#ifdef __cplusplus
149extern "C"{
150#endif
151
161
170
179
192
205
218
231
244
245#ifdef __cplusplus
246}
247#endif
248#endif // _C2X2KEY_H_
249
250 // End public_function group
252
253// ------------------------------------------------------------------------- END
#define C2X2KEY_RETVAL
Definition c2x2key.h:77
void c2x2key_default_cfg(c2x2key_t *ctx)
Click Default Configuration function.
uint8_t c2x2key_t1_state(c2x2key_t *ctx)
Taster 1 state function.
C2X2KEY_RETVAL c2x2key_init(c2x2key_t *ctx, c2x2key_cfg_t *cfg)
Initialization function.
uint8_t c2x2key_taster_pressed(c2x2key_t *ctx)
Taster Pressed function.
uint8_t c2x2key_t2_state(c2x2key_t *ctx)
Taster 2 state function.
void c2x2key_cfg_setup(c2x2key_cfg_t *cfg)
Config Object Initialization function.
uint8_t c2x2key_t4_state(c2x2key_t *ctx)
Taster 4 state function.
uint8_t c2x2key_t3_state(c2x2key_t *ctx)
Taster 3 state function.
Click configuration structure definition.
Definition c2x2key.h:110
pin_name_t t2o
Definition c2x2key.h:114
pin_name_t tint
Definition c2x2key.h:117
pin_name_t t3o
Definition c2x2key.h:115
pin_name_t t4o
Definition c2x2key.h:116
pin_name_t t1o
Definition c2x2key.h:113
Click ctx object definition.
Definition c2x2key.h:95
digital_in_t t4o
Definition c2x2key.h:101
digital_in_t t2o
Definition c2x2key.h:99
digital_in_t t3o
Definition c2x2key.h:100
digital_in_t t1o
Definition c2x2key.h:98
digital_in_t tint
Definition c2x2key.h:102