From: Keith Packard Date: Mon, 26 May 2014 04:11:23 +0000 (-0700) Subject: altos: Make MS5607 PROM a public variable X-Git-Tag: 1.3.2.2~71 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=3d5db24708b37d86eac187169e2553a408dfeb83 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 --- 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); /**/ diff --git a/src/test/ao_flight_test.c b/src/test/ao_flight_test.c index 3995d98d..1ee3ad27 100644 --- a/src/test/ao_flight_test.c +++ b/src/test/ao_flight_test.c @@ -309,7 +309,7 @@ struct ao_cmds { #if TELEMEGA #include "ao_convert_pa.c" #include -struct ao_ms5607_prom ms5607_prom; +struct ao_ms5607_prom ao_ms5607_prom; #include "ao_ms5607_convert.c" #define AO_PYRO_NUM 4 #include @@ -780,21 +780,21 @@ ao_sleep(void *wchan) continue; } else if (nword == 3 && strcmp(words[0], "ms5607") == 0) { if (strcmp(words[1], "reserved:") == 0) - ms5607_prom.reserved = strtoul(words[2], NULL, 10); + ao_ms5607_prom.reserved = strtoul(words[2], NULL, 10); else if (strcmp(words[1], "sens:") == 0) - ms5607_prom.sens = strtoul(words[2], NULL, 10); + ao_ms5607_prom.sens = strtoul(words[2], NULL, 10); else if (strcmp(words[1], "off:") == 0) - ms5607_prom.off = strtoul(words[2], NULL, 10); + ao_ms5607_prom.off = strtoul(words[2], NULL, 10); else if (strcmp(words[1], "tcs:") == 0) - ms5607_prom.tcs = strtoul(words[2], NULL, 10); + ao_ms5607_prom.tcs = strtoul(words[2], NULL, 10); else if (strcmp(words[1], "tco:") == 0) - ms5607_prom.tco = strtoul(words[2], NULL, 10); + ao_ms5607_prom.tco = strtoul(words[2], NULL, 10); else if (strcmp(words[1], "tref:") == 0) - ms5607_prom.tref = strtoul(words[2], NULL, 10); + ao_ms5607_prom.tref = strtoul(words[2], NULL, 10); else if (strcmp(words[1], "tempsens:") == 0) - ms5607_prom.tempsens = strtoul(words[2], NULL, 10); + ao_ms5607_prom.tempsens = strtoul(words[2], NULL, 10); else if (strcmp(words[1], "crc:") == 0) - ms5607_prom.crc = strtoul(words[2], NULL, 10); + ao_ms5607_prom.crc = strtoul(words[2], NULL, 10); continue; } else if (nword >= 3 && strcmp(words[0], "Pyro") == 0) { int p = strtoul(words[1], NULL, 10); diff --git a/src/test/ao_ms5607_convert_test.c b/src/test/ao_ms5607_convert_test.c index ad593204..1c571f1c 100644 --- a/src/test/ao_ms5607_convert_test.c +++ b/src/test/ao_ms5607_convert_test.c @@ -23,7 +23,7 @@ #include #include -struct ao_ms5607_prom ms5607_prom = { +struct ao_ms5607_prom ao_ms5607_prom = { 0x002c, 0xa6e0, 0x988e,