blob: 22583364d55aa93d0b39b5094dcdf3c8ade74bff [file] [log] [blame]
Björn Stenbergd9eb5c72002-03-28 15:09:10 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2002 by Alan Korr
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Björn Stenbergd9eb5c72002-03-28 15:09:10 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
Linus Nielsen Feltzingded68942004-11-02 21:42:39 +000021#include "config.h"
Björn Stenberg23820442002-05-13 12:29:34 +000022#include <stdbool.h>
Linus Nielsen Feltzingded68942004-11-02 21:42:39 +000023#include "cpu.h"
Björn Stenberg9b113d52002-04-26 09:05:36 +000024#include "led.h"
Jörg Hohensohn75bab492003-11-06 01:34:50 +000025#include "system.h"
Jörg Hohensohnc76fbf72005-02-19 00:34:15 +000026#include "kernel.h"
27
Jonathan Gordonbd47d482007-02-18 05:07:19 +000028#if (CONFIG_LED == LED_REAL)
Linus Nielsen Feltzingfafd2092004-06-22 10:52:39 +000029
Björn Stenberg9b113d52002-04-26 09:05:36 +000030void led(bool on)
Björn Stenberg191f4d22002-04-20 13:25:58 +000031{
Jens Arnold5690f782005-06-04 23:15:52 +000032 if ( on )
Jens Arnold548755a2005-11-24 00:10:14 +000033 {
34 or_b(0x40, &PBDRL);
35 }
36 else
37 {
38 and_b(~0x40, &PBDRL);
39 }
Björn Stenberg191f4d22002-04-20 13:25:58 +000040}
Linus Nielsen Feltzingfafd2092004-06-22 10:52:39 +000041
Jonathan Gordonbd47d482007-02-18 05:07:19 +000042#elif (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD)
Jens Arnold548755a2005-11-24 00:10:14 +000043
44static bool current;
45static long last_on; /* timestamp of switching off */
46
47void led(bool on)
48{
49 if (current && !on) /* switching off */
50 {
51 last_on = current_tick; /* remember for off delay */
52 }
53 current = on;
54}
55
56bool led_read(int delayticks) /* read by status bar update */
Jörg Hohensohnc76fbf72005-02-19 00:34:15 +000057{
Jörg Hohensohn2e429ff2005-02-19 14:44:31 +000058 /* reading "off" is delayed by user-supplied monoflop value */
Jens Arnold548755a2005-11-24 00:10:14 +000059 return (current || TIME_BEFORE(current_tick, last_on+delayticks));
Jörg Hohensohnc45d54b2004-09-10 12:55:55 +000060}
Jens Arnold548755a2005-11-24 00:10:14 +000061
62#else
63
64void led(bool on)
65{
66 (void)on;
67}
68#endif /* CONFIG_LED, HAVE_REMOTE_LCD */