summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2018-09-11 11:57:50 -0700
committerKeith Packard <keithp@keithp.com>2018-10-13 08:23:25 -0700
commit2cdb1f30c49ba460b0850d23ba9c85e0336af290 (patch)
tree880abd83761ec7ce5511b30ee621057eeb8412d8
parentcdaa0d7b272505c49017f409b7c0b8e3240608f0 (diff)
altos: Add generic LED driver.
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>
-rw-r--r--src/attiny/ao_arch.h2
-rw-r--r--src/attiny/ao_led_tiny.c (renamed from src/attiny/ao_led.c)19
-rw-r--r--src/avr-demo/Makefile2
-rw-r--r--src/avr/ao_led_avr.c (renamed from src/avr/ao_led.c)0
-rw-r--r--src/chaoskey-v0.1/Makefile2
-rw-r--r--src/chaoskey-v1.0/Makefile2
-rw-r--r--src/chaoskey-v1.0/ao_chaoskey.c2
-rw-r--r--src/detherm/Makefile2
-rw-r--r--src/drivers/ao_led.c (renamed from src/stm/ao_led.c)150
-rw-r--r--src/easymega-v1.0/Makefile2
-rw-r--r--src/easymega-v1.0/ao_easymega.c2
-rw-r--r--src/fox1ihu/Makefile2
-rw-r--r--src/fox1ihu/ao_fox1ihu.c2
-rw-r--r--src/kernel/ao.h2
-rw-r--r--src/kernel/ao_led.h202
-rw-r--r--src/kernel/ao_task.c1
-rw-r--r--src/kernel/ao_task.h2
-rw-r--r--src/lambdakey-v1.0/Makefile2
-rw-r--r--src/lpc/ao_led_lpc.c17
-rw-r--r--src/megadongle-v0.1/Makefile2
-rw-r--r--src/microkite/Makefile2
-rw-r--r--src/micropeak-v2.0/Makefile2
-rw-r--r--src/micropeak-v2.0/ao_micropeak.c2
-rw-r--r--src/micropeak/Makefile2
-rw-r--r--src/microsplash/Makefile2
-rw-r--r--src/nanopeak-v0.1/Makefile2
-rw-r--r--src/nucleao-32/Makefile2
-rw-r--r--src/pnpservo-v1/Makefile2
-rw-r--r--src/product/ao_micropeak.c2
-rw-r--r--src/stm-demo/Makefile2
-rw-r--r--src/stm-scheme-newlib/Makefile2
-rw-r--r--src/stm-vga/Makefile2
-rw-r--r--src/stm/ao_led_stm.c144
-rw-r--r--src/stm32f4-disco/Makefile5
-rw-r--r--src/stm32f4-disco/ao_disco.c41
-rw-r--r--src/stm32f4-disco/ao_pins.h29
-rw-r--r--src/stm32f4/ao_arch.h3
-rw-r--r--src/stm32f4/ao_arch_funcs.h228
-rw-r--r--src/stmf0/ao_led_stmf0.c (renamed from src/stmf0/ao_led.c)45
-rw-r--r--src/teleballoon-v2.0/Makefile2
-rw-r--r--src/teleballoon-v2.0/ao_teleballoon.c7
-rw-r--r--src/telebt-v3.0/Makefile2
-rw-r--r--src/telebt-v3.0/ao_telebt.c2
-rw-r--r--src/telebt-v4.0/Makefile2
-rw-r--r--src/telebt-v4.0/ao_telebt.c2
-rw-r--r--src/teledongle-v1.8/Makefile2
-rw-r--r--src/teledongle-v3.0/ao_teledongle.c2
-rw-r--r--src/telefireeight-v1.0/ao_pins.h29
-rw-r--r--src/telefireeight-v1.0/ao_telefireeight.c5
-rw-r--r--src/telefireone-v1.0/Makefile2
-rw-r--r--src/telefiretwo-v0.1/Makefile2
-rw-r--r--src/telefiretwo-v0.1/ao_telefiretwo.c5
-rw-r--r--src/telefiretwo-v0.2/Makefile2
-rw-r--r--src/telegps-v0.1/Makefile2
-rw-r--r--src/telegps-v2.0/Makefile2
-rw-r--r--src/telegps-v2.0/ao_telegps.c7
-rw-r--r--src/telelco-v0.2-cc1200/Makefile2
-rw-r--r--src/telelco-v0.2-cc1200/ao_telelco.c7
-rw-r--r--src/telelco-v0.2/Makefile2
-rw-r--r--src/telelco-v0.2/ao_telelco.c14
-rw-r--r--src/telelco-v0.3/Makefile2
-rw-r--r--src/telelco-v0.3/ao_telelco.c6
-rw-r--r--src/telelco-v2.0/ao_lco_v2.c4
-rw-r--r--src/telelco-v2.0/ao_pins.h73
-rw-r--r--src/telelco-v2.0/ao_telelco.c6
-rw-r--r--src/telelcotwo-v0.1/Makefile2
-rw-r--r--src/telelcotwo-v0.1/ao_telelcotwo.c6
-rw-r--r--src/telemega-v0.1/Makefile2
-rw-r--r--src/telemega-v0.1/ao_telemega.c5
-rw-r--r--src/telemega-v1.0/Makefile2
-rw-r--r--src/telemega-v1.0/ao_telemega.c2
-rw-r--r--src/telemega-v2.0/Makefile2
-rw-r--r--src/telemega-v2.0/ao_telemega.c2
-rw-r--r--src/telemega-v3.0/Makefile2
-rw-r--r--src/telemega-v3.0/ao_telemega.c2
-rw-r--r--src/telemetrum-v2.0/Makefile2
-rw-r--r--src/telemetrum-v2.0/ao_telemetrum.c2
-rw-r--r--src/telemetrum-v3.0/Makefile2
-rw-r--r--src/telemetrum-v3.0/ao_telemetrum.c5
-rw-r--r--src/telepyro-v0.1/Makefile2
-rw-r--r--src/telescience-pwm/Makefile2
-rw-r--r--src/telescience-v0.1/Makefile2
-rw-r--r--src/telescience-v0.2/Makefile2
-rw-r--r--src/tmgps-v2.0/Makefile2
-rw-r--r--src/usbtrng-v2.0/Makefile2
85 files changed, 843 insertions, 336 deletions
diff --git a/src/attiny/ao_arch.h b/src/attiny/ao_arch.h
index 84a94be7..a9c450fc 100644
--- a/src/attiny/ao_arch.h
+++ b/src/attiny/ao_arch.h
@@ -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_tiny.c
index 88505490..cd620f46 100644
--- a/src/attiny/ao_led.c
+++ b/src/attiny/ao_led_tiny.c
@@ -18,37 +18,35 @@
#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);
+ LED_PORT |= colors;
}
void
ao_led_off(uint8_t colors)
{
- LED_PORT &= ~(colors & ao_led_enable);
+ LED_PORT &= ~colors;
}
void
ao_led_set(uint8_t colors)
{
- LED_PORT = (LED_PORT & ~(ao_led_enable)) | (colors & ao_led_enable);
+ LED_PORT = (LED_PORT & ~LEDS_AVAILABLE) | (colors & LEDS_AVAILABLE);
}
void
ao_led_toggle(uint8_t colors)
{
- LED_PORT ^= (colors & ao_led_enable);
+ LED_PORT ^= (colors & LEDS_AVAILABLE);
}
void
-ao_led_for(uint8_t colors, uint16_t ticks)
+ao_led_for(uint8_t colors, AO_TICK_TYPE ticks)
{
ao_led_on(colors);
ao_delay(ticks);
@@ -56,9 +54,8 @@ ao_led_for(uint8_t colors, uint16_t ticks)
}
void
-ao_led_init(uint8_t enable)
+ao_led_init(void)
{
- ao_led_enable = enable;
- LED_PORT &= ~enable;
- LED_DDR |= enable;
+ LED_PORT &= ~LEDS_AVAILABLE;
+ LED_DDR |= LEDS_AVAILABLE;
}
diff --git a/src/avr-demo/Makefile b/src/avr-demo/Makefile
index e21ad047..0aca6f8a 100644
--- a/src/avr-demo/Makefile
+++ b/src/avr-demo/Makefile
@@ -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_avr.c
index 165e95d3..165e95d3 100644
--- a/src/avr/ao_led.c
+++ b/src/avr/ao_led_avr.c
diff --git a/src/chaoskey-v0.1/Makefile b/src/chaoskey-v0.1/Makefile
index 85392280..faa4a291 100644
--- a/src/chaoskey-v0.1/Makefile
+++ b/src/chaoskey-v0.1/Makefile
@@ -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 \
diff --git a/src/chaoskey-v1.0/Makefile b/src/chaoskey-v1.0/Makefile
index c6cf45bd..329f603d 100644
--- a/src/chaoskey-v1.0/Makefile
+++ b/src/chaoskey-v1.0/Makefile
@@ -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 \
diff --git a/src/chaoskey-v1.0/ao_chaoskey.c b/src/chaoskey-v1.0/ao_chaoskey.c
index 1165e454..80f5a4ba 100644
--- a/src/chaoskey-v1.0/ao_chaoskey.c
+++ b/src/chaoskey-v1.0/ao_chaoskey.c
@@ -24,7 +24,7 @@
void main(void)
{
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_clock_init();
ao_task_init();
ao_timer_init();
diff --git a/src/detherm/Makefile b/src/detherm/Makefile
index 6b0e0bf8..7681a049 100644
--- a/src/detherm/Makefile
+++ b/src/detherm/Makefile
@@ -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/stm/ao_led.c b/src/drivers/ao_led.c
index 481a6e87..0f7b7c27 100644
--- a/src/stm/ao_led.c
+++ b/src/drivers/ao_led.c
@@ -1,5 +1,5 @@
/*
- * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ * 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
@@ -18,7 +18,6 @@
#include "ao.h"
-#if LED_PER_LED
static const struct {
struct stm_gpio *port;
uint16_t pin;
@@ -71,146 +70,105 @@ static const struct {
#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]))
-#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);
+ 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)
{
-#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_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(AO_LED_TYPE enable)
+ao_led_init(void)
{
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/easymega-v1.0/Makefile b/src/easymega-v1.0/Makefile
index 3344da06..76e7319e 100644
--- a/src/easymega-v1.0/Makefile
+++ b/src/easymega-v1.0/Makefile
@@ -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 \
diff --git a/src/easymega-v1.0/ao_easymega.c b/src/easymega-v1.0/ao_easymega.c
index 9848c367..d00585f9 100644
--- a/src/easymega-v1.0/ao_easymega.c
+++ b/src/easymega-v1.0/ao_easymega.c
@@ -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();
diff --git a/src/fox1ihu/Makefile b/src/fox1ihu/Makefile
index e3226a24..61314db9 100644
--- a/src/fox1ihu/Makefile
+++ b/src/fox1ihu/Makefile
@@ -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 \
diff --git a/src/fox1ihu/ao_fox1ihu.c b/src/fox1ihu/ao_fox1ihu.c
index 2e1a2fdf..5ebb4b54 100644
--- a/src/fox1ihu/ao_fox1ihu.c
+++ b/src/fox1ihu/ao_fox1ihu.c
@@ -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();
diff --git a/src/kernel/ao.h b/src/kernel/ao.h
index 9c0c8604..1b269d73 100644
--- a/src/kernel/ao.h
+++ b/src/kernel/ao.h
@@ -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
diff --git a/src/kernel/ao_led.h b/src/kernel/ao_led.h
index 803f85b3..5d982ca6 100644
--- a/src/kernel/ao_led.h
+++ b/src/kernel/ao_led.h
@@ -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_ */
diff --git a/src/kernel/ao_task.c b/src/kernel/ao_task.c
index 4f7072cb..dc5c1913 100644
--- a/src/kernel/ao_task.c
+++ b/src/kernel/ao_task.c
@@ -569,4 +569,5 @@ ao_start_scheduler(void)
ao_arch_start_scheduler();
#endif
ao_yield();
+ __builtin_unreachable();
}
diff --git a/src/kernel/ao_task.h b/src/kernel/ao_task.h
index ffeb7313..f3789fa2 100644
--- a/src/kernel/ao_task.h
+++ b/src/kernel/ao_task.h
@@ -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
diff --git a/src/lambdakey-v1.0/Makefile b/src/lambdakey-v1.0/Makefile
index b94c3873..f8b5c7f5 100644
--- a/src/lambdakey-v1.0/Makefile
+++ b/src/lambdakey-v1.0/Makefile
@@ -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 \
diff --git a/src/lpc/ao_led_lpc.c b/src/lpc/ao_led_lpc.c
index 5fc726c0..3a2d4c98 100644
--- a/src/lpc/ao_led_lpc.c
+++ b/src/lpc/ao_led_lpc.c
@@ -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);
}
diff --git a/src/megadongle-v0.1/Makefile b/src/megadongle-v0.1/Makefile
index bbe2ea58..4290e088 100644
--- a/src/megadongle-v0.1/Makefile
+++ b/src/megadongle-v0.1/Makefile
@@ -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 \
diff --git a/src/microkite/Makefile b/src/microkite/Makefile
index b7523758..5eb97206 100644
--- a/src/microkite/Makefile
+++ b/src/microkite/Makefile
@@ -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 \
diff --git a/src/micropeak-v2.0/Makefile b/src/micropeak-v2.0/Makefile
index 32154fa6..c7d1b22d 100644
--- a/src/micropeak-v2.0/Makefile
+++ b/src/micropeak-v2.0/Makefile
@@ -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 \
diff --git a/src/micropeak-v2.0/ao_micropeak.c b/src/micropeak-v2.0/ao_micropeak.c
index 1cfa1209..df557e60 100644
--- a/src/micropeak-v2.0/ao_micropeak.c
+++ b/src/micropeak-v2.0/ao_micropeak.c
@@ -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();
diff --git a/src/micropeak/Makefile b/src/micropeak/Makefile
index 6e8cae14..f80d61b0 100644
--- a/src/micropeak/Makefile
+++ b/src/micropeak/Makefile
@@ -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 \
diff --git a/src/microsplash/Makefile b/src/microsplash/Makefile
index 9bb636f1..0342838e 100644
--- a/src/microsplash/Makefile
+++ b/src/microsplash/Makefile
@@ -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 \
diff --git a/src/nanopeak-v0.1/Makefile b/src/nanopeak-v0.1/Makefile
index d3779594..774d4adc 100644
--- a/src/nanopeak-v0.1/Makefile
+++ b/src/nanopeak-v0.1/Makefile
@@ -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 \
diff --git a/src/nucleao-32/Makefile b/src/nucleao-32/Makefile
index 2b9fe14f..1ab2eea1 100644
--- a/src/nucleao-32/Makefile
+++ b/src/nucleao-32/Makefile
@@ -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 \
diff --git a/src/pnpservo-v1/Makefile b/src/pnpservo-v1/Makefile
index 8606b1ae..443a6afb 100644
--- a/src/pnpservo-v1/Makefile
+++ b/src/pnpservo-v1/Makefile
@@ -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 \
diff --git a/src/product/ao_micropeak.c b/src/product/ao_micropeak.c
index 8aac79cd..8fed3069 100644
--- a/src/product/ao_micropeak.c
+++ b/src/product/ao_micropeak.c
@@ -57,7 +57,7 @@ ao_pips(void)
int
main(void)
{
- ao_led_init(LEDS_AVAILABLE);
+ ao_led_init();
ao_timer_init();
/* Init external hardware */
diff --git a/src/stm-demo/Makefile b/src/stm-demo/Makefile
index d4569c1a..ccce37a5 100644
--- a/src/stm-demo/Makefile
+++ b/src/stm-demo/Makefile
@@ -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 \
diff --git a/src/stm-scheme-newlib/Makefile b/src/stm-scheme-newlib/Makefile
index a4c249a3..1db58f10 100644
--- a/src/stm-scheme-newlib/Makefile
+++ b/src/stm-scheme-newlib/Makefile
@@ -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 \
diff --git a/src/stm-vga/Makefile b/src/stm-vga/Makefile
index 46a77272..fa0d008f 100644
--- a/src/stm-vga/Makefile
+++ b/src/stm-vga/Makefile
@@ -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_stm.c b/src/stm/ao_led_stm.c
new file mode 100644
index 00000000..7dcbb661
--- /dev/null
+++ b/src/stm/ao_led_stm.c
@@ -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
+ }
+ }
+}
diff --git a/src/stm32f4-disco/Makefile b/src/stm32f4-disco/Makefile
index 2d912b22..c970b879 100644
--- a/src/stm32f4-disco/Makefile
+++ b/src/stm32f4-disco/Makefile
@@ -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)
diff --git a/src/stm32f4-disco/ao_disco.c b/src/stm32f4-disco/ao_disco.c
index efbed947..c6cdbd23 100644
--- a/src/stm32f4-disco/ao_disco.c
+++ b/src/stm32f4-disco/ao_disco.c
@@ -14,24 +14,35 @@
#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();
}
diff --git a/src/stm32f4-disco/ao_pins.h b/src/stm32f4-disco/ao_pins.h
index c4dc5b4b..bbbc306e 100644
--- a/src/stm32f4-disco/ao_pins.h
+++ b/src/stm32f4-disco/ao_pins.h
@@ -14,16 +14,7 @@
#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 */
@@ -43,4 +34,22 @@
#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_ */
diff --git a/src/stm32f4/ao_arch.h b/src/stm32f4/ao_arch.h
index 805d756d..73eb793f 100644
--- a/src/stm32f4/ao_arch.h
+++ b/src/stm32f4/ao_arch.h
@@ -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
diff --git a/src/stm32f4/ao_arch_funcs.h b/src/stm32f4/ao_arch_funcs.h
index 252fe77a..8c0da03b 100644
--- a/src/stm32f4/ao_arch_funcs.h
+++ b/src/stm32f4/ao_arch_funcs.h
@@ -15,6 +15,234 @@
#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_stmf0.c
index a162932a..1564535e 100644
--- a/src/stmf0/ao_led.c
+++ b/src/stmf0/ao_led_stmf0.c
@@ -18,65 +18,63 @@
#include "ao.h"
-uint16_t ao_led_enable;
-
void
-ao_led_on(uint16_t colors)
+ao_led_on(AO_LED_TYPE colors)
{
#ifdef LED_PORT
- LED_PORT->bsrr = (colors & ao_led_enable);
+ LED_PORT->bsrr = (colors & LEDS_AVAILABLE);
#else
#ifdef LED_PORT_0
- LED_PORT_0->bsrr = ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+ 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 & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+ LED_PORT_1->bsrr = ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
#endif
#endif
}
void
-ao_led_off(uint16_t colors)
+ao_led_off(AO_LED_TYPE colors)
{
#ifdef LED_PORT
- LED_PORT->bsrr = (uint32_t) (colors & ao_led_enable) << 16;
+ LED_PORT->bsrr = (uint32_t) (colors & LEDS_AVAILABLE) << 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);
+ 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 & ao_led_enable) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16);
+ LED_PORT_1->bsrr = ((uint32_t) (colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << (LED_PORT_1_SHIFT + 16);
#endif
#endif
}
void
-ao_led_set(uint16_t colors)
+ao_led_set(AO_LED_TYPE colors)
{
- uint16_t on = colors & ao_led_enable;
- uint16_t off = ~colors & ao_led_enable;
+ 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(uint16_t colors)
+ao_led_toggle(AO_LED_TYPE colors)
{
#ifdef LED_PORT
- LED_PORT->odr ^= (colors & ao_led_enable);
+ LED_PORT->odr ^= (colors & LEDS_AVAILABLE);
#else
#ifdef LED_PORT_0
- LED_PORT_0->odr ^= ((colors & ao_led_enable) & LED_PORT_0_MASK) << LED_PORT_0_SHIFT;
+ 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 & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+ LED_PORT_1->odr ^= ((colors & LEDS_AVAILABLE) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
#endif
#endif
}
void
-ao_led_for(uint16_t colors, uint16_t ticks)
+ao_led_for(AO_LED_TYPE colors, AO_TICK_TYPE ticks)
{
ao_led_on(colors);
ao_delay(ticks);
@@ -89,26 +87,25 @@ ao_led_for(uint16_t colors, uint16_t ticks)
} while (0)
void
-ao_led_init(uint16_t enable)
+ao_led_init(void)
{
int bit;
- ao_led_enable = enable;
#ifdef LED_PORT
stm_rcc.ahbenr |= (1 << LED_PORT_ENABLE);
- LED_PORT->odr &= ~enable;
+ LED_PORT->odr &= ~LEDS_AVAILABLE;
#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;
+ 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 &= ~((enable & ao_led_enable) & LED_PORT_1_MASK) << LED_PORT_1_SHIFT;
+ 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 (enable & (1 << bit)) {
+ if (LEDS_AVAILABLE & (1 << bit)) {
#ifdef LED_PORT
init_led_pin(LED_PORT, bit);
#else
diff --git a/src/teleballoon-v2.0/Makefile b/src/teleballoon-v2.0/Makefile
index cb2ce253..ddbfaf5f 100644
--- a/src/teleballoon-v2.0/Makefile
+++ b/src/teleballoon-v2.0/Makefile
@@ -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 \
diff --git a/src/teleballoon-v2.0/ao_teleballoon.c b/src/teleballoon-v2.0/ao_teleballoon.c
index acb11f44..94393da0 100644
--- a/src/teleballoon-v2.0/ao_teleballoon.c
+++ b/src/teleballoon-v2.0/ao_teleballoon.c
@@ -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;
}
diff --git a/src/telebt-v3.0/Makefile b/src/telebt-v3.0/Makefile
index 4636c046..9892ad5f 100644
--- a/src/telebt-v3.0/Makefile
+++ b/src/telebt-v3.0/Makefile
@@ -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 \
diff --git a/src/telebt-v3.0/ao_telebt.c b/src/telebt-v3.0/ao_telebt.c
index 63633c90..3d48b6b9 100644
--- a/src/telebt-v3.0/ao_telebt.c
+++ b/src/telebt-v3.0/ao_telebt.c
@@ -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();
diff --git a/src/telebt-v4.0/Makefile b/src/telebt-v4.0/Makefile
index 38ac7513..4ad3287d 100644
--- a/src/telebt-v4.0/Makefile
+++ b/src/telebt-v4.0/Makefile
@@ -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 \
diff --git a/src/telebt-v4.0/ao_telebt.c b/src/telebt-v4.0/ao_telebt.c
index 953ec4bc..7c3c6e2a 100644
--- a/src/telebt-v4.0/ao_telebt.c
+++ b/src/telebt-v4.0/ao_telebt.c
@@ -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();
diff --git a/src/teledongle-v1.8/Makefile b/src/teledongle-v1.8/Makefile
index 6c05ce9f..461b5855 100644
--- a/src/teledongle-v1.8/Makefile
+++ b/src/teledongle-v1.8/Makefile
@@ -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 \
diff --git a/src/teledongle-v3.0/ao_teledongle.c b/src/teledongle-v3.0/ao_teledongle.c
index 32899af2..69abea6e 100644
--- a/src/teledongle-v3.0/ao_teledongle.c
+++ b/src/teledongle-v3.0/ao_teledongle.c
@@ -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();
diff --git a/src/telefireeight-v1.0/ao_pins.h b/src/telefireeight-v1.0/ao_pins.h
index 15e1fa11..ef533b36 100644
--- a/src/telefireeight-v1.0/ao_pins.h
+++ b/src/telefireeight-v1.0/ao_pins.h
@@ -107,7 +107,7 @@
#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 */
@@ -128,14 +128,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)
@@ -151,19 +145,10 @@
#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
diff --git a/src/telefireeight-v1.0/ao_telefireeight.c b/src/telefireeight-v1.0/ao_telefireeight.c
index bdcf3213..89541a02 100644
--- a/src/telefireeight-v1.0/ao_telefireeight.c
+++ b/src/telefireeight-v1.0/ao_telefireeight.c
@@ -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();
}
diff --git a/src/telefireone-v1.0/Makefile b/src/telefireone-v1.0/Makefile
index 53f088cb..773c8f69 100644
--- a/src/telefireone-v1.0/Makefile
+++ b/src/telefireone-v1.0/Makefile
@@ -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 \
diff --git a/src/telefiretwo-v0.1/Makefile b/src/telefiretwo-v0.1/Makefile
index 6454d6fd..72171fac 100644
--- a/src/telefiretwo-v0.1/Makefile
+++ b/src/telefiretwo-v0.1/Makefile
@@ -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 \
diff --git a/src/telefiretwo-v0.1/ao_telefiretwo.c b/src/telefiretwo-v0.1/ao_telefiretwo.c
index bdcf3213..89541a02 100644
--- a/src/telefiretwo-v0.1/ao_telefiretwo.c
+++ b/src/telefiretwo-v0.1/ao_telefiretwo.c
@@ -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();
}
diff --git a/src/telefiretwo-v0.2/Makefile b/src/telefiretwo-v0.2/Makefile
index 30985f9c..f43ece71 100644
--- a/src/telefiretwo-v0.2/Makefile
+++ b/src/telefiretwo-v0.2/Makefile
@@ -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 \
diff --git a/src/telegps-v0.1/Makefile b/src/telegps-v0.1/Makefile
index 46eb0ac5..0365f91f 100644
--- a/src/telegps-v0.1/Makefile
+++ b/src/telegps-v0.1/Makefile
@@ -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 \
diff --git a/src/telegps-v2.0/Makefile b/src/telegps-v2.0/Makefile
index 19d088d3..617efa65 100644
--- a/src/telegps-v2.0/Makefile
+++ b/src/telegps-v2.0/Makefile
@@ -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 \
diff --git a/src/telegps-v2.0/ao_telegps.c b/src/telegps-v2.0/ao_telegps.c
index 998c2008..1ba67f67 100644
--- a/src/telegps-v2.0/ao_telegps.c
+++ b/src/telegps-v2.0/ao_telegps.c
@@ -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;
}
diff --git a/src/telelco-v0.2-cc1200/Makefile b/src/telelco-v0.2-cc1200/Makefile
index 4ccf494c..9307aa2d 100644
--- a/src/telelco-v0.2-cc1200/Makefile
+++ b/src/telelco-v0.2-cc1200/Makefile
@@ -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 \
diff --git a/src/telelco-v0.2-cc1200/ao_telelco.c b/src/telelco-v0.2-cc1200/ao_telelco.c
index 3266da00..26f49d59 100644
--- a/src/telelco-v0.2-cc1200/ao_telelco.c
+++ b/src/telelco-v0.2-cc1200/ao_telelco.c
@@ -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;
}
diff --git a/src/telelco-v0.2/Makefile b/src/telelco-v0.2/Makefile
index 8279cac1..91ae67f0 100644
--- a/src/telelco-v0.2/Makefile
+++ b/src/telelco-v0.2/Makefile
@@ -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 \
diff --git a/src/telelco-v0.2/ao_telelco.c b/src/telelco-v0.2/ao_telelco.c
index 7b04d386..4eba3597 100644
--- a/src/telelco-v0.2/ao_telelco.c
+++ b/src/telelco-v0.2/ao_telelco.c
@@ -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;
}
diff --git a/src/telelco-v0.3/Makefile b/src/telelco-v0.3/Makefile
index c2592bf8..567ddf41 100644
--- a/src/telelco-v0.3/Makefile
+++ b/src/telelco-v0.3/Makefile
@@ -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 \
diff --git a/src/telelco-v0.3/ao_telelco.c b/src/telelco-v0.3/ao_telelco.c
index 7b04d386..c2ca68aa 100644
--- a/src/telelco-v0.3/ao_telelco.c
+++ b/src/telelco-v0.3/ao_telelco.c
@@ -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;
}
diff --git a/src/telelco-v2.0/ao_lco_v2.c b/src/telelco-v2.0/ao_lco_v2.c
index 90324cc8..daecf380 100644
--- a/src/telelco-v2.0/ao_lco_v2.c
+++ b/src/telelco-v2.0/ao_lco_v2.c
@@ -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
diff --git a/src/telelco-v2.0/ao_pins.h b/src/telelco-v2.0/ao_pins.h
index 95998dc7..ea709c1d 100644
--- a/src/telelco-v2.0/ao_pins.h
+++ b/src/telelco-v2.0/ao_pins.h
@@ -99,13 +99,7 @@
#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)
@@ -147,56 +141,23 @@
#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 */
diff --git a/src/telelco-v2.0/ao_telelco.c b/src/telelco-v2.0/ao_telelco.c
index 9693c657..59582569 100644
--- a/src/telelco-v2.0/ao_telelco.c
+++ b/src/telelco-v2.0/ao_telelco.c
@@ -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;
}
diff --git a/src/telelcotwo-v0.1/Makefile b/src/telelcotwo-v0.1/Makefile
index c68f3eb5..6a114aae 100644
--- a/src/telelcotwo-v0.1/Makefile
+++ b/src/telelcotwo-v0.1/Makefile
@@ -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 \
diff --git a/src/telelcotwo-v0.1/ao_telelcotwo.c b/src/telelcotwo-v0.1/ao_telelcotwo.c
index b3fcd200..6ced1912 100644
--- a/src/telelcotwo-v0.1/ao_telelcotwo.c
+++ b/src/telelcotwo-v0.1/ao_telelcotwo.c
@@ -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;
}
diff --git a/src/telemega-v0.1/Makefile b/src/telemega-v0.1/Makefile
index 78cfdefd..fde35aae 100644
--- a/src/telemega-v0.1/Makefile
+++ b/src/telemega-v0.1/Makefile
@@ -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 \
diff --git a/src/telemega-v0.1/ao_telemega.c b/src/telemega-v0.1/ao_telemega.c
index f8b7ecfa..d6ecbf31 100644
--- a/src/telemega-v0.1/ao_telemega.c
+++ b/src/telemega-v0.1/ao_telemega.c
@@ -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;
}
diff --git a/src/telemega-v1.0/Makefile b/src/telemega-v1.0/Makefile
index 372d53b8..62eda4ad 100644
--- a/src/telemega-v1.0/Makefile
+++ b/src/telemega-v1.0/Makefile
@@ -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 \
diff --git a/src/telemega-v1.0/ao_telemega.c b/src/telemega-v1.0/ao_telemega.c
index 50428b61..328c17ff 100644
--- a/src/telemega-v1.0/ao_telemega.c
+++ b/src/telemega-v1.0/ao_telemega.c
@@ -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();
diff --git a/src/telemega-v2.0/Makefile b/src/telemega-v2.0/Makefile
index 2592587a..78829fff 100644
--- a/src/telemega-v2.0/Makefile
+++ b/src/telemega-v2.0/Makefile
@@ -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 \
diff --git a/src/telemega-v2.0/ao_telemega.c b/src/telemega-v2.0/ao_telemega.c
index 6a58547e..623e8d1e 100644
--- a/src/telemega-v2.0/ao_telemega.c
+++ b/src/telemega-v2.0/ao_telemega.c
@@ -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();
diff --git a/src/telemega-v3.0/Makefile b/src/telemega-v3.0/Makefile
index df0f4dbb..b449b397 100644
--- a/src/telemega-v3.0/Makefile
+++ b/src/telemega-v3.0/Makefile
@@ -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 \
diff --git a/src/telemega-v3.0/ao_telemega.c b/src/telemega-v3.0/ao_telemega.c
index 2577f90c..d987c1ec 100644
--- a/src/telemega-v3.0/ao_telemega.c
+++ b/src/telemega-v3.0/ao_telemega.c
@@ -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();
diff --git a/src/telemetrum-v2.0/Makefile b/src/telemetrum-v2.0/Makefile
index 0196936b..e0192f61 100644
--- a/src/telemetrum-v2.0/Makefile
+++ b/src/telemetrum-v2.0/Makefile
@@ -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 \
diff --git a/src/telemetrum-v2.0/ao_telemetrum.c b/src/telemetrum-v2.0/ao_telemetrum.c
index 65f9be2c..dbf6090c 100644
--- a/src/telemetrum-v2.0/ao_telemetrum.c
+++ b/src/telemetrum-v2.0/ao_telemetrum.c
@@ -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();
diff --git a/src/telemetrum-v3.0/Makefile b/src/telemetrum-v3.0/Makefile
index c72e781a..071fd8dd 100644
--- a/src/telemetrum-v3.0/Makefile
+++ b/src/telemetrum-v3.0/Makefile
@@ -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 \
diff --git a/src/telemetrum-v3.0/ao_telemetrum.c b/src/telemetrum-v3.0/ao_telemetrum.c
index 2bb5192a..d75f339d 100644
--- a/src/telemetrum-v3.0/ao_telemetrum.c
+++ b/src/telemetrum-v3.0/ao_telemetrum.c
@@ -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;
diff --git a/src/telepyro-v0.1/Makefile b/src/telepyro-v0.1/Makefile
index dcac03dc..9b51d466 100644
--- a/src/telepyro-v0.1/Makefile
+++ b/src/telepyro-v0.1/Makefile
@@ -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 \
diff --git a/src/telescience-pwm/Makefile b/src/telescience-pwm/Makefile
index 493bd480..10c63d49 100644
--- a/src/telescience-pwm/Makefile
+++ b/src/telescience-pwm/Makefile
@@ -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 \
diff --git a/src/telescience-v0.1/Makefile b/src/telescience-v0.1/Makefile
index c55c48e2..8445c64d 100644
--- a/src/telescience-v0.1/Makefile
+++ b/src/telescience-v0.1/Makefile
@@ -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 \
diff --git a/src/telescience-v0.2/Makefile b/src/telescience-v0.2/Makefile
index 6b7ea8c7..bc0a1986 100644
--- a/src/telescience-v0.2/Makefile
+++ b/src/telescience-v0.2/Makefile
@@ -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 \
diff --git a/src/tmgps-v2.0/Makefile b/src/tmgps-v2.0/Makefile
index 9e3965c6..8a1293d2 100644
--- a/src/tmgps-v2.0/Makefile
+++ b/src/tmgps-v2.0/Makefile
@@ -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 \
diff --git a/src/usbtrng-v2.0/Makefile b/src/usbtrng-v2.0/Makefile
index 49798f1c..678a24de 100644
--- a/src/usbtrng-v2.0/Makefile
+++ b/src/usbtrng-v2.0/Makefile
@@ -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 \