git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@23 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
100 lines
4 KiB
C
100 lines
4 KiB
C
/****************************************************************************************
|
|
| Description: LED driver source file
|
|
| File Name: led.c
|
|
|
|
|
|----------------------------------------------------------------------------------------
|
|
| C O P Y R I G H T
|
|
|----------------------------------------------------------------------------------------
|
|
| Copyright (c) 2012 by Feaser http://www.feaser.com All rights reserved
|
|
|
|
|
|----------------------------------------------------------------------------------------
|
|
| L I C E N S E
|
|
|----------------------------------------------------------------------------------------
|
|
| This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
|
|
| modify it under the terms of the GNU General Public License as published by the Free
|
|
| Software Foundation, either version 3 of the License, or (at your option) any later
|
|
| version.
|
|
|
|
|
| OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
| without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
| PURPOSE. See the GNU General Public License for more details.
|
|
|
|
|
| You should have received a copy of the GNU General Public License along with OpenBLT.
|
|
| If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
| A special exception to the GPL is included to allow you to distribute a combined work
|
|
| that includes OpenBLT without being obliged to provide the source code for any
|
|
| proprietary components. The exception text is included at the bottom of the license
|
|
| file <license.html>.
|
|
|
|
|
****************************************************************************************/
|
|
|
|
/****************************************************************************************
|
|
* Include files
|
|
****************************************************************************************/
|
|
#include "header.h" /* generic header */
|
|
|
|
|
|
/****************************************************************************************
|
|
* Macro definitions
|
|
****************************************************************************************/
|
|
#define LED_TOGGLE_MS (500) /* toggle interval time in millisecodns */
|
|
|
|
|
|
/****************************************************************************************
|
|
** NAME: LedInit
|
|
** PARAMETER: none
|
|
** RETURN VALUE: none
|
|
** DESCRIPTION: Initializes the LED. The board doesn't have a dedicted LED so an
|
|
** inidicator on the LCD is used instead.
|
|
**
|
|
****************************************************************************************/
|
|
void LedInit(void)
|
|
{
|
|
/* initialize the LCD */
|
|
LCD_Init(LCD);
|
|
} /*** end of LedInit ***/
|
|
|
|
|
|
/****************************************************************************************
|
|
** NAME: LedToggle
|
|
** PARAMETER: none
|
|
** RETURN VALUE: none
|
|
** DESCRIPTION: Toggles the LED at a fixed time interval.
|
|
**
|
|
****************************************************************************************/
|
|
void LedToggle(void)
|
|
{
|
|
static unsigned char led_toggle_state = 0;
|
|
static unsigned long timer_counter_last = 0;
|
|
unsigned long timer_counter_now;
|
|
|
|
/* check if toggle interval time passed */
|
|
timer_counter_now = TimerGet();
|
|
if ( (timer_counter_now - timer_counter_last) < LED_TOGGLE_MS)
|
|
{
|
|
/* not yet time to toggle */
|
|
return;
|
|
}
|
|
|
|
/* determine toggle action */
|
|
if (led_toggle_state == 0)
|
|
{
|
|
led_toggle_state = 1;
|
|
/* turn the LED on */
|
|
LCD_Symbol(LCD, LCD_SYMBOL_OLIMEX, 1);
|
|
}
|
|
else
|
|
{
|
|
led_toggle_state = 0;
|
|
/* turn the LED off */
|
|
LCD_Symbol(LCD, LCD_SYMBOL_OLIMEX, 0);
|
|
}
|
|
|
|
/* store toggle time to determine next toggle interval */
|
|
timer_counter_last = timer_counter_now;
|
|
} /*** end of LedToggle ***/
|
|
|
|
|
|
/*********************************** end of led.c **************************************/
|