forked from cminyard/ser2net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathled.h
73 lines (56 loc) · 2.18 KB
/
led.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* ser2net - A program for allowing telnet connection to serial ports
* Copyright (C) 2001-2016 Corey Minyard <[email protected]>
* Copyright (C) 2016 Michael Heimpold <[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
* (at your option) 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.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LED_H
#define LED_H
struct led_driver_s;
struct led_s
{
struct led_s *next;
char *name;
struct led_driver_s *driver;
void *drv_data;
};
struct led_driver_s {
struct led_driver_s *next;
const char *name;
/* required: parse the parameters from config file */
int (*init)(struct led_s *led, char *config, int lineno);
/* optional, but required when drv_data is malloced in init */
int (*free)(struct led_s *led);
/* optional: called once during initialization, prepares the LED */
int (*configure)(void *drv_data);
/* required: called when data transfer should be signaled */
int (*flash)(void *drv_data);
/* optional: called during deinitialization, could switch the LED off */
int (*deconfigure)(void *drv_data);
};
/* Initializes and registers all LED drivers */
int led_driver_init(void);
/* Callback to register a given LED driver in the system */
int led_driver_register(struct led_driver_s *led_driver);
/* Handle an LED config line */
void handle_led(const char *name, char *cfg, int lineno);
/* Search for a LED by name */
struct led_s *find_led(const char *name);
/* Free all registered LEDs in the system */
void free_leds(void);
/* Flash the given LED */
int led_flash(struct led_s *led);
#endif /* LED_H */