telebt-v0.0 telebt-v0.1 \
telemetrum-v0.1-sky telemetrum-v0.1-sirf \
telelaunch-v0.1 \
- tidongle test telescience-v0.1
+ tidongle test telescience-v0.1 telepyro-v0.1
all: all-local all-recursive
volatile __xdata struct ao_adc ao_adc_ring[AO_ADC_RING];
volatile __data uint8_t ao_adc_head;
+#ifdef TELESCIENCE
const uint8_t adc_channels[AO_LOG_TELESCIENCE_NUM_ADC] = {
0x00,
0x01,
0x24,
0x25,
};
+#endif
+
+#ifdef TELEPYRO
+const uint8_t adc_channels[AO_TELEPYRO_NUM_ADC] = {
+ 0x00, /* ADC0 v_batt */
+ 0x04, /* ADC4 sense_a */
+ 0x05, /* ADC5 sense_b */
+ 0x06, /* ADC6 sense_c */
+ 0x07, /* ADC7 sense_d */
+ 0x23, /* ADC11 sense_e */
+ 0x22, /* ADC10 sense_f */
+ 0x21, /* ADC9 sense_g */
+};
+#endif
+
+#define NUM_ADC (sizeof (adc_channels) / sizeof (adc_channels[0]))
static uint8_t ao_adc_channel;
value = ADCL;
value |= (ADCH << 8);
ao_adc_ring[ao_adc_head].adc[ao_adc_channel] = value;
- if (++ao_adc_channel < AO_TELESCIENCE_NUM_ADC)
+ if (++ao_adc_channel < NUM_ADC)
ao_adc_start();
else {
ADCSRA = ADCSRA_INIT;
uint8_t i;
ao_adc_get(&packet);
printf("tick: %5u", packet.tick);
- for (i = 0; i < AO_TELESCIENCE_NUM_ADC; i++)
+ for (i = 0; i < NUM_ADC; i++)
printf (" %2d: %5u", i, packet.adc[i]);
printf ("\n");
}
#define SPI_SLAVE_PIN_2_5 0
#endif
+#ifdef TELEPYRO
+ #define LEDS_AVAILABLE 0
+ #define HAS_USB 1
+ #define HAS_LOG 0
+ #define TEENSY 0
+ #define USE_SERIAL_STDIN 1
+ #define HAS_SERIAL_1 1
+ #define HAS_USB 1
+ #define HAS_ADC 1
+ #define PACKET_HAS_SLAVE 0
+ #define HAS_BEEP 0
+
+ #define AVR_VCC_5V 0
+ #define AVR_VCC_3V3 1
+ #define AVR_CLOCK 8000000UL
+
+ #define SPI_SLAVE_CS_PORT PORTB
+ #define SPI_SLAVE_CS_PIN PINB
+ #define SPI_SLAVE_CS_PIN_NO PINB0
+
+ #define SPI_SLAVE_PIN_0_3 1
+ #define SPI_SLAVE_PIN_2_5 0
+#endif
+
#endif /* _AO_PINS_H_ */
void
ao_log_single(void);
+/*
+ * ao_pyro_slave.c
+ */
+
+#define AO_TELEPYRO_NUM_ADC 9
+
#endif /* _AO_H_ */
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "ao.h"
+#include "ao_product.h"
+
+struct ao_companion_command ao_companion_command;
+
+static const struct ao_companion_setup ao_telepyro_setup = {
+ .board_id = AO_idProduct_NUMBER,
+ .board_id_inverse = ~AO_idProduct_NUMBER,
+ .update_period = 50,
+ .channels = AO_TELEPYRO_NUM_ADC,
+};
+
+void ao_spi_slave(void)
+{
+ if (!ao_spi_read((uint8_t *) &ao_companion_command,
+ sizeof (ao_companion_command)))
+ return;
+
+ /* Figure out the outbound data */
+ switch (ao_companion_command.command) {
+ case AO_COMPANION_SETUP:
+ ao_spi_write((uint8_t *) &ao_telepyro_setup,
+ sizeof (ao_telepyro_setup));
+ break;
+ case AO_COMPANION_FETCH:
+ ao_spi_write((uint8_t *) &ao_adc_ring[ao_adc_ring_prev(ao_adc_head)].adc,
+ AO_TELEPYRO_NUM_ADC * sizeof (uint16_t));
+ break;
+ case AO_COMPANION_NOTIFY:
+ break;
+ default:
+ return;
+ }
+}
--- /dev/null
+/*
+ * 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.
+ */
+
+#include "ao.h"
+
+int
+main(void)
+{
+ ao_clock_init();
+
+ PORTE |= (1 << 6);
+ DDRE |= (1 << 6);
+
+ ao_avr_stdio_init();
+ ao_timer_init();
+ ao_cmd_init();
+ ao_spi_slave_init();
+ ao_usb_init();
+ ao_adc_init();
+ ao_start_scheduler();
+ return 0;
+}
--- /dev/null
+#
+# AltOS build
+#
+#
+vpath % ..:../core:../product:../drivers:../avr
+vpath ao-make-product.5c ../util
+
+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 \
+ ao_usb.h \
+ ao_pins.h \
+ altitude.h
+
+ALTOS_SRC = \
+ ao_clock.c \
+ ao_cmd.c \
+ ao_mutex.c \
+ ao_panic.c \
+ ao_product.c \
+ ao_stdio.c \
+ ao_task.c \
+ ao_timer.c \
+ ao_led.c \
+ ao_avr_stdio.c \
+ ao_romconfig.c \
+ ao_usb_avr.c \
+ ao_adc_avr.c \
+ ao_pyro_slave.c \
+ ao_spi_slave.c
+
+PRODUCT=TelePyro-v0.1
+MCU=atmega32u4
+PRODUCT_DEF=-DTELEPYRO
+IDPRODUCT=0x0011
+CFLAGS = $(PRODUCT_DEF) -I. -I../avr -I../core -I..
+CFLAGS += -g -mmcu=$(MCU) -Wall -Wstrict-prototypes -O3 -mcall-prologues -DAVR
+
+NICKLE=nickle
+
+PROG=telepyro-v0.1
+
+SRC=$(ALTOS_SRC) ao_telepyro.c
+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)
+
+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
+
+../altitude.h: make-altitude
+ nickle $< > $@
+
+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 $(OBJ)
+ rm -f ao_product.h
+
+install:
+
+uninstall:
+
+$(OBJ): ao.h ao_product.h ao_usb.h