adafruit-beaglebone-io-python/source/event_gpio.h
zserg 3265d156e4 * Minor style fixes
* Added comments
* Added debug logging
* Line 724 - now <initial> flag is properly reset upon removal of event detection from GPIO pin
2018-05-31 18:10:26 +01:00

83 lines
2.7 KiB
C

/*
Copyright (c) 2013 Adafruit
Original RPi.GPIO Author Ben Croston
Modified for BBIO Author Justin Cooper
This file incorporates work covered by the following copyright and
permission notice, all modified code adopts the original license:
Copyright (c) 2013 Ben Croston
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef EVENT_GPIO_H
#define EVENT_GPIO_H
#include "adafruit/bbio/error.h"
#define NO_EDGE 0
#define RISING_EDGE 1
#define FALLING_EDGE 2
#define BOTH_EDGE 3
#define INPUT 0
#define OUTPUT 1
#define ALT0 4
#define HIGH 1
#define LOW 0
#define MAX_FILENAME 60
#define USR_LED_GPIO_MIN 53
#define USR_LED_GPIO_MAX 56
#define USR_LED_RED 66
#define USR_LED_GREEN 67
#define BAT25 27
#define BAT50 11
#define BAT75 61
#define BAT100 10000 // Placeholder until I find the real number
#define WIFI 10001 // Ditto
#define PUD_OFF 0
#define PUD_DOWN 1
#define PUD_UP 2
BBIO_err gpio_export(unsigned int gpio);
BBIO_err gpio_unexport(unsigned int gpio);
void exports_cleanup(void);
BBIO_err gpio_set_direction(unsigned int gpio, unsigned int in_flag);
BBIO_err gpio_get_direction(unsigned int gpio, unsigned int *value);
BBIO_err gpio_set_value(unsigned int gpio, unsigned int value);
BBIO_err gpio_get_value(unsigned int gpio, unsigned int *value);
int add_edge_detect(unsigned int gpio, unsigned int edge);
void remove_edge_detect(unsigned int gpio);
int add_edge_callback(unsigned int gpio, void (*func)(unsigned int gpio));
int event_detected(unsigned int gpio);
int gpio_initial(unsigned int gpio);
int gpio_event_add(unsigned int gpio);
int gpio_event_remove(unsigned int gpio);
int gpio_is_evented(unsigned int gpio);
int event_initialise(void);
void event_cleanup(void);
int blocking_wait_for_edge(unsigned int gpio, unsigned int edge, int timeout);
#endif