Björn Stenberg | d9eb5c7 | 2002-03-28 15:09:10 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id$ |
| 9 | * |
| 10 | * Copyright (C) 2002 by Alan Korr |
| 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 12 | * 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 Stenberg | d9eb5c7 | 2002-03-28 15:09:10 +0000 | [diff] [blame] | 16 | * |
| 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
| 18 | * KIND, either express or implied. |
| 19 | * |
| 20 | ****************************************************************************/ |
Linus Nielsen Feltzing | ded6894 | 2004-11-02 21:42:39 +0000 | [diff] [blame] | 21 | #include "config.h" |
Björn Stenberg | 2382044 | 2002-05-13 12:29:34 +0000 | [diff] [blame] | 22 | #include <stdbool.h> |
Linus Nielsen Feltzing | ded6894 | 2004-11-02 21:42:39 +0000 | [diff] [blame] | 23 | #include "cpu.h" |
Björn Stenberg | 9b113d5 | 2002-04-26 09:05:36 +0000 | [diff] [blame] | 24 | #include "led.h" |
Jörg Hohensohn | 75bab49 | 2003-11-06 01:34:50 +0000 | [diff] [blame] | 25 | #include "system.h" |
Jörg Hohensohn | c76fbf7 | 2005-02-19 00:34:15 +0000 | [diff] [blame] | 26 | #include "kernel.h" |
| 27 | |
Jonathan Gordon | bd47d48 | 2007-02-18 05:07:19 +0000 | [diff] [blame] | 28 | #if (CONFIG_LED == LED_REAL) |
Linus Nielsen Feltzing | fafd209 | 2004-06-22 10:52:39 +0000 | [diff] [blame] | 29 | |
Björn Stenberg | 9b113d5 | 2002-04-26 09:05:36 +0000 | [diff] [blame] | 30 | void led(bool on) |
Björn Stenberg | 191f4d2 | 2002-04-20 13:25:58 +0000 | [diff] [blame] | 31 | { |
Jens Arnold | 5690f78 | 2005-06-04 23:15:52 +0000 | [diff] [blame] | 32 | if ( on ) |
Jens Arnold | 548755a | 2005-11-24 00:10:14 +0000 | [diff] [blame] | 33 | { |
| 34 | or_b(0x40, &PBDRL); |
| 35 | } |
| 36 | else |
| 37 | { |
| 38 | and_b(~0x40, &PBDRL); |
| 39 | } |
Björn Stenberg | 191f4d2 | 2002-04-20 13:25:58 +0000 | [diff] [blame] | 40 | } |
Linus Nielsen Feltzing | fafd209 | 2004-06-22 10:52:39 +0000 | [diff] [blame] | 41 | |
Jonathan Gordon | bd47d48 | 2007-02-18 05:07:19 +0000 | [diff] [blame] | 42 | #elif (CONFIG_LED == LED_VIRTUAL) || defined(HAVE_REMOTE_LCD) |
Jens Arnold | 548755a | 2005-11-24 00:10:14 +0000 | [diff] [blame] | 43 | |
| 44 | static bool current; |
| 45 | static long last_on; /* timestamp of switching off */ |
| 46 | |
| 47 | void 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 | |
| 56 | bool led_read(int delayticks) /* read by status bar update */ |
Jörg Hohensohn | c76fbf7 | 2005-02-19 00:34:15 +0000 | [diff] [blame] | 57 | { |
Jörg Hohensohn | 2e429ff | 2005-02-19 14:44:31 +0000 | [diff] [blame] | 58 | /* reading "off" is delayed by user-supplied monoflop value */ |
Jens Arnold | 548755a | 2005-11-24 00:10:14 +0000 | [diff] [blame] | 59 | return (current || TIME_BEFORE(current_tick, last_on+delayticks)); |
Jörg Hohensohn | c45d54b | 2004-09-10 12:55:55 +0000 | [diff] [blame] | 60 | } |
Jens Arnold | 548755a | 2005-11-24 00:10:14 +0000 | [diff] [blame] | 61 | |
| 62 | #else |
| 63 | |
| 64 | void led(bool on) |
| 65 | { |
| 66 | (void)on; |
| 67 | } |
| 68 | #endif /* CONFIG_LED, HAVE_REMOTE_LCD */ |