summaryrefslogtreecommitdiff
path: root/firmware/drivers/led.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/drivers/led.c')
-rw-r--r--firmware/drivers/led.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/firmware/drivers/led.c b/firmware/drivers/led.c
index 1e38fa63d3..118911a746 100644
--- a/firmware/drivers/led.c
+++ b/firmware/drivers/led.c
@@ -23,50 +23,50 @@
23#include "system.h" 23#include "system.h"
24#include "kernel.h" 24#include "kernel.h"
25 25
26static bool disk_led_status;
27static long last_on; /* timestamp of switching off */
28
29
30
31void disk_led_on(void)
32{
33 disk_led_status=true;
34#if CONFIG_LED == LED_REAL 26#if CONFIG_LED == LED_REAL
35#ifdef GMINI_ARCH
36 P2 |= 1;
37#else
38 or_b(0x40, &PBDRL);
39#endif
40#endif
41}
42 27
43void disk_led_off(void) 28void led(bool on)
44{ 29{
45 if(disk_led_status) 30 if ( on )
46 {
47 last_on = current_tick;/* remember for off delay */
48 disk_led_status=false;
49#if CONFIG_LED == LED_REAL
50#ifdef GMINI_ARCH 31#ifdef GMINI_ARCH
32 P2 |= 1;
33 else
51 P2 &= ~1; 34 P2 &= ~1;
52#else 35#else
36 {
37 or_b(0x40, &PBDRL);
38 }
39 else
40 {
53 and_b(~0x40, &PBDRL); 41 and_b(~0x40, &PBDRL);
54#endif
55#endif
56 } 42 }
43#endif
57} 44}
58 45
46#elif (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
47
48static bool current;
49static long last_on; /* timestamp of switching off */
50
59void led(bool on) 51void led(bool on)
60{ 52{
61 if ( on ) 53 if (current && !on) /* switching off */
62 disk_led_on(); 54 {
63 else 55 last_on = current_tick; /* remember for off delay */
64 disk_led_off(); 56 }
57 current = on;
65} 58}
66 59
67bool led_read(int delayticks) 60bool led_read(int delayticks) /* read by status bar update */
68{ 61{
69 /* reading "off" is delayed by user-supplied monoflop value */ 62 /* reading "off" is delayed by user-supplied monoflop value */
70 return (disk_led_status || 63 return (current || TIME_BEFORE(current_tick, last_on+delayticks));
71 TIME_BEFORE(current_tick, last_on+delayticks)); 64}
65
66#else
67
68void led(bool on)
69{
70 (void)on;
72} 71}
72#endif /* CONFIG_LED, HAVE_REMOTE_LCD */