upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
button.h
1 /*
2  * Authors: Brendan Le Foll <brendan.le.foll@intel.com>
3  * Mihai Tudor Panu <mihai.tudor.panu@intel.com>
4  * Sarah Knepper <sarah.knepper@intel.com>
5  * Abhishek Malik <abhishek.malik@intel.com>
6  * Copyright (c) 2014 - 2016 Intel Corporation.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  */
27 
28 #pragma once
29 
30 #include <stdlib.h>
31 #include <unistd.h>
32 #include <string.h>
33 #include <stdio.h>
34 
35 #include "upm.h"
36 #include "mraa/gpio.h"
37 
62 typedef struct _button_context {
63  mraa_gpio_context gpio;
64  bool isr_installed;
66 
72 button_context button_init(int pin);
73 
77 void button_close(button_context dev);
83 upm_result_t button_get_value(button_context dev, bool* val);
92 upm_result_t button_install_isr(button_context dev, mraa_gpio_edge_t edge_level, void (*isr)(void *), void *arg);
97 upm_result_t button_uninstall_isr(button_context);
API for the Button.
Definition: button.h:62
struct _button_context * button_context
API for the Button.