-
Notifications
You must be signed in to change notification settings - Fork 24
/
gpiod_callback.h
58 lines (48 loc) · 1.72 KB
/
gpiod_callback.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* ******************************************************************
* ZYNTHIAN PROJECT: libgpiod callbacks
*
* Implements a callback mechanism for libgpiod
*
* Copyright (C) 2015-2024 Fernando Moyano <[email protected]>
*
* ******************************************************************
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* For a full copy of the GNU General Public License see the LICENSE.txt file.
*
* ******************************************************************
*/
#ifndef GPIOD_CALLBACK_H
#define GPIOD_CALLBACK_H
#include <gpiod.h>
#define DEFAULT_GPIO_CHIP_DEVICE "/dev/gpiochip0"
#define NUM_GPIO_PINS 28
#define ZYNCORE_CONSUMER "zyncore"
// Callback data structure
struct gpiod_callback {
int pin;
struct gpiod_line *line;
void (*callback)(void);
};
extern struct gpiod_chip *gpio_chip;
extern int8_t wpi2gpio[32];
extern int8_t gpio2wpi[28];
// -------------------------------------------------------------------
int gpiod_init_callbacks();
int gpiod_line_register_callback(struct gpiod_line *line, void (*callback)(void));
int gpiod_line_unregister_callback(struct gpiod_line *line);
int gpiod_start_callbacks();
int gpiod_stop_callbacks();
int gpiod_restart_callbacks();
// -------------------------------------------------------------------
#endif