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