diff options
author | Keith Packard <keithp@keithp.com> | 2011-08-12 21:41:25 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2011-08-13 18:46:12 -0700 |
commit | fa7dd04741bf3fd9cedc59ed3b45b69ef9312609 (patch) | |
tree | 38fe668a33c9956eb240376a7bac24ed1d00886e | |
parent | c7f540330c040c521f9d7626009a406e704a5e41 (diff) |
altos: Send SPI message at flight state changes
Get the companion board starting its data logging as soon as possible
after boost starts.
Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r-- | src/ao.h | 1 | ||||
-rw-r--r-- | src/ao_companion.c | 15 |
2 files changed, 14 insertions, 2 deletions
@@ -1581,6 +1581,7 @@ ao_btm_init(void); #define AO_COMPANION_SETUP 1 #define AO_COMPANION_FETCH 2 +#define AO_COMPANION_NOTIFY 3 struct ao_companion_command { uint8_t command; diff --git a/src/ao_companion.c b/src/ao_companion.c index f54f5251..f0ce3f12 100644 --- a/src/ao_companion.c +++ b/src/ao_companion.c @@ -68,13 +68,24 @@ ao_companion_get_data(void) COMPANION_DESELECT(); } +static void +ao_companion_notify(void) +{ + COMPANION_SELECT(); + ao_companion_send_command(AO_COMPANION_NOTIFY); + COMPANION_DESELECT(); +} + void ao_companion(void) { ao_companion_running = ao_companion_get_setup(); while (ao_companion_running) { - ao_delay(ao_companion_setup.update_period); - ao_companion_get_data(); + ao_alarm(ao_companion_setup.update_period); + if (ao_sleep(DATA_TO_XDATA(&ao_flight_state))) + ao_companion_get_data(); + else + ao_companion_notify(); } ao_exit(); } |