__pdata uint8_t ao_config_dirty;
__xdata uint8_t ao_config_mutex;
+#ifndef AO_CONFIG_DEFAULT_APRS_INTERVAL
+#define AO_CONFIG_DEFAULT_APRS_INTERVAL 0
+#endif
#define AO_CONFIG_DEFAULT_MAIN_DEPLOY 250
#define AO_CONFIG_DEFAULT_RADIO_CHANNEL 0
#define AO_CONFIG_DEFAULT_CALLSIGN "N0CALL"
#define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ((uint32_t) 192 * (uint32_t) 1024)
#endif
#endif
+#ifndef AO_CONFIG_DEFAULT_RADIO_POWER
#define AO_CONFIG_DEFAULT_RADIO_POWER 0x60
+#endif
#define AO_CONFIG_DEFAULT_RADIO_AMP 0
#if HAS_EEPROM
memset(&ao_config.pyro, '\0', sizeof (ao_config.pyro));
#endif
if (minor < 13)
- ao_config.aprs_interval = 0;
+ ao_config.aprs_interval = AO_CONFIG_DEFAULT_APRS_INTERVAL;
#if HAS_RADIO_POWER
if (minor < 14)
ao_config.radio_power = AO_CONFIG_DEFAULT_RADIO_POWER;
#include "ao_log.h"
#include "ao_product.h"
+#ifndef HAS_RDF
+#define HAS_RDF 1
+#endif
+
static __pdata uint16_t ao_telemetry_interval;
static __pdata uint8_t ao_rdf = 0;
+
+#if HAS_RDF
static __pdata uint16_t ao_rdf_time;
+#endif
#if HAS_APRS
static __pdata uint16_t ao_aprs_time;
{
telemetry.generic.type = AO_TELEMETRY_CONFIGURATION;
telemetry.configuration.device = AO_idProduct_NUMBER;
+#if HAS_LOG
telemetry.configuration.flight = ao_log_full() ? 0 : ao_flight_number;
+#else
+ telemetry.configuration.flight = ao_flight_number;
+#endif
telemetry.configuration.config_major = AO_CONFIG_MAJOR;
telemetry.configuration.config_minor = AO_CONFIG_MINOR;
telemetry.configuration.apogee_delay = ao_config.apogee_delay;
for (;;) {
while (ao_telemetry_interval == 0)
ao_sleep(&telemetry);
- time = ao_rdf_time = ao_time();
+ time = ao_time();
+#if HAS_RDF
+ ao_rdf_time = time;
+#endif
#if HAS_APRS
ao_aprs_time = time;
#endif
#endif
}
#ifndef AO_SEND_ALL_BARO
+#if HAS_RDF
if (ao_rdf &&
#if HAS_APRS
!(ao_config.radio_enable & AO_RADIO_DISABLE_RDF) &&
#endif
ao_radio_rdf();
}
+#endif /* HAS_RDF */
#if HAS_APRS
if (ao_config.aprs_interval != 0 &&
(int16_t) (ao_time() - ao_aprs_time) >= 0)
ao_wakeup(&telemetry);
}
+#if HAS_RDF
void
ao_rdf_set(uint8_t rdf)
{
ao_rdf_time = ao_time() + AO_RDF_INTERVAL_TICKS;
}
}
+#endif
__xdata struct ao_task ao_telemetry_task;
uint8_t state = ao_radio_strobe(CC115L_SIDLE);
if ((state >> CC115L_STATUS_STATE) == CC115L_STATUS_STATE_IDLE)
break;
+ if ((state >> CC115L_STATUS_STATE) == CC115L_STATUS_STATE_TX_FIFO_UNDERFLOW)
+ ao_radio_strobe(CC115L_SFTX);
}
/* Flush any pending TX bytes */
ao_radio_strobe(CC115L_SFTX);
ao_config_get();
+ ao_radio_strobe(CC115L_SCAL);
+
ao_radio_configured = 1;
}
ao_radio_get(void)
{
static uint32_t last_radio_setting;
- static uint8_t last_power_setting;
ao_mutex_get(&ao_radio_mutex);
if (!ao_radio_configured)
ao_radio_reg_write(CC115L_FREQ0, ao_config.radio_setting);
last_radio_setting = ao_config.radio_setting;
}
- if (ao_config.radio_power != last_power_setting) {
- ao_radio_reg_write(CC115L_PA, ao_config.radio_power);
- last_power_setting = ao_config.radio_power;
- }
}
static void
ao_wakeup(&ao_radio_wake);
}
+#define POWER_STEP 0x08
+
+static void
+ao_radio_stx(void)
+{
+ uint8_t power;
+ ao_radio_pa_on();
+ ao_radio_reg_write(CC115L_PA, 0);
+ ao_radio_strobe(CC115L_STX);
+ for (power = POWER_STEP; power < ao_config.radio_power; power += POWER_STEP)
+ ao_radio_reg_write(CC115L_PA, power);
+ ao_radio_reg_write(CC115L_PA, ao_config.radio_power);
+}
+
static void
ao_radio_test_cmd(void)
{
ao_packet_slave_stop();
#endif
ao_radio_get();
- ao_radio_set_len(0xff);
- ao_radio_set_mode(AO_RADIO_MODE_RDF|AO_RADIO_MODE_BITS_FIXED);
ao_radio_strobe(CC115L_SFTX);
- ao_radio_pa_on();
- ao_radio_strobe(CC115L_STX);
+ ao_radio_set_len(0xff);
+ ao_radio_set_mode(AO_RADIO_MODE_RDF);
+ ao_radio_stx();
radio_on = 1;
}
if (mode == 3) {
}
}
+#if CC115L_TRACE
static inline int16_t
ao_radio_gpio_bits(void)
{
return AO_CC115L_DONE_INT_PORT->idr & ((1 << AO_CC115L_FIFO_INT_PIN) |
(1 << AO_CC115L_DONE_INT_PIN));
}
+#endif
static void
ao_radio_wait_fifo(void)
uint8_t fifo_space;
fifo_space = CC115L_FIFO_SIZE;
+ ao_radio_abort = 0;
+
+ ao_radio_strobe(CC115L_SFTX);
+
ao_radio_done = 0;
ao_radio_fifo = 0;
while (!done) {
ao_exti_enable(AO_CC115L_DONE_INT_PORT, AO_CC115L_DONE_INT_PIN);
if (!started) {
- ao_radio_pa_on();
- ao_radio_strobe(CC115L_STX);
+ ao_radio_stx();
started = 1;
}
}
__xdata struct ao_telemetry_location ao_gps_data;
__xdata struct ao_telemetry_satellite ao_gps_tracking_data;
-static const char ao_gps_set_nmea[] = "\r\n$PUBX,41,1,3,1,57600,0*2d\r\n";
+#ifndef AO_SERIAL_SPEED_UBLOX
+#define AO_SERIAL_SPEED_UBLOX AO_SERIAL_SPEED_57600
+#endif
-const char ao_gps_config[] = {
+#if AO_SERIAL_SPEED_UBLOX == AO_SERIAL_SPEED_57600
+#define SERIAL_SPEED_STRING "57600"
+#endif
+#if AO_SERIAL_SPEED_UBLOX == AO_SERIAL_SPEED_19200
+#define SERIAL_SPEED_STRING "19200"
+#endif
+#if AO_SERIAL_SPEED_UBLOX == AO_SERIAL_SPEED_9600
+#define SERIAL_SPEED_STRING "9600"
+#endif
-};
+static const char ao_gps_set_nmea[] = "\r\n$PUBX,41,1,3,1," SERIAL_SPEED_STRING ",0*2d\r\n";
struct ao_ublox_cksum {
uint8_t a, b;
for (i = 0; i < sizeof (ao_gps_set_nmea); i++)
ao_gps_putchar(ao_gps_set_nmea[i]);
+#if AO_SERIAL_SPEED_UBLOX != AO_SERIAL_SPEED_9600
/*
* Increase the baud rate
*/
- ao_gps_set_speed(AO_SERIAL_SPEED_57600);
+ ao_gps_set_speed(AO_SERIAL_SPEED_UBLOX);
+#endif
/*
* Pad with nulls to give the chip
}
int
-_ao_serial_pollchar(void)
+_ao_serial0_pollchar(void)
{
int c;
}
char
-ao_serial_getchar(void)
+ao_serial0_getchar(void)
{
int c;
ao_arch_block_interrupts();
- while ((c = _ao_serial_pollchar()) == AO_READ_AGAIN)
+ while ((c = _ao_serial0_pollchar()) == AO_READ_AGAIN)
ao_sleep(&ao_usart_rx_fifo);
ao_arch_release_interrupts();
return (char) c;
}
void
-ao_serial_putchar(char c)
+ao_serial0_putchar(char c)
{
ao_arch_block_interrupts();
while (ao_fifo_full(ao_usart_tx_fifo))
}
void
-ao_serial_drain(void)
+ao_serial0_drain(void)
{
ao_arch_block_interrupts();
while (!ao_fifo_empty(ao_usart_tx_fifo))
#include "ao_serial_lpc.h"
void
-ao_serial_set_speed(uint8_t speed)
+ao_serial0_set_speed(uint8_t speed)
{
if (speed > AO_SERIAL_SPEED_115200)
return;
lpc_usart.hden = ((0 << LPC_USART_HDEN_HDEN));
/* Set baud rate */
- ao_serial_set_speed(AO_SERIAL_SPEED_9600);
+ ao_serial0_set_speed(AO_SERIAL_SPEED_9600);
/* Enable interrupts */
lpc_usart.ier = ((1 << LPC_USART_IER_RBRINTEN) |
--- /dev/null
+#
+# AltOS build
+#
+#
+
+include ../lpc/Makefile.defs
+
+INC = \
+ ao.h \
+ ao_arch.h \
+ ao_arch_funcs.h \
+ ao_pins.h \
+ ao_product.h \
+ ao_task.h \
+ ao_whiten.h \
+ ao_cc115l.h \
+ ao_fec.h \
+ lpc.h \
+ Makefile
+
+
+ALTOS_SRC = \
+ ao_interrupt.c \
+ ao_boot_chain.c \
+ ao_product.c \
+ ao_romconfig.c \
+ ao_cmd.c \
+ ao_config.c \
+ ao_task.c \
+ ao_stdio.c \
+ ao_panic.c \
+ ao_timer_lpc.c \
+ ao_mutex.c \
+ ao_freq.c \
+ ao_spi_lpc.c \
+ ao_usb_lpc.c \
+ ao_exti_lpc.c \
+ ao_serial_lpc.c \
+ ao_gps_ublox.c \
+ ao_gps_show.c \
+ ao_cc115l.c \
+ ao_fec_tx.c \
+ ao_aprs.c \
+ ao_telemetry.c \
+ ao_storage.c \
+ ao_m25.c \
+ ao_log.c \
+ ao_log_mega.c \
+ ao_gps_report_mega.c \
+ $(SAMPLE_PROFILE)
+
+PRODUCT=TeleGPS-v0.3
+PRODUCT_DEF=-DTELEGPS
+IDPRODUCT=0x0025
+
+CFLAGS = $(PRODUCT_DEF) $(LPC_CFLAGS) $(PROFILE_DEF) -Os -g
+
+PROGNAME=telegps-v0.3
+PROG=$(PROGNAME)-$(VERSION).elf
+
+SRC=$(ALTOS_SRC) ao_telegps.c
+OBJ=$(SRC:.c=.o)
+
+all: $(PROG)
+
+LDFLAGS=-L../lpc -Wl,-Taltos.ld
+
+$(PROG): Makefile $(OBJ) altos.ld
+ $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(SAT_CLIB) -lgcc
+
+$(OBJ): $(INC)
+
+ao_product.h: ao-make-product.5c ../Version
+ $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
+
+distclean: clean
+
+clean:
+ rm -f *.o ao_serial_lpc.h $(PROGNAME)-*.elf
+ rm -f ao_product.h
+
+install:
+
+uninstall:
--- /dev/null
+/*
+ * Copyright © 2012 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_
+
+#define AO_STACK_SIZE 448
+
+#define IS_FLASH_LOADER 0
+
+/* Crystal on the board */
+#define AO_LPC_CLKIN 12000000
+
+/* Main clock frequency. 48MHz for USB so we don't use the USB PLL */
+#define AO_LPC_CLKOUT 48000000
+
+/* System clock frequency */
+#define AO_LPC_SYSCLK 24000000
+
+#define HAS_SERIAL_0 1
+#define SERIAL_0_18_19 1
+#define USE_SERIAL_0_STDIN 0
+
+#define ao_gps_getchar ao_serial0_getchar
+#define ao_gps_putchar ao_serial0_putchar
+#define ao_gps_set_speed ao_serial0_set_speed
+#define ao_gps_fifo (ao_usart_rx_fifo)
+
+#define HAS_EEPROM 1
+#define USE_INTERNAL_FLASH 0
+#define HAS_USB 1
+#define HAS_BEEP 0
+#define HAS_RADIO 1
+#define HAS_TELEMETRY 1
+#define HAS_RDF 0
+#define HAS_APRS 1
+#define HAS_RADIO_RECV 0
+
+#define HAS_USB_PULLUP 1
+#define AO_USB_PULLUP_PORT 0
+#define AO_USB_PULLUP_PIN 7
+
+/* Flash part */
+#define HAS_SPI_0 1
+#define SPI_SCK0_P0_6 1
+#define SPI_0_OSPEEDR AO_SPI_OSPEED_12MHz
+
+/* Radio */
+#define HAS_SPI_1 1
+#define SPI_SCK1_P1_15 1
+#define SPI_MISO1_P0_22 1
+#define SPI_MOSI1_P0_21 1
+
+#define HAS_GPS 1
+#define HAS_FLIGHT 0
+#define HAS_ADC 0
+#define HAS_LOG 1
+
+#define AO_CONFIG_DEFAULT_APRS_INTERVAL 5
+#define AO_CONFIG_DEFAULT_RADIO_POWER 0xc0
+
+/*
+ * GPS
+ */
+
+#define AO_SERIAL_SPEED_UBLOX AO_SERIAL_SPEED_9600
+
+/*
+ * Radio (cc115l)
+ */
+
+/* gets pretty close to 434.550 */
+
+#define AO_RADIO_CAL_DEFAULT 0x10b6a5
+
+#define HAS_RADIO_POWER 1
+#define AO_FEC_DEBUG 0
+#define AO_CC115L_SPI_CS_PORT 0
+#define AO_CC115L_SPI_CS_PIN 3
+#define AO_CC115L_SPI_BUS 0
+
+#define AO_CC115L_FIFO_INT_GPIO_IOCFG CC115L_IOCFG2
+#define AO_CC115L_FIFO_INT_PORT 0
+#define AO_CC115L_FIFO_INT_PIN 20
+
+#define AO_CC115L_DONE_INT_GPIO_IOCFG CC115L_IOCFG0
+#define AO_CC115L_DONE_INT_PORT 0
+#define AO_CC115L_DONE_INT_PIN 2
+
+/*
+ * Flash (M25)
+ */
+#define M25_MAX_CHIPS 1
+#define AO_M25_SPI_CS_PORT 0
+#define AO_M25_SPI_CS_MASK (1 << 23)
+#define AO_M25_SPI_BUS 1
+
+#define PACKET_HAS_SLAVE 0
+
+#endif /* _AO_PINS_H_ */
--- /dev/null
+/*
+ * Copyright © 2013 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_exti.h>
+#include <ao_fat.h>
+
+uint16_t ao_flight_number = 1;
+
+int
+main(void)
+{
+ ao_clock_init();
+
+#if HAS_STACK_GUARD
+ ao_mpu_init();
+#endif
+
+ ao_task_init();
+ ao_timer_init();
+
+
+ ao_spi_init();
+ ao_exti_init();
+
+ ao_storage_init();
+
+ ao_serial_init();
+
+ ao_cmd_init();
+
+ ao_usb_init();
+ ao_radio_init();
+
+ ao_gps_init();
+#if HAS_LOG
+ ao_gps_report_mega_init();
+#endif
+
+ ao_telemetry_init();
+ ao_telemetry_set_interval(AO_SEC_TO_TICKS(1));
+
+#if HAS_SAMPLE_PROFILE
+ ao_sample_profile_init();
+#endif
+ ao_config_init();
+
+ ao_start_scheduler();
+ return 0;
+}
--- /dev/null
+#
+# AltOS flash loader build
+#
+#
+
+TOPDIR=../..
+HARDWARE=telegps-v0.3
+include $(TOPDIR)/lpc/Makefile-flash.defs
--- /dev/null
+/*
+ * Copyright © 2013 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 <ao_flash_lpc_pins.h>
+
+#define AO_BOOT_PIN 1
+#define AO_BOOT_APPLICATION_GPIO 0
+#define AO_BOOT_APPLICATION_PIN 19
+#define AO_BOOT_APPLICATION_VALUE 1
+#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP
+
+#define HAS_USB_PULLUP 1
+#define AO_USB_PULLUP_PORT 0
+#define AO_USB_PULLUP_PIN 7
+
+#endif /* _AO_PINS_H_ */