X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Fao_sample.c;h=b2b8e9f63ff662385054b6a904797f38e6c77ce9;hp=84cf1e00b8f70aba0ddf42427b7195b8a8297981;hb=40544dbfe09c64f7764a5f0686415805611fab25;hpb=08e6bbef2c3529dfd468ef221c526fc9f3ed5b81 diff --git a/src/ao_sample.c b/src/ao_sample.c index 84cf1e00..b2b8e9f6 100644 --- a/src/ao_sample.c +++ b/src/ao_sample.c @@ -37,21 +37,21 @@ __data uint8_t ao_sample_adc; * Sensor calibration values */ -__xdata int16_t ao_ground_pres; /* startup pressure */ -__xdata int16_t ao_ground_height; /* MSL of ao_ground_pres */ +__pdata int16_t ao_ground_pres; /* startup pressure */ +__pdata int16_t ao_ground_height; /* MSL of ao_ground_pres */ #if HAS_ACCEL -__xdata int16_t ao_ground_accel; /* startup acceleration */ -__xdata int16_t ao_accel_2g; /* factory accel calibration */ -__xdata int32_t ao_accel_scale; /* sensor to m/s² conversion */ +__pdata int16_t ao_ground_accel; /* startup acceleration */ +__pdata int16_t ao_accel_2g; /* factory accel calibration */ +__pdata int32_t ao_accel_scale; /* sensor to m/s² conversion */ #endif -static __xdata uint8_t ao_preflight; /* in preflight mode */ +static __pdata uint8_t ao_preflight; /* in preflight mode */ -static __xdata uint16_t nsamples; -__xdata int32_t ao_sample_pres_sum; +static __pdata uint16_t nsamples; +__pdata int32_t ao_sample_pres_sum; #if HAS_ACCEL -__xdata int32_t ao_sample_accel_sum; +__pdata int32_t ao_sample_accel_sum; #endif static void @@ -139,7 +139,7 @@ ao_sample(void) * * ao_sample_accel 32767 * = ------------ * ------------ - * 32737 ao_accel_ref + * 32767 ao_accel_ref * * Multiply through by 32767: * @@ -179,6 +179,8 @@ ao_sample(void) * just dropped a bit of noise off the low end. */ ao_sample_accel = (uint16_t) ((((uint32_t) ao_sample_accel << 16) / (ao_accel_ref[ao_sample_adc] << 1))) >> 1; + if (ao_config.pad_orientation != AO_PAD_ORIENTATION_ANTENNA_UP) + ao_sample_accel = 0x7fff - ao_sample_accel; ao_adc->accel = ao_sample_accel; #endif #endif