Force idle mode by shorting the SPI clock to ground at boot time.
authorKeith Packard <keithp@keithp.com>
Sun, 10 Jan 2010 06:06:19 +0000 (22:06 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 10 Jan 2010 06:06:19 +0000 (22:06 -0800)
This allows you to override the flight mode detection code in case the
accelerometer calibration is broken somehow. Hold the SPI clock shoted
to ground until the LED comes on, then remove it.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao.h
src/ao_flight.c
src/ao_telemetrum.c

index 1f27fe9247b290ccc9e2814229563c8f19c8152c..2c6eb2b91180d254818ca2553849a0b2cde95a90 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -618,6 +618,7 @@ extern __pdata int16_t                      ao_ground_pres;
 extern __pdata int16_t                 ao_ground_accel;
 extern __pdata int16_t                 ao_min_pres;
 extern __pdata uint16_t                        ao_launch_time;
 extern __pdata int16_t                 ao_ground_accel;
 extern __pdata int16_t                 ao_min_pres;
 extern __pdata uint16_t                        ao_launch_time;
+extern __xdata uint8_t                 ao_flight_force_idle;
 
 /* Flight thread */
 void
 
 /* Flight thread */
 void
index f57573d0547b15baf2e804441837dc122db03ab3..e0fd97f2464b901a61649037e61a9848e46b819e 100644 (file)
@@ -50,6 +50,8 @@ __data uint8_t ao_flight_adc;
 __pdata int16_t ao_raw_accel, ao_raw_accel_prev, ao_raw_pres;
 __pdata int16_t ao_accel_2g;
 
 __pdata int16_t ao_raw_accel, ao_raw_accel_prev, ao_raw_pres;
 __pdata int16_t ao_accel_2g;
 
+__xdata uint8_t ao_flight_force_idle;
+
 /* Accelerometer calibration
  *
  * We're sampling the accelerometer through a resistor divider which
 /* Accelerometer calibration
  *
  * We're sampling the accelerometer through a resistor divider which
@@ -221,8 +223,10 @@ ao_flight(void)
 
                        /* Go to pad state if the nose is pointing up */
                        ao_config_get();
 
                        /* Go to pad state if the nose is pointing up */
                        ao_config_get();
-                       if (ao_config.accel_plus_g != 0 && ao_config.accel_minus_g != 0 &&
-                           ao_flight_accel < ao_config.accel_plus_g + ACCEL_NOSE_UP)
+                       if (ao_config.accel_plus_g != 0 &&
+                           ao_config.accel_minus_g != 0 &&
+                           ao_flight_accel < ao_config.accel_plus_g + ACCEL_NOSE_UP &&
+                           !ao_flight_force_idle)
                        {
                                /* Disable the USB controller in flight mode
                                 * to save power
                        {
                                /* Disable the USB controller in flight mode
                                 * to save power
index 0de3572abcd62dbe642ea7216cf7a8310f417a41..89743837c6daf81eaf6571b21e0187d2d4dd3e92 100644 (file)
@@ -29,10 +29,20 @@ main(void)
 {
        ao_clock_init();
 
 {
        ao_clock_init();
 
+
        /* Turn on the red LED until the system is stable */
        ao_led_init(AO_LED_RED);
        ao_led_on(AO_LED_RED);
 
        /* Turn on the red LED until the system is stable */
        ao_led_init(AO_LED_RED);
        ao_led_on(AO_LED_RED);
 
+       /* A hack -- look at the SPI clock pin, if it's sitting at
+        *  ground, then we force the computer to idle mode instead of
+        *  flight mode
+        */
+       if (P1_3 == 0) {
+               ao_flight_force_idle = 1;
+               while (P1_3 == 0)
+                       ;
+       }
        ao_timer_init();
        ao_adc_init();
        ao_beep_init();
        ao_timer_init();
        ao_adc_init();
        ao_beep_init();