OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [m68k/] [idp/] [console/] [leds.c] - Blame information for rev 562

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
2
 * leds.c -- control the led's on a Motorola mc68ec0x0 board.
3
 *           Written by rob@cygnus.com (Rob Savoye)
4
 *
5
 *  $Id: leds.c,v 1.2 2001-09-27 12:00:09 chris Exp $
6
 */
7
#include "leds.h"
8
 
9
void zylons();
10
void led_putnum();
11
void clear_leds();
12
 
13
/*
14
 * led_putnum -- 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
 */
35
void
36
led_putnum ( num )
37
char num;
38
{
39
    static unsigned char *leds = (unsigned char *)LED_ADDR;
40
    static unsigned char num_bits [18] = {
41
      0xff,                                             /* clear all */
42
      0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x98, /* numbers 0-9 */
43
      0x98, 0x20, 0x3, 0x27, 0x21, 0x4, 0xe             /* letters a-f */
44
    };
45
 
46
    if (num >= '0' && num <= '9')
47
      num = (num - '0') + 1;
48
 
49
    if (num >= 'a' && num <= 'f')
50
      num = (num - 'a') + 12;
51
 
52
    if (num == ' ')
53
      num = 0;
54
 
55
    *leds = num_bits[(int)num];
56
}
57
 
58
/* This procedure added by Doug McBride, Colorado Space Grant College --
59
   Probably should be a macro instead */
60
void
61
clear_leds ( )
62
{
63
    static unsigned char *leds = (unsigned char *)LED_ADDR;
64
    *leds = 0xFF;
65
}
66
 
67
/*
68
 * zylons -- draw a rotating pattern. NOTE: this function never returns.
69
 */
70
void
71
zylons()
72
{
73
  unsigned char *leds   = (unsigned char *)LED_ADDR;
74
  unsigned char curled = 0xfe;
75
  void delay( int );
76
 
77
  while (1)
78
    {
79
      *leds = curled;
80
      curled = (curled >> 1) | (curled << 7);
81
      delay ( 8000 );
82
    }
83
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.