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
38#include "drv_digital_in.h"
39
40// -------------------------------------------------------------- PUBLIC MACROS
50#define KEYLOCK2_MAP_MIKROBUS( cfg, mikrobus ) \
51 cfg.in1 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
52 cfg.in2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
53 cfg.in3 = MIKROBUS( mikrobus, MIKROBUS_INT );
60#define KEYLOCK2_RETVAL uint8_t
61
62#define KEYLOCK2_OK 0x00
63#define KEYLOCK2_INIT_ERROR 0xFF
70#define KEYLOCK2_STATE_RST_PIN 0x01
71#define KEYLOCK2_STATE_PWM_PIN 0x02
72#define KEYLOCK2_STATE_INT_PIN 0x03
79#define KEYLOCK2_POSITION_1 0x01
80#define KEYLOCK2_POSITION_2 0x02
81#define KEYLOCK2_POSITION_3 0x03 // End group macro
85// --------------------------------------------------------------- PUBLIC TYPES
94typedef struct
95{
96 // Input pins
97
98 digital_in_t in1;
99 digital_in_t in2;
100 digital_in_t in3;
101
102} keylock2_t;
103
107typedef struct
108{
109 // Additional gpio pins
110
111 pin_name_t in1;
112 pin_name_t in2;
113 pin_name_t in3;
114
116 // End types group
118// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
119
125#ifdef __cplusplus
126extern "C"{
127#endif
128
138
149
157uint8_t keylock2_get_pin_state ( uint8_t pin );
158
168
169#ifdef __cplusplus
170}
171#endif
172#endif // _KEYLOCK2_H_
173 // End public_function group
176
177// ------------------------------------------------------------------------- END
#define KEYLOCK2_RETVAL
Definition: keylock2.h:60
uint8_t keylock2_get_position(keylock2_t *ctx)
Get Pin State.
uint8_t keylock2_get_pin_state(uint8_t pin)
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.
Click configuration structure definition.
Definition: keylock2.h:108
pin_name_t in2
Definition: keylock2.h:112
pin_name_t in1
Definition: keylock2.h:111
pin_name_t in3
Definition: keylock2.h:113
Click ctx object definition.
Definition: keylock2.h:95
digital_in_t in2
Definition: keylock2.h:99
digital_in_t in3
Definition: keylock2.h:100
digital_in_t in1
Definition: keylock2.h:98