altos/telemini-v3.0: Add 'recovery mode' on PA14 (pin 6 on dbg header)
authorKeith Packard <keithp@keithp.com>
Fri, 5 May 2017 05:07:51 +0000 (22:07 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 5 May 2017 05:10:36 +0000 (22:10 -0700)
Connect this pin to GND (pin 3) and TeleMini will come up with N0CALL
at 434.550MHz using the original frequency calibration. Helps recover
from accidental mis-configuration.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/telemini-v3.0/ao_pins.h
src/telemini-v3.0/ao_telemini.c

index 0551e1fcbb0707150390d4e5522634345c6c05fd..17cff2aeb0e53497316fcc34e718888f9484d791 100644 (file)
 #define HAS_IGNITE_REPORT      1
 #define AO_SMALL_ALTITUDE_TABLE        1
 
+/* Use debug connector clock for recovery mode */
+#define HAS_FORCE_FREQ         1
+#define AO_RECOVERY_PORT       (&stm_gpioa)
+#define AO_RECOVERY_PIN                14
+#define AO_RECOVERY_VALUE      0
+#define AO_RECOVERY_MODE       AO_EXTI_MODE_PULL_UP
+
 /* Beeper is on Tim1 CH3 */
 #define BEEPER_CHANNEL         4
 #define BEEPER_TIMER           2
index ecd16dd204adbaeef418b786698710f13033a0d0..a50268b9001ffd0247495460f469554d99343794 100644 (file)
 #include <ao.h>
 #include <ao_exti.h>
 
+static void
+ao_check_recovery(void)
+{
+       int     i;
+       ao_enable_input(AO_RECOVERY_PORT, AO_RECOVERY_PIN, AO_RECOVERY_MODE);
+       for (i = 0; i < 100; i++)
+               ao_arch_nop();
+       if (ao_gpio_get(AO_RECOVERY_PORT, AO_RECOVERY_PIN, AO_RECOVERY) == AO_RECOVERY_VALUE) {
+               ao_flight_force_idle = 1;
+               ao_force_freq = 1;
+       }
+       ao_gpio_set_mode(AO_RECOVERY_PORT, AO_RECOVERY_PIN, 0);
+       ao_disable_port(AO_RECOVERY_PORT);
+}
+
 void
 main(void)
 {
+       ao_check_recovery();
+
        ao_clock_init();
        ao_task_init();
        ao_timer_init();