blob: c3df762dd3f656b945e5f8046788f1ecd2df2f63 (
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
|
#include <FreeRTOS.h>
#include <task.h>
#include <lpc17xx_gpio.h>
#include <BoardConsole.h>
#define LED1_wire 18
#define LED2_wire 20
#define LED3_wire 21
#define LED4_wire 23
static void setupLEDs() {
GPIO_SetDir(1, (1 << LED1_wire) | (1 << LED2_wire) | (1 << LED3_wire) | (1 << LED4_wire), 1);
}
void litLED(int led, int value) {
if ((led >= 4) || (led < 0))
return;
switch (led) {
case 1: led = 1 << LED1_wire; break;
case 2: led = 1 << LED2_wire; break;
case 3: led = 1 << LED3_wire; break;
case 4: led = 1 << LED4_wire; break;
}
if (value) {
GPIO_SetValue(1, led);
} else {
GPIO_ClearValue(1, led);
}
}
int main() {
setupLEDs();
litLED(1, 1);
litLED(2, 0);
litLED(3, 1);
litLED(4, 0);
BoardConsolePuts("Hello World.");
vTaskStartScheduler();
return 0;
}
|