altos: Add generic LED driver.
authorKeith Packard <keithp@keithp.com>
Tue, 11 Sep 2018 18:57:50 +0000 (11:57 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 13 Oct 2018 15:23:25 +0000 (08:23 -0700)
This driver uses the generic GPIO functions and allows per-LED port
and pin configuration. It supports up to 32 LEDs.

Rename SoC-specific LED drivers.

Remove enabled parameter to ao_led_init

Signed-off-by: Keith Packard <keithp@keithp.com>
89 files changed:
src/attiny/ao_arch.h
src/attiny/ao_led.c [deleted file]
src/attiny/ao_led_tiny.c [new file with mode: 0644]
src/avr-demo/Makefile
src/avr/ao_led.c [deleted file]
src/avr/ao_led_avr.c [new file with mode: 0644]
src/chaoskey-v0.1/Makefile
src/chaoskey-v1.0/Makefile
src/chaoskey-v1.0/ao_chaoskey.c
src/detherm/Makefile
src/drivers/ao_led.c [new file with mode: 0644]
src/easymega-v1.0/Makefile
src/easymega-v1.0/ao_easymega.c
src/fox1ihu/Makefile
src/fox1ihu/ao_fox1ihu.c
src/kernel/ao.h
src/kernel/ao_led.h
src/kernel/ao_task.c
src/kernel/ao_task.h
src/lambdakey-v1.0/Makefile
src/lpc/ao_led_lpc.c
src/megadongle-v0.1/Makefile
src/microkite/Makefile
src/micropeak-v2.0/Makefile
src/micropeak-v2.0/ao_micropeak.c
src/micropeak/Makefile
src/microsplash/Makefile
src/nanopeak-v0.1/Makefile
src/nucleao-32/Makefile
src/pnpservo-v1/Makefile
src/product/ao_micropeak.c
src/stm-demo/Makefile
src/stm-scheme-newlib/Makefile
src/stm-vga/Makefile
src/stm/ao_led.c [deleted file]
src/stm/ao_led_stm.c [new file with mode: 0644]
src/stm32f4-disco/Makefile
src/stm32f4-disco/ao_disco.c
src/stm32f4-disco/ao_pins.h
src/stm32f4/ao_arch.h
src/stm32f4/ao_arch_funcs.h
src/stmf0/ao_led.c [deleted file]
src/stmf0/ao_led_stmf0.c [new file with mode: 0644]
src/teleballoon-v2.0/Makefile
src/teleballoon-v2.0/ao_teleballoon.c
src/telebt-v3.0/Makefile
src/telebt-v3.0/ao_telebt.c
src/telebt-v4.0/Makefile
src/telebt-v4.0/ao_telebt.c
src/teledongle-v1.8/Makefile
src/teledongle-v3.0/ao_teledongle.c
src/telefireeight-v1.0/ao_pins.h
src/telefireeight-v1.0/ao_telefireeight.c
src/telefireone-v1.0/Makefile
src/telefiretwo-v0.1/Makefile
src/telefiretwo-v0.1/ao_telefiretwo.c
src/telefiretwo-v0.2/Makefile
src/telegps-v0.1/Makefile
src/telegps-v2.0/Makefile
src/telegps-v2.0/ao_telegps.c
src/telelco-v0.2-cc1200/Makefile
src/telelco-v0.2-cc1200/ao_telelco.c
src/telelco-v0.2/Makefile
src/telelco-v0.2/ao_telelco.c
src/telelco-v0.3/Makefile
src/telelco-v0.3/ao_telelco.c
src/telelco-v2.0/ao_lco_v2.c
src/telelco-v2.0/ao_pins.h
src/telelco-v2.0/ao_telelco.c
src/telelcotwo-v0.1/Makefile
src/telelcotwo-v0.1/ao_telelcotwo.c
src/telemega-v0.1/Makefile
src/telemega-v0.1/ao_telemega.c
src/telemega-v1.0/Makefile
src/telemega-v1.0/ao_telemega.c
src/telemega-v2.0/Makefile
src/telemega-v2.0/ao_telemega.c
src/telemega-v3.0/Makefile
src/telemega-v3.0/ao_telemega.c
src/telemetrum-v2.0/Makefile
src/telemetrum-v2.0/ao_telemetrum.c
src/telemetrum-v3.0/Makefile
src/telemetrum-v3.0/ao_telemetrum.c
src/telepyro-v0.1/Makefile
src/telescience-pwm/Makefile
src/telescience-v0.1/Makefile
src/telescience-v0.2/Makefile
src/tmgps-v2.0/Makefile
src/usbtrng-v2.0/Makefile

index 84a94be7e452f4fc22d188a864257f7a97f26ee1..a9c450fcce036dac59975bc3edd03d63d3ca6103 100644 (file)
@@ -34,6 +34,8 @@
 
 #define AO_PORT_TYPE   uint8_t
 
+#define AO_LED_TYPE    uint8_t
+
 /* Various definitions to make GCC look more like SDCC */
 
 #define ao_arch_naked_declare  __attribute__((naked))
diff --git a/src/attiny/ao_led.c b/src/attiny/ao_led.c
deleted file mode 100644 (file)
index 8850549..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright Â© 2009 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-#include "ao.h"
-
-uint8_t ao_led_enable;
-
-#define LED_PORT       PORTB
-#define LED_DDR                DDRB
-
-void
-ao_led_on(uint8_t colors)
-{
-       LED_PORT |= (colors & ao_led_enable);
-}
-
-void
-ao_led_off(uint8_t colors)
-{
-       LED_PORT &= ~(colors & ao_led_enable);
-}
-
-void
-ao_led_set(uint8_t colors)
-{
-       LED_PORT = (LED_PORT & ~(ao_led_enable)) | (colors & ao_led_enable);
-}
-
-void
-ao_led_toggle(uint8_t colors)
-{
-       LED_PORT ^= (colors & ao_led_enable);
-}
-
-void
-ao_led_for(uint8_t colors, uint16_t ticks) 
-{
-       ao_led_on(colors);
-       ao_delay(ticks);
-       ao_led_off(colors);
-}
-
-void
-ao_led_init(uint8_t enable)
-{
-       ao_led_enable = enable;
-       LED_PORT &= ~enable;
-       LED_DDR |= enable;
-}
diff --git a/src/attiny/ao_led_tiny.c b/src/attiny/ao_led_tiny.c
new file mode 100644 (file)
index 0000000..cd620f4
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright Â© 2009 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "ao.h"
+
+#define LED_PORT       PORTB
+#define LED_DDR                DDRB
+
+void
+ao_led_on(uint8_t colors)
+{
+       LED_PORT |= colors;
+}
+
+void
+ao_led_off(uint8_t colors)
+{
+       LED_PORT &= ~colors;
+}
+
+void
+ao_led_set(uint8_t colors)
+{
+       LED_PORT = (LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE);
+}
+
+void
+ao_led_toggle(uint8_t colors)
+{
+       LED_PORT ^= (colors & LEDS_AVAILABLE);
+}
+
+void
+ao_led_for(uint8_t colors, AO_TICK_TYPE ticks)
+{
+       ao_led_on(colors);
+       ao_delay(ticks);
+       ao_led_off(colors);
+}
+
+void
+ao_led_init(void)
+{
+       LED_PORT &= ~LEDS_AVAILABLE;
+       LED_DDR |= LEDS_AVAILABLE;
+}
index e21ad0471ea85465d89838c267830ab70fc6d0f8..0aca6f8af6252447d07224cd660646fbfd432650 100644 (file)
@@ -38,7 +38,7 @@ ALTOS_SRC = \
        ao_stdio.c \
        ao_task.c \
        ao_timer.c \
-       ao_led.c \
+       ao_led_avr.c \
        ao_usb_avr.c \
        ao_lcd.c
 
diff --git a/src/avr/ao_led.c b/src/avr/ao_led.c
deleted file mode 100644 (file)
index 165e95d..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright Â© 2009 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-#include "ao.h"
-
-uint8_t ao_led_enable;
-
-#define LED_PORT       PORTB
-#define LED_DDR                DDRB
-
-void
-ao_led_on(uint8_t colors)
-{
-       LED_PORT |= (colors & ao_led_enable);
-}
-
-void
-ao_led_off(uint8_t colors)
-{
-       LED_PORT &= ~(colors & ao_led_enable);
-}
-
-void
-ao_led_set(uint8_t colors)
-{
-       LED_PORT = (LED_PORT & ~(ao_led_enable)) | (colors & ao_led_enable);
-}
-
-void
-ao_led_toggle(uint8_t colors)
-{
-       LED_PORT ^= (colors & ao_led_enable);
-}
-
-void
-ao_led_for(uint8_t colors, uint16_t ticks) 
-{
-       ao_led_on(colors);
-       ao_delay(ticks);
-       ao_led_off(colors);
-}
-
-void
-ao_led_init(uint8_t enable)
-{
-       ao_led_enable = enable;
-       if ((LED_DDR & enable)) {
-               printf ("oops! restarted\n");
-               ao_panic(AO_PANIC_REBOOT);
-       }
-       LED_PORT &= ~enable;
-       LED_DDR |= enable;
-}
diff --git a/src/avr/ao_led_avr.c b/src/avr/ao_led_avr.c
new file mode 100644 (file)
index 0000000..165e95d
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright Â© 2009 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "ao.h"
+
+uint8_t ao_led_enable;
+
+#define LED_PORT       PORTB
+#define LED_DDR                DDRB
+
+void
+ao_led_on(uint8_t colors)
+{
+       LED_PORT |= (colors & ao_led_enable);
+}
+
+void
+ao_led_off(uint8_t colors)
+{
+       LED_PORT &= ~(colors & ao_led_enable);
+}
+
+void
+ao_led_set(uint8_t colors)
+{
+       LED_PORT = (LED_PORT & ~(ao_led_enable)) | (colors & ao_led_enable);
+}
+
+void
+ao_led_toggle(uint8_t colors)
+{
+       LED_PORT ^= (colors & ao_led_enable);
+}
+
+void
+ao_led_for(uint8_t colors, uint16_t ticks) 
+{
+       ao_led_on(colors);
+       ao_delay(ticks);
+       ao_led_off(colors);
+}
+
+void
+ao_led_init(uint8_t enable)
+{
+       ao_led_enable = enable;
+       if ((LED_DDR & enable)) {
+               printf ("oops! restarted\n");
+               ao_panic(AO_PANIC_REBOOT);
+       }
+       LED_PORT &= ~enable;
+       LED_DDR |= enable;
+}
index 853922804b839fa31b967b238057f8cc23c130bc..faa4a291b0d7e6c81df64bfd89f173f6a9ddb49e 100644 (file)
@@ -28,7 +28,7 @@ ALTOS_SRC = \
        ao_adc_fast.c \
        ao_crc_stm.c \
        ao_stdio.c \
-       ao_led.c \
+       ao_led_stmf0.c \
        ao_romconfig.c \
        ao_boot_chain.c \
        ao_usb_stm.c \
index c6cf45bd348e2203dc778cbaec325c5c17879afa..329f603d1107a58cc83b5d8d0767735a25a30c47 100644 (file)
@@ -30,7 +30,7 @@ ALTOS_SRC = \
        ao_adc_fast.c \
        ao_crc_stm.c \
        ao_stdio.c \
-       ao_led.c \
+       ao_led_stmf0.c \
        ao_romconfig.c \
        ao_boot_chain.c \
        ao_usb_stm.c \
index 1165e4540fbe5e445a1e7aa32ef54681d76ae262..80f5a4ba613152fff72d8f3c36891dc5c76b5d75 100644 (file)
@@ -24,7 +24,7 @@
 
 void main(void)
 {
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_clock_init();
        ao_task_init();
        ao_timer_init();
index 6b0e0bf8767b749d0f2f2d15023a5d18e2df278e..7681a0495411a3ca868908de08c9c492177e859d 100644 (file)
@@ -27,7 +27,7 @@ ALTOS_SRC = \
        ao_spi_stm.c \
        ao_exti_stm.c \
        ao_stdio.c \
-       ao_led.c \
+       ao_led_stmf0.c \
        ao_log.c \
        ao_log_mini.c \
        ao_sample.c \
diff --git a/src/drivers/ao_led.c b/src/drivers/ao_led.c
new file mode 100644 (file)
index 0000000..0f7b7c2
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * Copyright Â© 2018 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "ao.h"
+
+static const struct {
+       struct stm_gpio *port;
+       uint16_t        pin;
+} ao_leds[] = {
+#ifdef LED_0_PORT
+    [0] { LED_0_PORT, LED_0_PIN },
+#endif
+#ifdef LED_1_PORT
+    [1] { LED_1_PORT, LED_1_PIN },
+#endif
+#ifdef LED_2_PORT
+    [2] { LED_2_PORT, LED_2_PIN },
+#endif
+#ifdef LED_3_PORT
+    [3] { LED_3_PORT, LED_3_PIN },
+#endif
+#ifdef LED_4_PORT
+    [4] { LED_4_PORT, LED_4_PIN },
+#endif
+#ifdef LED_5_PORT
+    [5] { LED_5_PORT, LED_5_PIN },
+#endif
+#ifdef LED_6_PORT
+    [6] { LED_6_PORT, LED_6_PIN },
+#endif
+#ifdef LED_7_PORT
+    [7] { LED_7_PORT, LED_7_PIN },
+#endif
+#ifdef LED_8_PORT
+    [8] { LED_8_PORT, LED_8_PIN },
+#endif
+#ifdef LED_9_PORT
+    [9] { LED_9_PORT, LED_9_PIN },
+#endif
+#ifdef LED_10_PORT
+    [10] { LED_10_PORT, LED_10_PIN },
+#endif
+#ifdef LED_11_PORT
+    [11] { LED_11_PORT, LED_11_PIN },
+#endif
+#ifdef LED_12_PORT
+    [12] { LED_12_PORT, LED_12_PIN },
+#endif
+#ifdef LED_13_PORT
+    [13] { LED_13_PORT, LED_13_PIN },
+#endif
+#ifdef LED_14_PORT
+    [14] { LED_14_PORT, LED_14_PIN },
+#endif
+#ifdef LED_15_PORT
+    [15] { LED_15_PORT, LED_15_PIN },
+#endif
+#ifdef LED_16_PORT
+    [16] { LED_16_PORT, LED_16_PIN },
+#endif
+#ifdef LED_17_PORT
+    [17] { LED_17_PORT, LED_17_PIN },
+#endif
+#ifdef LED_18_PORT
+    [18] { LED_18_PORT, LED_18_PIN },
+#endif
+#ifdef LED_19_PORT
+    [19] { LED_19_PORT, LED_19_PIN },
+#endif
+#ifdef LED_20_PORT
+    [20] { LED_20_PORT, LED_20_PIN },
+#endif
+#ifdef LED_21_PORT
+    [21] { LED_21_PORT, LED_21_PIN },
+#endif
+#ifdef LED_22_PORT
+    [22] { LED_22_PORT, LED_22_PIN },
+#endif
+#ifdef LED_23_PORT
+    [23] { LED_23_PORT, LED_23_PIN },
+#endif
+#ifdef LED_24_PORT
+    [24] { LED_24_PORT, LED_24_PIN },
+#endif
+#ifdef LED_25_PORT
+    [25] { LED_25_PORT, LED_25_PIN },
+#endif
+#ifdef LED_26_PORT
+    [26] { LED_26_PORT, LED_26_PIN },
+#endif
+#ifdef LED_27_PORT
+    [27] { LED_27_PORT, LED_27_PIN },
+#endif
+#ifdef LED_28_PORT
+    [28] { LED_28_PORT, LED_28_PIN },
+#endif
+#ifdef LED_29_PORT
+    [29] { LED_29_PORT, LED_29_PIN },
+#endif
+#ifdef LED_30_PORT
+    [30] { LED_30_PORT, LED_30_PIN },
+#endif
+#ifdef LED_31_PORT
+    [31] { LED_31_PORT, LED_31_PIN },
+#endif
+};
+#define N_LED  (sizeof (ao_leds)/sizeof(ao_leds[0]))
+
+void
+ao_led_on(AO_LED_TYPE colors)
+{
+       AO_LED_TYPE i;
+       for (i = 0; i < N_LED; i++)
+               if (colors & (1 << i))
+                       ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 1);
+}
+
+void
+ao_led_off(AO_LED_TYPE colors)
+{
+       AO_LED_TYPE i;
+       for (i = 0; i < N_LED; i++)
+               if (colors & (1 << i))
+                       ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 0);
+}
+
+void
+ao_led_set(AO_LED_TYPE colors)
+{
+       AO_LED_TYPE i;
+       for (i = 0; i < N_LED; i++)
+               ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, (colors >> i) & 1);
+}
+
+void
+ao_led_toggle(AO_LED_TYPE colors)
+{
+       AO_LED_TYPE i;
+       for (i = 0; i < N_LED; i++)
+               if (colors & (1 << i))
+                       ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, ~ao_gpio_get(ao_leds[i].port, ao_leds[i].pin));
+}
+
+void
+ao_led_for(AO_LED_TYPE colors, AO_TICK_TYPE ticks) 
+{
+       ao_led_on(colors);
+       ao_delay(ticks);
+       ao_led_off(colors);
+}
+
+void
+ao_led_init(void)
+{
+       AO_LED_TYPE     bit;
+
+       for (bit = 0; bit < N_LED; bit++)
+               ao_enable_output(ao_leds[bit].port, ao_leds[bit].pin, 0);
+}
index 3344da06f60673dec80f452ec6977668e8a908fb..76e7319e43b85c419d65527cb9824d592f73ae43 100644 (file)
@@ -53,7 +53,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 9848c36779c4dfd352f71e3c0f7ef17a7b3d6b0f..d00585f9b234998da202006a5ed5b9f91e4a209c 100644 (file)
@@ -43,7 +43,7 @@ main(void)
 #endif
 
        ao_task_init();
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
index e3226a24fade2100cbdeaf297807ece4d0269a53..61314db93cb7f2687e83469f4854f5b36544508a 100644 (file)
@@ -37,7 +37,7 @@ ALTOS_SRC = \
        ao_romconfig.c \
        ao_cmd.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 2e1a2fdfe6a81d092fb5751c37f8caad380de5e5..5ebb4b549bae1b5e729b1d2a14f05a64ab39bde9 100644 (file)
@@ -31,7 +31,7 @@ main(void)
 #endif
 
        ao_task_init();
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_led_on(AO_LED_RED|AO_LED_GREEN|AO_LED_RED_2|AO_LED_GREEN_2);
        ao_timer_init();
 
index 9c0c86044558ba0d417d3d144eaa81a98b0c95f7..1b269d73e09b8871d9e5834e3c18327351511d3c 100644 (file)
@@ -230,7 +230,7 @@ ao_cmd_filter(void);
 #include <ao_beep.h>
 #endif
 
-#if LEDS_AVAILABLE
+#if LEDS_AVAILABLE || HAS_LED
 #include <ao_led.h>
 #endif
 
index 803f85b3d9b652ab5a88f4b3cf298990b7fe5ee6..5d982ca6d1f0e7101467d072ce215678e8ae8793 100644 (file)
@@ -26,7 +26,7 @@
 #define AO_LED_NONE    0
 
 #ifndef AO_LED_TYPE
-#define AO_LED_TYPE uint8_t
+#define AO_LED_TYPE uint32_t
 #endif
 
 /* Turn on the specified LEDs */
@@ -55,6 +55,204 @@ ao_led_for(AO_LED_TYPE colors, uint16_t ticks);
 
 /* Initialize the LEDs */
 void
-ao_led_init(AO_LED_TYPE enable);
+ao_led_init(void);
+
+#ifdef LED_0_PORT
+#define AO_LED_0 (1 << 0)
+#else
+#define AO_LED_0 0
+#endif
+#ifdef LED_1_PORT
+#define AO_LED_1 (1 << 1)
+#else
+#define AO_LED_1 0
+#endif
+#ifdef LED_2_PORT
+#define AO_LED_2 (1 << 2)
+#else
+#define AO_LED_2 0
+#endif
+#ifdef LED_3_PORT
+#define AO_LED_3 (1 << 3)
+#else
+#define AO_LED_3 0
+#endif
+#ifdef LED_4_PORT
+#define AO_LED_4 (1 << 4)
+#else
+#define AO_LED_4 0
+#endif
+#ifdef LED_5_PORT
+#define AO_LED_5 (1 << 5)
+#else
+#define AO_LED_5 0
+#endif
+#ifdef LED_6_PORT
+#define AO_LED_6 (1 << 6)
+#else
+#define AO_LED_6 0
+#endif
+#ifdef LED_7_PORT
+#define AO_LED_7 (1 << 7)
+#else
+#define AO_LED_7 0
+#endif
+#ifdef LED_8_PORT
+#define AO_LED_8 (1 << 8)
+#else
+#define AO_LED_8 0
+#endif
+#ifdef LED_9_PORT
+#define AO_LED_9 (1 << 9)
+#else
+#define AO_LED_9 0
+#endif
+#ifdef LED_10_PORT
+#define AO_LED_10 (1 << 10)
+#else
+#define AO_LED_10 0
+#endif
+#ifdef LED_11_PORT
+#define AO_LED_11 (1 << 11)
+#else
+#define AO_LED_11 0
+#endif
+#ifdef LED_12_PORT
+#define AO_LED_12 (1 << 12)
+#else
+#define AO_LED_12 0
+#endif
+#ifdef LED_13_PORT
+#define AO_LED_13 (1 << 13)
+#else
+#define AO_LED_13 0
+#endif
+#ifdef LED_14_PORT
+#define AO_LED_14 (1 << 14)
+#else
+#define AO_LED_14 0
+#endif
+#ifdef LED_15_PORT
+#define AO_LED_15 (1 << 15)
+#else
+#define AO_LED_15 0
+#endif
+#ifdef LED_16_PORT
+#define AO_LED_16 (1 << 16)
+#else
+#define AO_LED_16 0
+#endif
+#ifdef LED_17_PORT
+#define AO_LED_17 (1 << 17)
+#else
+#define AO_LED_17 0
+#endif
+#ifdef LED_18_PORT
+#define AO_LED_18 (1 << 18)
+#else
+#define AO_LED_18 0
+#endif
+#ifdef LED_19_PORT
+#define AO_LED_19 (1 << 19)
+#else
+#define AO_LED_19 0
+#endif
+#ifdef LED_20_PORT
+#define AO_LED_20 (1 << 20)
+#else
+#define AO_LED_20 0
+#endif
+#ifdef LED_21_PORT
+#define AO_LED_21 (1 << 21)
+#else
+#define AO_LED_21 0
+#endif
+#ifdef LED_22_PORT
+#define AO_LED_22 (1 << 22)
+#else
+#define AO_LED_22 0
+#endif
+#ifdef LED_23_PORT
+#define AO_LED_23 (1 << 23)
+#else
+#define AO_LED_23 0
+#endif
+#ifdef LED_24_PORT
+#define AO_LED_24 (1 << 24)
+#else
+#define AO_LED_24 0
+#endif
+#ifdef LED_25_PORT
+#define AO_LED_25 (1 << 25)
+#else
+#define AO_LED_25 0
+#endif
+#ifdef LED_26_PORT
+#define AO_LED_26 (1 << 26)
+#else
+#define AO_LED_26 0
+#endif
+#ifdef LED_27_PORT
+#define AO_LED_27 (1 << 27)
+#else
+#define AO_LED_27 0
+#endif
+#ifdef LED_28_PORT
+#define AO_LED_28 (1 << 28)
+#else
+#define AO_LED_28 0
+#endif
+#ifdef LED_29_PORT
+#define AO_LED_29 (1 << 29)
+#else
+#define AO_LED_29 0
+#endif
+#ifdef LED_30_PORT
+#define AO_LED_30 (1 << 30)
+#else
+#define AO_LED_30 0
+#endif
+#ifdef LED_31_PORT
+#define AO_LED_31 (1 << 31)
+#else
+#define AO_LED_31 0
+#endif
+
+#define AO_LEDS_AVAILABLE (AO_LED_0 |          \
+                          AO_LED_1 |           \
+                          AO_LED_2 |           \
+                          AO_LED_3 |           \
+                          AO_LED_4 |           \
+                          AO_LED_5 |           \
+                          AO_LED_6 |           \
+                          AO_LED_7 |           \
+                          AO_LED_8 |           \
+                          AO_LED_9 |           \
+                          AO_LED_10 |          \
+                          AO_LED_11 |          \
+                          AO_LED_12 |          \
+                          AO_LED_13 |          \
+                          AO_LED_14 |          \
+                          AO_LED_15 |          \
+                          AO_LED_16 |          \
+                          AO_LED_17 |          \
+                          AO_LED_18 |          \
+                          AO_LED_19 |          \
+                          AO_LED_20 |          \
+                          AO_LED_21 |          \
+                          AO_LED_22 |          \
+                          AO_LED_23 |          \
+                          AO_LED_24 |          \
+                          AO_LED_25 |          \
+                          AO_LED_26 |          \
+                          AO_LED_27 |          \
+                          AO_LED_28 |          \
+                          AO_LED_29 |          \
+                          AO_LED_30 |          \
+                          AO_LED_31)
+
+#ifndef LEDS_AVAILABLE
+#define LEDS_AVAILABLE AO_LEDS_AVAILABLE
+#endif
 
 #endif /* _AO_LED_H_ */
index 4f7072cb84bfbb26ce5d4ca2b193acaf960867e7..dc5c19132caeb121a21b5bbe0698da713a68c9d8 100644 (file)
@@ -569,4 +569,5 @@ ao_start_scheduler(void)
        ao_arch_start_scheduler();
 #endif
        ao_yield();
+       __builtin_unreachable();
 }
index ffeb7313ba423af2c55cd052c6728ef4d48eb896..f3789fa2cd2725a6fd3207561e124263815ed530 100644 (file)
@@ -134,7 +134,7 @@ ao_task_info(void);
 
 /* Start the scheduler. This will not return */
 void
-ao_start_scheduler(void);
+ao_start_scheduler(void) __attribute__((noreturn));
 
 #if HAS_TASK_QUEUE
 void
index b94c3873a210bc9f4a31e8f3b1243f0d075c743f..f8b5c7f5d43d9e4e41861da10df0d3a680c88c59 100644 (file)
@@ -27,7 +27,7 @@ ALTOS_SRC = \
        ao_interrupt.c \
        ao_product.c \
        ao_cmd.c \
-       ao_led.c \
+       ao_led_stmf0.c \
        ao_notask.c \
        ao_stdio.c \
        ao_panic.c \
index 5fc726c079c50939e4848615165975a8b8777307..3a2d4c9886986b72889c50a07c0d13a0ba937cde 100644 (file)
@@ -35,8 +35,8 @@ ao_led_off(AO_PORT_TYPE colors)
 void
 ao_led_set(AO_PORT_TYPE colors)
 {
-       AO_PORT_TYPE    on = colors & ao_led_enable;
-       AO_PORT_TYPE    off = ~colors & ao_led_enable;
+       AO_PORT_TYPE    on = colors & LEDS_AVAILABLE;
+       AO_PORT_TYPE    off = ~colors & LEDS_AVAILABLE;
 
        ao_led_off(off);
        ao_led_on(on);
@@ -57,18 +57,17 @@ ao_led_for(AO_PORT_TYPE colors, uint16_t ticks)
 }
 
 void
-ao_led_init(AO_PORT_TYPE enable)
+ao_led_init(void)
 {
-       ao_led_enable = enable;
        ao_enable_port(LED_PORT);
        if (LED_PORT == 0) {
-               if (enable & (1 << 11))
+               if (LEDS_AVAILABLE & (1 << 11))
                        lpc_ioconf.pio0_11 = LPC_IOCONF_FUNC_PIO0_11 | (1 << LPC_IOCONF_ADMODE);
-               if (enable & (1 << 12))
+               if (LEDS_AVAILABLE & (1 << 12))
                        lpc_ioconf.pio0_12 = LPC_IOCONF_FUNC_PIO0_12 | (1 << LPC_IOCONF_ADMODE);
-               if (enable & (1 << 14))
+               if (LEDS_AVAILABLE & (1 << 14))
                        lpc_ioconf.pio0_14 = LPC_IOCONF_FUNC_PIO0_14 | (1 << LPC_IOCONF_ADMODE);
        }
-       lpc_gpio.dir[LED_PORT] |= enable;
-       ao_led_off(enable);
+       lpc_gpio.dir[LED_PORT] |= LEDS_AVAILABLE;
+       ao_led_off(LEDS_AVAILABLE);
 }
index bbe2ea587e254bad422db666ddd49ef284601a04..4290e088f14c7928d4891ff00d173cb89a8faa9d 100644 (file)
@@ -36,7 +36,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index b7523758ce8396c931c3e0c71c3b32b8c2ea2e4b..5eb97206d0004b286cf3920117f8b25e749cdefc 100644 (file)
@@ -29,7 +29,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
 ALTOS_SRC = \
        ao_micropeak.c \
        ao_spi_attiny.c \
-       ao_led.c \
+       ao_led_tiny.c \
        ao_clock.c \
        ao_ms5607.c \
        ao_exti.c \
index 32154fa69e0bd5792ffd809add1b92b1177025a4..c7d1b22d374a28caddfc698e19b81f8b39ba1af8 100644 (file)
@@ -18,7 +18,7 @@ ALTOS_SRC = \
        ao_micropeak.c \
        ao_spi_stm.c \
        ao_dma_stm.c \
-       ao_led.c \
+       ao_led_stmf0.c \
        ao_timer.c \
        ao_ms5607.c \
        ao_exti_stm.c \
index 1cfa1209df781ffe788dd00511a4c9a67e7cb110..df557e60f1b9168e42e9afe2cb247e25fbe25f23 100644 (file)
@@ -252,7 +252,7 @@ main(void)
        else
                ao_hsi_init();
 
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_task_init();
        ao_timer_init();
        ao_serial_init();
index 6e8cae1499aa6665e0450f5ac83ca70c32450be1..f80d61b0743ef297e6eb41dd69503b6fef0414f7 100644 (file)
@@ -29,7 +29,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
 ALTOS_SRC = \
        ao_micropeak.c \
        ao_spi_attiny.c \
-       ao_led.c \
+       ao_led_tiny.c \
        ao_clock.c \
        ao_ms5607.c \
        ao_exti.c \
index 9bb636f17622c516461d868b59fe7f972b10976d..0342838e3c3f2d632ee3765159c14204e1f8b02c 100644 (file)
@@ -29,7 +29,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
 ALTOS_SRC = \
        ao_micropeak.c \
        ao_spi_attiny.c \
-       ao_led.c \
+       ao_led_tiny.c \
        ao_clock.c \
        ao_ms5607.c \
        ao_exti.c \
index d377959490d09b632271ba88964a34f75540538b..774d4adc742e56ba23e7b8cbb0603c14d35f3185 100644 (file)
@@ -19,7 +19,7 @@ LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w:
 ALTOS_SRC = \
        ao_micropeak.c \
        ao_spi_attiny.c \
-       ao_led.c \
+       ao_led_tiny.c \
        ao_clock.c \
        ao_ms5607.c \
        ao_exti.c \
index 2b9fe14fd638ecfade0724eba42d4101004e4122..1ab2eea188a56453f43f3d8c1386fddef456ad8d 100644 (file)
@@ -26,7 +26,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stmf0.c \
        ao_beep_stm.c \
        ao_dma_stm.c \
        ao_stdio.c \
index 8606b1aed8e00fe7d6731e2bd3c14997cce438a3..443a6afbdb5dc1297f3297d11f6e05ee43475446 100644 (file)
@@ -24,7 +24,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stmf0.c \
        ao_dma_stm.c \
        ao_stdio.c \
        ao_mutex.c \
index 8aac79cd141d4b6ed209836f80007116be5e6fa2..8fed3069a3eef7eefe3081a13c4dae1908a7be14 100644 (file)
@@ -57,7 +57,7 @@ ao_pips(void)
 int
 main(void)
 {
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_timer_init();
 
        /* Init external hardware */
index d4569c1a9b80539074976472e451096a4320a919..ccce37a5a9b2cdbd175fe25b1bc01c4db2bfb4c8 100644 (file)
@@ -23,7 +23,7 @@ ALTOS_SRC = \
        ao_romconfig.c \
        ao_cmd.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index a4c249a304ca6451af1899db79c1120f69119bc3..1db58f10b131e2767ff5f6c5ca1b01c1cf1d60db 100644 (file)
@@ -30,7 +30,7 @@ ALTOS_SRC = \
        ao_romconfig.c \
        ao_cmd.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio_newlib.c \
        ao_panic.c \
        ao_timer.c \
index 46a77272f9bfeb37825f808ba1f75569919048c6..fa0d008f36bff178aa6d6f4db2460a1ce9958566 100644 (file)
@@ -28,7 +28,7 @@ ALTOS_SRC = \
        ao_romconfig.c \
        ao_cmd.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
diff --git a/src/stm/ao_led.c b/src/stm/ao_led.c
deleted file mode 100644 (file)
index 481a6e8..0000000
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright Â© 2012 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-#include "ao.h"
-
-#if LED_PER_LED
-static const struct {
-       struct stm_gpio *port;
-       uint16_t        pin;
-} ao_leds[] = {
-#ifdef LED_0_PORT
-    [0] { LED_0_PORT, LED_0_PIN },
-#endif
-#ifdef LED_1_PORT
-    [1] { LED_1_PORT, LED_1_PIN },
-#endif
-#ifdef LED_2_PORT
-    [2] { LED_2_PORT, LED_2_PIN },
-#endif
-#ifdef LED_3_PORT
-    [3] { LED_3_PORT, LED_3_PIN },
-#endif
-#ifdef LED_4_PORT
-    [4] { LED_4_PORT, LED_4_PIN },
-#endif
-#ifdef LED_5_PORT
-    [5] { LED_5_PORT, LED_5_PIN },
-#endif
-#ifdef LED_6_PORT
-    [6] { LED_6_PORT, LED_6_PIN },
-#endif
-#ifdef LED_7_PORT
-    [7] { LED_7_PORT, LED_7_PIN },
-#endif
-#ifdef LED_8_PORT
-    [8] { LED_8_PORT, LED_8_PIN },
-#endif
-#ifdef LED_9_PORT
-    [9] { LED_9_PORT, LED_9_PIN },
-#endif
-#ifdef LED_10_PORT
-    [10] { LED_10_PORT, LED_10_PIN },
-#endif
-#ifdef LED_11_PORT
-    [11] { LED_11_PORT, LED_11_PIN },
-#endif
-#ifdef LED_12_PORT
-    [12] { LED_12_PORT, LED_12_PIN },
-#endif
-#ifdef LED_13_PORT
-    [13] { LED_13_PORT, LED_13_PIN },
-#endif
-#ifdef LED_14_PORT
-    [14] { LED_14_PORT, LED_14_PIN },
-#endif
-#ifdef LED_15_PORT
-    [15] { LED_15_PORT, LED_15_PIN },
-#endif
-};
-#define N_LED  (sizeof (ao_leds)/sizeof(ao_leds[0]))
-#endif
-static AO_LED_TYPE ao_led_enable;
-
-void
-ao_led_on(AO_LED_TYPE colors)
-{
-#ifdef LED_PER_LED
-       AO_LED_TYPE i;
-       for (i = 0; i < N_LED; i++)
-               if (colors & (1 << i))
-                       ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 1);
-#else
-#ifdef LED_PORT
-       LED_PORT->bsrr = (colors & ao_led_enable);
-#else
-#ifdef LED_PORT_0
-       LED_PORT_0->bsrr = ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
-#endif
-#ifdef LED_PORT_1
-       LED_PORT_1->bsrr = ((colors & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
-#endif
-#endif
-#endif
-}
-
-void
-ao_led_off(AO_LED_TYPE colors)
-{
-#ifdef LED_PER_LED
-       AO_LED_TYPE i;
-       for (i = 0; i < N_LED; i++)
-               if (colors & (1 << i))
-                       ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, 0);
-#else
-#ifdef LED_PORT
-       LED_PORT->bsrr = (uint32_t) (colors & ao_led_enable) << 16;
-#else
-#ifdef LED_PORT_0
-       LED_PORT_0->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_0_MASK) << (LED_PORT_0_SHIFT + 16);
-#endif
-#ifdef LED_PORT_1
-       LED_PORT_1->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16);
-#endif
-#endif
-#endif
-}
-
-void
-ao_led_set(AO_LED_TYPE colors)
-{
-       AO_LED_TYPE     on = colors & ao_led_enable;
-       AO_LED_TYPE     off = ~colors & ao_led_enable;
-
-       ao_led_off(off);
-       ao_led_on(on);
-}
-
-void
-ao_led_toggle(AO_LED_TYPE colors)
-{
-#ifdef LED_PER_LED
-       AO_LED_TYPE i;
-       for (i = 0; i < N_LED; i++)
-               if (colors & (1 << i))
-                       ao_gpio_set(ao_leds[i].port, ao_leds[i].pin, ~ao_gpio_get(ao_leds[i].port, ao_leds[i].pin));
-#else
-#ifdef LED_PORT
-       LED_PORT->odr ^= (colors & ao_led_enable);
-#else
-#ifdef LED_PORT_0
-       LED_PORT_0->odr ^= ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
-#endif
-#ifdef LED_PORT_1
-       LED_PORT_1->odr ^= ((colors & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
-#endif
-#endif
-#endif
-}
-
-void
-ao_led_for(AO_LED_TYPE colors, AO_LED_TYPE ticks) 
-{
-       ao_led_on(colors);
-       ao_delay(ticks);
-       ao_led_off(colors);
-}
-
-#define init_led_pin(port, bit) do { \
-               stm_moder_set(port, bit, STM_MODER_OUTPUT);             \
-               stm_otyper_set(port, bit, STM_OTYPER_PUSH_PULL);        \
-       } while (0)
-
-void
-ao_led_init(AO_LED_TYPE enable)
-{
-       AO_LED_TYPE     bit;
-
-       ao_led_enable = enable;
-#if LED_PER_LED
-       for (bit = 0; bit < N_LED; bit++)
-               ao_enable_output(ao_leds[bit].port, ao_leds[bit].pin, 0);
-#else
-#ifdef LED_PORT
-       stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
-       LED_PORT->odr &= ~enable;
-#else
-#ifdef LED_PORT_0
-       stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE);
-       LED_PORT_0->odr &= ~((enable & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
-#endif
-#ifdef LED_PORT_1
-       stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE);
-       LED_PORT_1->odr &= ~((enable & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
-#endif
-#ifdef LED_PORT_2
-       stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE);
-       LED_PORT_1->odr &= ~((enable & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
-#endif
-#endif
-       for (bit = 0; bit < 16; bit++) {
-               if (enable & (1 << bit)) {
-#ifdef LED_PORT
-                       init_led_pin(LED_PORT, bit);
-#else
-#ifdef LED_PORT_0
-                       if (LED_PORT_0_MASK & (1 << bit))
-                               init_led_pin(LED_PORT_0, bit + LED_PORT_0_SHIFT);
-#endif
-#ifdef LED_PORT_1
-                       if (LED_PORT_1_MASK & (1 << bit))
-                               init_led_pin(LED_PORT_1, bit + LED_PORT_1_SHIFT);
-#endif
-#ifdef LED_PORT_2
-                       if (LED_PORT_2_MASK & (1 << bit))
-                               init_led_pin(LED_PORT_2, bit + LED_PORT_2_SHIFT);
-#endif
-#endif
-               }
-       }
-#endif
-}
diff --git a/src/stm/ao_led_stm.c b/src/stm/ao_led_stm.c
new file mode 100644 (file)
index 0000000..7dcbb66
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright Â© 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "ao.h"
+
+#if LED_PER_LED
+#error LED_PER_LED support is in ao_led.c now
+#endif
+
+void
+ao_led_on(AO_LED_TYPE colors)
+{
+#ifdef LED_PORT
+       LED_PORT->bsrr = (colors & LEDS_AVAILABLE);
+#else
+#ifdef LED_PORT_0
+       LED_PORT_0->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+#endif
+#ifdef LED_PORT_1
+       LED_PORT_1->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+#endif
+#ifdef LED_PORT_2
+       LED_PORT_2->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_2_MASK) << LED_PORT_2_SHIFT;
+#endif
+#endif
+}
+
+void
+ao_led_off(AO_LED_TYPE colors)
+{
+#ifdef LED_PORT
+       LED_PORT->bsrr = (uint32_t) (colors & LEDS_AVAILABLE) << 16;
+#else
+#ifdef LED_PORT_0
+       LED_PORT_0->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << (LED_PORT_0_SHIFT + 16);
+#endif
+#ifdef LED_PORT_1
+       LED_PORT_1->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16);
+#endif
+#ifdef LED_PORT_2
+       LED_PORT_2->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_2_MASK) << (LED_PORT_2_SHIFT + 16);
+#endif
+#endif
+}
+
+void
+ao_led_set(AO_LED_TYPE colors)
+{
+       AO_LED_TYPE     on = colors & LEDS_AVAILABLE;
+       AO_LED_TYPE     off = ~colors & LEDS_AVAILABLE;
+
+       ao_led_off(off);
+       ao_led_on(on);
+}
+
+void
+ao_led_toggle(AO_LED_TYPE colors)
+{
+#ifdef LED_PORT
+       LED_PORT->odr ^= (colors & LEDS_AVAILABLE);
+#else
+#ifdef LED_PORT_0
+       LED_PORT_0->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+#endif
+#ifdef LED_PORT_1
+       LED_PORT_1->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+#endif
+#ifdef LED_PORT_2
+       LED_PORT_2->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_2_MASK) << LED_PORT_2_SHIFT;
+#endif
+#endif
+}
+
+void
+ao_led_for(AO_LED_TYPE colors, AO_LED_TYPE ticks) 
+{
+       ao_led_on(colors);
+       ao_delay(ticks);
+       ao_led_off(colors);
+}
+
+#define init_led_pin(port, bit) do { \
+               stm_moder_set(port, bit, STM_MODER_OUTPUT);             \
+               stm_otyper_set(port, bit, STM_OTYPER_PUSH_PULL);        \
+       } while (0)
+
+void
+ao_led_init(void)
+{
+       AO_LED_TYPE     bit;
+
+#ifdef LED_PORT
+       stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
+       LED_PORT->odr &= ~LEDS_AVAILABLE;
+#else
+#ifdef LED_PORT_0
+       stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE);
+       LED_PORT_0->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+#endif
+#ifdef LED_PORT_1
+       stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE);
+       LED_PORT_1->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+#endif
+#ifdef LED_PORT_2
+       stm_rcc.ahbenr |= (1 << LED_PORT_2_ENABLE);
+       LED_PORT_2->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_2_MASK) << LED_PORT_2_SHIFT;
+#endif
+#endif
+       for (bit = 0; bit < sizeof (AO_LED_TYPE) * 8; bit++) {
+               if (LEDS_AVAILABLE & (1 << bit)) {
+#ifdef LED_PORT
+                       init_led_pin(LED_PORT, bit);
+#else
+#ifdef LED_PORT_0
+                       if (LED_PORT_0_MASK & (1 << bit))
+                               init_led_pin(LED_PORT_0, bit + LED_PORT_0_SHIFT);
+#endif
+#ifdef LED_PORT_1
+                       if (LED_PORT_1_MASK & (1 << bit))
+                               init_led_pin(LED_PORT_1, bit + LED_PORT_1_SHIFT);
+#endif
+#ifdef LED_PORT_2
+                       if (LED_PORT_2_MASK & (1 << bit))
+                               init_led_pin(LED_PORT_2, bit + LED_PORT_2_SHIFT);
+#endif
+#endif
+               }
+       }
+}
index 2d912b226fe1d47bcd151990723008b7b82991db..c970b879ccc96a7b69e62798cd67b505589d8c88 100644 (file)
@@ -3,7 +3,10 @@ include ../stm32f4/Makefile-raw.defs
 ALTOS_SRC = \
        ao_interrupt.c \
        ao_panic.c \
-       ao_timer.c
+       ao_timer.c \
+       ao_led.c \
+       ao_task.c \
+       ao_stdio.c
 
 CFLAGS = $(STM32F4_CFLAGS)
 
index efbed947a1d4c54267fcbfad8282a5807ddb4435..c6cdbd234d9c61cf2382e1f494e8c89216c8580b 100644 (file)
 
 #include <ao.h>
 
-void main(void)
+static struct ao_task red_task;
+static struct ao_task green_task;
+
+static void
+red(void)
 {
-       float           x;
-       int             r = 1;
-       int             g = 0;
+       for (;;) {
+               ao_led_toggle(LED_RED);
+               ao_delay(AO_MS_TO_TICKS(500));
+       }
+}
 
-       ao_clock_init();
+static void
+green(void)
+{
+       for (;;) {
+               ao_led_toggle(LED_GREEN);
+               ao_delay(AO_MS_TO_TICKS(450));
+       }
+}
 
+void main(void)
+{
+       ao_clock_init();
        ao_timer_init();
+       ao_led_init();
+       ao_task_init();
 
-       ao_enable_output(LED_GREEN_PORT, LED_GREEN_PIN, 0);
-       ao_enable_output(LED_RED_PORT, LED_RED_PIN, 1);
-       for (;;) {
-               ao_gpio_set(LED_GREEN_PORT, LED_GREEN_PIN, g);
-               ao_gpio_set(LED_RED_PORT, LED_RED_PIN, r);
-               g ^= 1;
-               r ^= 1;
-               for (x = 0.0f; x < 100000.0f; x = x + 0.1f)
-                       ao_arch_nop();
-       }
+       ao_add_task(&red_task, red, "red");
+       ao_add_task(&green_task, green, "green");
+       ao_start_scheduler();
 }
index c4dc5b4b2f20800c6254e12cdf99f03267904ed3..bbbc306e85b7f7e223b278a750038709469529ed 100644 (file)
 #ifndef _AO_PINS_H_
 #define _AO_PINS_H_
 
-#define HAS_BEEP       0
-
-#define B_USER_PORT    (&stm_gpioa)
-#define B_USER_PIN     0
-
-#define LED_GREEN_PORT (&stm_gpioc)
-#define LED_GREEN_PIN  5
-#define LED_RED_PORT   (&stm_gpioe)
-#define LED_RED_PIN    3
-
+/* Clock tree configuration */
 #define AO_HSE         8000000 /* fed from st/link processor */
 #define AO_HSE_BYPASS  1       /* no xtal, directly fed */
 
 
 #define DEBUG_THE_CLOCK        1
 
+#define HAS_USB                0
+#define HAS_BEEP       0
+
+#define B_USER_PORT    (&stm_gpioa)
+#define B_USER_PIN     0
+
+/* LEDs */
+
+#define HAS_LED                1
+
+#define LED_0_PORT     (&stm_gpioc)
+#define LED_0_PIN      5
+#define LED_GREEN      (1 << 0)
+
+#define LED_1_PORT     (&stm_gpioe)
+#define LED_1_PIN      3
+#define LED_RED                (1 << 1)
+
 #endif /* _AO_PINS_H_ */
index 805d756d12f4ab4c529a6b17709d69ce1824ce7f..73eb793fbd0164b5657e4285db724bdb0dd1511a 100644 (file)
@@ -29,9 +29,6 @@
 #define ao_arch_task_members\
        uint32_t *sp;                   /* saved stack pointer */
 
-#define ao_arch_block_interrupts()     asm("cpsid i")
-#define ao_arch_release_interrupts()   asm("cpsie i")
-
 #define ao_arch_naked_declare  __attribute__((naked))
 #define ao_arch_naked_define
 
index 252fe77a5330eaa81b7783cd9bda4188f44a125f..8c0da03bf37b402bc39826a946b712b2f62942c1 100644 (file)
 #ifndef _AO_ARCH_FUNCS_H_
 #define _AO_ARCH_FUNCS_H_
 
+/* task functions */
+
+#define ARM_PUSH32(stack, val) (*(--(stack)) = (val))
+
+typedef uint32_t       ao_arch_irq_t;
+
+static inline void
+ao_arch_block_interrupts(void) {
+#ifdef AO_NONMASK_INTERRUPTS
+       asm("msr basepri,%0" : : "r" (AO_STM_NVIC_BASEPRI_MASK));
+#else
+       asm("cpsid i");
+#endif
+}
+
+static inline void
+ao_arch_release_interrupts(void) {
+#ifdef AO_NONMASK_INTERRUPTS
+       asm("msr basepri,%0" : : "r" (0x0));
+#else
+       asm("cpsie i");
+#endif
+}
+
+static inline uint32_t
+ao_arch_irqsave(void) {
+       uint32_t        val;
+#ifdef AO_NONMASK_INTERRUPTS
+       asm("mrs %0,basepri" : "=r" (val));
+#else
+       asm("mrs %0,primask" : "=r" (val));
+#endif
+       ao_arch_block_interrupts();
+       return val;
+}
+
+static inline void
+ao_arch_irqrestore(uint32_t basepri) {
+#ifdef AO_NONMASK_INTERRUPTS
+       asm("msr basepri,%0" : : "r" (basepri));
+#else
+       asm("msr primask,%0" : : "r" (basepri));
+#endif
+}
+
+static inline void
+ao_arch_memory_barrier() {
+       asm volatile("" ::: "memory");
+}
+
+static inline void
+ao_arch_irq_check(void) {
+#ifdef AO_NONMASK_INTERRUPTS
+       uint32_t        basepri;
+       asm("mrs %0,basepri" : "=r" (basepri));
+       if (basepri == 0)
+               ao_panic(AO_PANIC_IRQ);
+#else
+       uint32_t        primask;
+       asm("mrs %0,primask" : "=r" (primask));
+       if ((primask & 1) == 0)
+               ao_panic(AO_PANIC_IRQ);
+#endif
+}
+
+#if HAS_TASK
+static inline void
+ao_arch_init_stack(struct ao_task *task, void *start)
+{
+       uint32_t        *sp = (uint32_t *) ((void*) task->stack + AO_STACK_SIZE);
+       uint32_t        a = (uint32_t) start;
+       int             i;
+
+       /* Return address (goes into LR) */
+       ARM_PUSH32(sp, a);
+
+       /* Clear register values r0-r12 */
+       i = 13;
+       while (i--)
+               ARM_PUSH32(sp, 0);
+
+       /* APSR */
+       ARM_PUSH32(sp, 0);
+
+       /* Clear register values s0-s31 */
+       i = 32;
+       while (i--)
+               ARM_PUSH32(sp, 0);
+
+       /* FPSCR */
+       ARM_PUSH32(sp, 0);
+
+       /* BASEPRI with interrupts enabled */
+       ARM_PUSH32(sp, 0);
+
+       task->sp = sp;
+}
+
+static inline void ao_arch_save_regs(void) {
+       /* Save general registers */
+       asm("push {r0-r12,lr}");
+
+       /* Save APSR */
+       asm("mrs r0,apsr");
+       asm("push {r0}");
+
+       /* Save FPU registers */
+       asm("vpush {s0-s15}");
+       asm("vpush {s16-s31}");
+
+       /* Save FPSCR */
+       asm("vmrs r0,fpscr");
+       asm("push {r0}");
+
+#ifdef AO_NONMASK_INTERRUPTS
+       /* Save BASEPRI */
+       asm("mrs r0,basepri");
+#else
+       /* Save PRIMASK */
+       asm("mrs r0,primask");
+#endif
+       asm("push {r0}");
+}
+
+static inline void ao_arch_save_stack(void) {
+       uint32_t        *sp;
+       asm("mov %0,sp" : "=&r" (sp) );
+       ao_cur_task->sp = (sp);
+}
+
+static inline void ao_arch_restore_stack(void) {
+       /* Switch stacks */
+       asm("mov sp, %0" : : "r" (ao_cur_task->sp) );
+
+#ifdef AO_NONMASK_INTERRUPTS
+       /* Restore BASEPRI */
+       asm("pop {r0}");
+       asm("msr basepri,r0");
+#else
+       /* Restore PRIMASK */
+       asm("pop {r0}");
+       asm("msr primask,r0");
+#endif
+
+       /* Restore FPSCR */
+       asm("pop {r0}");
+       asm("vmsr fpscr,r0");
+
+       /* Restore FPU registers */
+       asm("vpop {s16-s31}");
+       asm("vpop {s0-s15}");
+
+       /* Restore APSR */
+       asm("pop {r0}");
+       asm("msr apsr_nczvq,r0");
+
+       /* Restore general registers */
+       asm("pop {r0-r12,lr}\n");
+
+       /* Return to calling function */
+       asm("bx lr");
+}
+
+#ifndef HAS_SAMPLE_PROFILE
+#define HAS_SAMPLE_PROFILE 0
+#endif
+
+#if DEBUG
+#define HAS_ARCH_VALIDATE_CUR_STACK    1
+
+static inline void
+ao_validate_cur_stack(void)
+{
+       uint8_t         *psp;
+
+       asm("mrs %0,psp" : "=&r" (psp));
+       if (ao_cur_task &&
+           psp <= ao_cur_task->stack &&
+           psp >= ao_cur_task->stack - 256)
+               ao_panic(AO_PANIC_STACK);
+}
+#endif
+
+#if !HAS_SAMPLE_PROFILE
+#define HAS_ARCH_START_SCHEDULER       1
+
+static inline void ao_arch_start_scheduler(void) {
+       uint32_t        sp;
+       uint32_t        control;
+
+       asm("mrs %0,msp" : "=&r" (sp));
+       asm("msr psp,%0" : : "r" (sp));
+       asm("mrs %0,control" : "=r" (control));
+       control |= (1 << 1);
+       asm("msr control,%0" : : "r" (control));
+       asm("isb");
+}
+#endif
+
+#define ao_arch_isr_stack()
+
+#endif
+
+static inline void
+ao_arch_wait_interrupt(void) {
+#ifdef AO_NONMASK_INTERRUPTS
+       asm(
+           "dsb\n"                     /* Serialize data */
+           "isb\n"                     /* Serialize instructions */
+           "cpsid i\n"                 /* Block all interrupts */
+           "msr basepri,%0\n"          /* Allow all interrupts through basepri */
+           "wfi\n"                     /* Wait for an interrupt */
+           "cpsie i\n"                 /* Allow all interrupts */
+           "msr basepri,%1\n"          /* Block interrupts through basepri */
+           : : "r" (0), "r" (AO_STM_NVIC_BASEPRI_MASK));
+#else
+       asm("\twfi\n");
+       ao_arch_release_interrupts();
+       ao_arch_block_interrupts();
+#endif
+}
+
+#define ao_arch_critical(b) do {                       \
+               uint32_t __mask = ao_arch_irqsave();    \
+               do { b } while (0);                     \
+               ao_arch_irqrestore(__mask);             \
+       } while (0)
+
 /* GPIO functions */
 
 #define ao_power_register(gpio)
diff --git a/src/stmf0/ao_led.c b/src/stmf0/ao_led.c
deleted file mode 100644 (file)
index a162932..0000000
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright Â© 2012 Keith Packard <keithp@keithp.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-#include "ao.h"
-
-uint16_t ao_led_enable;
-
-void
-ao_led_on(uint16_t colors)
-{
-#ifdef LED_PORT
-       LED_PORT->bsrr = (colors & ao_led_enable);
-#else
-#ifdef LED_PORT_0
-       LED_PORT_0->bsrr = ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
-#endif
-#ifdef LED_PORT_1
-       LED_PORT_1->bsrr = ((colors & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
-#endif
-#endif
-}
-
-void
-ao_led_off(uint16_t colors)
-{
-#ifdef LED_PORT
-       LED_PORT->bsrr = (uint32_t) (colors & ao_led_enable) << 16;
-#else
-#ifdef LED_PORT_0
-       LED_PORT_0->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_0_MASK) << (LED_PORT_0_SHIFT + 16);
-#endif
-#ifdef LED_PORT_1
-       LED_PORT_1->bsrr = ((uint32_t) (colors & ao_led_enable) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16);
-#endif
-#endif
-}
-
-void
-ao_led_set(uint16_t colors)
-{
-       uint16_t        on = colors & ao_led_enable;
-       uint16_t        off = ~colors & ao_led_enable;
-
-       ao_led_off(off);
-       ao_led_on(on);
-}
-
-void
-ao_led_toggle(uint16_t colors)
-{
-#ifdef LED_PORT
-       LED_PORT->odr ^= (colors & ao_led_enable);
-#else
-#ifdef LED_PORT_0
-       LED_PORT_0->odr ^= ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
-#endif
-#ifdef LED_PORT_1
-       LED_PORT_1->odr ^= ((colors & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
-#endif
-#endif
-}
-
-void
-ao_led_for(uint16_t colors, uint16_t ticks) 
-{
-       ao_led_on(colors);
-       ao_delay(ticks);
-       ao_led_off(colors);
-}
-
-#define init_led_pin(port, bit) do { \
-               stm_moder_set(port, bit, STM_MODER_OUTPUT);             \
-               stm_otyper_set(port, bit, STM_OTYPER_PUSH_PULL);        \
-       } while (0)
-
-void
-ao_led_init(uint16_t enable)
-{
-       int     bit;
-
-       ao_led_enable = enable;
-#ifdef LED_PORT
-       stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
-       LED_PORT->odr &= ~enable;
-#else
-#ifdef LED_PORT_0
-       stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE);
-       LED_PORT_0->odr &= ~((enable & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
-#endif
-#ifdef LED_PORT_1
-       stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE);
-       LED_PORT_1->odr &= ~((enable & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
-#endif
-#endif
-       for (bit = 0; bit < 16; bit++) {
-               if (enable & (1 << bit)) {
-#ifdef LED_PORT
-                       init_led_pin(LED_PORT, bit);
-#else
-#ifdef LED_PORT_0
-                       if (LED_PORT_0_MASK & (1 << bit))
-                               init_led_pin(LED_PORT_0, bit + LED_PORT_0_SHIFT);
-#endif
-#ifdef LED_PORT_1
-                       if (LED_PORT_1_MASK & (1 << bit))
-                               init_led_pin(LED_PORT_1, bit + LED_PORT_1_SHIFT);
-#endif
-#endif
-               }
-       }
-}
diff --git a/src/stmf0/ao_led_stmf0.c b/src/stmf0/ao_led_stmf0.c
new file mode 100644 (file)
index 0000000..1564535
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright Â© 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "ao.h"
+
+void
+ao_led_on(AO_LED_TYPE colors)
+{
+#ifdef LED_PORT
+       LED_PORT->bsrr = (colors & LEDS_AVAILABLE);
+#else
+#ifdef LED_PORT_0
+       LED_PORT_0->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+#endif
+#ifdef LED_PORT_1
+       LED_PORT_1->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+#endif
+#endif
+}
+
+void
+ao_led_off(AO_LED_TYPE colors)
+{
+#ifdef LED_PORT
+       LED_PORT->bsrr = (uint32_t) (colors & LEDS_AVAILABLE) << 16;
+#else
+#ifdef LED_PORT_0
+       LED_PORT_0->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << (LED_PORT_0_SHIFT + 16);
+#endif
+#ifdef LED_PORT_1
+       LED_PORT_1->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16);
+#endif
+#endif
+}
+
+void
+ao_led_set(AO_LED_TYPE colors)
+{
+       AO_LED_TYPE     on = colors & LEDS_AVAILABLE;
+       AO_LED_TYPE     off = ~colors & LEDS_AVAILABLE;
+
+       ao_led_off(off);
+       ao_led_on(on);
+}
+
+void
+ao_led_toggle(AO_LED_TYPE colors)
+{
+#ifdef LED_PORT
+       LED_PORT->odr ^= (colors & LEDS_AVAILABLE);
+#else
+#ifdef LED_PORT_0
+       LED_PORT_0->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+#endif
+#ifdef LED_PORT_1
+       LED_PORT_1->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+#endif
+#endif
+}
+
+void
+ao_led_for(AO_LED_TYPE colors, AO_TICK_TYPE ticks) 
+{
+       ao_led_on(colors);
+       ao_delay(ticks);
+       ao_led_off(colors);
+}
+
+#define init_led_pin(port, bit) do { \
+               stm_moder_set(port, bit, STM_MODER_OUTPUT);             \
+               stm_otyper_set(port, bit, STM_OTYPER_PUSH_PULL);        \
+       } while (0)
+
+void
+ao_led_init(void)
+{
+       int     bit;
+
+#ifdef LED_PORT
+       stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
+       LED_PORT->odr &= ~LEDS_AVAILABLE;
+#else
+#ifdef LED_PORT_0
+       stm_rcc.ahbenr |= (1 << LED_PORT_0_ENABLE);
+       LED_PORT_0->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+#endif
+#ifdef LED_PORT_1
+       stm_rcc.ahbenr |= (1 << LED_PORT_1_ENABLE);
+       LED_PORT_1->odr &= (uint32_t) ~(LEDS_AVAILABLE & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+#endif
+#endif
+       for (bit = 0; bit < 16; bit++) {
+               if (LEDS_AVAILABLE & (1 << bit)) {
+#ifdef LED_PORT
+                       init_led_pin(LED_PORT, bit);
+#else
+#ifdef LED_PORT_0
+                       if (LED_PORT_0_MASK & (1 << bit))
+                               init_led_pin(LED_PORT_0, bit + LED_PORT_0_SHIFT);
+#endif
+#ifdef LED_PORT_1
+                       if (LED_PORT_1_MASK & (1 << bit))
+                               init_led_pin(LED_PORT_1, bit + LED_PORT_1_SHIFT);
+#endif
+#endif
+               }
+       }
+}
index cb2ce253951167359234671765672d2902b44924..ddbfaf5f7e2fa52a33456b97897ff04e9a3d8e35 100644 (file)
@@ -46,7 +46,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index acb11f44b998079abea0af134a5768d496e20cd1..94393da099fad6f6248a25a302f462399a8522a1 100644 (file)
@@ -43,8 +43,8 @@ main(void)
 
        ao_task_init();
        ao_serial_init();
-       ao_led_init(LEDS_AVAILABLE);
-       ao_led_on(AO_LED_RED);
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
        ao_spi_init();
@@ -87,7 +87,8 @@ main(void)
 #if HAS_SAMPLE_PROFILE
        ao_sample_profile_init();
 #endif
-       
+       ao_led_off(LEDS_AVAILABLE);
+
        ao_start_scheduler();
        return 0;
 }
index 4636c046fd2f4813af436ac268b195fe5303430b..9892ad5fcc7cef849d5a1a3779f04dc82bf9dc4c 100644 (file)
@@ -37,7 +37,7 @@ ALTOS_SRC = \
        ao_config.c \
        ao_data.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 63633c90ceea197c44bef6d1bf078f1d67f28319..3d48b6b928563c7bb1ed93bddc4af283a9ce2f98 100644 (file)
@@ -34,7 +34,7 @@ main(void)
        ao_clock_init();
 
        ao_task_init();
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
index 38ac7513d055e94530d7982adbda21503389991c..4ad3287dd86d27b0c0a1bb4b49d125d947ba6598 100644 (file)
@@ -27,7 +27,7 @@ ALTOS_SRC = \
        ao_config.c \
        ao_data.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stmf0.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 953ec4bc98c124a1e55f1e26b0f28b7e8543c6e3..7c3c6e2a7c625cac14715383a9311c672efceb9a 100644 (file)
@@ -29,7 +29,7 @@ main(void)
        ao_clock_init();
 
        ao_task_init();
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
index 6c05ce9fd04fa126724761eee306f018208018c5..461b585594342d254bee726ce62e6f2ff09bd8bb 100644 (file)
@@ -38,7 +38,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 32899af239f0bf272c947d65fddc4bfdf5eb7ae4..69abea6edef1eb50d0aba8755c9c830e75c05ac6 100644 (file)
@@ -31,7 +31,7 @@ main(void)
 #endif
 
        ao_task_init();
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
index 15e1fa111c96f0623b0f75d3c9ba62bfe666a5a4..ef533b3640496f48f6a5570daae434395d9ca633 100644 (file)
 #define AO_CC1200_INT_GPIO     2
 #define AO_CC1200_INT_GPIO_IOCFG       CC1200_IOCFG2
 
-#define LED_PER_LED            1
+#define HAS_LED                        1
 #define LED_TYPE               uint16_t
 
 /* Continuity leds 1-8 */
 #define LED_7_PORT             (&stm_gpioa)
 #define LED_7_PIN              10
 
-#define LED_PIN_CONTINUITY_0   0
-#define LED_PIN_CONTINUITY_1   1
-#define LED_PIN_CONTINUITY_2   2
-#define LED_PIN_CONTINUITY_3   3
-#define LED_PIN_CONTINUITY_4   4
-#define LED_PIN_CONTINUITY_5   5
-#define LED_PIN_CONTINUITY_6   6
-#define LED_PIN_CONTINUITY_7   7
+#define AO_LED_CONTINUITY(c)   (1 << (c))
+#define AO_LED_CONTINUITY_MASK (0xff)
 
 /* ARM */
 #define LED_8_PORT             (&stm_gpioe)
 #define LED_11_PORT            (&stm_gpioe)
 #define LED_11_PIN             6
 
-#define LED_PIN_GREEN          9
-#define LED_PIN_AMBER          10
-#define LED_PIN_RED            11
-
-#define AO_LED_CONTINUITY(c)   (1 << (c))
-#define AO_LED_CONTINUITY_MASK (0xff)
-
-#define AO_LED_ARMED           (1 << LED_PIN_ARMED)
-#define AO_LED_GREEN           (1 << LED_PIN_GREEN)
-#define AO_LED_AMBER           (1 << LED_PIN_AMBER)
-#define AO_LED_RED             (1 << LED_PIN_RED)
-
-#define LEDS_AVAILABLE         (0xfff)
+#define AO_LED_ARMED           AO_LED_8
+#define AO_LED_GREEN           AO_LED_9
+#define AO_LED_AMBER           AO_LED_10
+#define AO_LED_RED             AO_LED_11
 
 /* Alarm A */
 #define AO_SIREN
index bdcf3213ddac77c861ef844ce7b9303158784947..89541a024636504284ab0e12e220e2b51bdded75 100644 (file)
@@ -26,7 +26,8 @@ main(void)
 {
        ao_clock_init();
 
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
 
        ao_task_init();
 
@@ -51,5 +52,7 @@ main(void)
 
 //     ao_radio_cmac_cmd_init();
 
+       ao_led_off(LEDS_AVAILABLE);
+
        ao_start_scheduler();
 }
index 53f088cb2eabfdb05580300ae21a29843203c9d4..773c8f69c685066b5d8248557354000a96b47d43 100644 (file)
@@ -34,7 +34,7 @@ ALTOS_SRC = \
        ao_data.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 6454d6fd71a0c062ddc6359bc269244ddcd91db6..72171fac51429baf365d2c4a9514dbbc3f50c197 100644 (file)
@@ -33,7 +33,7 @@ ALTOS_SRC = \
        ao_data.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index bdcf3213ddac77c861ef844ce7b9303158784947..89541a024636504284ab0e12e220e2b51bdded75 100644 (file)
@@ -26,7 +26,8 @@ main(void)
 {
        ao_clock_init();
 
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
 
        ao_task_init();
 
@@ -51,5 +52,7 @@ main(void)
 
 //     ao_radio_cmac_cmd_init();
 
+       ao_led_off(LEDS_AVAILABLE);
+
        ao_start_scheduler();
 }
index 30985f9ce0dfa033991333663558881f312ba120..f43ece71eb647e72f9bc2bd613fa54bb0b263556 100644 (file)
@@ -33,7 +33,7 @@ ALTOS_SRC = \
        ao_data.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 46eb0ac5edc6278e7175d527a40d364eb3916d5f..0365f91f354e64f5b9c808d35adcc282dbaf2021 100644 (file)
@@ -44,7 +44,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 19d088d381853e67590d340c5c5dec06473eba4e..617efa65a346e482b55ef13721f7dc39b669180a 100644 (file)
@@ -21,7 +21,7 @@ INC = \
 
 ALTOS_SRC = \
        ao_adc_stm.c \
-       ao_led.c \
+       ao_led_stmf0.c \
        ao_interrupt.c \
        ao_boot_chain.c \
        ao_product.c \
index 998c20086ccccbfeea4270df7aecdce0572429e2..1ba67f675cc0c50d6f5f972771765bc2b168492f 100644 (file)
@@ -29,8 +29,8 @@ main(void)
        ao_cmd_init();
        ao_config_init();
 
-       ao_led_init(LEDS_AVAILABLE);
-       ao_led_on(AO_LED_GREEN);
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
 
        /* internal systems */
        ao_timer_init();
@@ -53,8 +53,7 @@ main(void)
        ao_telemetry_init();
        ao_tracker_init();
 
-       ao_led_off(AO_LED_GREEN);
+       ao_led_off(LEDS_AVAILABLE);
 
        ao_start_scheduler();
-       return 0;
 }
index 4ccf494c73bf22e3f7be1d613f12f44494a920ed..9307aa2daa7861a20ada6a52f3f414d9b782e268 100644 (file)
@@ -40,7 +40,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 3266da008caeb50a1f68e93c114ce9e5430d5769..26f49d5942f467c351301de80671e25bdbe4fd9f 100644 (file)
@@ -45,9 +45,8 @@ main(void)
        ao_timer_init();
        ao_dma_init();
 
-       ao_led_init(LEDS_AVAILABLE);
-       ao_led_on(AO_LED_GREEN);
-
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
 
        ao_spi_init();
        ao_exti_init();
@@ -74,6 +73,8 @@ main(void)
        ao_lco_cmd_init();
 //     ao_radio_cmac_cmd_init();
 
+       ao_led_off(LEDS_AVAILABLE);
+
        ao_start_scheduler();
        return 0;
 }
index 8279cac1fd81ec7090e4e187eb4938ae794bf1a7..91ae67f092aa851677d69d65e864ee3cf6c27723 100644 (file)
@@ -39,7 +39,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 7b04d386f8985d6521f9251610322bc66a1a3e9c..4eba3597950879078ae5969ad1079fe675fc7748 100644 (file)
@@ -35,9 +35,9 @@ int
 main(void)
 {
        ao_clock_init();
-       
-       ao_led_init(LEDS_AVAILABLE);
-       ao_led_on(AO_LED_GREEN);
+
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
        ao_task_init();
 
        ao_timer_init();
@@ -55,17 +55,19 @@ main(void)
        ao_button_init();
 
        ao_eeprom_init();
-       
+
        ao_radio_init();
 
        ao_usb_init();
 
        ao_config_init();
-       
+
        ao_lco_init();
        ao_lco_cmd_init();
 //     ao_radio_cmac_cmd_init();
-       
+
+       ao_led_off(LEDS_AVAILABLE);
+
        ao_start_scheduler();
        return 0;
 }
index c2592bf86e3c1b7a3781c3a9537982227f6a8b56..567ddf419ad167f32ec760ed24b562679c54a9e3 100644 (file)
@@ -40,7 +40,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 7b04d386f8985d6521f9251610322bc66a1a3e9c..c2ca68aa58cf4b29c18bd95d98bbf55885ae6c61 100644 (file)
@@ -36,8 +36,8 @@ main(void)
 {
        ao_clock_init();
        
-       ao_led_init(LEDS_AVAILABLE);
-       ao_led_on(AO_LED_GREEN);
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
        ao_task_init();
 
        ao_timer_init();
@@ -66,6 +66,8 @@ main(void)
        ao_lco_cmd_init();
 //     ao_radio_cmac_cmd_init();
        
+       ao_led_off(LEDS_AVAILABLE);
+
        ao_start_scheduler();
        return 0;
 }
index 90324cc89e93c28534ecd42a8f50f70e38b0ec04..daecf380260a2e82e277e6091a267921c5d06c5f 100644 (file)
@@ -243,9 +243,9 @@ ao_lco_display_test()
        ao_seven_segment_set(AO_LCO_BOX_DIGIT_1, 8 | 0x10);
        ao_seven_segment_set(AO_LCO_BOX_DIGIT_10, 8 | 0x10);
        ao_mutex_put(&ao_lco_display_mutex);
-       ao_led_on(LEDS_AVAILABLE);
+       ao_led_on(AO_LEDS_AVAILABLE);
        ao_delay(AO_MS_TO_TICKS(1000));
-       ao_led_off(LEDS_AVAILABLE);
+       ao_led_off(AO_LEDS_AVAILABLE);
 }
 
 static void
index 95998dc781775ec7b5ea0641822bd956a9c55e64..ea709c1dbb60613700f2043c43cb06d3c2837182 100644 (file)
 
 #define LOW_LEVEL_DEBUG                0
 
-#define LED_PER_LED            1
-#define LED_TYPE               uint16_t
-
-#define LED_ENABLE_BITS                ((1 << STM_RCC_AHBENR_GPIOAEN) |        \
-                                (1 << STM_RCC_AHBENR_GPIOCEN) |        \
-                                (1 << STM_RCC_AHBENR_GPIODEN) |        \
-                                (1 << STM_RCC_AHBENR_GPIOEEN))
+#define HAS_LED                        1
 
 /* PC7 - PC9, LED 0 - 2 */
 #define LED_0_PORT             (&stm_gpioc)
 #define LED_15_PORT            (&stm_gpioa)
 #define LED_15_PIN             5
 
-#define LED_PIN_RED            0
-#define LED_PIN_AMBER          1
-#define LED_PIN_GREEN          2
-#define LED_PIN_BOX            3
-#define LED_PIN_PAD            4
-#define LED_PIN_DRAG           5
-#define LED_PIN_CONTINUITY_7   6
-#define LED_PIN_CONTINUITY_6   7
-#define LED_PIN_CONTINUITY_5   8
-#define LED_PIN_CONTINUITY_4   9
-#define LED_PIN_CONTINUITY_3   10
-#define LED_PIN_CONTINUITY_2   11
-#define LED_PIN_CONTINUITY_1   12
-#define LED_PIN_CONTINUITY_0   13
-#define LED_PIN_REMOTE_ARM     14
-#define LED_PIN_FIRE           15
-#define AO_LED_RED             (1 << LED_PIN_RED)
-#define AO_LED_AMBER           (1 << LED_PIN_AMBER)
-#define AO_LED_GREEN           (1 << LED_PIN_GREEN)
-#define AO_LED_BOX             (1 << LED_PIN_BOX)
-#define AO_LED_PAD             (1 << LED_PIN_PAD)
-#define AO_LED_DRAG            (1 << LED_PIN_DRAG)
-#define AO_LED_CONTINUITY_7    (1 << LED_PIN_CONTINUITY_7)
-#define AO_LED_CONTINUITY_6    (1 << LED_PIN_CONTINUITY_6)
-#define AO_LED_CONTINUITY_5    (1 << LED_PIN_CONTINUITY_5)
-#define AO_LED_CONTINUITY_4    (1 << LED_PIN_CONTINUITY_4)
-#define AO_LED_CONTINUITY_3    (1 << LED_PIN_CONTINUITY_3)
-#define AO_LED_CONTINUITY_2    (1 << LED_PIN_CONTINUITY_2)
-#define AO_LED_CONTINUITY_1    (1 << LED_PIN_CONTINUITY_1)
-#define AO_LED_CONTINUITY_0    (1 << LED_PIN_CONTINUITY_0)
+#define AO_LED_RED             AO_LED_0
+#define AO_LED_AMBER           AO_LED_1
+#define AO_LED_GREEN           AO_LED_2
+#define AO_LED_BOX             AO_LED_3
+#define AO_LED_PAD             AO_LED_4
+#define AO_LED_DRAG            AO_LED_5
+#define AO_LED_CONTINUITY_7    AO_LED_6
+#define AO_LED_CONTINUITY_6    AO_LED_7
+#define AO_LED_CONTINUITY_5    AO_LED_8
+#define AO_LED_CONTINUITY_4    AO_LED_9
+#define AO_LED_CONTINUITY_3    AO_LED_10
+#define AO_LED_CONTINUITY_2    AO_LED_11
+#define AO_LED_CONTINUITY_1    AO_LED_12
+#define AO_LED_CONTINUITY_0    AO_LED_13
 #define AO_LED_CONTINUITY_NUM  8
-#define AO_LED_REMOTE_ARM      (1 << LED_PIN_REMOTE_ARM)
-#define AO_LED_FIRE            (1 << LED_PIN_FIRE)
-
-#define LEDS_AVAILABLE         (AO_LED_RED |           \
-                                AO_LED_AMBER |         \
-                                AO_LED_GREEN |         \
-                                AO_LED_BOX |           \
-                                AO_LED_PAD |           \
-                                AO_LED_DRAG |          \
-                                AO_LED_CONTINUITY_7 |  \
-                                AO_LED_CONTINUITY_6 |  \
-                                AO_LED_CONTINUITY_5 |  \
-                                AO_LED_CONTINUITY_4 |  \
-                                AO_LED_CONTINUITY_3 |  \
-                                AO_LED_CONTINUITY_2 |  \
-                                AO_LED_CONTINUITY_1 |  \
-                                AO_LED_CONTINUITY_0 |  \
-                                AO_LED_REMOTE_ARM |    \
-                                AO_LED_FIRE)
+#define AO_LED_REMOTE_ARM      AO_LED_14
+#define AO_LED_FIRE            AO_LED_15
 
 /* LCD displays */
 
index 9693c6576cf712ace1791a50f50be69f89ebadf5..59582569ffd1a1e78905be186f81aa916c062701 100644 (file)
@@ -37,8 +37,8 @@ main(void)
 {
        ao_clock_init();
        
-       ao_led_init(LEDS_AVAILABLE);
-       ao_led_on(AO_LED_GREEN);
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
        ao_task_init();
 
        ao_timer_init();
@@ -68,6 +68,8 @@ main(void)
        ao_lco_cmd_init();
 //     ao_radio_cmac_cmd_init();
        
+       ao_led_off(LEDS_AVAILABLE);
+
        ao_start_scheduler();
        return 0;
 }
index c68f3eb5dd1dae776b262b0458e12c9b861573b0..6a114aae2658085a308a642312cecfd3c9bc54b8 100644 (file)
@@ -36,7 +36,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index b3fcd200745c2c160bc08fbf38ab3951f22ff4b2..6ced1912dbb667fdb85f2a14a24d5f7cb164fd9d 100644 (file)
@@ -34,8 +34,8 @@ main(void)
 {
        ao_clock_init();
 
-       ao_led_init(LEDS_AVAILABLE);
-       ao_led_on(AO_LED_GREEN);
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
        ao_beep_init();
        ao_task_init();
 
@@ -61,6 +61,8 @@ main(void)
        ao_lco_cmd_init();
 //     ao_radio_cmac_cmd_init();
 
+       ao_led_off(LEDS_AVAILABLE);
+
        ao_start_scheduler();
        return 0;
 }
index 78cfdefdc1765f9344dd3f5620445ef04ade58ba..fde35aae52b6a45574375d1e2ecc8e0f52a828d5 100644 (file)
@@ -53,7 +53,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index f8b7ecfad41e2d3e216a6ae8772e42bfa5c7220a..d6ecbf318ae430b1d495257e04bb2009c46b6517 100644 (file)
@@ -45,8 +45,8 @@ main(void)
 
        ao_task_init();
        ao_serial_init();
-       ao_led_init(LEDS_AVAILABLE);
-       ao_led_on(AO_LED_GREEN);
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
        ao_i2c_init();
@@ -98,6 +98,7 @@ main(void)
        ao_sample_profile_init();
 #endif
        
+       ao_led_off(LEDS_AVAILABLE);
        ao_start_scheduler();
        return 0;
 }
index 372d53b8b26c9ad942e4fe6a1ffacdcbb0320904..62eda4ad2192a3efb49e676cc417c62c3c4b499d 100644 (file)
@@ -55,7 +55,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 50428b61d77941795f90f17cf3c0ce4b76ad7cba..328c17ff0516e5cf4ca40b523f6d26f3faa6fbed 100644 (file)
@@ -45,7 +45,7 @@ main(void)
 
        ao_task_init();
        ao_serial_init();
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
index 2592587aeb8882f2a1cddabedc3662f1a5ea5229..78829fff4452aa120f084eaa03e6f9bb6f091b9a 100644 (file)
@@ -55,7 +55,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 6a58547eda8b58d7b51785fe611c85737c180b63..623e8d1ea5803e6d1edb713091a93fae77edb9d6 100644 (file)
@@ -46,7 +46,7 @@ main(void)
 
        ao_task_init();
        ao_serial_init();
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
index df0f4dbb5d97a12cdf16a761aaa9be9a0a081cc0..b449b397accb99b2c620e8bc4169ae7a2d264670 100644 (file)
@@ -53,7 +53,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 2577f90c60fab7c9765d1e7debea0e547c1a8f2c..d987c1ec5cb8d4c1a01c8e28a6744feec42ed465 100644 (file)
@@ -45,7 +45,7 @@ main(void)
 
        ao_task_init();
        ao_serial_init();
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
index 0196936b9b51d07fc84b1a6c8c2338f4a3bb37b2..e0192f610721fc5221422d7ad634e55cbb1ca412 100644 (file)
@@ -46,7 +46,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 65f9be2c0bdd00ee8d98a84d4a2c2f03b3229199..dbf6090cc9a5e2aff1173e4fd4cf7f4fcbc6234a 100644 (file)
@@ -43,7 +43,7 @@ main(void)
 
        ao_task_init();
        ao_serial_init();
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
index c72e781a0a3f608ce666f240520b0ae154009350..071fd8dd17f889031634365980ebcc7bff064729 100644 (file)
@@ -46,7 +46,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 2bb5192aef97d6014464cbcbab386c81cab47700..d75f339df3886f2edbe3fa30dfbebbbb7b7ee7c6 100644 (file)
@@ -43,8 +43,8 @@ main(void)
 
        ao_task_init();
        ao_serial_init();
-       ao_led_init(LEDS_AVAILABLE);
-       ao_led_on(AO_LED_RED);
+       ao_led_init();
+       ao_led_on(LEDS_AVAILABLE);
        ao_timer_init();
 
        ao_spi_init();
@@ -88,6 +88,7 @@ main(void)
 #if HAS_SAMPLE_PROFILE
        ao_sample_profile_init();
 #endif
+       ao_led_off(LEDS_AVAILABLE);
 
        ao_start_scheduler();
        return 0;
index dcac03dc57ffa35ac166591705eb3e3f4cb0e407..9b51d466e29d98ce3418a57928c33a427dd79474 100644 (file)
@@ -29,7 +29,7 @@ ALTOS_SRC = \
        ao_stdio.c \
        ao_task.c \
        ao_timer.c \
-       ao_led.c \
+       ao_led_avr.c \
        ao_avr_stdio.c \
        ao_romconfig.c \
        ao_usb_avr.c \
index 493bd4800e0d3628ad5b4bbe697fd8b710fcad4b..10c63d49ae9c0ced9575023fcab6d5a65eb78aa5 100644 (file)
@@ -42,7 +42,7 @@ ALTOS_SRC = \
        ao_stdio.c \
        ao_task.c \
        ao_timer.c \
-       ao_led.c \
+       ao_led_avr.c \
        ao_avr_stdio.c \
        ao_romconfig.c \
        ao_usb_avr.c \
index c55c48e2a347c2d70f7cf41941934ba49c45ee23..8445c64dc85e00abeeee15a13336cd05a6bdda11 100644 (file)
@@ -42,7 +42,7 @@ ALTOS_SRC = \
        ao_stdio.c \
        ao_task.c \
        ao_timer.c \
-       ao_led.c \
+       ao_led_avr.c \
        ao_avr_stdio.c \
        ao_romconfig.c \
        ao_usb_avr.c \
index 6b7ea8c783ec6e441587a39f163c67e56c83af58..bc0a1986bf6fe7294d7232a94c2cbae3493f67d1 100644 (file)
@@ -35,7 +35,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 9e3965c629bad22e5eb4e55cbd60b7c41723a7b1..8a1293d2f0627e0b93f210f6bbfa7f41c598a71a 100644 (file)
@@ -46,7 +46,7 @@ ALTOS_SRC = \
        ao_cmd.c \
        ao_config.c \
        ao_task.c \
-       ao_led.c \
+       ao_led_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
index 49798f1c85aa8ae6749e680d75151ff7aa44b897..678a24de4c2777040327c90c8cabef676628d392 100644 (file)
@@ -27,7 +27,7 @@ ALTOS_SRC = \
        ao_adc_fast.c \
        ao_crc_stm.c \
        ao_stdio.c \
-       ao_led.c \
+       ao_led_stmf0.c \
        ao_romconfig.c \
        ao_boot_chain.c \
        ao_cmd.c \