Parent directory

led.h

1507 bytes
 1/*
 2Copyright 2011 Jun Wako <wakojun@gmail.com>
 3
 4This program is free software: you can redistribute it and/or modify
 5it under the terms of the GNU General Public License as published by
 6the Free Software Foundation, either version 2 of the License, or
 7(at your option) any later version.
 8
 9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program.  If not, see <http://www.gnu.org/licenses/>.
16*/
17
18#pragma once
19
20#include <stdint.h>
21#include <stdbool.h>
22
23/* FIXME: Add doxygen comments here. */
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29typedef union {
30    uint8_t raw;
31    struct {
32        bool    num_lock : 1;
33        bool    caps_lock : 1;
34        bool    scroll_lock : 1;
35        bool    compose : 1;
36        bool    kana : 1;
37        uint8_t reserved : 3;
38    };
39} led_t;
40
41void led_set(uint8_t usb_led);
42
43void led_init_ports(void);
44
45void led_suspend(void);
46
47void led_wakeup(void);
48
49void led_task(void);
50
51/* Callbacks */
52bool led_update_user(led_t led_state);
53bool led_update_kb(led_t led_state);
54void led_update_ports(led_t led_state);
55
56uint32_t last_led_activity_time(void);    // Timestamp of the LED activity
57uint32_t last_led_activity_elapsed(void); // Number of milliseconds since the last LED activity
58
59#ifdef __cplusplus
60}
61#endif