summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-05-25 21:11:23 -0700
committerKeith Packard <keithp@keithp.com>2014-05-25 21:11:23 -0700
commit3d5db24708b37d86eac187169e2553a408dfeb83 (patch)
tree590deb5bddea98984909271a8e2c91f60bcc36af /src
parent4df84dd5d007120f54cbda380789306608f2fc46 (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')
-rw-r--r--src/drivers/ao_ms5607.c22
-rw-r--r--src/drivers/ao_ms5607.h4
-rw-r--r--src/drivers/ao_ms5607_convert.c12
-rw-r--r--src/drivers/ao_ms5607_convert_8051.c20
-rw-r--r--src/test/ao_flight_test.c18
-rw-r--r--src/test/ao_ms5607_convert_test.c2
6 files changed, 38 insertions, 40 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);
/**/
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 <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);
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 <stdint.h>
#include <ao_ms5607.h>
-struct ao_ms5607_prom ms5607_prom = {
+struct ao_ms5607_prom ao_ms5607_prom = {
0x002c,
0xa6e0,
0x988e,