source: rtems/c/src/lib/libbsp/m68k/idp/console/leds.c @ 1f9f30a1

4.104.114.84.95
Last change on this file since 1f9f30a1 was 1f9f30a1, checked in by Ralf Corsepius <ralf.corsepius@…>, on 01/02/05 at 02:59:19

2005-01-02 Ralf Corsepius <ralf_corsepius@…>

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