]> git.gag.com Git - fw/altos/commitdiff
first cut at adding "health" LED management task
authorBdale Garbee <bdale@gag.com>
Sat, 27 Jul 2024 23:40:18 +0000 (17:40 -0600)
committerBdale Garbee <bdale@gag.com>
Tue, 6 May 2025 18:37:26 +0000 (12:37 -0600)
src/quantimotor-v1/Makefile
src/quantimotor-v1/ao_pins.h
src/quantimotor-v1/ao_quantimotor.c

index d033f920749adb45629e911b80abacaf696f7e17..3022bd0da14626dd66f828b83638e2f995325cc7 100644 (file)
@@ -33,7 +33,8 @@ ALTOS_SRC = \
        ao_romconfig.c \
        ao_adc_lpc.c \
        ao_serial_lpc.c \
-       ao_usb_lpc.c 
+       ao_usb_lpc.c \
+       ao_led_lpc.c
 
 PRODUCT=QuantiMotor-v1
 PRODUCT_DEF=-DQUANTIMOTOR_V_1
index 22a731fe90c44ca8021bfda6253a5822a3daa4bf..e352cf6e7c0dabc73eba21b0293ec873cb596d0c 100644 (file)
 
 #define AO_DATA_RING           16
 
+/* SOM sets "health" high when system is ready */
+#define HEALTH_PORT            1
+#define HEALTH_PIN             19
+
+/* LED */
+
+#define LED_PORT                0
+#define LED_PIN_HEALTH          8
+#define AO_LED_HEALTH           (1 << LED_PIN_HEALTH)
+#define LEDS_AVAILABLE          (AO_LED_HEALTH)
+#define AO_LED_PANIC           AO_LED_HEALTH
+
 /*
  * ADC
  */
index d15f248f2defffbac773dd0779a3e3bd6613c02b..33ba6940e77ab8e198a263adae203df4386b27a3 100644 (file)
@@ -5,9 +5,11 @@
 
 #include <ao.h>
 #include <ao_serial.h>
+#include <ao_exti.h>
 
 static struct ao_task ao_console_read_task;
 static struct ao_task ao_console_write_task;
+static struct ao_task ao_health_indicator_task;
 
 static void
 ao_console_read(void)
@@ -35,6 +37,27 @@ ao_console_write(void)
         }
 }
 
+static void
+ao_health_indicator(void)
+{
+       int     ledstate = 0;
+
+        for (;;) {
+               if (ao_gpio_get(HEALTH_PORT, HEALTH_PIN)) {
+                       ao_led_on(AO_LED_HEALTH);
+               } else {
+                       if (ledstate) {
+                               ledstate = 0;
+                               ao_led_off(AO_LED_HEALTH);
+                       } else {
+                               ledstate = 1;
+                               ao_led_on(AO_LED_HEALTH);
+                       }
+               }
+               ao_delay(AO_MS_TO_TICKS(1000));
+       }
+}
+
 int
 main(void)
 {
@@ -42,6 +65,12 @@ main(void)
        ao_task_init();
        ao_timer_init();
 
+       ao_led_init();
+
+       /* set up the input we watch to sense SOM "health" */
+       /* choosing pull down so SOM has to actually assert readiness */
+       ao_enable_input(HEALTH_PORT, HEALTH_PIN, AO_EXTI_MODE_PULL_DOWN);
+
        ao_adc_init();
 
        ao_usb_init();
@@ -54,6 +83,7 @@ main(void)
 
        ao_add_task(&ao_console_read_task, ao_console_read, "console_read");
        ao_add_task(&ao_console_write_task, ao_console_write, "console_write");
+       ao_add_task(&ao_health_indicator_task, ao_health_indicator, "health_indicator");
 
        ao_start_scheduler();
        return 0;