Change altos build process to support per-product compile-time changes
authorKeith Packard <keithp@keithp.com>
Sun, 21 Feb 2010 04:22:16 +0000 (20:22 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 21 Feb 2010 04:30:27 +0000 (20:30 -0800)
This creates per-product subdirectories and recompiles everything for
each product, allowing per-product compile-time changes for things
like peripheral pin assignments and attached serial devices.

Signed-off-by: Keith Packard <keithp@keithp.com>
28 files changed:
src/Makefile
src/Makefile.proto [new file with mode: 0644]
src/ao.h
src/ao_adc.c
src/ao_config.c
src/ao_dbg.c
src/ao_host.h
src/ao_packet.c
src/ao_packet_slave.c
src/ao_pins.h [new file with mode: 0644]
src/ao_reboot.c [new file with mode: 0644]
src/ao_stdio.c
src/ao_teledongle.c
src/ao_telemetrum.c
src/ao_timer.c
src/teledongle-v0.1/Makefile [new file with mode: 0644]
src/teledongle-v0.1/Makefile.defs [new file with mode: 0644]
src/teledongle-v0.2/Makefile [new file with mode: 0644]
src/teledongle-v0.2/Makefile.defs [new file with mode: 0644]
src/telemetrum-v0.1-sirf/Makefile [new file with mode: 0644]
src/telemetrum-v0.1-sirf/Makefile.defs [new file with mode: 0644]
src/telemetrum-v0.1-sky/Makefile [new file with mode: 0644]
src/telemetrum-v0.1-sky/Makefile.defs [new file with mode: 0644]
src/telemetrum-v0.2/Makefile [new file with mode: 0644]
src/telemetrum-v0.2/Makefile.defs [new file with mode: 0644]
src/test/Makefile [new file with mode: 0644]
src/tidongle/Makefile [new file with mode: 0644]
src/tidongle/Makefile.defs [new file with mode: 0644]

index dcd41718e984113c72d90c7d5dc0521e2d3ab748..e2699ee680350e8d9b982393ff72c4aa7bb3ff67 100644 (file)
 #
 CC=sdcc
 
-ifndef VERSION
-VERSION=$(shell git describe)
-endif
+SUBDIRS=telemetrum-v0.2 teledongle-v0.2 telemetrum-v0.1-sky telemetrum-v0.1-sirf teledongle-v0.1 tidongle test
 
-CFLAGS=--model-small --debug --opt-code-speed
+all: all-recursive
 
-LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size 0x8000 \
-       --xram-loc 0xf000 --xram-size 0xda2 --iram-size 0xff
+RECURSIVE_TARGETS = all-recursive clean-recursive install-recursive
 
-INC = \
-       ao.h \
-       cc1111.h \
-       altitude.h \
-       25lc1024.h
-
-#
-# Common AltOS sources
-#
-ALTOS_SRC = \
-       ao_cmd.c \
-       ao_dma.c \
-       ao_mutex.c \
-       ao_panic.c \
-       ao_task.c \
-       ao_timer.c \
-       _bp.c
-
-#
-# Shared AltOS drivers
-#
-ALTOS_DRIVER_SRC = \
-       ao_beep.c \
-       ao_config.c \
-       ao_led.c \
-       ao_radio.c \
-       ao_stdio.c \
-       ao_usb.c
-
-TELE_COMMON_SRC = \
-       ao_packet.c \
-       ao_packet_slave.c \
-       ao_state.c
-
-#
-# Receiver code
-#
-TELE_RECEIVER_SRC =\
-       ao_monitor.c \
-       ao_gps_print.c \
-       ao_packet_master.c \
-       ao_rssi.c
-
-#
-# Shared Tele drivers (on TeleMetrum, TeleTerra, TeleDongle)
-#
-
-TELE_DRIVER_SRC = \
-       ao_convert.c \
-       ao_serial.c
-
-#
-# Drivers for partially-flled boards (TT, TD and TI)
-#
-TELE_FAKE_SRC = \
-       ao_adc_fake.c \
-       ao_ee_fake.c
-
-#
-# Debug dongle driver (only on TI)
-#
-DBG_DONGLE_SRC = \
-       ao_dbg.c
-
-#
-# Drivers only on TeleMetrum
-#
-TM_DRIVER_SRC = \
-       ao_adc.c \
-       ao_flash.c \
-       ao_gps_report.c \
-       ao_ignite.c
-
-#
-# Drivers only on TeleMetrum
-#
-TM_SIRF_DRIVER_SRC = \
-       ao_gps_sirf.c
-#
-# Drivers only on TeleMetrum
-#
-TM_SKY_DRIVER_SRC = \
-       ao_gps_skytraq.c
-
-#
-# Tasks run on TeleMetrum
-#
-TM_TASK_SRC = \
-       ao_flight.c \
-       ao_log.c \
-       ao_report.c \
-       ao_telemetry.c
-
-TM_MAIN_SRC = \
-       ao_telemetrum.c
-
-#
-# All sources for TeleMetrum
-#
-TM_SRC = \
-       $(ALTOS_SRC) \
-       $(ALTOS_DRIVER_SRC) \
-       $(TELE_DRIVER_SRC) \
-       $(TELE_COMMON_SRC) \
-       $(TM_DRIVER_SRC) \
-       $(TM_TASK_SRC) \
-       $(TM_MAIN_SRC)
-
-TM_SIRF_SRC = \
-       $(TM_SRC) \
-       $(TM_SIRF_DRIVER_SRC)
-
-TM_SKY_SRC = \
-       $(TM_SRC) \
-       $(TM_SKY_DRIVER_SRC)
-
-TI_MAIN_SRC = \
-       ao_tidongle.c
-
-#
-# All sources for the TI debug dongle
-#
-TI_SRC = \
-       $(ALTOS_SRC) \
-       $(ALTOS_DRIVER_SRC) \
-       $(TELE_RECEIVER_SRC) \
-       $(TELE_COMMON_SRC) \
-       $(TELE_FAKE_SRC) \
-       $(TI_MAIN_SRC) \
-       $(DBG_DONGLE_SRC)
-
-TT_MAIN_SRC = \
-       ao_teleterra.c
-#
-# All sources for TeleTerra
-#
-TT_SRC = \
-       $(ALTOS_SRC) \
-       $(ALTOS_DRIVER_SRC) \
-       $(TELE_RECEIVER_SRC) \
-       $(TELE_DRIVER_SRC) \
-       $(TELE_COMMON_SRC) \
-       $(TELE_FAKE_SRC) \
-       $(TT_MAIN_SRC)
-
-
-#
-# Sources for TeleDongle
-#
-
-TD_MAIN_SRC = \
-       ao_teledongle.c
-
-TD_SRC = \
-       $(ALTOS_SRC) \
-       $(ALTOS_DRIVER_SRC) \
-       $(TELE_RECEIVER_SRC) \
-       $(TELE_COMMON_SRC) \
-       $(TELE_FAKE_SRC) \
-       $(TD_MAIN_SRC)
-
-SRC = \
-       $(ALTOS_SRC) \
-       $(ALTOS_DRIVER_SRC) \
-       $(TELE_DRIVER_SRC) \
-       $(TELE_RECEIVER_SRC) \
-       $(TELE_COMMON_SRC) \
-       $(TELE_FAKE_SRC) \
-       $(TM_DRIVER_SRC) \
-       $(TM_SIRF_DRIVER_SRC) \
-       $(TM_SKY_DRIVER_SRC) \
-       $(TM_TASK_SRC) \
-       $(TM_MAIN_SRC) \
-       $(TI_MAIN_SRC) \
-       $(TD_MAIN_SRC) \
-       $(TT_MAIN_SRC)
-
-TM_SIRF_REL=$(TM_SIRF_SRC:.c=.rel) ao_product-telemetrum.rel
-TM_SKY_REL=$(TM_SKY_SRC:.c=.rel) ao_product-telemetrum.rel
-TI_REL=$(TI_SRC:.c=.rel) ao_product-tidongle.rel
-TT_REL=$(TT_SRC:.c=.rel) ao_product-teleterra.rel
-TD_REL=$(TD_SRC:.c=.rel) ao_product-teledongle.rel
-
-PROD_REL=\
-       ao_product-telemetrum.rel \
-       ao_product-tidongle.rel \
-       ao_product-teleterra.rel \
-       ao_product-teledongle.rel
-
-REL=$(SRC:.c=.rel) $(PROD_REL)
-ADB=$(REL:.rel=.adb)
-ASM=$(REL:.rel=.asm)
-LNK=$(REL:.rel=.lnk)
-LST=$(REL:.rel=.lst)
-RST=$(REL:.rel=.rst)
-SYM=$(REL:.rel=.sym)
-
-PROGS= telemetrum-sirf.ihx telemetrum-sky.ihx tidongle.ihx \
-       teleterra.ihx teledongle.ihx
-
-HOST_PROGS=ao_flight_test ao_gps_test ao_gps_test_skytraq
-
-PCDB=$(PROGS:.ihx=.cdb)
-PLNK=$(PROGS:.ihx=.lnk)
-PMAP=$(PROGS:.ihx=.map)
-PMEM=$(PROGS:.ihx=.mem)
-PAOM=$(PROGS:.ihx=)
-
-%.rel : %.c $(INC)
-       $(CC) -c $(CFLAGS) -o$*.rel $*.c
-
-all: $(PROGS) $(HOST_PROGS)
-
-telemetrum-sirf.ihx: $(TM_SIRF_REL) Makefile
-       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TM_SIRF_REL)
-       sh check-stack ao.h telemetrum-sirf.mem
-
-telemetrum-sky.ihx: $(TM_SKY_REL) Makefile
-       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TM_SKY_REL)
-       sh check-stack ao.h telemetrum-sky.mem
-
-telemetrum-sky.ihx: telemetrum-sirf.ihx
-
-tidongle.ihx: $(TI_REL) Makefile
-       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TI_REL)
-       sh check-stack ao.h tidongle.mem
-
-tidongle.ihx: telemetrum-sky.ihx
-
-teleterra.ihx: $(TT_REL) Makefile
-       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TT_REL)
-       sh check-stack ao.h teleterra.mem
-
-teleterra.ihx: tidongle.ihx
-
-teledongle.ihx: $(TD_REL) Makefile
-       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(TD_REL)
-       sh check-stack ao.h teledongle.mem
-
-teledongle.ihx: teleterra.ihx
-
-altitude.h: make-altitude
-       nickle make-altitude > altitude.h
-
-TELEMETRUM_DEFS=ao-telemetrum.h
-TELETERRA_DEFS=ao-teleterra.h
-TELEDONGLE_DEFS=ao-teledongle.h
-TIDONGLE_DEFS=ao-tidongle.h
-
-ALL_DEFS=$(TELEMETRUM_DEFS) $(TELETERRA_DEFS) \
-       $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
-ao_product-telemetrum.rel: ao_product.c $(TELEMETRUM_DEFS)
-       $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEMETRUM_DEFS)\"' -o$@ ao_product.c
-
-ao_product-teleterra.rel: ao_product.c $(TELETERRA_DEFS)
-       $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELETERRA_DEFS)\"' -o$@ ao_product.c
-
-ao_product-teledongle.rel: ao_product.c $(TELEDONGLE_DEFS)
-       $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TELEDONGLE_DEFS)\"' -o$@ ao_product.c
-
-ao_product-tidongle.rel: ao_product.c $(TIDONGLE_DEFS)
-       $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"$(TIDONGLE_DEFS)\"' -o$@ ao_product.c
-
-$(TELEMETRUM_DEFS): ao-make-product.5c
-       nickle ao-make-product.5c -m altusmetrum.org -p TeleMetrum -v $(VERSION) > $@
-
-$(TELETERRA_DEFS): ao-make-product.5c
-       nickle ao-make-product.5c -m altusmetrum.org -p TeleTerra -v $(VERSION) > $@
-
-$(TELEDONGLE_DEFS): ao-make-product.5c
-       nickle ao-make-product.5c -m altusmetrum.org -p TeleDongle -v $(VERSION) > $@
-
-$(TIDONGLE_DEFS): ao-make-product.5c
-       nickle ao-make-product.5c -m altusmetrum.org -p TIDongle -v $(VERSION) > $@
+$(RECURSIVE_TARGETS):
+       @target=`echo $@ | sed 's/-recursive//'`; \
+       for subdir in $(SUBDIRS); do \
+               echo "Making $$target in $$subdir"; \
+               (cd $$subdir && $(MAKE) $$target) || exit 1; \
+       done
 
 distclean:     clean
 
-clean:
-       rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
-       rm -f $(PROGS) $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
-       rm -f $(ALL_DEFS) $(HOST_PROGS)
-       rm -f $(TELEMETRUM_DEFS) $(TELETERRA_DEFS) $(TELEDONGLE_DEFS) $(TIDONGLE_DEFS)
+clean: clean-recursive
 
-install:
+install: install-recursive
 
 uninstall:
-
-ao_flight_test: ao_flight.c ao_flight_test.c ao_host.h
-       cc -g -o $@ ao_flight_test.c
-
-ao_gps_test: ao_gps_sirf.c ao_gps_test.c ao_gps_print.c ao_host.h
-       cc -g -o $@ ao_gps_test.c
-
-ao_gps_test_skytraq: ao_gps_skytraq.c ao_gps_test_skytraq.c ao_gps_print.c ao_host.h
-       cc -g -o $@ ao_gps_test_skytraq.c
diff --git a/src/Makefile.proto b/src/Makefile.proto
new file mode 100644 (file)
index 0000000..958b757
--- /dev/null
@@ -0,0 +1,217 @@
+#
+# AltOS build
+#
+#
+vpath %.c ..
+vpath %.h ..
+vpath make-altitude ..
+vpath ao-make-product.5c ..
+
+CC=sdcc
+
+ifndef VERSION
+VERSION=$(shell git describe)
+endif
+
+CFLAGS=--model-small --debug --opt-code-speed
+
+LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size 0x8000 \
+       --xram-loc 0xf000 --xram-size 0xda2 --iram-size 0xff
+
+INC = \
+       ao.h \
+       ao_pins.h \
+       cc1111.h \
+       altitude.h \
+       25lc1024.h
+
+#
+# Common AltOS sources
+#
+ALTOS_SRC = \
+       ao_cmd.c \
+       ao_dma.c \
+       ao_mutex.c \
+       ao_panic.c \
+       ao_task.c \
+       ao_timer.c \
+       _bp.c
+
+#
+# Shared AltOS drivers
+#
+ALTOS_DRIVER_SRC = \
+       ao_beep.c \
+       ao_config.c \
+       ao_led.c \
+       ao_radio.c \
+       ao_stdio.c \
+       ao_usb.c
+
+TELE_COMMON_SRC = \
+       ao_packet.c \
+       ao_packet_slave.c \
+       ao_state.c
+
+#
+# Receiver code
+#
+TELE_RECEIVER_SRC =\
+       ao_monitor.c \
+       ao_gps_print.c \
+       ao_packet_master.c \
+       ao_rssi.c
+
+#
+# Shared Tele drivers (on TeleMetrum, TeleTerra, TeleDongle)
+#
+
+TELE_DRIVER_SRC = \
+       ao_convert.c \
+       ao_serial.c
+
+#
+# Debug dongle driver (only on TI)
+#
+DBG_SRC = \
+       ao_dbg.c
+
+#
+# Drivers only on TeleMetrum
+#
+TM_DRIVER_SRC = \
+       ao_adc.c \
+       ao_gps_report.c \
+       ao_ignite.c
+
+#
+# 25LC1024 driver source
+EE_DRIVER_SRC = \
+       ao_ee.c
+
+#
+# AT45DB161D driver source
+
+FLASH_DRIVER_SRC = \
+       ao_flash.c
+
+#
+# SiRF driver source
+#
+SIRF_DRIVER_SRC = \
+       ao_gps_sirf.c
+#
+# Skytraq driver source
+#
+SKY_DRIVER_SRC = \
+       ao_gps_skytraq.c
+
+#
+# Tasks run on TeleMetrum
+#
+TM_TASK_SRC = \
+       ao_flight.c \
+       ao_log.c \
+       ao_report.c \
+       ao_telemetry.c
+
+TM_MAIN_SRC = \
+       ao_telemetrum.c
+
+#
+# Base sources for TeleMetrum
+#
+TM_BASE_SRC = \
+       $(ALTOS_SRC) \
+       $(ALTOS_DRIVER_SRC) \
+       $(TELE_DRIVER_SRC) \
+       $(TELE_COMMON_SRC) \
+       $(TM_DRIVER_SRC) \
+       $(TM_TASK_SRC) \
+       $(TM_MAIN_SRC)
+
+TI_MAIN_SRC = \
+       ao_tidongle.c
+
+#
+# All sources for the TI debug dongle
+#
+TI_SRC = \
+       $(ALTOS_SRC) \
+       $(ALTOS_DRIVER_SRC) \
+       $(TELE_RECEIVER_SRC) \
+       $(TELE_COMMON_SRC) \
+       $(TI_MAIN_SRC) \
+       $(DBG_SRC)
+
+TT_MAIN_SRC = \
+       ao_teleterra.c
+#
+# All sources for TeleTerra
+#
+TT_SRC = \
+       $(ALTOS_SRC) \
+       $(ALTOS_DRIVER_SRC) \
+       $(TELE_RECEIVER_SRC) \
+       $(TELE_DRIVER_SRC) \
+       $(TELE_COMMON_SRC) \
+       $(TT_MAIN_SRC)
+
+
+#
+# Sources for TeleDongle
+#
+
+TD_MAIN_SRC = \
+       ao_teledongle.c
+
+TD_SRC = \
+       $(ALTOS_SRC) \
+       $(ALTOS_DRIVER_SRC) \
+       $(TELE_RECEIVER_SRC) \
+       $(TELE_COMMON_SRC) \
+       $(TD_MAIN_SRC)
+
+include Makefile.defs
+
+REL=$(SRC:.c=.rel) ao_product.rel
+ADB=$(REL:.rel=.adb)
+ASM=$(REL:.rel=.asm)
+LNK=$(REL:.rel=.lnk)
+LST=$(REL:.rel=.lst)
+RST=$(REL:.rel=.rst)
+SYM=$(REL:.rel=.sym)
+
+PCDB=$(PROG:.ihx=.cdb)
+PLNK=$(PROG:.ihx=.lnk)
+PMAP=$(PROG:.ihx=.map)
+PMEM=$(PROG:.ihx=.mem)
+PAOM=$(PROG:.ihx=)
+
+%.rel : %.c $(INC)
+       $(CC) -c $(CFLAGS) -o$@ $<
+
+all: $(PROG)
+
+$(PROG): $(REL) Makefile Makefile.defs ../Makefile.proto
+       $(CC) $(LDFLAGS) $(CFLAGS) -o $@ $(REL)
+
+../altitude.h: make-altitude
+       nickle $< > $@
+
+ao_product.h: ao-make-product.5c
+             nickle $< -m altusmetrum.org -p $(PRODUCT) -v $(VERSION) > $@
+
+ao_product.rel: ao_product.c ao_product.h
+       $(CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"ao_product.h\"' -o$@ $<
+
+distclean:     clean
+
+clean:
+       rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
+       rm -f $(PROG) $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
+       rm -f ao_product.h
+
+install:
+
+uninstall:
index d6be2223a33251fd6eb27291555c3c3e0a6ba119..b43f5ecd1132f190bda58524834d6fa8a585f570 100644 (file)
--- a/src/ao.h
+++ b/src/ao.h
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <stddef.h>
 #include "cc1111.h"
+#include "ao_pins.h"
 
 #define TRUE 1
 #define FALSE 0
@@ -148,15 +149,7 @@ void
 ao_clock_init(void);
 
 /*
- * ao_adc.c
- */
-
-#define AO_ADC_RING    32
-#define ao_adc_ring_next(n)    (((n) + 1) & (AO_ADC_RING - 1))
-#define ao_adc_ring_prev(n)    (((n) - 1) & (AO_ADC_RING - 1))
-
-/*
- * One set of samples read from the A/D converter
+ * One set of samples read from the A/D converter or telemetry
  */
 struct ao_adc {
        uint16_t        tick;           /* tick when the sample was read */
@@ -168,6 +161,20 @@ struct ao_adc {
        int16_t         sense_m;        /* main continuity sense */
 };
 
+#ifndef HAS_ADC
+#error Please define HAS_ADC
+#endif
+
+#if HAS_ADC
+/*
+ * ao_adc.c
+ */
+
+#define AO_ADC_RING    32
+#define ao_adc_ring_next(n)    (((n) + 1) & (AO_ADC_RING - 1))
+#define ao_adc_ring_prev(n)    (((n) - 1) & (AO_ADC_RING - 1))
+
+
 /*
  * A/D data is stored in a ring, with the next sample to be written
  * at ao_adc_head
@@ -188,15 +195,16 @@ void
 ao_adc_get(__xdata struct ao_adc *packet);
 
 /* The A/D interrupt handler */
-#if !AO_NO_ADC_ISR
+
 void
 ao_adc_isr(void) interrupt 1;
-#endif
 
 /* Initialize the A/D converter */
 void
 ao_adc_init(void);
 
+#endif /* HAS_ADC */
+
 /*
  * ao_beep.c
  */
@@ -696,13 +704,16 @@ ao_dbg_init(void);
  * ao_serial.c
  */
 
-#if !AO_NO_SERIAL_ISR
+#ifndef HAS_SERIAL_1
+#error Please define HAS_SERIAL_1
+#endif
+
+#if HAS_SERIAL_1
 void
 ao_serial_rx1_isr(void) interrupt 3;
 
 void
 ao_serial_tx1_isr(void) interrupt 14;
-#endif
 
 char
 ao_serial_getchar(void) __critical;
@@ -719,6 +730,7 @@ ao_serial_set_speed(uint8_t speed);
 
 void
 ao_serial_init(void);
+#endif
 
 /*
  * ao_gps.c
index 2b972e6cd087d041e67d9c81cfb2383f065efa56..50f968488ab2ebf6b06257de3d2ab408967e99b7 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include "ao.h"
+#include "ao_pins.h"
 
 volatile __xdata struct ao_adc ao_adc_ring[AO_ADC_RING];
 volatile __data uint8_t                ao_adc_head;
@@ -52,11 +53,13 @@ ao_adc_isr(void) interrupt 1
        a[0] = ADCL;
        a[1] = ADCH;
        if (sequence < 5) {
+#if HAS_EXTERNAL_TEMP == 0
                /* start next channel conversion */
                /* v0.2 replaces external temp sensor with internal one */
                if (sequence == 1)
                        ADCCON3 = ADCCON3_EREF_1_25 | ADCCON3_EDIV_512 | ADCCON3_ECH_TEMP;
                else
+#endif
                        ADCCON3 = ADCCON3_EREF_VDD | ADCCON3_EDIV_512 | (sequence + 1);
        } else {
                /* record this conversion series */
@@ -86,7 +89,9 @@ ao_adc_init(void)
 {
        ADCCFG = ((1 << 0) |    /* acceleration */
                  (1 << 1) |    /* pressure */
-/*               (1 << 2) |      v0.1 temperature */
+#if HAS_EXTERNAL_TEMP
+                 (1 << 2) |    /* v0.1 temperature */
+#endif
                  (1 << 3) |    /* battery voltage */
                  (1 << 4) |    /* drogue sense */
                  (1 << 5));    /* main sense */
index 4349bca856ac3a18e97aba1fe62f0939f3dc251d..f8ea27feb54e6c9124efe526317fab397ac222ce 100644 (file)
@@ -38,18 +38,22 @@ __xdata uint8_t ao_config_mutex;
  */
 const uint32_t ao_radio_cal = 1186611;
 
+#if HAS_EEPROM
 static void
 _ao_config_put(void)
 {
        ao_ee_write_config((uint8_t *) &ao_config, sizeof (ao_config));
 }
+#endif
 
 static void
 _ao_config_get(void)
 {
        if (ao_config_loaded)
                return;
+#if HAS_EEPROM
        ao_ee_read_config((uint8_t *) &ao_config, sizeof (ao_config));
+#endif
        if (ao_config.major != AO_CONFIG_MAJOR) {
                ao_config.major = AO_CONFIG_MAJOR;
                ao_config.minor = AO_CONFIG_MINOR;
@@ -149,6 +153,8 @@ ao_config_radio_channel_set(void) __reentrant
        ao_config_radio_channel_show();
 }
 
+#if HAS_ADC
+
 void
 ao_config_main_deploy_show(void) __reentrant
 {
@@ -259,6 +265,8 @@ ao_config_apogee_delay_set(void) __reentrant
        ao_config_apogee_delay_show();
 }
 
+#endif /* HAS_ADC */
+
 void
 ao_config_radio_cal_show(void) __reentrant
 {
@@ -296,25 +304,31 @@ void
 ao_config_write(void) __reentrant;
 
 __code struct ao_config_var ao_config_vars[] = {
+#if HAS_ADC
        { 'm',  ao_config_main_deploy_set,      ao_config_main_deploy_show,
                "m <meters>  Set height above launch for main deploy (in meters)" },
        { 'd',  ao_config_apogee_delay_set,     ao_config_apogee_delay_show,
                "d <delay>   Set apogee igniter delay (in seconds)" },
+#endif /* HAS_ADC */
        { 'r',  ao_config_radio_channel_set,    ao_config_radio_channel_show,
                "r <channel> Set radio channel (freq = 434.550 + channel * .1)" },
        { 'c',  ao_config_callsign_set,         ao_config_callsign_show,
                "c <call>    Set callsign broadcast in each packet (8 char max)" },
+#if HAS_ADC
        { 'a',  ao_config_accel_calibrate_set,  ao_config_accel_calibrate_show,
                "a <+g> <-g> Set accelerometer calibration (0 for auto)" },
+#endif /* HAS_ADC */
        { 'f',  ao_config_radio_cal_set,        ao_config_radio_cal_show,
                "f <cal>     Set radio calibration value (cal = rf/(xtal/2^16))" },
        { 's',  ao_config_show,                 ao_config_show,
                "s           Show current config values" },
+#if HAS_EEPROM
        { 'w',  ao_config_write,                ao_config_write,
                "w           Write current values to eeprom" },
+#endif
        { '?',  ao_config_help,                 ao_config_help,
                "?           Show available config variables" },
-       { 0,    ao_config_main_deploy_set,      ao_config_main_deploy_show,
+       { 0,    ao_config_help, ao_config_help,
                NULL },
 };
 
@@ -359,6 +373,7 @@ ao_config_show(void) __reentrant
                        (*ao_config_vars[cmd].show)();
 }
 
+#if HAS_EEPROM
 void
 ao_config_write(void) __reentrant
 {
@@ -370,6 +385,7 @@ ao_config_write(void) __reentrant
        }
        ao_mutex_put(&ao_config_mutex);
 }
+#endif
 
 __code struct ao_cmds ao_config_cmds[] = {
        { 'c',  ao_config_set,  "c <var> <value>                    Set config variable (? for help, s to show)" },
index b218897c627fd7664aa041a394e14243a553ec95..d0633f9288afceeaf084480b68846228f52af9e0 100644 (file)
  */
 
 #include "ao.h"
-
-#define DBG_CLOCK      (1 << 3)
-#define DBG_DATA       (1 << 4)
-#define DBG_RESET_N    (1 << 5)
-
-#define DBG_CLOCK_PIN  (P0_3)
-#define DBG_DATA_PIN   (P0_4)
-#define DBG_RESET_N_PIN        (P0_5)
+#include "ao_pins.h"
 
 static void
 ao_dbg_send_bits(uint8_t msk, uint8_t val) __reentrant
 {
-       P0 = (P0 & ~msk) | (val & msk);
+       DBG_PORT = (DBG_PORT & ~msk) | (val & msk);
        _asm
                nop
                nop
@@ -40,8 +33,8 @@ ao_dbg_send_byte(uint8_t byte)
 {
        __xdata uint8_t b, d;
 
-       P0 |= DBG_DATA;
-       P0DIR |= DBG_DATA;
+       DBG_PORT |= DBG_DATA;
+       DBG_PORT_DIR |= DBG_DATA;
        for (b = 0; b < 8; b++) {
                d = 0;
                if (byte & 0x80)
@@ -50,7 +43,7 @@ ao_dbg_send_byte(uint8_t byte)
                ao_dbg_send_bits(DBG_CLOCK|DBG_DATA, DBG_CLOCK|d);
                ao_dbg_send_bits(DBG_CLOCK|DBG_DATA,     0    |d);
        }
-       P0DIR &= ~DBG_DATA;
+       DBG_PORT_DIR &= ~DBG_DATA;
 }
 
 uint8_t
@@ -171,20 +164,15 @@ ao_dbg_read_byte(void)
 static void
 ao_dbg_set_pins(void)
 {
-       /* Disable peripheral use of P0 */
-       ADCCFG = 0;
-       P0SEL = 0;
-
-
-       /* make P0_4 tri-state */
-       P0INP = DBG_DATA;
-       P2INP &= ~(P2INP_PDUP0_PULL_DOWN);
+       /* make DBG_DATA tri-state */
+       DBG_PORT_INP |= DBG_DATA;
 
        /* Raise RESET_N and CLOCK */
-       P0 = DBG_RESET_N | DBG_CLOCK;
+       DBG_PORT |= DBG_RESET_N | DBG_CLOCK;
 
        /* RESET_N and CLOCK are outputs now */
-       P0DIR = DBG_RESET_N | DBG_CLOCK;
+       DBG_PORT_DIR |= DBG_RESET_N | DBG_CLOCK;
+       DBG_PORT_DIR &= ~DBG_DATA;
 }
 
 static void
index 6b42f9f93e8775c8b3d1a1e9e34eee752948e2b4..fa03a9104c8bffd9581f1722f2021109a4d5f634 100644 (file)
@@ -117,30 +117,6 @@ struct ao_cmds {
 };
 
 
-static int16_t altitude_table[2048] = {
-#include "altitude.h"
-};
-
-int16_t
-ao_pres_to_altitude(int16_t pres) __reentrant
-{
-       pres = pres >> 4;
-       if (pres < 0) pres = 0;
-       if (pres > 2047) pres = 2047;
-       return altitude_table[pres];
-}
-
-int16_t
-ao_altitude_to_pres(int16_t alt) __reentrant
-{
-       int16_t pres;
-
-       for (pres = 0; pres < 2047; pres++)
-               if (altitude_table[pres] <= alt)
-                       break;
-       return pres << 4;
-}
-
 struct ao_config {
        uint16_t        main_deploy;
        int16_t         accel_zero_g;
index 98fdcb90388c50803eea8b1ab3c965faa49ea98d..dcd1647c1ed1c7a6bf273b2307012325351d8bce 100644 (file)
@@ -113,6 +113,11 @@ ao_packet_recv(void)
        return dma_done;
 }
 
+#ifndef PACKET_HAS_MASTER
+#define PACKET_HAS_MASTER 1
+#endif
+
+#if PACKET_HAS_MASTER
 void
 ao_packet_flush(void)
 {
@@ -122,12 +127,15 @@ ao_packet_flush(void)
        if (ao_packet_tx_used && ao_packet_master_sleeping)
                ao_wake_task(&ao_packet_task);
 }
+#endif /* PACKET_HAS_MASTER */
 
 void
 ao_packet_putchar(char c) __reentrant
 {
        while (ao_packet_tx_used == AO_PACKET_MAX && ao_packet_enable) {
+#if PACKET_HAS_MASTER
                ao_packet_flush();
+#endif
                ao_sleep(&tx_data);
        }
 
index 122c4da0588148ffb18d9b8daacc5a553cdbcfca..4c947fbffed989f324f24b98f08107ad6ef80a4a 100644 (file)
@@ -56,5 +56,5 @@ ao_packet_slave_init(void)
 {
        ao_add_stdio(ao_packet_pollchar,
                     ao_packet_putchar,
-                    ao_packet_flush);
+                    NULL);
 }
diff --git a/src/ao_pins.h b/src/ao_pins.h
new file mode 100644 (file)
index 0000000..84d8a1a
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright © 2010 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * 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.
+ */
+
+#ifndef _AO_PINS_H_
+#define _AO_PINS_H_
+
+#if defined(TELEMETRUM_V_0_2)
+       #define HAS_SERIAL_1            1
+       #define HAS_ADC                 1
+       #define HAS_EEPROM              1
+       #define HAS_DBG                 1
+       #define DBG_ON_P1               1
+       #define DBG_ON_P0               0
+       #define PACKET_HAS_MASTER       0
+       #define PACKET_HAS_SLAVE        1
+
+       #define LEDS_AVAILABLE          (AO_LED_RED)
+       #define HAS_EXTERNAL_TEMP       0
+#endif
+
+#if defined(TELEDONGLE_V_0_2)
+       #define HAS_SERIAL_1            0
+       #define HAS_ADC                 0
+       #define HAS_DBG                 1
+       #define HAS_EEPROM              0
+       #define DBG_ON_P1               1
+       #define DBG_ON_P0               0
+       #define PACKET_HAS_MASTER       1
+       #define PACKET_HAS_SLAVE        0
+       #define LEDS_AVAILABLE          (AO_LED_RED)
+#endif
+
+#if defined(TELEMETRUM_V_0_1)
+       #define HAS_SERIAL_1            1
+       #define HAS_ADC                 1
+       #define HAS_DBG                 0
+       #define HAS_EEPROM              1
+       #define DBG_ON_P1               0
+       #define DBG_ON_P0               1
+       #define PACKET_HAS_MASTER       0
+       #define PACKET_HAS_SLAVE        1
+       #define LEDS_AVAILABLE          (AO_LED_RED|AO_LED_GREEN)
+       #define HAS_EXTERNAL_TEMP       1
+#endif
+
+#if defined(TELEDONGLE_V_0_1)
+       #define HAS_SERIAL_1            0
+       #define HAS_ADC                 0
+       #define HAS_DBG                 0
+       #define HAS_EEPROM              0
+       #define DBG_ON_P1               0
+       #define DBG_ON_P0               1
+       #define PACKET_HAS_MASTER       1
+       #define PACKET_HAS_SLAVE        0
+       #define LEDS_AVAILABLE          (AO_LED_RED|AO_LED_GREEN)
+#endif
+
+#if defined(TIDONGLE)
+       #define HAS_SERIAL_1            0
+       #define HAS_ADC                 0
+       #define HAS_DBG                 1
+       #define HAS_EEPROM              0
+       #define DBG_ON_P1               0
+       #define DBG_ON_P0               1
+       #define PACKET_HAS_MASTER       1
+       #define PACKET_HAS_SLAVE        0
+       #define LEDS_AVAILABLE          (AO_LED_RED)
+#endif
+
+#if DBG_ON_P1
+
+       #define DBG_CLOCK       (1 << 4)        /* mi0 */
+       #define DBG_DATA        (1 << 5)        /* mo0 */
+       #define DBG_RESET_N     (1 << 3)        /* c0 */
+
+       #define DBG_CLOCK_PIN   (P1_4)
+       #define DBG_DATA_PIN    (P1_5)
+       #define DBG_RESET_N_PIN (P1_3)
+
+       #define DBG_PORT_NUM    1
+       #define DBG_PORT        P1
+       #define DBG_PORT_SEL    P1SEL
+       #define DBG_PORT_INP    P1INP
+       #define DBG_PORT_DIR    P1DIR
+
+#endif /* DBG_ON_P1 */
+
+#if DBG_ON_P0
+
+       #define DBG_CLOCK       (1 << 3)
+       #define DBG_DATA        (1 << 4)
+       #define DBG_RESET_N     (1 << 5)
+
+       #define DBG_CLOCK_PIN   (P0_3)
+       #define DBG_DATA_PIN    (P0_4)
+       #define DBG_RESET_N_PIN (P0_5)
+
+       #define DBG_PORT_NUM    0
+       #define DBG_PORT        P0
+       #define DBG_PORT_SEL    P0SEL
+       #define DBG_PORT_INP    P0INP
+       #define DBG_PORT_DIR    P0DIR
+
+#endif /* DBG_ON_P0 */
+
+#ifndef HAS_SERIAL_1
+#error Please define HAS_SERIAL_1
+#endif
+
+#ifndef HAS_ADC
+#error Please define HAS_ADC
+#endif
+
+#ifndef HAS_EEPROM
+#error Please define HAS_EEPROM
+#endif
+
+#ifndef HAS_DBG
+#error Please define HAS_DBG
+#endif
+
+#ifndef PACKET_HAS_MASTER
+#error Please define PACKET_HAS_MASTER
+#endif
+
+#ifndef PACKET_HAS_SLAVE
+#error Please define PACKET_HAS_SLAVE
+#endif
+
+#endif /* _AO_PINS_H_ */
diff --git a/src/ao_reboot.c b/src/ao_reboot.c
new file mode 100644 (file)
index 0000000..82ea32e
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2009 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * 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.
+ */
+
+#include "ao.h"
+
+/* Use the watchdog timer to force a complete reboot
+ */
+void
+ao_reboot(void)
+{
+       WDCTL = WDCTL_EN | WDCTL_MODE_WATCHDOG | WDCTL_INT_32768;
+       ao_sleep(AO_SEC_TO_TICKS(2));
+       ao_panic(AO_PANIC_REBOOT);
+}
index 7bc416e1cf2a35ccce874033f61bf583e2f93830..8add30b842b04e1135a11201780a3d778da74671 100644 (file)
@@ -38,7 +38,8 @@ putchar(char c)
 void
 flush(void)
 {
-       stdios[ao_cur_stdio].flush();
+       if (stdios[ao_cur_stdio].flush)
+               stdios[ao_cur_stdio].flush();
 }
 
 __xdata uint8_t ao_stdin_ready;
index e4828d80dcef17452bb4ab9eb4c7915cdf6f61c2..b07b1746ab81635c874b725f642426f388d2acf6 100644 (file)
@@ -15,8 +15,6 @@
  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
  */
 
-#define AO_NO_SERIAL_ISR 1
-#define AO_NO_ADC_ISR 1
 #include "ao.h"
 
 void
@@ -35,6 +33,9 @@ main(void)
        ao_radio_init();
        ao_packet_slave_init();
        ao_packet_master_init();
+#if HAS_DBG
+       ao_dbg_init();
+#endif
        ao_config_init();
        ao_start_scheduler();
 }
index 89743837c6daf81eaf6571b21e0187d2d4dd3e92..fd0adae8f419abd7489ea761dca584be64a32439 100644 (file)
@@ -16,6 +16,7 @@
  */
 
 #include "ao.h"
+#include "ao_pins.h"
 
 /* stub so as telemetrum doesn't have monitor mode */
 void
@@ -31,7 +32,7 @@ main(void)
 
 
        /* Turn on the red LED until the system is stable */
-       ao_led_init(AO_LED_RED);
+       ao_led_init(LEDS_AVAILABLE);
        ao_led_on(AO_LED_RED);
 
        /* A hack -- look at the SPI clock pin, if it's sitting at
@@ -59,6 +60,9 @@ main(void)
        ao_radio_init();
        ao_packet_slave_init();
        ao_igniter_init();
+#if HAS_DBG
+       ao_dbg_init();
+#endif
        ao_config_init();
        ao_start_scheduler();
 }
index e81f937d9604096bc3995620a0b17730d55d74c9..d1731475c226eee9992ae00315c333b1877f2285 100644 (file)
@@ -36,24 +36,30 @@ ao_delay(uint16_t ticks)
 #define T1_CLOCK_DIVISOR       8       /* 24e6/8 = 3e6 */
 #define T1_SAMPLE_TIME         30000   /* 3e6/30000 = 100 */
 
+#if HAS_ADC
 volatile __data uint8_t        ao_adc_interval = 1;
 volatile __data uint8_t        ao_adc_count;
+#endif
 
 void ao_timer_isr(void) interrupt 9
 {
        ++ao_tick_count;
+#if HAS_ADC
        if (++ao_adc_count == ao_adc_interval) {
                ao_adc_count = 0;
                ao_adc_poll();
        }
+#endif
 }
 
+#if HAS_ADC
 void
 ao_timer_set_adc_interval(uint8_t interval) __critical
 {
        ao_adc_interval = interval;
        ao_adc_count = 0;
 }
+#endif
 
 void
 ao_timer_init(void)
diff --git a/src/teledongle-v0.1/Makefile b/src/teledongle-v0.1/Makefile
new file mode 100644 (file)
index 0000000..d8867b1
--- /dev/null
@@ -0,0 +1 @@
+include ../Makefile.proto
diff --git a/src/teledongle-v0.1/Makefile.defs b/src/teledongle-v0.1/Makefile.defs
new file mode 100644 (file)
index 0000000..3526b4c
--- /dev/null
@@ -0,0 +1,9 @@
+PROG = teledongle-v0.1.ihx
+
+SRC = \
+       $(TD_SRC) \
+       $(DBG_SRC)
+
+PRODUCT=TeleDongle-v0.1
+
+CFLAGS += -DTELEDONGLE_V_0_1 -I.
diff --git a/src/teledongle-v0.2/Makefile b/src/teledongle-v0.2/Makefile
new file mode 100644 (file)
index 0000000..d8867b1
--- /dev/null
@@ -0,0 +1 @@
+include ../Makefile.proto
diff --git a/src/teledongle-v0.2/Makefile.defs b/src/teledongle-v0.2/Makefile.defs
new file mode 100644 (file)
index 0000000..faad4dc
--- /dev/null
@@ -0,0 +1,9 @@
+PROG = teledongle-v0.2.ihx
+
+SRC = \
+       $(TD_SRC) \
+       $(DBG_SRC)
+
+PRODUCT=TeleDongle-v0.2
+
+CFLAGS += -DTELEDONGLE_V_0_2 -I.
diff --git a/src/telemetrum-v0.1-sirf/Makefile b/src/telemetrum-v0.1-sirf/Makefile
new file mode 100644 (file)
index 0000000..d8867b1
--- /dev/null
@@ -0,0 +1 @@
+include ../Makefile.proto
diff --git a/src/telemetrum-v0.1-sirf/Makefile.defs b/src/telemetrum-v0.1-sirf/Makefile.defs
new file mode 100644 (file)
index 0000000..1157d67
--- /dev/null
@@ -0,0 +1,11 @@
+PROG = telemetrum-v0.1-sirf.ihx
+
+SRC = \
+       $(TM_BASE_SRC) \
+       $(EE_DRIVER_SRC) \
+       $(SIRF_DRIVER_SRC) \
+       $(DBG_SRC)
+
+PRODUCT=TeleMetrum-v0.1-SiRF
+
+CFLAGS += -DTELEMETRUM_V_0_1 -I.
diff --git a/src/telemetrum-v0.1-sky/Makefile b/src/telemetrum-v0.1-sky/Makefile
new file mode 100644 (file)
index 0000000..d8867b1
--- /dev/null
@@ -0,0 +1 @@
+include ../Makefile.proto
diff --git a/src/telemetrum-v0.1-sky/Makefile.defs b/src/telemetrum-v0.1-sky/Makefile.defs
new file mode 100644 (file)
index 0000000..ff7fd1b
--- /dev/null
@@ -0,0 +1,11 @@
+PROG = telemetrum-v0.1-sky.ihx
+
+SRC = \
+       $(TM_BASE_SRC) \
+       $(EE_DRIVER_SRC) \
+       $(SKY_DRIVER_SRC) \
+       $(DBG_SRC)
+
+PRODUCT=TeleMetrum-v0.1
+
+CFLAGS += -DTELEMETRUM_V_0_1 -I.
diff --git a/src/telemetrum-v0.2/Makefile b/src/telemetrum-v0.2/Makefile
new file mode 100644 (file)
index 0000000..d8867b1
--- /dev/null
@@ -0,0 +1 @@
+include ../Makefile.proto
diff --git a/src/telemetrum-v0.2/Makefile.defs b/src/telemetrum-v0.2/Makefile.defs
new file mode 100644 (file)
index 0000000..d5b0a96
--- /dev/null
@@ -0,0 +1,11 @@
+PROG = telemetrum-v0.2.ihx
+
+SRC = \
+       $(TM_BASE_SRC) \
+       $(FLASH_DRIVER_SRC) \
+       $(SKY_DRIVER_SRC) \
+       $(DBG_SRC)
+
+PRODUCT=TeleMetrum-v0.2
+
+CFLAGS += -DTELEMETRUM_V_0_2 -I.
diff --git a/src/test/Makefile b/src/test/Makefile
new file mode 100644 (file)
index 0000000..f6e9b9f
--- /dev/null
@@ -0,0 +1,24 @@
+vpath % ..
+
+PROGS=ao_flight_test ao_gps_test ao_gps_test_skytraq ao_convert_test
+
+CFLAGS=-I.. -I.
+
+all: $(PROGS)
+
+clean:
+       rm -f $(PROGS)
+
+install:
+
+ao_flight_test: ao_flight_test.c ao_flight_test.c ao_host.h
+       cc -g -o $@ $<
+
+ao_gps_test: ao_gps_test.c ao_gps_sirf.c ao_gps_print.c ao_host.h
+       cc -g -o $@ $<
+
+ao_gps_test_skytraq: ao_gps_test_skytraq.c ao_gps_skytraq.c ao_gps_print.c ao_host.h
+       cc -g -o $@ $<
+
+ao_convert_test: ao_convert_test.c ao_convert.c altitude.h
+       cc -g -o $@ $<
diff --git a/src/tidongle/Makefile b/src/tidongle/Makefile
new file mode 100644 (file)
index 0000000..d8867b1
--- /dev/null
@@ -0,0 +1 @@
+include ../Makefile.proto
diff --git a/src/tidongle/Makefile.defs b/src/tidongle/Makefile.defs
new file mode 100644 (file)
index 0000000..1676294
--- /dev/null
@@ -0,0 +1,8 @@
+PROG = tidongle.ihx
+
+SRC = \
+       $(TI_SRC)
+
+PRODUCT=TIDongle
+
+CFLAGS += -DTIDONGLE -I.