From: Keith Packard Date: Sat, 13 Aug 2011 04:41:25 +0000 (-0700) Subject: altos: Send SPI message at flight state changes X-Git-Tag: 0.9.6.0~12 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=fa7dd04741bf3fd9cedc59ed3b45b69ef9312609 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 --- diff --git a/src/ao.h b/src/ao.h index de47f3df..b14b65f2 100644 --- a/src/ao.h +++ b/src/ao.h @@ -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(); }