Added Software projects
git-svn-id: file:///srv/dev-disk-by-uuid-17e88007-4d0c-45e0-8757-cacfcc458630/repositories/svn/Diplomarbeit@55 9fe90eed-be63-e94b-8204-d34ff4c2ff93
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
/* ---------------------------------------------------------------------------
|
||||
* dio.c - v0.1 (c) 2007 Micro-key bv
|
||||
* ---------------------------------------------------------------------------
|
||||
* Micro-key bv
|
||||
* Industrieweg 28, 9804 TG Noordhorn
|
||||
* Postbus 92, 9800 AB Zuidhorn
|
||||
* The Netherlands
|
||||
* Tel: +31 594 503020
|
||||
* Fax: +31 594 505825
|
||||
* Email: support@microkey.nl
|
||||
* Web: www.microkey.nl
|
||||
* ---------------------------------------------------------------------------
|
||||
* Description: Digital inputs/outputs interface.
|
||||
* ---------------------------------------------------------------------------
|
||||
* Version(s): 0.1, 28-11-2007, fvds.
|
||||
* Creation.
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* System include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Application include files
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#include "LPC23xx.h"
|
||||
#include "types.h"
|
||||
#include "leds.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local constant and macro definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
#define LED0_MASK 0x00000010
|
||||
#define LED1_MASK 0x00000020
|
||||
#define LEDS_MASK (LED0_MASK | LED1_MASK)
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Global variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local variable definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* Local function definitions
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
void ledInit()
|
||||
{
|
||||
SCS |= (1UL<<0);
|
||||
// set GPIOM in SCS for fast IO
|
||||
|
||||
// Set pin 4 & 5 of port 4 as output
|
||||
FIO0DIR |= LEDS_MASK;
|
||||
|
||||
// Turn LED's off
|
||||
FIO0CLR = LEDS_MASK;
|
||||
}
|
||||
|
||||
void ledSet(t_led_ids ledId, BOOLEAN on)
|
||||
{
|
||||
UINT32 ledMask;
|
||||
|
||||
ledMask = (ledId == LED0 ? LED0_MASK : LED1_MASK);
|
||||
|
||||
if (on == TRUE)
|
||||
{
|
||||
FIO0SET = ledMask;
|
||||
}
|
||||
else
|
||||
{
|
||||
FIO0CLR = ledMask;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BOOLEAN ledGet( t_led_ids ledId )
|
||||
{
|
||||
UINT32 ledMask;
|
||||
|
||||
ledMask = (ledId == LED0 ? LED0_MASK : LED1_MASK);
|
||||
|
||||
|
||||
if (FIO0PIN & ledMask)
|
||||
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void ledToggle(t_led_ids ledId)
|
||||
{
|
||||
UINT32 ledMask;
|
||||
|
||||
ledMask = (ledId == LED0 ? LED0_MASK : LED1_MASK);
|
||||
if (FIO0PIN & ledMask)
|
||||
{
|
||||
FIO0CLR = ledMask;
|
||||
// Turn off led
|
||||
}
|
||||
else
|
||||
{
|
||||
FIO0SET = ledMask;
|
||||
// Turn on led
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user