diff options
author | Keith Packard <keithp@keithp.com> | 2012-10-18 15:18:52 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2012-10-18 15:18:52 -0700 |
commit | 5a55501660ebab3b858a48483c5df1cfb4e858e4 (patch) | |
tree | 9b5d8305d9c65b10f82f6839bb1b5c169681ef00 /src/core/ao_convert_pa.c | |
parent | 0361235c9ef56738ba0e97be88a85afef0ce8268 (diff) | |
parent | 440365bd17d804c2f574c35164612cf1682397d7 (diff) |
Merge branch 'master' into mm-ms5611
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/core/ao_convert_pa.c')
-rw-r--r-- | src/core/ao_convert_pa.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/core/ao_convert_pa.c b/src/core/ao_convert_pa.c index 0c93caea..55fe6e7d 100644 --- a/src/core/ao_convert_pa.c +++ b/src/core/ao_convert_pa.c @@ -19,14 +19,22 @@ #include "ao.h" #endif -static const int32_t altitude_table[] = { +#ifndef AO_CONST_ATTRIB +#define AO_CONST_ATTRIB +#endif + +static const alt_t altitude_table[] AO_CONST_ATTRIB = { #include "altitude-pa.h" }; +#ifndef FETCH_ALT +#define FETCH_ALT(o) altitude_table[o] +#endif + #define ALT_SCALE (1 << ALT_SHIFT) #define ALT_MASK (ALT_SCALE - 1) -int32_t +alt_t ao_pa_to_altitude(int32_t pa) { int16_t o; @@ -40,11 +48,12 @@ ao_pa_to_altitude(int32_t pa) o = pa >> ALT_SHIFT; part = pa & ALT_MASK; - low = (int32_t) altitude_table[o] * (ALT_SCALE - part); - high = (int32_t) altitude_table[o+1] * part + (ALT_SCALE >> 1); + low = (alt_t) FETCH_ALT(o) * (ALT_SCALE - part); + high = (alt_t) FETCH_ALT(o+1) * part + (ALT_SCALE >> 1); return (low + high) >> ALT_SHIFT; } +#ifdef AO_CONVERT_TEST int32_t ao_altitude_to_pa(int32_t alt) { @@ -70,3 +79,4 @@ ao_altitude_to_pa(int32_t alt) pa = 0; return pa; } +#endif |