summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-04-25 13:16:27 -0700
committerKeith Packard <keithp@keithp.com>2009-04-25 13:16:27 -0700
commit45976af820fc41099928df71ea8304c56eb9fc7c (patch)
tree9c69ee467ebdcd7b120c829244025a4e52b31785
parent4a050704ad2c497e9f1b0988334228b0bbc4c170 (diff)
Make LED usage depend on target device
-rw-r--r--ao.h8
-rw-r--r--ao_led.c25
-rw-r--r--ao_monitor.c6
-rw-r--r--ao_teledongle.c4
-rw-r--r--ao_telemetrum.c4
-rw-r--r--ao_teleterra.c4
-rw-r--r--ao_tidongle.c7
7 files changed, 38 insertions, 20 deletions
diff --git a/ao.h b/ao.h
index 2cad7621..e9761c18 100644
--- a/ao.h
+++ b/ao.h
@@ -241,13 +241,17 @@ ao_led_off(uint8_t colors);
void
ao_led_set(uint8_t colors);
+/* Toggle the specified LEDs */
+void
+ao_led_toggle(uint8_t colors);
+
/* Turn on the specified LEDs for the indicated interval */
void
ao_led_for(uint8_t colors, uint16_t ticks) __reentrant;
/* Initialize the LEDs */
void
-ao_led_init(void);
+ao_led_init(uint8_t enable);
/*
* ao_usb.c
@@ -729,7 +733,7 @@ void
ao_monitor(void);
void
-ao_monitor_init(void);
+ao_monitor_init(uint8_t led);
/*
* ao_stdio.c
diff --git a/ao_led.c b/ao_led.c
index 1268ff69..6c698b4b 100644
--- a/ao_led.c
+++ b/ao_led.c
@@ -17,22 +17,32 @@
#include "ao.h"
+#define AO_LED_ALL (AO_LED_GREEN|AO_LED_RED)
+
+__pdata uint8_t ao_led_enable;
+
void
ao_led_on(uint8_t colors)
{
- P1 |= colors;
+ P1 |= (colors & ao_led_enable);
}
void
ao_led_off(uint8_t colors)
{
- P1 &= ~colors;
+ P1 &= ~(colors & ao_led_enable);
}
void
ao_led_set(uint8_t colors)
{
- P1 = (P1 & ~3) | colors;
+ P1 = (P1 & ~(ao_led_enable)) | (colors & ao_led_enable);
+}
+
+void
+ao_led_toggle(uint8_t colors)
+{
+ P1 ^= (colors & ao_led_enable);
}
void
@@ -44,9 +54,10 @@ ao_led_for(uint8_t colors, uint16_t ticks) __reentrant
}
void
-ao_led_init(void)
+ao_led_init(uint8_t enable)
{
- P1SEL &= ~3;
- P1 &= ~3;
- P1DIR |= 3;
+ ao_led_enable = enable;
+ P1SEL &= ~enable;
+ P1 &= ~enable;
+ P1DIR |= enable;
}
diff --git a/ao_monitor.c b/ao_monitor.c
index 845b63bf..15b56f05 100644
--- a/ao_monitor.c
+++ b/ao_monitor.c
@@ -23,6 +23,7 @@ const char const * const ao_state_names[] = {
};
__xdata uint8_t ao_monitoring;
+__pdata uint8_t ao_monitor_led;
void
ao_monitor(void)
@@ -52,7 +53,7 @@ ao_monitor(void)
recv.telemetry.adc.sense_m);
ao_gps_print(&recv.telemetry.gps);
ao_usb_flush();
- ao_led_for(AO_LED_GREEN, AO_MS_TO_TICKS(10));
+ ao_led_toggle(ao_monitor_led);
}
}
@@ -72,8 +73,9 @@ __code struct ao_cmds ao_monitor_cmds[] = {
};
void
-ao_monitor_init(void)
+ao_monitor_init(uint8_t monitor_led)
{
+ ao_monitor_led = monitor_led;
ao_monitoring = 0;
ao_cmd_register(&ao_monitor_cmds[0]);
ao_add_task(&ao_monitor_task, ao_monitor, "monitor");
diff --git a/ao_teledongle.c b/ao_teledongle.c
index a855d768..7473d810 100644
--- a/ao_teledongle.c
+++ b/ao_teledongle.c
@@ -27,12 +27,12 @@ main(void)
;
/* Turn on the LED until the system is stable */
- ao_led_init();
+ ao_led_init(AO_LED_RED|AO_LED_GREEN);
ao_led_on(AO_LED_RED);
ao_timer_init();
ao_cmd_init();
ao_usb_init();
- ao_monitor_init();
+ ao_monitor_init(AO_LED_GREEN);
ao_radio_init();
ao_dbg_init();
ao_start_scheduler();
diff --git a/ao_telemetrum.c b/ao_telemetrum.c
index 542db799..87469521 100644
--- a/ao_telemetrum.c
+++ b/ao_telemetrum.c
@@ -25,7 +25,7 @@ main(void)
;
/* Turn on the red LED until the system is stable */
- ao_led_init();
+ ao_led_init(AO_LED_RED|AO_LED_GREEN);
ao_led_on(AO_LED_RED);
ao_timer_init();
@@ -41,7 +41,7 @@ main(void)
ao_gps_init();
ao_telemetry_init();
ao_radio_init();
- ao_monitor_init();
+ ao_monitor_init(AO_LED_GREEN);
ao_igniter_init();
ao_dbg_init();
ao_start_scheduler();
diff --git a/ao_teleterra.c b/ao_teleterra.c
index 6a2b0047..41ab7bf0 100644
--- a/ao_teleterra.c
+++ b/ao_teleterra.c
@@ -26,7 +26,7 @@ main(void)
;
/* Turn on the red LED until the system is stable */
- ao_led_init();
+ ao_led_init(AO_LED_RED|AO_LED_GREEN);
ao_led_on(AO_LED_RED);
ao_timer_init();
ao_beep_init();
@@ -34,7 +34,7 @@ main(void)
ao_usb_init();
ao_serial_init();
ao_gps_init();
- ao_monitor_init();
+ ao_monitor_init(AO_LED_GREEN);
ao_radio_init();
ao_dbg_init();
ao_start_scheduler();
diff --git a/ao_tidongle.c b/ao_tidongle.c
index ea21e127..4ef86971 100644
--- a/ao_tidongle.c
+++ b/ao_tidongle.c
@@ -27,16 +27,17 @@ main(void)
;
/* Turn on the LED until the system is stable */
- ao_led_init();
+ ao_led_init(AO_LED_RED);
ao_led_on(AO_LED_RED);
ao_timer_init();
ao_cmd_init();
ao_usb_init();
- ao_monitor_init();
+ ao_monitor_init(AO_LED_RED);
ao_radio_init();
ao_dbg_init();
/* Bring up the USB link */
- ao_led_on(AO_LED_GREEN);
+ P1DIR |= 1;
+ P1 |= 1;
ao_start_scheduler();
}