source: rtems/c/src/lib/libbsp/m68k/idp/console/leds.c @ 2395a38

4.104.114.84.95
Last change on this file since 2395a38 was 2395a38, checked in by Joel Sherrill <joel.sherrill@…>, on 06/22/07 at 14:07:55

2007-06-22 Joel Sherrill <joel.sherrill@…>

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