From 24167015705ae831692b95735968b04a876f935e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 4 Apr 2014 23:34:48 -0700 Subject: altos: Rename 'core' to 'kernel' core remains a bad name to use -- dirvish skips files (and directories, it seems) with that name. Signed-off-by: Keith Packard --- src/test/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/test') diff --git a/src/test/Makefile b/src/test/Makefile index c6025219..7cb86140 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -1,4 +1,4 @@ -vpath % ..:../core:../drivers:../util:../micropeak:../aes:../product +vpath % ..:../kernel:../drivers:../util:../micropeak:../aes:../product PROGS=ao_flight_test ao_flight_test_baro ao_flight_test_accel ao_flight_test_noisy_accel ao_flight_test_mm \ ao_gps_test ao_gps_test_skytraq ao_gps_test_ublox ao_convert_test ao_convert_pa_test ao_fec_test \ @@ -9,7 +9,7 @@ INCS=ao_kalman.h ao_ms5607.h ao_log.h ao_data.h altitude-pa.h altitude.h ao_quat KALMAN=make-kalman -CFLAGS=-I.. -I. -I../core -I../drivers -I../micropeak -I../product -O0 -g -Wall +CFLAGS=-I.. -I. -I../kernel -I../drivers -I../micropeak -I../product -O0 -g -Wall all: $(PROGS) ao_aprs_data.wav @@ -52,7 +52,7 @@ ao_kalman.h: $(KALMAN) (cd .. && make ao_kalman.h) ao_fec_test: ao_fec_test.c ao_fec_tx.c ao_fec_rx.c - cc $(CFLAGS) -DAO_FEC_DEBUG=1 -o $@ ao_fec_test.c ../core/ao_fec_tx.c ../core/ao_fec_rx.c -lm + cc $(CFLAGS) -DAO_FEC_DEBUG=1 -o $@ ao_fec_test.c ../kernel/ao_fec_tx.c ../kernel/ao_fec_rx.c -lm ao_aprs_test: ao_aprs_test.c ao_aprs.c cc $(CFLAGS) -o $@ ao_aprs_test.c -- cgit v1.2.3 From 43be26603827b5930bf3e8082610cfa19b45534d Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 21 May 2014 13:58:54 -0700 Subject: altos/test: Get APRS generation test working again APRS now includes sat info, so we have to fake that up to generate an APRS test file Signed-off-by: Keith Packard --- src/test/Makefile | 2 +- src/test/ao_aprs_test.c | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/test') diff --git a/src/test/Makefile b/src/test/Makefile index 7cb86140..017f7f71 100644 --- a/src/test/Makefile +++ b/src/test/Makefile @@ -55,7 +55,7 @@ ao_fec_test: ao_fec_test.c ao_fec_tx.c ao_fec_rx.c cc $(CFLAGS) -DAO_FEC_DEBUG=1 -o $@ ao_fec_test.c ../kernel/ao_fec_tx.c ../kernel/ao_fec_rx.c -lm ao_aprs_test: ao_aprs_test.c ao_aprs.c - cc $(CFLAGS) -o $@ ao_aprs_test.c + cc $(CFLAGS) -o $@ ao_aprs_test.c -lm SOX_INPUT_ARGS=--type raw --encoding unsigned-integer -b 8 -c 1 -r 9600 SOX_OUTPUT_ARGS=--type wav diff --git a/src/test/ao_aprs_test.c b/src/test/ao_aprs_test.c index 69147786..b1d17d3f 100644 --- a/src/test/ao_aprs_test.c +++ b/src/test/ao_aprs_test.c @@ -23,7 +23,16 @@ #include +#define AO_GPS_NUM_SAT_MASK (0xf << 0) +#define AO_GPS_NUM_SAT_SHIFT (0) + +#define AO_GPS_VALID (1 << 4) +#define AO_GPS_RUNNING (1 << 5) +#define AO_GPS_DATE_VALID (1 << 6) +#define AO_GPS_COURSE_VALID (1 << 7) + struct ao_telemetry_location ao_gps_data; +struct ao_telemetry_satellite ao_gps_tracking_data; #define AO_APRS_TEST @@ -73,7 +82,7 @@ ao_radio_send_aprs(ao_radio_fill_func fill); * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ @@ -96,6 +105,7 @@ int main(int argc, char **argv) ao_gps_data.latitude = (45.0 + 28.25 / 60.0) * 10000000; ao_gps_data.longitude = (-(122 + 44.2649 / 60.0)) * 10000000; ao_gps_data.altitude = 84; + ao_gps_data.flags = (AO_GPS_VALID|AO_GPS_RUNNING); /* Transmit one packet */ ao_aprs_send(); -- cgit v1.2.3 From 161ae96f9ec11e2586df07c0f6d724ddc4dad76c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 21 May 2014 14:00:05 -0700 Subject: altos/test: Parse mega ground data. Fix pyro parsing This gets ao_flight_test_mega working with eeprom files Signed-off-by: Keith Packard --- src/test/ao_flight_test.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/test') diff --git a/src/test/ao_flight_test.c b/src/test/ao_flight_test.c index 0abb4090..3995d98d 100644 --- a/src/test/ao_flight_test.c +++ b/src/test/ao_flight_test.c @@ -732,6 +732,18 @@ ao_sleep(void *wchan) ao_flight_started = 1; ao_ground_pres = int32(bytes, 4); ao_ground_height = ao_pa_to_altitude(ao_ground_pres); + ao_ground_accel_along = int16(bytes, 8); + ao_ground_accel_across = int16(bytes, 10); + ao_ground_accel_through = int16(bytes, 12); + ao_ground_roll = int16(bytes, 14); + ao_ground_pitch = int16(bytes, 16); + ao_ground_yaw = int16(bytes, 18); + ao_ground_mpu6000.accel_x = ao_ground_accel_across; + ao_ground_mpu6000.accel_y = ao_ground_accel_along; + ao_ground_mpu6000.accel_z = ao_ground_accel_through; + ao_ground_mpu6000.gyro_x = ao_ground_pitch >> 9; + ao_ground_mpu6000.gyro_y = ao_ground_roll >> 9; + ao_ground_mpu6000.gyro_z = ao_ground_yaw >> 9; break; case 'A': ao_data_static.tick = tick; @@ -791,7 +803,7 @@ ao_sleep(void *wchan) for (i = 2; i < nword; i++) { for (j = 0; j < NUM_PYRO_VALUES; j++) - if (!strcmp (words[2], ao_pyro_values[j].name)) + if (!strcmp (words[i], ao_pyro_values[j].name)) break; if (j == NUM_PYRO_VALUES) continue; -- cgit v1.2.3 From 3d5db24708b37d86eac187169e2553a408dfeb83 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 25 May 2014 21:11:23 -0700 Subject: 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 --- src/drivers/ao_ms5607.c | 22 +++++++++++----------- src/drivers/ao_ms5607.h | 4 +--- src/drivers/ao_ms5607_convert.c | 12 ++++++------ src/drivers/ao_ms5607_convert_8051.c | 20 ++++++++++---------- src/test/ao_flight_test.c | 18 +++++++++--------- src/test/ao_ms5607_convert_test.c | 2 +- 6 files changed, 38 insertions(+), 40 deletions(-) (limited to 'src/test') 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, -- cgit v1.2.3 From 535271f7312f1a88af11d4f1dbf3d405b660f26c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 25 May 2014 21:14:42 -0700 Subject: altos/test: Fix ADC structure for mega, use ao_config.h This switches from hand-coding the ao_config structure to using ao_config.h and also updates the ADC structure for ao_flight_test_mega to using the same one as telemega does natively Signed-off-by: Keith Packard --- src/test/ao_flight_test.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/test') diff --git a/src/test/ao_flight_test.c b/src/test/ao_flight_test.c index 1ee3ad27..0647fc6c 100644 --- a/src/test/ao_flight_test.c +++ b/src/test/ao_flight_test.c @@ -49,13 +49,12 @@ int ao_gps_new; #define HAS_MPU6000 1 #define HAS_MMA655X 1 #define HAS_HMC5883 1 +#define HAS_BEEP 1 struct ao_adc { int16_t sense[AO_ADC_NUM_SENSE]; int16_t v_batt; int16_t v_pbatt; - int16_t accel_ref; - int16_t accel; int16_t temp; }; #else @@ -317,22 +316,8 @@ struct ao_ms5607_prom ao_ms5607_prom; #include "ao_convert.c" #endif -struct ao_config { - uint16_t main_deploy; - int16_t accel_plus_g; - int16_t accel_minus_g; - uint8_t pad_orientation; - uint16_t apogee_lockout; -#if TELEMEGA - struct ao_pyro pyro[AO_PYRO_NUM]; /* minor version 12 */ - int16_t accel_zero_along; - int16_t accel_zero_across; - int16_t accel_zero_through; -#endif -}; - -#define AO_PAD_ORIENTATION_ANTENNA_UP 0 -#define AO_PAD_ORIENTATION_ANTENNA_DOWN 1 +#include +#include #define ao_config_get() @@ -1003,6 +988,7 @@ void run_flight_fixed(char *name, FILE *f, int summary, char *info) emulator_in = f; emulator_info = info; ao_summary = summary; + ao_flight_init(); ao_flight(); } -- cgit v1.2.3 From 12c408c5aa1d234fe9c946078d8a343b4fda7ebb Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 30 May 2014 17:30:08 -0700 Subject: altos: Test APRS altitude encoding MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verify fixed point version against naïve implementation Signed-off-by: Keith Packard --- src/test/ao_aprs_test.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/test') diff --git a/src/test/ao_aprs_test.c b/src/test/ao_aprs_test.c index b1d17d3f..86cf527a 100644 --- a/src/test/ao_aprs_test.c +++ b/src/test/ao_aprs_test.c @@ -97,9 +97,36 @@ audio_gap(int secs) #endif } +#include + +int +ao_aprs_encode_altitude_expensive(int meters) +{ + double feet = meters / 0.3048; + + double encode = log(feet) / log(1.002); + return floor(encode + 0.5); +} + // This is where we go after reset. int main(int argc, char **argv) { + int e, x; + int a; + + for (a = 1; a < 100000; a++) { + e = ao_aprs_encode_altitude(a); + x = ao_aprs_encode_altitude_expensive(a); + + if (e != x) { + double back_feet, back_meters; + back_feet = pow(1.002, e); + back_meters = back_feet * 0.3048; + fprintf (stderr, "APRS altitude encoding failure: altitude %d actual %d expected %d actual meters %f\n", + a, e, x, back_meters); + } + } + audio_gap(1); ao_gps_data.latitude = (45.0 + 28.25 / 60.0) * 10000000; -- cgit v1.2.3