keylock2 2.0.0.0
keylock2.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 KEYLOCK2_H
36#define KEYLOCK2_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_in.h"
53
54// -------------------------------------------------------------- PUBLIC MACROS
64#define KEYLOCK2_MAP_MIKROBUS( cfg, mikrobus ) \
65 cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
66 cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
67 cfg.in3 = MIKROBUS( mikrobus, MIKROBUS_INT );
74#define KEYLOCK2_RETVAL uint8_t
75
76#define KEYLOCK2_OK 0x00
77#define KEYLOCK2_INIT_ERROR 0xFF
84#define KEYLOCK2_STATE_RST_PIN 0x01
85#define KEYLOCK2_STATE_PWM_PIN 0x02
86#define KEYLOCK2_STATE_INT_PIN 0x03
93#define KEYLOCK2_POSITION_1 0x01
94#define KEYLOCK2_POSITION_2 0x02
95#define KEYLOCK2_POSITION_3 0x03
98 // End group macro
99// --------------------------------------------------------------- PUBLIC TYPES
108typedef struct
109{
110 // Input pins
111
112 digital_in_t in1;
113 digital_in_t in2;
114 digital_in_t in3;
115
116} keylock2_t;
117
121typedef struct
122{
123 // Additional gpio pins
124
125 pin_name_t in1;
126 pin_name_t in2;
127 pin_name_t in3;
128
130
131 // End types group
132// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
133
139#ifdef __cplusplus
140extern "C"{
141#endif
142
152
163
171uint8_t keylock2_get_pin_state ( keylock2_t *ctx, uint8_t pin );
172
182
183#ifdef __cplusplus
184}
185#endif
186#endif // _KEYLOCK2_H_
187
188 // End public_function group
190
191// ------------------------------------------------------------------------- END
#define KEYLOCK2_RETVAL
Definition keylock2.h:74
uint8_t keylock2_get_position(keylock2_t *ctx)
Get Pin State.
KEYLOCK2_RETVAL keylock2_init(keylock2_t *ctx, keylock2_cfg_t *cfg)
Initialization function.
void keylock2_cfg_setup(keylock2_cfg_t *cfg)
Config Object Initialization function.
uint8_t keylock2_get_pin_state(keylock2_t *ctx, uint8_t pin)
Get Pin State.
Click configuration structure definition.
Definition keylock2.h:122
pin_name_t in2
Definition keylock2.h:126
pin_name_t in1
Definition keylock2.h:125
pin_name_t in3
Definition keylock2.h:127
Click ctx object definition.
Definition keylock2.h:109
digital_in_t in2
Definition keylock2.h:113
digital_in_t in3
Definition keylock2.h:114
digital_in_t in1
Definition keylock2.h:112