button2  2.1.0.0
button2.h
Go to the documentation of this file.
1 /****************************************************************************
2 ** Copyright (C) 2020 MikroElektronika d.o.o.
3 ** Contact: https://www.mikroe.com/contact
4 **
5 ** Permission is hereby granted, free of charge, to any person obtaining a copy
6 ** of this software and associated documentation files (the "Software"), to deal
7 ** in the Software without restriction, including without limitation the rights
8 ** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 ** copies of the Software, and to permit persons to whom the Software is
10 ** furnished to do so, subject to the following conditions:
11 ** The above copyright notice and this permission notice shall be
12 ** included in all copies or substantial portions of the Software.
13 **
14 ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16 ** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 ** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19 ** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20 ** USE OR OTHER DEALINGS IN THE SOFTWARE.
21 ****************************************************************************/
22 
28 #ifndef BUTTON2_H
29 #define BUTTON2_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
39 #ifdef PREINIT_SUPPORTED
40 #include "preinit.h"
41 #endif
42 
43 #ifdef MikroCCoreVersion
44  #if MikroCCoreVersion >= 1
45  #include "delays.h"
46  #endif
47 #endif
48 
49 #include "drv_digital_out.h"
50 #include "drv_digital_in.h"
51 
72 #define BUTTON2_SWITCH_OFF 0
73 #define BUTTON2_SWITCH_ON 1
74 
79 #define BUTTON2_BUTTON_PRESSED 0
80 #define BUTTON2_BUTTON_RELESED 1
81  // button2_set
83 
98 #define BUTTON2_MAP_MIKROBUS( cfg, mikrobus ) \
99  cfg.led = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
100  cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
101  // button2_map // button2
104 
109 typedef struct
110 {
111  digital_out_t led;
113  digital_in_t int_pin;
115 } button2_t;
116 
121 typedef struct
122 {
123  pin_name_t led;
124  pin_name_t int_pin;
126 } button2_cfg_t;
127 
132 typedef enum
133 {
135  BUTTON2_ERROR = -1
136 
138 
155 
169 err_t button2_init ( button2_t *ctx, button2_cfg_t *cfg );
170 
180 
190 
200 
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 #endif // BUTTON2_H
216  // button2
218 
219 // ------------------------------------------------------------------------ END
button2_cfg_t
Button 2 Click configuration object.
Definition: button2.h:122
button2_init
err_t button2_init(button2_t *ctx, button2_cfg_t *cfg)
Button 2 initialization function.
button2_t
Button 2 Click context object.
Definition: button2.h:110
button2_t::led
digital_out_t led
Definition: button2.h:111
button2_toggle_led
void button2_toggle_led(button2_t *ctx)
Button 2 toggle led function.
button2_cfg_t::int_pin
pin_name_t int_pin
Definition: button2.h:124
button2_enable_led
void button2_enable_led(button2_t *ctx)
Button 2 enable led function.
BUTTON2_ERROR
@ BUTTON2_ERROR
Definition: button2.h:135
button2_cfg_setup
void button2_cfg_setup(button2_cfg_t *cfg)
Button 2 configuration object setup function.
button2_return_value_t
button2_return_value_t
Button 2 Click return value data.
Definition: button2.h:133
button2_cfg_t::led
pin_name_t led
Definition: button2.h:123
button2_disable_led
void button2_disable_led(button2_t *ctx)
Button 2 disable led function.
button2_get_int_pin
uint8_t button2_get_int_pin(button2_t *ctx)
Button 2 get int pin function.
button2_t::int_pin
digital_in_t int_pin
Definition: button2.h:113
BUTTON2_OK
@ BUTTON2_OK
Definition: button2.h:134