Make LED usage depend on target device
authorKeith Packard <keithp@keithp.com>
Sat, 25 Apr 2009 20:16:27 +0000 (13:16 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 25 Apr 2009 20:16:27 +0000 (13:16 -0700)
ao.h
ao_led.c
ao_monitor.c
ao_teledongle.c
ao_telemetrum.c
ao_teleterra.c
ao_tidongle.c

diff --git a/ao.h b/ao.h
index 2cad7621c5e5db33d072954149ed05b66b441924..e9761c183029405525e4536e46c1b56240ff6e4c 100644 (file)
--- a/ao.h
+++ b/ao.h
@@ -241,13 +241,17 @@ ao_led_off(uint8_t colors);
 void
 ao_led_set(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
 /* 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
 
 /*
  * ao_usb.c
@@ -729,7 +733,7 @@ void
 ao_monitor(void);
 
 void
 ao_monitor(void);
 
 void
-ao_monitor_init(void);
+ao_monitor_init(uint8_t led);
 
 /*
  * ao_stdio.c
 
 /*
  * ao_stdio.c
index 1268ff6952cef8a4a95084214165f986917c5f38..6c698b4be42192b6532f9278d617c4230743d64f 100644 (file)
--- a/ao_led.c
+++ b/ao_led.c
 
 #include "ao.h"
 
 
 #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)
 {
 void
 ao_led_on(uint8_t colors)
 {
-       P1 |= colors;
+       P1 |= (colors & ao_led_enable);
 }
 
 void
 ao_led_off(uint8_t colors)
 {
 }
 
 void
 ao_led_off(uint8_t colors)
 {
-       P1 &= ~colors;
+       P1 &= ~(colors & ao_led_enable);
 }
 
 void
 ao_led_set(uint8_t colors)
 {
 }
 
 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
 }
 
 void
@@ -44,9 +54,10 @@ ao_led_for(uint8_t colors, uint16_t ticks) __reentrant
 }
 
 void
 }
 
 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;
 }
 }
index 845b63bf624840e0ea4914fc7f98d0fec0fe87d9..15b56f058b6ab821c5083aae01ade569a53915ab 100644 (file)
@@ -23,6 +23,7 @@ const char const * const ao_state_names[] = {
 };
 
 __xdata uint8_t ao_monitoring;
 };
 
 __xdata uint8_t ao_monitoring;
+__pdata uint8_t ao_monitor_led;
 
 void
 ao_monitor(void)
 
 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();
                       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
 };
 
 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");
        ao_monitoring = 0;
        ao_cmd_register(&ao_monitor_cmds[0]);
        ao_add_task(&ao_monitor_task, ao_monitor, "monitor");
index a855d768202bc7966a6e80d84306a269807be410..7473d81074b8fac19bdeb329db9812d9b53a502d 100644 (file)
@@ -27,12 +27,12 @@ main(void)
                ;
        
        /* Turn on the LED until the system is stable */
                ;
        
        /* 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_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();
        ao_radio_init();
        ao_dbg_init();
        ao_start_scheduler();
index 542db79940ae6ae406b0e1db969145eaca3f6db5..8746952183ec877ddbc7cfa797f54a6a9b63753a 100644 (file)
@@ -25,7 +25,7 @@ main(void)
                ;
 
        /* Turn on the red LED until the system is stable */
                ;
 
        /* 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_led_on(AO_LED_RED);
 
        ao_timer_init();
@@ -41,7 +41,7 @@ main(void)
        ao_gps_init();
        ao_telemetry_init();
        ao_radio_init();
        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();
        ao_igniter_init();
        ao_dbg_init();
        ao_start_scheduler();
index 6a2b0047d12d6e6b7a08172126fcb5d0152b80ac..41ab7bf0459e06caf3b9de26acbe83f8e919e434 100644 (file)
@@ -26,7 +26,7 @@ main(void)
                ;
 
        /* Turn on the red LED until the system is stable */
                ;
 
        /* 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();
        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_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();
        ao_radio_init();
        ao_dbg_init();
        ao_start_scheduler();
index ea21e12779c22c6419c81e813e7e0d0f8d814709..4ef86971e2dd8f721de2330b419ee8414142dca7 100644 (file)
@@ -27,16 +27,17 @@ main(void)
                ;
        
        /* Turn on the LED until the system is stable */
                ;
        
        /* 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_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_radio_init();
        ao_dbg_init();
        /* Bring up the USB link */
-       ao_led_on(AO_LED_GREEN);
+       P1DIR |= 1;
+       P1 |= 1;
        ao_start_scheduler();
 }
 
        ao_start_scheduler();
 }