diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 2 | ||||
-rw-r--r-- | firmware/drivers/led.c | 54 | ||||
-rw-r--r-- | firmware/export/led.h | 4 |
3 files changed, 31 insertions, 29 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index fb8ed7b6d7..e5056c54df 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -65,9 +65,7 @@ drivers/lcd-ipod.c | |||
65 | drivers/lcd-h300.c | 65 | drivers/lcd-h300.c |
66 | #endif | 66 | #endif |
67 | drivers/power.c | 67 | drivers/power.c |
68 | #ifdef CONFIG_LED | ||
69 | drivers/led.c | 68 | drivers/led.c |
70 | #endif | ||
71 | #ifndef SIMULATOR | 69 | #ifndef SIMULATOR |
72 | drivers/adc.c | 70 | drivers/adc.c |
73 | #ifdef HAVE_MMC | 71 | #ifdef HAVE_MMC |
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 | ||
26 | static bool disk_led_status; | ||
27 | static long last_on; /* timestamp of switching off */ | ||
28 | |||
29 | |||
30 | |||
31 | void 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 | ||
28 | void led(bool on) | 43 | void 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 | |||
48 | static bool current; | ||
49 | static long last_on; /* timestamp of switching off */ | ||
50 | |||
51 | void led(bool on) | 59 | void 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 | ||
60 | bool led_read(int delayticks) /* read by status bar update */ | 67 | bool 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 */ | ||
diff --git a/firmware/export/led.h b/firmware/export/led.h index f1b3b95447..1dad329e4b 100644 --- a/firmware/export/led.h +++ b/firmware/export/led.h | |||
@@ -23,8 +23,6 @@ | |||
23 | #include <stdbool.h> | 23 | #include <stdbool.h> |
24 | 24 | ||
25 | extern void led( bool on ); | 25 | extern void led( bool on ); |
26 | #if CONFIG_LED == LED_VIRTUAL | 26 | extern bool led_read(int delayticks); |
27 | extern bool led_read(int delayticks); /* read for status bar */ | ||
28 | #endif | ||
29 | 27 | ||
30 | #endif | 28 | #endif |