diff options
Diffstat (limited to 'firmware/led.c')
-rw-r--r-- | firmware/led.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/firmware/led.c b/firmware/led.c new file mode 100644 index 0000000000..e8922e7891 --- /dev/null +++ b/firmware/led.c | |||
@@ -0,0 +1,68 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include <led.h> | ||
21 | |||
22 | #define turn_on() \ | ||
23 | set_bit (LEDB,PBDR+1) | ||
24 | |||
25 | #define turn_off() \ | ||
26 | clear_bit (LEDB,PBDR+1) | ||
27 | |||
28 | #define start_timer() \ | ||
29 | set_bit (2,ITUTSTR) | ||
30 | |||
31 | #define stop_timer() \ | ||
32 | clear_bit (2,ITUTSTR) | ||
33 | |||
34 | #define eoi(subinterrupt) \ | ||
35 | clear_bit (subinterrupt,ITUTSR2) | ||
36 | |||
37 | #define set_volume(volume) \ | ||
38 | HI(ITUGRA2) = volume & 0x7FFF | ||
39 | |||
40 | |||
41 | void led_set_volume (unsigned short volume) | ||
42 | { | ||
43 | volume <<= 10; | ||
44 | if (volume == 0) | ||
45 | led_turn_off (); | ||
46 | else if (volume == 0x8000) | ||
47 | led_turn_on (); | ||
48 | else | ||
49 | { | ||
50 | set_volume (volume); | ||
51 | start_timer (); | ||
52 | } | ||
53 | } | ||
54 | |||
55 | #pragma interrupt | ||
56 | void IMIA2 (void) | ||
57 | { | ||
58 | turn_off (); | ||
59 | eoi (0); | ||
60 | } | ||
61 | |||
62 | #pragma interrupt | ||
63 | void OVI2 (void) | ||
64 | { | ||
65 | turn_on (); | ||
66 | eoi (2); | ||
67 | } | ||
68 | |||