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

Subversion Repositories or1k

[/] [or1k/] [branches/] [newlib/] [newlib/] [libgloss/] [m68k/] [leds.c] - Blame information for rev 1777

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

Line No. Rev Author Line
1 39 lampret
/*
2
 * leds.c -- control the led's on a Motorola mc68ec0x0 board.
3
 *
4
 * Copyright (c) 1995 Cygnus Support
5
 *
6
 * The authors hereby grant permission to use, copy, modify, distribute,
7
 * and license this software and its documentation for any purpose, provided
8
 * that existing copyright notices are retained in all copies and that this
9
 * notice is included verbatim in any distributions. No written agreement,
10
 * license, or royalty fee is required for any of the authorized uses.
11
 * Modifications to this software may be copyrighted by their authors
12
 * and need not follow the licensing terms described here, provided that
13
 * the new terms are clearly indicated on the first page of each file where
14
 * they apply.
15
 */
16
#include "leds.h"
17
 
18
void zylons();
19
void led_putnum();
20
 
21
/*
22
 * led_putnum -- print a hex number on the LED. the value of num must be a char with
23
 *              the ascii value. ie... number 0 is '0', a is 'a', ' ' (null) clears
24
 *              the led display.
25
 *              Setting the bit to 0 turns it on, 1 turns it off.
26
 *              the LED's are controlled by setting the right bit mask in the base
27
 *              address.
28
 *              The bits are:
29
 *                      [d.p | g | f | e | d | c | b | a ] is the byte.
30
 *
31
 *              The locations are:
32
 *
33
 *                       a
34
 *                     -----
35
 *                  f |     | b
36
 *                    |  g  |
37
 *                     -----
38
 *                    |     |
39
 *                  e |     | c
40
 *                     -----
41
 *                       d                . d.p (decimal point)
42
 */
43
void
44
led_putnum ( num )
45
char num;
46
{
47
    static unsigned char *leds = (unsigned char *)LED_ADDR;
48
    static unsigned char num_bits [18] = {
49
      0xff,                                             /* clear all */
50
      0xc0, 0xf9, 0xa4, 0xb0, 0x99, 0x92, 0x82, 0xf8, 0x80, 0x98, /* numbers 0-9 */
51
      0x98, 0x20, 0x3, 0x27, 0x21, 0x4, 0xe             /* letters a-f */
52
    };
53
 
54
    if (num >= '0' && num <= '9')
55
      num = (num - '0') + 1;
56
 
57
    if (num >= 'a' && num <= 'f')
58
      num = (num - 'a') + 12;
59
 
60
    if (num == ' ')
61
      num = 0;
62
 
63
    *leds = num_bits[num];
64
}
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
      delay ( 200 );
80
    }
81
}

powered by: WebSVN 2.1.0

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