summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-01-15 12:25:57 -0800
committerKeith Packard <keithp@keithp.com>2011-01-16 20:24:36 -0800
commit2887fe7affc0706dbeb2f04df9a00a9b799903ed (patch)
treea0f24870448c27f6fa708dadffb49a22db719a1f /src
parent2681a17500913cbaf3966f09380bb1d6b59e3863 (diff)
altos: Optimize fetching of ADC data in flight code
This stores the address of the desired sample in a local variable and then fetches through that. Saves quite a few instructions. Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src')
-rw-r--r--src/ao_flight.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/ao_flight.c b/src/ao_flight.c
index 9eb9a014..637acd52 100644
--- a/src/ao_flight.c
+++ b/src/ao_flight.c
@@ -151,12 +151,14 @@ ao_flight(void)
while (ao_flight_adc != ao_adc_head) {
__pdata uint8_t ticks;
__pdata int16_t ao_vel_change;
+ __xdata struct ao_adc *ao_adc;
ao_flight_prev_tick = ao_flight_tick;
/* Capture a sample */
- ao_raw_accel = ao_adc_ring[ao_flight_adc].accel;
- ao_raw_pres = ao_adc_ring[ao_flight_adc].pres;
- ao_flight_tick = ao_adc_ring[ao_flight_adc].tick;
+ ao_adc = &ao_adc_ring[ao_flight_adc];
+ ao_flight_tick = ao_adc->tick;
+ ao_raw_accel = ao_adc->accel;
+ ao_raw_pres = ao_adc->pres;
ao_flight_accel -= ao_flight_accel >> 4;
ao_flight_accel += ao_raw_accel >> 4;