altos: Make MS5607 PROM a public variable
authorKeith Packard <keithp@keithp.com>
Mon, 26 May 2014 04:11:23 +0000 (21:11 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 26 May 2014 04:11:23 +0000 (21:11 -0700)
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>
src/drivers/ao_ms5607.c
src/drivers/ao_ms5607.h
src/drivers/ao_ms5607_convert.c
src/drivers/ao_ms5607_convert_8051.c
src/test/ao_flight_test.c
src/test/ao_ms5607_convert_test.c

index 58ab91973ce0b63b5a51c0e6b053a1b903d10fa8..6098699edf4b1735a8a0ede41fd163722ba809aa 100644 (file)
@@ -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
index 206efd64f8c2e8ccf7934ef0441c3bff70f16b78..b58178fd136fcce36e6b8aaca4bcd2419b25d1bb 100644 (file)
@@ -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_ */
index bfb952a47e7b2c8a1da54701a34765d6cd7e38f3..4d412cbe9ed18ee3e1d47fbdaf1a250230917efa 100644 (file)
@@ -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) {
index f3a48c464b784830462bd29b840abaa57a826f11..a74086d9cb4086a2efd0cc2d993295a762dfe677 100644 (file)
@@ -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);
        /**/
index 3995d98d199b721b8f1f1cf7be2737e40d320bb5..1ee3ad2756fd9d79cf0d8ea28c656be5f3f2ba15 100644 (file)
@@ -309,7 +309,7 @@ struct ao_cmds {
 #if TELEMEGA
 #include "ao_convert_pa.c"
 #include <ao_ms5607.h>
-struct ao_ms5607_prom  ms5607_prom;
+struct ao_ms5607_prom  ao_ms5607_prom;
 #include "ao_ms5607_convert.c"
 #define AO_PYRO_NUM    4
 #include <ao_pyro.h>
@@ -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);
index ad593204b2394a9157220b575f4146621cd132f8..1c571f1cbd1587aeedeb4c79c78655ed98943fda 100644 (file)
@@ -23,7 +23,7 @@
 #include <stdint.h>
 #include <ao_ms5607.h>
 
-struct ao_ms5607_prom ms5607_prom = {
+struct ao_ms5607_prom ao_ms5607_prom = {
        0x002c,
        0xa6e0,
        0x988e,