From fba1d605a627d03f9587ec060c45fb5d3e96aaeb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 26 Sep 2011 11:50:28 -0700 Subject: altos: Delay reboot by a second to avoid re-entering idle mode TM and Tm go into idle mode if they receive a packet after boot time. When tebooting the device over the packet link, the packet master would be (rapidly) polling the device for additional data and so the device would invariably receive a packet during bootup and go into idle mode again. Delay the reboot by a second to give the controller time to disable the master end of the packet link. Signed-off-by: Keith Packard --- src/ao_cmd.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/ao_cmd.c b/src/ao_cmd.c index 1442ebea..8037195a 100644 --- a/src/ao_cmd.c +++ b/src/ao_cmd.c @@ -208,6 +208,13 @@ ao_reboot(void) ao_cmd_white(); if (!ao_match_word("eboot")) return; + + /* Delay waiting for the packet master to be turned off + * so that we don't end up back in idle mode because we + * received a packet after boot. + */ + flush(); + ao_delay(AO_SEC_TO_TICKS(1)); WDCTL = WDCTL_EN | WDCTL_MODE_WATCHDOG | WDCTL_INT_64; ao_delay(AO_SEC_TO_TICKS(2)); ao_panic(AO_PANIC_REBOOT); -- cgit v1.2.3 From 0d10e25766b96f5660e213115cf27b71ff164405 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 27 Sep 2011 21:06:54 -0700 Subject: altos: TM: Don't turn on packet slave mode until idle/invalid state Leave the packet link disabled until we've checked the accelerometer. That way, we cannot accidentally get to idle mode when the rocket is on the rail. Signed-off-by: Keith Packard --- src/ao_flight.c | 11 ++++++++++- src/ao_packet_slave.c | 6 ++++-- src/ao_telemetrum.c | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ao_flight.c b/src/ao_flight.c index 85c1825b..0a9cc046 100644 --- a/src/ao_flight.c +++ b/src/ao_flight.c @@ -91,6 +91,8 @@ ao_flight(void) */ ao_flight_state = ao_flight_invalid; + /* Turn on packet system in invalid mode on TeleMetrum */ + ao_packet_slave_start(); } else #endif if (!ao_flight_force_idle @@ -108,8 +110,10 @@ ao_flight(void) ao_usb_disable(); #endif - /* Disable packet mode in pad state */ +#if !HAS_ACCEL + /* Disable packet mode in pad state on TeleMini */ ao_packet_slave_stop(); +#endif /* Turn on telemetry system */ ao_rdf_set(1); @@ -121,6 +125,11 @@ ao_flight(void) /* Set idle mode */ ao_flight_state = ao_flight_idle; +#if HAS_ACCEL + /* Turn on packet system in idle mode on TeleMetrum */ + ao_packet_slave_start(); +#endif + /* signal successful initialization by turning off the LED */ ao_led_off(AO_LED_RED); } diff --git a/src/ao_packet_slave.c b/src/ao_packet_slave.c index 9f14052a..d7cafa68 100644 --- a/src/ao_packet_slave.c +++ b/src/ao_packet_slave.c @@ -37,8 +37,10 @@ ao_packet_slave(void) void ao_packet_slave_start(void) { - ao_packet_enable = 1; - ao_add_task(&ao_packet_task, ao_packet_slave, "slave"); + if (!ao_packet_enable) { + ao_packet_enable = 1; + ao_add_task(&ao_packet_task, ao_packet_slave, "slave"); + } } void diff --git a/src/ao_telemetrum.c b/src/ao_telemetrum.c index f560740a..ea77f5af 100644 --- a/src/ao_telemetrum.c +++ b/src/ao_telemetrum.c @@ -57,7 +57,7 @@ main(void) ao_gps_report_init(); ao_telemetry_init(); ao_radio_init(); - ao_packet_slave_init(TRUE); + ao_packet_slave_init(FALSE); ao_igniter_init(); #if HAS_DBG ao_dbg_init(); -- cgit v1.2.3