blob: 0cfaedbea6484faeafe335b7a0595a1a7a171f5a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
/*----------------------------------------------------------------------------
* Name: LED.c
* Purpose: low level LED functions
* Note(s):
*----------------------------------------------------------------------------
* This file is part of the uVision/ARM development tools.
* This software may only be used under the terms of a valid, current,
* end user licence from KEIL for a compatible version of KEIL software
* development tools. Nothing else gives you the right to use this software.
*
* This software is supplied "AS IS" without warranties of any kind.
*
* Copyright (c) 2009-2011 Keil - An ARM Company. All rights reserved.
*----------------------------------------------------------------------------*/
#include "LPC17xx.h" /* LPC17xx definitions */
#include "LED.h"
const unsigned long led_mask[] = { 1UL<<28, 1UL<<29, 1UL<<31, 1UL<< 2,
1UL<< 3, 1UL<< 4, 1UL<< 5, 1UL<< 6 };
/*----------------------------------------------------------------------------
initialize LED Pins
*----------------------------------------------------------------------------*/
void LED_Init (void) {
LPC_SC->PCONP |= (1 << 15); /* enable power to GPIO & IOCON */
LPC_GPIO1->FIODIR |= 0xB0000000; /* LEDs on PORT1 are output */
LPC_GPIO2->FIODIR |= 0x0000007C; /* LEDs on PORT2 are output */
}
/*----------------------------------------------------------------------------
Function that turns on requested LED
*----------------------------------------------------------------------------*/
void LED_On (unsigned int num) {
if (num < 3) LPC_GPIO1->FIOPIN |= led_mask[num];
else LPC_GPIO2->FIOPIN |= led_mask[num];
}
/*----------------------------------------------------------------------------
Function that turns off requested LED
*----------------------------------------------------------------------------*/
void LED_Off (unsigned int num) {
if (num < 3) LPC_GPIO1->FIOPIN &= ~led_mask[num];
else LPC_GPIO2->FIOPIN &= ~led_mask[num];
}
/*----------------------------------------------------------------------------
Function that outputs value to LEDs
*----------------------------------------------------------------------------*/
void LED_Out(unsigned int value) {
int i;
for (i = 0; i < LED_NUM; i++) {
if (value & (1<<i)) {
LED_On (i);
} else {
LED_Off(i);
}
}
}
|