keylock2  2.0.0.0
keylock2.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 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 );
54 
60 #define KEYLOCK2_RETVAL uint8_t
61 
62 #define KEYLOCK2_OK 0x00
63 #define KEYLOCK2_INIT_ERROR 0xFF
64 
70 #define KEYLOCK2_STATE_RST_PIN 0x01
71 #define KEYLOCK2_STATE_PWM_PIN 0x02
72 #define KEYLOCK2_STATE_INT_PIN 0x03
73 
79 #define KEYLOCK2_POSITION_1 0x01
80 #define KEYLOCK2_POSITION_2 0x02
81 #define KEYLOCK2_POSITION_3 0x03
82  // End group macro
85 // --------------------------------------------------------------- PUBLIC TYPES
94 typedef 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 
107 typedef 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
126 extern "C"{
127 #endif
128 
137 void keylock2_cfg_setup ( keylock2_cfg_t *cfg );
138 
149 
157 uint8_t keylock2_get_pin_state ( uint8_t pin );
158 
167 uint8_t keylock2_get_position ( keylock2_t *ctx );
168 
169 #ifdef __cplusplus
170 }
171 #endif
172 #endif // _KEYLOCK2_H_
173  // End public_function group
176 
177 // ------------------------------------------------------------------------- END
uint8_t keylock2_get_position(keylock2_t *ctx)
Get Pin State.
digital_in_t in3
Definition: keylock2.h:100
void keylock2_cfg_setup(keylock2_cfg_t *cfg)
Config Object Initialization function.
KEYLOCK2_RETVAL keylock2_init(keylock2_t *ctx, keylock2_cfg_t *cfg)
Initialization function.
digital_in_t in1
Definition: keylock2.h:98
pin_name_t in1
Definition: keylock2.h:111
Click ctx object definition.
Definition: keylock2.h:94
uint8_t keylock2_get_pin_state(uint8_t pin)
Get Pin State.
#define KEYLOCK2_RETVAL
Definition: keylock2.h:60
Click configuration structure definition.
Definition: keylock2.h:107
pin_name_t in3
Definition: keylock2.h:113
digital_in_t in2
Definition: keylock2.h:99
pin_name_t in2
Definition: keylock2.h:112