summaryrefslogtreecommitdiff
path: root/firmware/src/os/led.c
diff options
context:
space:
mode:
authorlaforge <laforge@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-09-21 12:03:18 +0000
committerlaforge <laforge@6dc7ffe9-61d6-0310-9af1-9938baff3ed1>2006-09-21 12:03:18 +0000
commit817d9211d5f3c608dc231e1d3232d22294f9c782 (patch)
tree8eb6072a701d524bfc268f260c9725b725c9c4f1 /firmware/src/os/led.c
parent59a94d4e6a239be93523e6adf31691d9643f1eab (diff)
some code cleanup
git-svn-id: https://svn.openpcd.org:2342/trunk@214 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'firmware/src/os/led.c')
-rw-r--r--firmware/src/os/led.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/firmware/src/os/led.c b/firmware/src/os/led.c
index 96ffecc..2a57558 100644
--- a/firmware/src/os/led.c
+++ b/firmware/src/os/led.c
@@ -26,6 +26,11 @@
#include <os/req_ctx.h>
#include <os/dbgu.h>
+static const int ledport[] = {
+ [1] = OPENPCD_PIO_LED1,
+ [2] = OPENPCD_PIO_LED2,
+};
+
static int led2port(int led)
{
if (led == 1)
@@ -38,11 +43,12 @@ static int led2port(int led)
void led_switch(int led, int on)
{
- int port = led2port(led);
-
- if (port == -1)
+ int port;
+
+ if (led < 1 || led > 2)
return;
+ port = ledport[led];
if (on)
AT91F_PIO_ClearOutput(AT91C_BASE_PIOA, port);
else
@@ -51,19 +57,21 @@ void led_switch(int led, int on)
int led_get(int led)
{
- int port = led2port(led);
+ int port;
- if (port == -1)
+ if (led < 1 || led > 2)
return -1;
+ port = ledport[led];
+
return !(AT91F_PIO_GetOutputDataStatus(AT91C_BASE_PIOA) & port);
}
int led_toggle(int led)
{
int on = led_get(led);
- if (on == -1)
- return -1;
+ if (on < 0)
+ return on;
if (on)
led_switch(led, 0);
personal git repositories of Harald Welte. Your mileage may vary