1 | /* |
---|
2 | * leds.c -- control the led's on a Motorola mc68ec0x0 board. |
---|
3 | * Written by rob@cygnus.com (Rob Savoye) |
---|
4 | */ |
---|
5 | #include "leds.h" |
---|
6 | |
---|
7 | void zylons(void); |
---|
8 | void clear_leds(void); |
---|
9 | |
---|
10 | /* |
---|
11 | * led_putnum -- |
---|
12 | * print a hex number on the LED. the value of num must be a char with |
---|
13 | * the ascii value. ie... number 0 is '0', a is 'a', ' ' (null) clears |
---|
14 | * the led display. |
---|
15 | * Setting the bit to 0 turns it on, 1 turns it off. |
---|
16 | * the LED's are controlled by setting the right bit mask in the base |
---|
17 | * address. |
---|
18 | * The bits are: |
---|
19 | * [d.p | g | f | e | d | c | b | a ] is the byte. |
---|
20 | * |
---|
21 | * The locations are: |
---|
22 | * |
---|
23 | * a |
---|
24 | * ----- |
---|
25 | * f | | b |
---|
26 | * | g | |
---|
27 | * ----- |
---|
28 | * | | |
---|
29 | * e | | c |
---|
30 | * ----- |
---|
31 | * d . d.p (decimal point) |
---|
32 | */ |
---|
33 | void |
---|
34 | led_putnum ( char num ) |
---|
35 | { |
---|
36 | static unsigned char *leds = (unsigned char *)LED_ADDR; |
---|
37 | static unsigned char num_bits [18] = { |
---|
38 | 0xff, /* clear all */ |
---|
39 | 0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x98, /* numbers 0-9 */ |
---|
40 | 0x98, 0x20, 0x3, 0x27, 0x21, 0x4, 0xe /* letters a-f */ |
---|
41 | }; |
---|
42 | |
---|
43 | if (num >= '0' && num <= '9') |
---|
44 | num = (num - '0') + 1; |
---|
45 | |
---|
46 | if (num >= 'a' && num <= 'f') |
---|
47 | num = (num - 'a') + 12; |
---|
48 | |
---|
49 | if (num == ' ') |
---|
50 | num = 0; |
---|
51 | |
---|
52 | *leds = num_bits[(int)num]; |
---|
53 | } |
---|
54 | |
---|
55 | /* This procedure added by Doug McBride, Colorado Space Grant College -- |
---|
56 | Probably should be a macro instead */ |
---|
57 | void |
---|
58 | clear_leds ( ) |
---|
59 | { |
---|
60 | static unsigned char *leds = (unsigned char *)LED_ADDR; |
---|
61 | *leds = 0xFF; |
---|
62 | } |
---|
63 | |
---|
64 | void rtems_bsp_delay( int ); |
---|
65 | |
---|
66 | /* |
---|
67 | * zylons -- draw a rotating pattern. NOTE: this function never returns. |
---|
68 | */ |
---|
69 | void |
---|
70 | zylons() |
---|
71 | { |
---|
72 | unsigned char *leds = (unsigned char *)LED_ADDR; |
---|
73 | unsigned char curled = 0xfe; |
---|
74 | |
---|
75 | while (1) |
---|
76 | { |
---|
77 | *leds = curled; |
---|
78 | curled = (curled >> 1) | (curled << 7); |
---|
79 | rtems_bsp_delay ( 8000 ); |
---|
80 | } |
---|
81 | } |
---|