src-avr: Add a couple of missing files
authorKeith Packard <keithp@keithp.com>
Wed, 18 May 2011 00:51:55 +0000 (17:51 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 18 May 2011 00:51:55 +0000 (17:51 -0700)
These are part of the ../src directory, I think

Signed-off-by: Keith Packard <keithp@keithp.com>
src-avr/Makefile.proto [new file with mode: 0644]
src-avr/Version.in [new file with mode: 0644]
src-avr/ao-make-product.5c [new file with mode: 0644]
src-avr/check-stack [new file with mode: 0755]

diff --git a/src-avr/Makefile.proto b/src-avr/Makefile.proto
new file mode 100644 (file)
index 0000000..ca68edb
--- /dev/null
@@ -0,0 +1,366 @@
+#
+# AltOS build
+#
+#
+vpath %.c ..
+vpath %.h ..
+vpath make-altitude ..
+vpath make-kalman ..
+vpath kalman.5c ../kalman
+vpath kalman_filter.5c ../kalman
+vpath load_csv.5c ../kalman
+vpath matrix.5c ../kalman
+vpath ao-make-product.5c ..
+
+CC=sdcc
+
+ifndef VERSION
+include ../Version
+endif
+
+CFLAGS=--model-small --debug --opt-code-speed -DCODESIZE=$(CODESIZE)
+
+CODESIZE ?= 0x8000
+
+LDFLAGS=--out-fmt-ihx --code-loc 0x0000 --code-size $(CODESIZE) \
+       --xram-loc 0xf000 --xram-size 0xda2 --iram-size 0xff
+
+INC = \
+       ao.h \
+       ao_pins.h \
+       cc1111.h \
+       altitude.h \
+       ao_kalman.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 \
+       ao_romconfig.c \
+       _bp.c
+
+#
+# Shared AltOS drivers
+#
+ALTOS_DRIVER_SRC = \
+       ao_config.c \
+       ao_led.c \
+       ao_radio.c \
+       ao_stdio.c
+
+BEEP_DRIVER_SRC = \
+       ao_beep.c
+
+USB_DRIVER_SRC = \
+       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
+
+#
+# Serial port driver
+#
+SERIAL_DRIVER_SRC = \
+       ao_serial.c
+
+#
+# Spi bus driver
+#
+SPI_DRIVER_SRC = \
+       ao_spi.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 \
+       $(BEEP_DRIVER_SRC) \
+       $(USB_DRIVER_SRC)
+
+#
+# 25LC1024 driver source
+EE_DRIVER_SRC = \
+       ao_storage.c \
+       ao_ee.c
+
+#
+# AT45DB161D driver source
+
+FLASH_DRIVER_SRC = \
+       ao_storage.c \
+       ao_flash.c
+
+#
+# Numonyx M25P80 driver source
+#
+
+M25_DRIVER_SRC = \
+       ao_storage.c \
+       ao_m25.c
+
+#
+# SiRF driver source
+#
+SIRF_DRIVER_SRC = \
+       ao_gps_sirf.c
+
+#
+# Skytraq driver source
+#
+SKY_DRIVER_SRC = \
+       ao_gps_skytraq.c
+
+
+#
+# BTM-182 driver source
+#
+BTM_DRIVER_SRC = \
+       ao_btm.c
+
+#
+# Tasks run on TeleMetrum
+#
+TM_TASK_SRC = \
+       ao_flight.c \
+       ao_sample.c \
+       ao_kalman.c \
+       ao_log.c \
+       ao_log_big.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) \
+       $(SERIAL_DRIVER_SRC) \
+       $(TELE_COMMON_SRC) \
+       $(TM_DRIVER_SRC) \
+       $(TM_TASK_SRC) \
+       $(TM_MAIN_SRC)
+
+#
+# Sources for TeleMini
+TMINI_DRIVER_SRC = \
+       ao_adc.c \
+       ao_ignite.c \
+       ao_config.c \
+       ao_storage.c \
+       ao_intflash.c
+
+TMINI_TASK_SRC = \
+       ao_flight.c \
+       ao_sample.c \
+       ao_kalman.c \
+       ao_log.c \
+       ao_log_tiny.c \
+       ao_report.c \
+       ao_telemetry_tiny.c
+
+TMINI_MAIN_SRC = \
+       ao_telemini.c
+
+TMINI_BASE_SRC = \
+       $(ALTOS_SRC) \
+       $(ALTOS_DRIVER_SRC) \
+       $(TELE_DRIVER_SRC) \
+       $(TELE_COMMON_SRC) \
+       $(TMINI_DRIVER_SRC) \
+       $(TMINI_TASK_SRC) \
+       $(TMINI_MAIN_SRC)
+
+#
+# Sources for TeleNano
+TNANO_DRIVER_SRC = \
+       ao_adc.c \
+       ao_config.c \
+       ao_storage.c \
+       ao_intflash.c
+
+TNANO_TASK_SRC = \
+       ao_flight_nano.c \
+       ao_sample.c \
+       ao_kalman.c \
+       ao_log.c \
+       ao_log_tiny.c \
+       ao_report.c \
+       ao_telemetry_tiny.c
+
+TNANO_MAIN_SRC = \
+       ao_telenano.c
+
+TNANO_BASE_SRC = \
+       $(ALTOS_SRC) \
+       $(ALTOS_DRIVER_SRC) \
+       $(TELE_DRIVER_SRC) \
+       $(TELE_COMMON_SRC) \
+       $(TNANO_DRIVER_SRC) \
+       $(TNANO_TASK_SRC) \
+       $(TNANO_MAIN_SRC)
+
+#
+# Sources for TeleDongle
+#
+
+TBT_MAIN_SRC = \
+       ao_telebt.c
+
+TBT_BASE_SRC = \
+       $(ALTOS_SRC) \
+       $(ALTOS_DRIVER_SRC) \
+       $(TELE_RECEIVER_SRC) \
+       $(TELE_COMMON_SRC) \
+       $(SERIAL_DRIVER_SRC) \
+       $(USB_DRIVER_SRC) \
+       $(BTM_DRIVER_SRC) \
+       $(DBG_SRC) \
+       $(TBT_MAIN_SRC)
+
+#
+# TI Dongle sources
+#
+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) \
+       $(USB_DRIVER_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) \
+       $(USB_DRIVER_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) \
+       $(USB_DRIVER_SRC) \
+       $(TD_MAIN_SRC)
+
+include Makefile.defs
+
+CFLAGS += $(PRODUCT_DEF) -I.
+
+NICKLE=nickle
+CHECK_STACK=sh ../check-stack
+
+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=)
+
+V=0
+# The user has explicitly enabled quiet compilation.
+ifeq ($(V),0)
+quiet = @printf "  $1 $2 $@\n"; $($1)
+endif
+# Otherwise, print the full command line.
+quiet ?= $($1)
+
+%.rel : %.c $(INC)
+       $(call quiet,CC,$(PRODUCT_DEF)) $(CFLAGS) -c -o$@ $<
+
+all: ../$(PROG)
+
+../$(PROG): $(REL) Makefile Makefile.defs ../Makefile.proto
+       $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) ..
+       $(call quiet,CHECK_STACK) ../ao.h $(PMEM)
+
+../altitude.h: make-altitude
+       nickle $< > $@
+
+../ao_kalman.h: make-kalman kalman.5c kalman_filter.5c load_csv.5c matrix.5c
+       sh $< > $@
+
+ao_product.h: ao-make-product.5c ../Version
+       $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
+
+ao_product.rel: ao_product.c ao_product.h
+       $(call quiet,CC) -c $(CFLAGS) -D PRODUCT_DEFS='\"ao_product.h\"' -o$@ $<
+
+distclean:     clean
+
+clean:
+       rm -f $(ADB) $(ASM) $(LNK) $(LST) $(REL) $(RST) $(SYM)
+       rm -f $(PCDB) $(PLNK) $(PMAP) $(PMEM) $(PAOM)
+       rm -f ao_product.h
+       rm -f ../$(PROG)
+
+install:
+
+uninstall:
diff --git a/src-avr/Version.in b/src-avr/Version.in
new file mode 100644 (file)
index 0000000..aff9490
--- /dev/null
@@ -0,0 +1 @@
+VERSION=@VERSION@
diff --git a/src-avr/ao-make-product.5c b/src-avr/ao-make-product.5c
new file mode 100644 (file)
index 0000000..5f2eb8e
--- /dev/null
@@ -0,0 +1,103 @@
+#!/bin/sh
+
+autoimport ParseArgs;
+
+void
+write_ucs2(string a, string description)
+{
+       int len = String::length(a);
+
+       printf("/* %s */\n", description);
+       printf("#define AO_%s_LEN 0x%02x\n", description, len * 2 + 2);
+       printf("#define AO_%s_STRING \"%s\"\n", description, a);
+       printf("#define AO_%s_UCS2", description);
+       for (int i = 0; i < len; i++) {
+               int     c = a[i];
+               if (i > 0)
+                       printf(",");
+               if (0x20 <= c && c < 128)
+                       printf(" '%c', 0", c);
+               else
+                       printf(" LE_WORD(0x%04x),", c);
+       }
+       printf("\n\n");
+}
+
+void
+write_string(string a, string description)
+{
+       printf ("/* %s */\n", description);
+       printf ("#define AO_%s_STRING \"%s\"\n", description, a);
+}
+
+void
+write_int(int a, string description)
+{
+       printf ("/* %s */\n", description);
+       printf ("#define AO_%s_NUMBER %d\n\n", description, a);
+}
+
+void
+write_hex(int a, string description)
+{
+       printf ("/* %s */\n", description);
+       printf ("#define AO_%s_NUMBER 0x%04x\n\n", description, a);
+}
+
+string manufacturer = "altusmetrum.org";
+string product = "TeleMetrum";
+string version = "0.0";
+int serial = 1;
+int user_argind = 0;
+int id_product = 0x000a;
+
+argdesc argd = {
+       .args = {
+               {
+                       .var = { .arg_string = &manufacturer },
+                       .abbr = 'm',
+                       .name = "manufacturer",
+                       .expr_name = "manf",
+                       .desc = "Manufacturer name." },
+               {
+                       .var = { .arg_string = &product },
+                       .abbr = 'p',
+                       .name = "product",
+                       .expr_name = "prod",
+                       .desc = "Product name." },
+               {
+                       .var = { .arg_int = &id_product },
+                       .abbr = 'i',
+                       .name = "id_product",
+                       .expr_name = "id_p",
+                       .desc = "Product ID." },
+               {
+                       .var = { .arg_int = &serial },
+                       .abbr = 's',
+                       .name = "serial",
+                       .expr_name = "number",
+                       .desc = "Serial number." },
+               {
+                       .var = { .arg_string = &version },
+                       .abbr = 'v',
+                       .name = "version",
+                       .expr_name = "string",
+                       .desc = "Program version." },
+       },
+       .prog_name = "usb descriptors",
+};
+
+void
+main()
+{
+       string[dim(argv)-1] nargv = {[n] = argv[n+1]};
+       parseargs(&argd, &nargv);
+       write_ucs2(manufacturer, "iManufacturer");
+       write_ucs2(product, "iProduct");
+       write_ucs2(sprintf("%06d", serial), "iSerial");
+       write_int(serial, "iSerial");
+       write_hex(id_product, "idProduct");
+       write_string(version, "iVersion");
+}
+
+main();
diff --git a/src-avr/check-stack b/src-avr/check-stack
new file mode 100755 (executable)
index 0000000..1e8044e
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh
+HEADER=$1
+MEM=$2
+
+HEADER_STACK=`awk '/#define AO_STACK_START/ {print strtonum($3)}' $HEADER`
+MEM_STACK=`awk '/Stack starts at/ {print strtonum ($4)}' $MEM`
+
+if [ "$HEADER_STACK" -lt "$MEM_STACK" ]; then
+        echo $MEM_STACK | awk '{ printf ("Set AO_STACK_START to at least 0x%x\n", $1); }'
+       exit 1
+else
+       exit 0
+fi