diff options
Diffstat (limited to 'src')
56 files changed, 347 insertions, 154 deletions
diff --git a/src/Makedefs.in b/src/Makedefs.in new file mode 100644 index 00000000..6dc9ab0f --- /dev/null +++ b/src/Makedefs.in @@ -0,0 +1,10 @@ +ARM_CC=@ARM_CC@ +HAVE_ARM_M3_CC=@HAVE_ARM_M3_CC@ +HAVE_ARM_M0_CC=@HAVE_ARM_M0_CC@ + +SDCC=@SDCC@ +HAVE_SDCC=@HAVE_SDCC@ + +AVR_CC=@AVR_CC@ +AVR_OBJCOPY=@AVR_OBJCOPY@ +HAVE_AVR_CC=@HAVE_AVR_CC@ diff --git a/src/Makefile b/src/Makefile index af2630fc..ae231c64 100644 --- a/src/Makefile +++ b/src/Makefile @@ -13,6 +13,7 @@ vpath load_csv.5c kalman vpath matrix.5c kalman include Version +include Makedefs SDCCDIRS=\ telemetrum-v1.2 telemetrum-v1.1 telemetrum-v1.0 \ @@ -23,39 +24,38 @@ SDCCDIRS=\ telefire-v0.1 telefire-v0.2 \ telemini-v2.0 -AVRDIRS=\ - telescience-v0.1 telescience-pwm micropeak - -ARMDIRS=\ +ARMM3DIRS=\ telemega-v0.1 telemega-v0.1/flash-loader \ telemega-v0.3 telemega-v0.3/flash-loader \ megadongle-v0.1 megadongle-v0.1/flash-loader \ telegps-v0.3 telegps-v0.3/flash-loader \ stm-bringup stm-demo \ telelco-v0.2 telelco-v0.2/flash-loader \ - telescience-v0.2 telescience-v0.2/flash-loader \ - easymini-v0.1 easymini-v0.1/flash-loader + telescience-v0.2 telescience-v0.2/flash-loader ARMM0DIRS=\ - easymini-v0.1 + easymini-v1.0 easymini-v1.0/flash-loader + +AVRDIRS=\ + telescience-v0.1 telescience-pwm micropeak nanopeak-v0.1 -ifneq ($(shell which sdcc),) +ifeq ($(strip $(HAVE_SDCC)),yes) SUBDIRS += $(SDCCDIRS) endif -ifneq ($(shell which avr-gcc),) - SUBDIRS += $(AVRDIRS) +ifeq ($(strip ($HAVE_ARM_M3_CC)),yes) + SUBDIRS += $(ARMM3DIRS) endif -ifneq ($(shell which /opt/cortex/bin/arm-none-eabi-gcc),) - SUBDIRS += $(ARMDIRS) +ifneq ($(strip ($HAVE_ARM_M0_CC)),yes) + SUBDIRS += $(ARMM0DIRS) endif -ifneq ($(shell which /usr/bin/arm-none-eabi-gcc),) - SUBDIRS += $(ARMM0DIRS) +ifeq ($(strip $(HAVE_AVR_CC)),yes) + SUBDIRS += $(AVRDIRS) endif -ALLDIRS=$(SDCCDIRS) $(AVRDIRS) $(ARMDIRS) +ALLDIRS=$(SDCCDIRS) $(ARMM3DIRS) $(ARMM0DIRS) $(AVRDIRS) all: all-local all-recursive diff --git a/src/micropeak/ao_async.c b/src/attiny/ao_async.c index 3556f54c..3556f54c 100644 --- a/src/micropeak/ao_async.c +++ b/src/attiny/ao_async.c diff --git a/src/micropeak/ao_async.h b/src/attiny/ao_async.h index 1b239712..1b239712 100644 --- a/src/micropeak/ao_async.h +++ b/src/attiny/ao_async.h diff --git a/src/avr-demo/Makefile b/src/avr-demo/Makefile index 93295166..6d9bfea2 100644 --- a/src/avr-demo/Makefile +++ b/src/avr-demo/Makefile @@ -11,18 +11,12 @@ vpath load_csv.5c ../kalman vpath matrix.5c ../kalman vpath ao-make-product.5c ../util +include ../avr/Makefile.defs + MCU=atmega32u4 DUDECPUTYPE=m32u4 #PROGRAMMER=stk500v2 -P usb -PROGRAMMER=usbtiny -LOADCMD=avrdude LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: -CC=avr-gcc -OBJCOPY=avr-objcopy - -ifndef VERSION -include ../Version -endif INC = \ ao.h \ diff --git a/src/avr/Makefile.defs b/src/avr/Makefile.defs new file mode 100644 index 00000000..eeb9a881 --- /dev/null +++ b/src/avr/Makefile.defs @@ -0,0 +1,16 @@ +ifndef TOPDIR +TOPDIR=.. +endif + +ifndef VERSION +include $(TOPDIR)/Version +endif + +include $(TOPDIR)/Makedefs + +CC=$(AVR_CC) +OBJCOPY=$(AVR_OBJCOPY) +LDSCRIPTS=/usr/lib/avr/lib/ldscripts + +PROGRAMMER=usbtiny +LOADCMD=avrdude diff --git a/src/cc1111/Makefile.cc1111 b/src/cc1111/Makefile.cc1111 index 0e19603b..78b653b3 100644 --- a/src/cc1111/Makefile.cc1111 +++ b/src/cc1111/Makefile.cc1111 @@ -1,4 +1,5 @@ -CC=sdcc +include ../Makedefs +CC=$(SDCC) CFLAGS=--model-small --debug --opt-code-speed -DCODESIZE=$(CODESIZE) diff --git a/src/core/ao_flight.c b/src/core/ao_flight.c index 1322195b..88dc816d 100644 --- a/src/core/ao_flight.c +++ b/src/core/ao_flight.c @@ -134,8 +134,10 @@ ao_flight(void) ao_rdf_set(1); ao_telemetry_set_interval(AO_TELEMETRY_INTERVAL_PAD); #endif +#if HAS_LED /* signal successful initialization by turning off the LED */ ao_led_off(AO_LED_RED); +#endif } else { /* Set idle mode */ ao_flight_state = ao_flight_idle; @@ -145,8 +147,10 @@ ao_flight(void) ao_packet_slave_start(); #endif +#if HAS_LED /* signal successful initialization by turning off the LED */ ao_led_off(AO_LED_RED); +#endif } /* wakeup threads due to state change */ ao_wakeup(DATA_TO_XDATA(&ao_flight_state)); diff --git a/src/core/ao_log.h b/src/core/ao_log.h index f6ab4520..4b09faeb 100644 --- a/src/core/ao_log.h +++ b/src/core/ao_log.h @@ -44,8 +44,9 @@ extern __pdata enum ao_flight_state ao_log_state; #define AO_LOG_FORMAT_TELEMETRY 3 /* 32 byte ao_telemetry records */ #define AO_LOG_FORMAT_TELESCIENCE 4 /* 32 byte typed telescience records */ #define AO_LOG_FORMAT_TELEMEGA 5 /* 32 byte typed telemega records */ -#define AO_LOG_FORMAT_MINI 6 /* 16-byte MS5607 baro only */ +#define AO_LOG_FORMAT_EASYMINI 6 /* 16-byte MS5607 baro only, 3.0V supply */ #define AO_LOG_FORMAT_TELEMETRUM 7 /* 16-byte typed telemetrum records */ +#define AO_LOG_FORMAT_TELEMINI 8 /* 16-byte MS5607 baro only, 3.3V supply */ #define AO_LOG_FORMAT_NONE 127 /* No log at all */ extern __code uint8_t ao_log_format; @@ -275,7 +276,8 @@ struct ao_log_metrum { uint16_t flight; /* 4 */ int16_t ground_accel; /* 6 */ uint32_t ground_pres; /* 8 */ - } flight; /* 12 */ + uint32_t ground_temp; /* 12 */ + } flight; /* 16 */ /* AO_LOG_STATE */ struct { uint16_t state; /* 4 */ diff --git a/src/micropeak/ao_log_micro.c b/src/core/ao_log_micro.c index d665efb5..d665efb5 100644 --- a/src/micropeak/ao_log_micro.c +++ b/src/core/ao_log_micro.c diff --git a/src/micropeak/ao_log_micro.h b/src/core/ao_log_micro.h index 976852ee..976852ee 100644 --- a/src/micropeak/ao_log_micro.h +++ b/src/core/ao_log_micro.h diff --git a/src/core/ao_log_mini.c b/src/core/ao_log_mini.c index 46b285f3..99a85982 100644 --- a/src/core/ao_log_mini.c +++ b/src/core/ao_log_mini.c @@ -23,7 +23,7 @@ static __xdata uint8_t ao_log_mutex; static __xdata struct ao_log_mini log; -__code uint8_t ao_log_format = AO_LOG_FORMAT_MINI; +__code uint8_t ao_log_format = AO_LOG_FORMAT; static uint8_t ao_log_csum(__xdata uint8_t *b) __reentrant diff --git a/src/micropeak/ao_microflight.c b/src/core/ao_microflight.c index 714bb90a..714bb90a 100644 --- a/src/micropeak/ao_microflight.c +++ b/src/core/ao_microflight.c diff --git a/src/micropeak/ao_microkalman.c b/src/core/ao_microkalman.c index 0684ea2b..0684ea2b 100644 --- a/src/micropeak/ao_microkalman.c +++ b/src/core/ao_microkalman.c diff --git a/src/micropeak/ao_report_tiny.c b/src/core/ao_report_micro.c index 0e8e287f..0e8e287f 100644 --- a/src/micropeak/ao_report_tiny.c +++ b/src/core/ao_report_micro.c diff --git a/src/core/ao_telemetry.c b/src/core/ao_telemetry.c index cd95aa6b..6b47a06a 100644 --- a/src/core/ao_telemetry.c +++ b/src/core/ao_telemetry.c @@ -182,6 +182,7 @@ ao_send_metrum_sensor(void) { __xdata struct ao_data *packet = (__xdata struct ao_data *) &ao_data_ring[ao_data_ring_prev(ao_sample_data)]; + telemetry.generic.tick = packet->tick; telemetry.generic.type = AO_TELEMETRY_METRUM_SENSOR; telemetry.metrum_sensor.state = ao_flight_state; diff --git a/src/easymini-v0.1/.gitignore b/src/easymini-v1.0/.gitignore index e5f7d586..e5f7d586 100644 --- a/src/easymini-v0.1/.gitignore +++ b/src/easymini-v1.0/.gitignore diff --git a/src/easymini-v0.1/Makefile b/src/easymini-v1.0/Makefile index 9847656c..ec305c94 100644 --- a/src/easymini-v0.1/Makefile +++ b/src/easymini-v1.0/Makefile @@ -32,7 +32,6 @@ ALTOS_SRC = \ ao_sample.c \ ao_data.c \ ao_convert_pa.c \ - ao_led_lpc.c \ ao_task.c \ ao_log.c \ ao_log_mini.c \ @@ -47,13 +46,13 @@ ALTOS_SRC = \ ao_m25.c \ ao_ms5607.c -PRODUCT=EasyMini-v0.1 -PRODUCT_DEF=-DEASYMINI_V_0_1 +PRODUCT=EasyMini-v1.0 +PRODUCT_DEF=-DEASYMINI_V_1_0 IDPRODUCT=0x0026 CFLAGS = $(PRODUCT_DEF) $(LPC_CFLAGS) -g -Os -PROGNAME=easymini-v0.1 +PROGNAME=easymini-v1.0 PROG=$(PROGNAME)-$(VERSION).elf SRC=$(ALTOS_SRC) ao_easymini.c diff --git a/src/easymini-v0.1/ao_easymini.c b/src/easymini-v1.0/ao_easymini.c index 97230b61..97230b61 100644 --- a/src/easymini-v0.1/ao_easymini.c +++ b/src/easymini-v1.0/ao_easymini.c diff --git a/src/easymini-v0.1/ao_pins.h b/src/easymini-v1.0/ao_pins.h index c09fb4c2..e721030d 100644 --- a/src/easymini-v0.1/ao_pins.h +++ b/src/easymini-v1.0/ao_pins.h @@ -16,7 +16,7 @@ */ #define HAS_BEEP 1 -#define HAS_LED 1 +#define HAS_LED 0 #define AO_STACK_SIZE 384 @@ -31,13 +31,6 @@ /* System clock frequency */ #define AO_LPC_SYSCLK 24000000 -#define LED_PORT 0 -#define LED_PIN_RED 7 - -#define AO_LED_RED (1 << LED_PIN_RED) - -#define LEDS_AVAILABLE AO_LED_RED - #define HAS_USB 1 #define HAS_USB_CONNECT 0 @@ -48,6 +41,8 @@ #define PACKET_HAS_SLAVE 0 +#define AO_LOG_FORMAT AO_LOG_FORMAT_EASYMINI + /* USART */ #define HAS_SERIAL 0 diff --git a/src/easymini-v0.1/flash-loader/Makefile b/src/easymini-v1.0/flash-loader/Makefile index ab828b22..78bb4092 100644 --- a/src/easymini-v0.1/flash-loader/Makefile +++ b/src/easymini-v1.0/flash-loader/Makefile @@ -4,5 +4,5 @@ # TOPDIR=../.. -HARDWARE=easymini-v0.1 +HARDWARE=easymini-v1.0 include $(TOPDIR)/lpc/Makefile-flash.defs diff --git a/src/easymini-v0.1/flash-loader/ao_pins.h b/src/easymini-v1.0/flash-loader/ao_pins.h index 4330151d..4330151d 100644 --- a/src/easymini-v0.1/flash-loader/ao_pins.h +++ b/src/easymini-v1.0/flash-loader/ao_pins.h diff --git a/src/lpc/Makefile-flash.defs b/src/lpc/Makefile-flash.defs index 6bdd204c..ab7181b9 100644 --- a/src/lpc/Makefile-flash.defs +++ b/src/lpc/Makefile-flash.defs @@ -6,14 +6,16 @@ vpath ao-make-product.5c $(TOPDIR)/util .elf.ihx: objcopy -O ihex $*.elf $@ -CC=arm-none-eabi-gcc -SAT=/opt/cortex -SAT_CLIB=$(SAT)/lib/pdclib-cortex-m0.a -SAT_CFLAGS=-I$(SAT)/include ifndef VERSION include $(TOPDIR)/Version endif +include $(TOPDIR)/Makedefs + +CC=$(ARM_CC) +SAT=/opt/cortex +SAT_CLIB=$(SAT)/lib/pdclib-cortex-m0.a +SAT_CFLAGS=-I$(SAT)/include AO_CFLAGS=-I. -I$(TOPDIR)/lpc -I$(TOPDIR)/core -I$(TOPDIR)/drivers -I$(TOPDIR)/product -I$(TOPDIR) STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m0 -mthumb -ffreestanding -nostdlib $(AO_CFLAGS) $(SAT_CFLAGS) diff --git a/src/lpc/Makefile.defs b/src/lpc/Makefile.defs index 9e87cee1..d541230a 100644 --- a/src/lpc/Makefile.defs +++ b/src/lpc/Makefile.defs @@ -7,21 +7,24 @@ vpath load_csv.5c ../kalman vpath matrix.5c ../kalman vpath ao-make-product.5c ../util -CC=/usr/bin/arm-none-eabi-gcc -SAT=/opt/cortex -SAT_CLIB=$(SAT)/lib/pdclib-cortex-m0.a -SAT_CFLAGS=-I$(SAT)/include - -#CC=/opt/arm-gcc-bits/bin/arm-none-eabi-gcc +ifndef TOPDIR +TOPDIR=.. +endif ifndef VERSION -include ../Version +include $(TOPDIR)/Version endif +include $(TOPDIR)/Makedefs + +CC=$(ARM_CC) +SAT=/opt/cortex +SAT_CLIB=$(SAT)/lib/pdclib-cortex-m0.a +SAT_CFLAGS=-I$(SAT)/include -AO_CFLAGS=-I. -I../lpc -I../core -I../drivers -I.. +AO_CFLAGS=-I. -I$(TOPDIR)/lpc -I$(TOPDIR)/core -I$(TOPDIR)/drivers -I$(TOPDIR) LPC_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m0 -mthumb -ffreestanding -nostdlib $(AO_CFLAGS) $(SAT_CFLAGS) -LDFLAGS=-L../stm -Wl,-Taltos.ld +LDFLAGS=$(LPC_CFLAGS) -L$(TOPDIR)/stm -Wl,-Taltos.ld NICKLE=nickle @@ -34,10 +37,10 @@ endif quiet ?= $($1) .c.o: - $(call quiet,CC) -c $(CFLAGS) -o $@ $< + $(call quiet,CC) -c $(CFLAGS) $< -ao_serial_lpc.h: ../lpc/baud_rate ao_pins.h - nickle ../lpc/baud_rate `awk '/AO_LPC_CLKOUT/{print $$3}' ao_pins.h` > $@ +ao_serial_lpc.h: $(TOPDIR)/lpc/baud_rate ao_pins.h + nickle $(TOPDIR)/lpc/baud_rate `awk '/AO_LPC_CLKOUT/{print $$3}' ao_pins.h` > $@ ao_serial_lpc.o: ao_serial_lpc.h diff --git a/src/lpc/ao_arch_funcs.h b/src/lpc/ao_arch_funcs.h index 9a3219a2..0891903e 100644 --- a/src/lpc/ao_arch_funcs.h +++ b/src/lpc/ao_arch_funcs.h @@ -235,6 +235,7 @@ static inline void ao_arch_start_scheduler(void) { asm("mrs %0,control" : "=&r" (control)); control |= (1 << 1); asm("msr control,%0" : : "r" (control)); + asm("isb"); } #endif /* _AO_ARCH_FUNCS_H_ */ diff --git a/src/micropeak/Makefile b/src/micropeak/Makefile index 44e0b873..35dfaab8 100644 --- a/src/micropeak/Makefile +++ b/src/micropeak/Makefile @@ -2,25 +2,19 @@ # Tiny AltOS build # # -vpath % ../attiny:../drivers:../core:.. +vpath % ../attiny:../drivers:../core:../product:.. vpath ao-make-product.5c ../util vpath make-altitude-pa ../util +include ../avr/Makefile.defs + MCU=attiny85 DUDECPUTYPE=t85 #PROGRAMMER=stk500v2 -P usb -PROGRAMMER=usbtiny -LOADCMD=avrdude LOADSLOW=-i 32 -B 32 LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: -CC=avr-gcc -OBJCOPY=avr-objcopy - -LDFLAGS=-L/usr/lib/ldscripts -Tavr25.x -ifndef VERSION -include ../Version -endif +LDFLAGS=-L$(LDSCRIPTS) -Tavr25.x ALTOS_SRC = \ ao_micropeak.c \ @@ -30,7 +24,7 @@ ALTOS_SRC = \ ao_ms5607.c \ ao_exti.c \ ao_convert_pa.c \ - ao_report_tiny.c \ + ao_report_micro.c \ ao_notask.c \ ao_eeprom_tiny.c \ ao_panic.c \ @@ -53,7 +47,7 @@ INC=\ IDPRODUCT=0 PRODUCT=MicroPeak-v0.1 PRODUCT_DEF=-DMICROPEAK -CFLAGS = $(PRODUCT_DEF) -I. -I../attiny -I../core -I.. -I../drivers +CFLAGS = $(PRODUCT_DEF) -I. -I../attiny -I../core -I.. -I../drivers -I../product CFLAGS += -g -mmcu=$(MCU) -Wall -Wstrict-prototypes -O2 -mcall-prologues -DATTINY NICKLE=nickle diff --git a/src/nanopeak-v0.1/.gitignore b/src/nanopeak-v0.1/.gitignore new file mode 100644 index 00000000..27cd0a7c --- /dev/null +++ b/src/nanopeak-v0.1/.gitignore @@ -0,0 +1,2 @@ +ao_product.h +nanopeak-* diff --git a/src/nanopeak-v0.1/Makefile b/src/nanopeak-v0.1/Makefile new file mode 100644 index 00000000..154d78f6 --- /dev/null +++ b/src/nanopeak-v0.1/Makefile @@ -0,0 +1,108 @@ +# +# Tiny AltOS build +# +# +vpath % ../attiny:../drivers:../core:../product:.. +vpath ao-make-product.5c ../util +vpath make-altitude-pa ../util + +include ../avr/Makefile.defs + +MCU=attiny85 +DUDECPUTYPE=t85 +#PROGRAMMER=stk500v2 -P usb +LOADSLOW=-i 32 -B 32 +LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: + +LDFLAGS=-L$(LDSCRIPTS) -Tavr25.x + +ALTOS_SRC = \ + ao_micropeak.c \ + ao_spi_attiny.c \ + ao_led.c \ + ao_clock.c \ + ao_ms5607.c \ + ao_exti.c \ + ao_convert_pa.c \ + ao_report_micro.c \ + ao_notask.c \ + ao_eeprom_tiny.c \ + ao_panic.c \ + ao_log_micro.c \ + ao_async.c \ + ao_microflight.c \ + ao_microkalman.c + +INC=\ + ao.h \ + ao_pins.h \ + ao_arch.h \ + ao_arch_funcs.h \ + ao_exti.h \ + ao_ms5607.h \ + ao_log_micro.h \ + ao_micropeak.h \ + altitude-pa.h + +IDPRODUCT=0 +PRODUCT=NanoPeak-v0.1 +PRODUCT_DEF=-DNANOPEAK +CFLAGS = $(PRODUCT_DEF) -I. -I../attiny -I../core -I.. -I../drivers -I../product +CFLAGS += -g -mmcu=$(MCU) -Wall -Wstrict-prototypes -O2 -mcall-prologues -DATTINY + +NICKLE=nickle + +PROG=nanopeak-v0.1 + +SRC=$(ALTOS_SRC) +OBJ=$(SRC:.c=.o) + +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) + +all: $(PROG) $(PROG).hex + +CHECK=sh ../util/check-avr-mem + +$(PROG): Makefile $(OBJ) + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) + $(call quiet,CHECK) $(PROG) || ($(RM) -f $(PROG); exit 1) + +$(PROG).hex: $(PROG) + avr-size $(PROG) + $(OBJCOPY) -R .eeprom -O ihex $(PROG) $@ + + +load: $(PROG).hex + $(LOADCMD) $(LOADARG)$(PROG).hex + +load-slow: $(PROG).hex + $(LOADCMD) $(LOADSLOW) $(LOADARG)$(PROG).hex + +ao_product.h: ao-make-product.5c ../Version + $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@ + +ao_product.o: ao_product.c ao_product.h + +%.o : %.c $(INC) + $(call quiet,CC) -c $(CFLAGS) $< + +distclean: clean + +clean: + rm -f *.o $(PROG) $(PROG).hex + rm -f ao_product.h + +../altitude-pa.h: make-altitude-pa + nickle $< > $@ + +install: + +uninstall: + +$(OBJ): ao_product.h $(INC) diff --git a/src/nanopeak-v0.1/ao_pins.h b/src/nanopeak-v0.1/ao_pins.h new file mode 100644 index 00000000..bd4a06d1 --- /dev/null +++ b/src/nanopeak-v0.1/ao_pins.h @@ -0,0 +1,65 @@ +/* + * Copyright © 2011 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_ +#include <avr/pgmspace.h> + +#define AO_LED_ORANGE (1<<3) +#define AO_LED_SERIAL 3 +#define AO_LED_PANIC AO_LED_ORANGE +#define AO_LED_REPORT AO_LED_ORANGE +#define LEDS_AVAILABLE (AO_LED_ORANGE) +#define USE_SERIAL_1_STDIN 0 +#define HAS_USB 0 +#define PACKET_HAS_SLAVE 0 +#define HAS_SERIAL_1 0 +#define HAS_TASK 0 +#define HAS_MS5607 1 +#define HAS_MS5611 0 +#define HAS_EEPROM 0 +#define HAS_BEEP 0 +#define AVR_CLOCK 250000UL + +/* SPI */ +#define SPI_PORT PORTB +#define SPI_PIN PINB +#define SPI_DIR DDRB +#define AO_MS5607_CS_PORT PORTB +#define AO_MS5607_CS_PIN 4 + +/* MS5607 */ +#define AO_MS5607_SPI_INDEX 0 +#define AO_MS5607_MISO_PORT PORTB +#define AO_MS5607_MISO_PIN 0 +#define AO_MS5607_BARO_OVERSAMPLE 4096 +#define AO_MS5607_TEMP_OVERSAMPLE 1024 + +/* I2C */ +#define I2C_PORT PORTB +#define I2C_PIN PINB +#define I2C_DIR DDRB +#define I2C_PIN_SCL PINB2 +#define I2C_PIN_SDA PINB0 + +#define AO_CONST_ATTRIB PROGMEM +typedef int32_t alt_t; +#define FETCH_ALT(o) ((alt_t) pgm_read_dword(&altitude_table[o])) + +#define AO_ALT_VALUE(x) ((x) * (alt_t) 10) + +#endif /* _AO_PINS_H_ */ diff --git a/src/product/Makefile.teledongle b/src/product/Makefile.teledongle index 3101b777..da9bcba0 100644 --- a/src/product/Makefile.teledongle +++ b/src/product/Makefile.teledongle @@ -80,9 +80,9 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile +$(PROG): $(REL) Makefile $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ diff --git a/src/product/Makefile.telelaunch b/src/product/Makefile.telelaunch index 1e55989c..a5e2eb7f 100644 --- a/src/product/Makefile.telelaunch +++ b/src/product/Makefile.telelaunch @@ -82,9 +82,9 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile +$(PROG): $(REL) Makefile $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ diff --git a/src/product/Makefile.telemetrum b/src/product/Makefile.telemetrum index 5e3eed7f..c740a483 100644 --- a/src/product/Makefile.telemetrum +++ b/src/product/Makefile.telemetrum @@ -94,10 +94,10 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. +$(PROG): $(REL) Makefile + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version diff --git a/src/product/Makefile.telemini b/src/product/Makefile.telemini index ef8906ba..0884079e 100644 --- a/src/product/Makefile.telemini +++ b/src/product/Makefile.telemini @@ -83,10 +83,10 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. +$(PROG): $(REL) Makefile + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version diff --git a/src/product/Makefile.telenano b/src/product/Makefile.telenano index 67410ae0..c31989ee 100644 --- a/src/product/Makefile.telenano +++ b/src/product/Makefile.telenano @@ -82,9 +82,9 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile +$(PROG): $(REL) Makefile $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ diff --git a/src/product/ao_flash_pins.h b/src/product/ao_flash_pins.h index 439ba75c..dd67d820 100644 --- a/src/product/ao_flash_pins.h +++ b/src/product/ao_flash_pins.h @@ -35,7 +35,6 @@ #define HAS_VERSION 0 #define AO_BOOT_CHAIN 1 -#define AO_BOOT_PIN 1 #define IS_FLASH_LOADER 1 diff --git a/src/micropeak/ao_micropeak.c b/src/product/ao_micropeak.c index 10f0d192..10f0d192 100644 --- a/src/micropeak/ao_micropeak.c +++ b/src/product/ao_micropeak.c diff --git a/src/micropeak/ao_micropeak.h b/src/product/ao_micropeak.h index 382b98d9..3e3dec15 100644 --- a/src/micropeak/ao_micropeak.h +++ b/src/product/ao_micropeak.h @@ -28,7 +28,7 @@ #define BOOST_DETECT 120 /* 10m at sea level, 12m at 2000m */ /* Wait after power on before doing anything to give the user time to assemble the rocket */ -#define BOOST_DELAY AO_SEC_TO_TICKS(30) +#define BOOST_DELAY AO_SEC_TO_TICKS(60) /* Pressure change (in Pa) to detect landing */ #define LAND_DETECT 24 /* 2m at sea level, 2.4m at 2000m */ diff --git a/src/spiradio-v0.1/Makefile b/src/spiradio-v0.1/Makefile index a207d34f..e644bc49 100644 --- a/src/spiradio-v0.1/Makefile +++ b/src/spiradio-v0.1/Makefile @@ -73,10 +73,10 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. +$(PROG): $(REL) Makefile + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version diff --git a/src/stm/Makefile-flash.defs b/src/stm/Makefile-flash.defs index 86f76d46..f429d9bd 100644 --- a/src/stm/Makefile-flash.defs +++ b/src/stm/Makefile-flash.defs @@ -6,14 +6,15 @@ vpath ao-make-product.5c $(TOPDIR)/util .elf.ihx: objcopy -O ihex $*.elf $@ -CC=/opt/cortex/bin/arm-none-eabi-gcc -SAT=/opt/cortex -SAT_CLIB=$(SAT)/lib/pdclib-cortex-m3.a -SAT_CFLAGS=-I$(SAT)/include - ifndef VERSION include $(TOPDIR)/Version endif +include $(TOPDIR)/Makedefs + +CC=$(ARM_CC) +SAT=/opt/cortex +SAT_CLIB=$(SAT)/lib/pdclib-cortex-m3.a +SAT_CFLAGS=-I$(SAT)/include AO_CFLAGS=-I. -I$(TOPDIR)/stm -I$(TOPDIR)/core -I$(TOPDIR)/drivers -I$(TOPDIR)/product -I$(TOPDIR) STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb -ffreestanding -nostdlib $(AO_CFLAGS) $(SAT_CFLAGS) diff --git a/src/stm/Makefile.defs b/src/stm/Makefile.defs index 8ef30521..ede75f80 100644 --- a/src/stm/Makefile.defs +++ b/src/stm/Makefile.defs @@ -12,14 +12,19 @@ vpath ao-make-product.5c ../util .elf.ihx: objcopy -O ihex $*.elf $@ -SAT=/opt/cortex -CC=$(SAT)/bin/arm-none-eabi-gcc -SAT_CLIB=$(SAT)/lib/pdclib-cortex-m3.a -SAT_CFLAGS=-I$(SAT)/include +ifndef TOPDIR +TOPDIR=.. +endif ifndef VERSION -include ../Version +include $(TOPDIR)/Version endif +include $(TOPDIR)/Makedefs + +CC=$(ARM_CC) +SAT=/opt/cortex +SAT_CLIB=$(SAT)/lib/pdclib-cortex-m3.a +SAT_CFLAGS=-I$(SAT)/include AO_CFLAGS=-I. -I../stm -I../core -I../drivers -I.. STM_CFLAGS=-std=gnu99 -mlittle-endian -mcpu=cortex-m3 -mthumb -ffreestanding -nostdlib $(AO_CFLAGS) $(SAT_CFLAGS) diff --git a/src/stm/ao_arch_funcs.h b/src/stm/ao_arch_funcs.h index 9bb2d7cd..b461cd3f 100644 --- a/src/stm/ao_arch_funcs.h +++ b/src/stm/ao_arch_funcs.h @@ -329,7 +329,7 @@ static inline void ao_arch_restore_stack(void) { /* Restore APSR */ asm("pop {r0}"); - asm("msr apsr,r0"); + asm("msr apsr_nczvq,r0"); /* Restore general registers */ asm("pop {r0-r12,lr}\n"); @@ -354,6 +354,7 @@ static inline void ao_arch_start_scheduler(void) { asm("mrs %0,control" : "=&r" (control)); control |= (1 << 1); asm("msr control,%0" : : "r" (control)); + asm("isb"); } #endif diff --git a/src/teleballoon-v1.1/Makefile b/src/teleballoon-v1.1/Makefile index 2eea996e..6ff076a9 100644 --- a/src/teleballoon-v1.1/Makefile +++ b/src/teleballoon-v1.1/Makefile @@ -103,7 +103,7 @@ quiet ?= $($1) all: $(PROG) $(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version diff --git a/src/telebt-v1.0/Makefile b/src/telebt-v1.0/Makefile index 911a8b09..40853fc3 100644 --- a/src/telebt-v1.0/Makefile +++ b/src/telebt-v1.0/Makefile @@ -82,7 +82,7 @@ quiet ?= $($1) all: $(PROG) $(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version diff --git a/src/telefire-v0.1/Makefile b/src/telefire-v0.1/Makefile index 712b2e8b..f9e11698 100644 --- a/src/telefire-v0.1/Makefile +++ b/src/telefire-v0.1/Makefile @@ -84,10 +84,10 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. +$(PROG): $(REL) Makefile + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version diff --git a/src/telefire-v0.2/Makefile b/src/telefire-v0.2/Makefile index 3353bc1a..a820990a 100644 --- a/src/telefire-v0.2/Makefile +++ b/src/telefire-v0.2/Makefile @@ -84,10 +84,10 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. +$(PROG): $(REL) Makefile + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version diff --git a/src/telegps-v0.3/ao_telegps.c b/src/telegps-v0.3/ao_telegps.c index f9f62316..608817e7 100644 --- a/src/telegps-v0.3/ao_telegps.c +++ b/src/telegps-v0.3/ao_telegps.c @@ -49,6 +49,7 @@ main(void) ao_gps_init(); #if HAS_LOG ao_gps_report_mega_init(); + ao_log_init(); #endif ao_telemetry_init(); diff --git a/src/telemetrum-v2.0/ao_telemetrum.c b/src/telemetrum-v2.0/ao_telemetrum.c index e365417d..d79aba54 100644 --- a/src/telemetrum-v2.0/ao_telemetrum.c +++ b/src/telemetrum-v2.0/ao_telemetrum.c @@ -42,7 +42,7 @@ main(void) ao_task_init(); ao_serial_init(); ao_led_init(LEDS_AVAILABLE); - ao_led_on(AO_LED_GREEN); + ao_led_on(AO_LED_RED); ao_timer_init(); ao_spi_init(); diff --git a/src/telemini-v2.0/Makefile b/src/telemini-v2.0/Makefile index 40878778..fcac2c48 100644 --- a/src/telemini-v2.0/Makefile +++ b/src/telemini-v2.0/Makefile @@ -81,7 +81,7 @@ PROGNAME = telemini-v$(TELEMINI_VER) PROG = $(PROGNAME)-$(VERSION).ihx PRODUCT=TeleMini-v$(TELEMINI_VER) PRODUCT_DEF=-DTELEMINI_V_$(TELEMINI_DEF) -IDPRODUCT=0x000a +IDPRODUCT=0x0027 include ../cc1111/Makefile.cc1111 @@ -96,10 +96,10 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. +$(PROG): $(REL) Makefile + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version diff --git a/src/telemini-v2.0/ao_pins.h b/src/telemini-v2.0/ao_pins.h index 264ad16d..c4681ee2 100644 --- a/src/telemini-v2.0/ao_pins.h +++ b/src/telemini-v2.0/ao_pins.h @@ -102,6 +102,7 @@ #define AO_IGNITER_CHARGE_TIME AO_MS_TO_TICKS(2000) #define AO_SEND_MINI +#define AO_LOG_FORMAT AO_LOG_FORMAT_TELEMINI /* * ADC diff --git a/src/telemini-v2.0/ao_telemini.c b/src/telemini-v2.0/ao_telemini.c index 294f768a..0d8dd1cb 100644 --- a/src/telemini-v2.0/ao_telemini.c +++ b/src/telemini-v2.0/ao_telemini.c @@ -24,36 +24,42 @@ __xdata uint8_t ao_force_freq; void main(void) { - /* - * Reduce the transient on the ignite pins at startup by - * pulling the pins low as soon as possible at power up - */ - ao_ignite_set_pins(); - ao_clock_init(); +#if HAS_STACK_GUARD + ao_mpu_init(); +#endif + ao_task_init(); + /* Turn on the red LED until the system is stable */ ao_led_init(LEDS_AVAILABLE); ao_led_on(AO_LED_RED); - ao_task_init(); - ao_timer_init(); + + ao_spi_init(); + ao_exti_init(); ao_adc_init(); +#if HAS_BEEP ao_beep_init(); +#endif ao_cmd_init(); - ao_spi_init(); - ao_exti_init(); +#if HAS_MS5607 ao_ms5607_init(); +#endif ao_storage_init(); + ao_flight_init(); ao_log_init(); ao_report_init(); + ao_usb_init(); ao_telemetry_init(); ao_radio_init(); ao_packet_slave_init(TRUE); + ao_igniter_init(); + ao_config_init(); ao_start_scheduler(); } diff --git a/src/telepyro-v0.1/Makefile b/src/telepyro-v0.1/Makefile index 6743ba66..025b324a 100644 --- a/src/telepyro-v0.1/Makefile +++ b/src/telepyro-v0.1/Makefile @@ -5,18 +5,12 @@ vpath % .:..:../core:../product:../drivers:../avr vpath ao-make-product.5c ../util +include ../avr/Makefile.defs + MCU=atmega32u4 DUDECPUTYPE=m32u4 #PROGRAMMER=stk500v2 -P usb -PROGRAMMER=usbtiny -LOADCMD=avrdude LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: -CC=avr-gcc -OBJCOPY=avr-objcopy - -ifndef VERSION -include ../Version -endif INC = \ ao.h \ diff --git a/src/telescience-pwm/Makefile b/src/telescience-pwm/Makefile index ce2a8fde..7f39d3f1 100644 --- a/src/telescience-pwm/Makefile +++ b/src/telescience-pwm/Makefile @@ -5,20 +5,14 @@ vpath % ..:../core:../product:../drivers:../avr vpath ao-make-product.5c ../util +include ../avr/Makefile.defs + MCU=atmega32u4 DUDECPUTYPE=m32u4 #PROGRAMMER=stk500v2 -P usb -PROGRAMMER=usbtiny -LOADCMD=avrdude LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: -CC=avr-gcc -OBJCOPY=avr-objcopy - -LDFLAGS=-L/usr/lib/ldscripts -Tavr5.x -ifndef VERSION -include ../Version -endif +LDFLAGS=-L$(LDSCRIPTS) -Tavr5.x INC = \ ao.h \ diff --git a/src/telescience-v0.1/Makefile b/src/telescience-v0.1/Makefile index 81054a75..a65b3ad0 100644 --- a/src/telescience-v0.1/Makefile +++ b/src/telescience-v0.1/Makefile @@ -5,20 +5,14 @@ vpath % ..:../core:../product:../drivers:../avr vpath ao-make-product.5c ../util +include ../avr/Makefile.defs + MCU=atmega32u4 DUDECPUTYPE=m32u4 #PROGRAMMER=stk500v2 -P usb -PROGRAMMER=usbtiny -LOADCMD=avrdude LOADARG=-p $(DUDECPUTYPE) -c $(PROGRAMMER) -e -U flash:w: -CC=avr-gcc -OBJCOPY=avr-objcopy - -LDFLAGS=-L/usr/lib/ldscripts -Tavr5.x -ifndef VERSION -include ../Version -endif +LDFLAGS=-L$(LDSCRIPTS) -Tavr5.x INC = \ ao.h \ diff --git a/src/teleshield-v0.1/Makefile b/src/teleshield-v0.1/Makefile index ab2a025f..e8b262ef 100644 --- a/src/teleshield-v0.1/Makefile +++ b/src/teleshield-v0.1/Makefile @@ -92,10 +92,10 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. +$(PROG): $(REL) Makefile + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version diff --git a/src/teleterra-v0.2/Makefile b/src/teleterra-v0.2/Makefile index 68a8d1b6..88637360 100644 --- a/src/teleterra-v0.2/Makefile +++ b/src/teleterra-v0.2/Makefile @@ -86,10 +86,10 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. +$(PROG): $(REL) Makefile + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version diff --git a/src/tidongle/Makefile b/src/tidongle/Makefile index 1514c4df..b2ba537b 100644 --- a/src/tidongle/Makefile +++ b/src/tidongle/Makefile @@ -72,10 +72,10 @@ endif # Otherwise, print the full command line. quiet ?= $($1) -all: ../$(PROG) +all: $(PROG) -../$(PROG): $(REL) Makefile - $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) && cp $(PROG) $(PMAP) .. +$(PROG): $(REL) Makefile + $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(REL) $(call quiet,CHECK_STACK) ../cc1111/ao_arch.h $(PMEM) || rm $@ ao_product.h: ao-make-product.5c ../Version |