source: trunk/libs/newlib/src/libgloss/m68k/leds.c @ 547

Last change on this file since 547 was 444, checked in by satin@…, 7 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

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