diff options
| author | Keith Packard <keithp@keithp.com> | 2014-05-25 21:11:23 -0700 |
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2014-05-25 21:11:23 -0700 |
| commit | 3d5db24708b37d86eac187169e2553a408dfeb83 (patch) | |
| tree | 590deb5bddea98984909271a8e2c91f60bcc36af /src/drivers | |
| parent | 4df84dd5d007120f54cbda380789306608f2fc46 (diff) | |
altos: Make MS5607 PROM a public variable
This will let the fake flight code update it as necessary, without
creating a new interface in ao_ms5607.c
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/drivers')
| -rw-r--r-- | src/drivers/ao_ms5607.c | 22 | ||||
| -rw-r--r-- | src/drivers/ao_ms5607.h | 4 | ||||
| -rw-r--r-- | src/drivers/ao_ms5607_convert.c | 12 | ||||
| -rw-r--r-- | src/drivers/ao_ms5607_convert_8051.c | 20 |
4 files changed, 28 insertions, 30 deletions
diff --git a/src/drivers/ao_ms5607.c b/src/drivers/ao_ms5607.c index 58ab9197..6098699e 100644 --- a/src/drivers/ao_ms5607.c +++ b/src/drivers/ao_ms5607.c @@ -21,8 +21,8 @@ #if HAS_MS5607 || HAS_MS5611 -static __xdata struct ao_ms5607_prom ms5607_prom; -static __xdata uint8_t ms5607_configured; +__xdata struct ao_ms5607_prom ao_ms5607_prom; +static __xdata uint8_t ms5607_configured; static void ao_ms5607_start(void) { @@ -111,7 +111,7 @@ ao_ms5607_setup(void) return; ms5607_configured = 1; ao_ms5607_reset(); - ao_ms5607_prom_read(&ms5607_prom); + ao_ms5607_prom_read(&ao_ms5607_prom); } static __xdata volatile uint8_t ao_ms5607_done; @@ -208,14 +208,14 @@ __xdata struct ao_task ao_ms5607_task; void ao_ms5607_info(void) { - printf ("ms5607 reserved: %u\n", ms5607_prom.reserved); - printf ("ms5607 sens: %u\n", ms5607_prom.sens); - printf ("ms5607 off: %u\n", ms5607_prom.off); - printf ("ms5607 tcs: %u\n", ms5607_prom.tcs); - printf ("ms5607 tco: %u\n", ms5607_prom.tco); - printf ("ms5607 tref: %u\n", ms5607_prom.tref); - printf ("ms5607 tempsens: %u\n", ms5607_prom.tempsens); - printf ("ms5607 crc: %u\n", ms5607_prom.crc); + printf ("ms5607 reserved: %u\n", ao_ms5607_prom.reserved); + printf ("ms5607 sens: %u\n", ao_ms5607_prom.sens); + printf ("ms5607 off: %u\n", ao_ms5607_prom.off); + printf ("ms5607 tcs: %u\n", ao_ms5607_prom.tcs); + printf ("ms5607 tco: %u\n", ao_ms5607_prom.tco); + printf ("ms5607 tref: %u\n", ao_ms5607_prom.tref); + printf ("ms5607 tempsens: %u\n", ao_ms5607_prom.tempsens); + printf ("ms5607 crc: %u\n", ao_ms5607_prom.crc); } static void diff --git a/src/drivers/ao_ms5607.h b/src/drivers/ao_ms5607.h index 206efd64..b58178fd 100644 --- a/src/drivers/ao_ms5607.h +++ b/src/drivers/ao_ms5607.h @@ -57,6 +57,7 @@ struct ao_ms5607_value { }; extern __xdata struct ao_ms5607_sample ao_ms5607_current; +extern __xdata struct ao_ms5607_prom ao_ms5607_prom; void ao_ms5607_setup(void); @@ -74,7 +75,4 @@ void ao_ms5607_convert(__xdata struct ao_ms5607_sample *sample, __xdata struct ao_ms5607_value *value); -void -ao_ms5607_get_prom(__data struct ao_ms5607_prom *prom); - #endif /* _AO_MS5607_H_ */ diff --git a/src/drivers/ao_ms5607_convert.c b/src/drivers/ao_ms5607_convert.c index bfb952a4..4d412cbe 100644 --- a/src/drivers/ao_ms5607_convert.c +++ b/src/drivers/ao_ms5607_convert.c @@ -25,16 +25,16 @@ ao_ms5607_convert(struct ao_ms5607_sample *sample, struct ao_ms5607_value *value int64_t OFF; int64_t SENS; - dT = sample->temp - ((int32_t) ms5607_prom.tref << 8); + dT = sample->temp - ((int32_t) ao_ms5607_prom.tref << 8); - TEMP = 2000 + (((int64_t) dT * ms5607_prom.tempsens) >> 23); + TEMP = 2000 + (((int64_t) dT * ao_ms5607_prom.tempsens) >> 23); #if HAS_MS5611 - OFF = ((int64_t) ms5607_prom.off << 16) + (((int64_t) ms5607_prom.tco * dT) >> 7); - SENS = ((int64_t) ms5607_prom.sens << 15) + (((int64_t) ms5607_prom.tcs * dT) >> 8); + OFF = ((int64_t) ao_ms5607_prom.off << 16) + (((int64_t) ao_ms5607_prom.tco * dT) >> 7); + SENS = ((int64_t) ao_ms5607_prom.sens << 15) + (((int64_t) ao_ms5607_prom.tcs * dT) >> 8); #else - OFF = ((int64_t) ms5607_prom.off << 17) + (((int64_t) ms5607_prom.tco * dT) >> 6); - SENS = ((int64_t) ms5607_prom.sens << 16) + (((int64_t) ms5607_prom.tcs * dT) >> 7); + OFF = ((int64_t) ao_ms5607_prom.off << 17) + (((int64_t) ao_ms5607_prom.tco * dT) >> 6); + SENS = ((int64_t) ao_ms5607_prom.sens << 16) + (((int64_t) ao_ms5607_prom.tcs * dT) >> 7); #endif if (TEMP < 2000) { diff --git a/src/drivers/ao_ms5607_convert_8051.c b/src/drivers/ao_ms5607_convert_8051.c index f3a48c46..a74086d9 100644 --- a/src/drivers/ao_ms5607_convert_8051.c +++ b/src/drivers/ao_ms5607_convert_8051.c @@ -40,30 +40,30 @@ ao_ms5607_convert(__xdata struct ao_ms5607_sample *sample, __LOCAL ao_int64_t SENS; __LOCAL ao_int64_t a; - dT = sample->temp - ((int32_t) ms5607_prom.tref << 8); + dT = sample->temp - ((int32_t) ao_ms5607_prom.tref << 8); - /* TEMP = 2000 + (((int64_t) dT * ms5607_prom.tempsens) >> 23); */ - ao_mul64_32_32(&a, dT, ms5607_prom.tempsens); + /* TEMP = 2000 + (((int64_t) dT * ao_ms5607_prom.tempsens) >> 23); */ + ao_mul64_32_32(&a, dT, ao_ms5607_prom.tempsens); ao_rshift64(&a, &a, 23); TEMP = 2000 + a.low; /* */ - /* OFF = ((int64_t) ms5607_prom.off << SHIFT_OFF) + (((int64_t) ms5607_prom.tco * dT) >> SHIFT_TCO);*/ + /* OFF = ((int64_t) ao_ms5607_prom.off << SHIFT_OFF) + (((int64_t) ao_ms5607_prom.tco * dT) >> SHIFT_TCO);*/ #if SHIFT_OFF > 16 - OFF.high = ms5607_prom.off >> (32 - SHIFT_OFF); + OFF.high = ao_ms5607_prom.off >> (32 - SHIFT_OFF); #else OFF.high = 0; #endif - OFF.low = (uint32_t) ms5607_prom.off << SHIFT_OFF; - ao_mul64_32_32(&a, ms5607_prom.tco, dT); + OFF.low = (uint32_t) ao_ms5607_prom.off << SHIFT_OFF; + ao_mul64_32_32(&a, ao_ms5607_prom.tco, dT); ao_rshift64(&a, &a, SHIFT_TCO); ao_plus64(&OFF, &OFF, &a); /**/ - /* SENS = ((int64_t) ms5607_prom.sens << SHIFT_SENS) + (((int64_t) ms5607_prom.tcs * dT) >> SHIFT_TCS); */ + /* SENS = ((int64_t) ao_ms5607_prom.sens << SHIFT_SENS) + (((int64_t) ao_ms5607_prom.tcs * dT) >> SHIFT_TCS); */ SENS.high = 0; - SENS.low = (uint32_t) ms5607_prom.sens << SHIFT_SENS; - ao_mul64_32_32(&a, ms5607_prom.tcs, dT); + SENS.low = (uint32_t) ao_ms5607_prom.sens << SHIFT_SENS; + ao_mul64_32_32(&a, ao_ms5607_prom.tcs, dT); ao_rshift64(&a, &a, SHIFT_TCS); ao_plus64(&SENS, &SENS, &a); /**/ |
