#
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
--- /dev/null
+#
+# 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:
#include <string.h>
#include <stddef.h>
#include "cc1111.h"
+#include "ao_pins.h"
#define TRUE 1
#define FALSE 0
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 */
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
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
*/
* 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;
void
ao_serial_init(void);
+#endif
/*
* ao_gps.c
*/
#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;
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 */
{
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 */
*/
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;
ao_config_radio_channel_show();
}
+#if HAS_ADC
+
void
ao_config_main_deploy_show(void) __reentrant
{
ao_config_apogee_delay_show();
}
+#endif /* HAS_ADC */
+
void
ao_config_radio_cal_show(void) __reentrant
{
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 },
};
(*ao_config_vars[cmd].show)();
}
+#if HAS_EEPROM
void
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)" },
*/
#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
{
__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)
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
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
};
-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;
return dma_done;
}
+#ifndef PACKET_HAS_MASTER
+#define PACKET_HAS_MASTER 1
+#endif
+
+#if PACKET_HAS_MASTER
void
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);
}
{
ao_add_stdio(ao_packet_pollchar,
ao_packet_putchar,
- ao_packet_flush);
+ NULL);
}
--- /dev/null
+/*
+ * 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_ */
--- /dev/null
+/*
+ * 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);
+}
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;
* 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
ao_radio_init();
ao_packet_slave_init();
ao_packet_master_init();
+#if HAS_DBG
+ ao_dbg_init();
+#endif
ao_config_init();
ao_start_scheduler();
}
*/
#include "ao.h"
+#include "ao_pins.h"
/* stub so as telemetrum doesn't have monitor mode */
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
ao_radio_init();
ao_packet_slave_init();
ao_igniter_init();
+#if HAS_DBG
+ ao_dbg_init();
+#endif
ao_config_init();
ao_start_scheduler();
}
#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)
--- /dev/null
+include ../Makefile.proto
--- /dev/null
+PROG = teledongle-v0.1.ihx
+
+SRC = \
+ $(TD_SRC) \
+ $(DBG_SRC)
+
+PRODUCT=TeleDongle-v0.1
+
+CFLAGS += -DTELEDONGLE_V_0_1 -I.
--- /dev/null
+include ../Makefile.proto
--- /dev/null
+PROG = teledongle-v0.2.ihx
+
+SRC = \
+ $(TD_SRC) \
+ $(DBG_SRC)
+
+PRODUCT=TeleDongle-v0.2
+
+CFLAGS += -DTELEDONGLE_V_0_2 -I.
--- /dev/null
+include ../Makefile.proto
--- /dev/null
+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.
--- /dev/null
+include ../Makefile.proto
--- /dev/null
+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.
--- /dev/null
+include ../Makefile.proto
--- /dev/null
+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.
--- /dev/null
+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 $@ $<
--- /dev/null
+include ../Makefile.proto
--- /dev/null
+PROG = tidongle.ihx
+
+SRC = \
+ $(TI_SRC)
+
+PRODUCT=TIDongle
+
+CFLAGS += -DTIDONGLE -I.