From 87c65469e3c5c991d6ad67fba9a77cb596d4bcac Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Wed, 14 Aug 2024 01:15:36 -0600 Subject: [PATCH] add support for TeleGPS v4.0 --- Makefile.am | 2 + Releasing | 4 +- altosui/Makefile.am | 3 +- altosui/altos-windows.nsi.in | 1 + src/Makefile | 1 + src/telegps-v4.0/Makefile | 88 ++++++++++++ src/telegps-v4.0/ao_pins.h | 170 +++++++++++++++++++++++ src/telegps-v4.0/ao_telegps.c | 59 ++++++++ src/telegps-v4.0/flash-loader/.gitignore | 2 + src/telegps-v4.0/flash-loader/Makefile | 8 ++ src/telegps-v4.0/flash-loader/ao_pins.h | 36 +++++ telegps/Makefile.am | 3 +- telegps/telegps-windows.nsi.in | 1 + 13 files changed, 374 insertions(+), 4 deletions(-) create mode 100644 src/telegps-v4.0/Makefile create mode 100644 src/telegps-v4.0/ao_pins.h create mode 100644 src/telegps-v4.0/ao_telegps.c create mode 100644 src/telegps-v4.0/flash-loader/.gitignore create mode 100644 src/telegps-v4.0/flash-loader/Makefile create mode 100644 src/telegps-v4.0/flash-loader/ao_pins.h diff --git a/Makefile.am b/Makefile.am index 7e56ebc4..6c4eb1d7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -61,6 +61,8 @@ fat_altos = \ src/teledongle-v3.0/teledongle-v3.0-$(VERSION).ihx \ src/telegps-v1.0/telegps-v1.0-$(VERSION).ihx \ src/telegps-v2.0/telegps-v2.0-$(VERSION).ihx \ + src/telegps-v3.0/telegps-v3.0-$(VERSION).ihx \ + src/telegps-v4.0/telegps-v4.0-$(VERSION).ihx \ src/telemega-v1.0/telemega-v1.0-$(VERSION).ihx \ src/telemega-v2.0/telemega-v2.0-$(VERSION).ihx \ src/telemega-v3.0/telemega-v3.0-$(VERSION).ihx \ diff --git a/Releasing b/Releasing index 3cae2856..331ec700 100644 --- a/Releasing +++ b/Releasing @@ -122,7 +122,7 @@ These are Bdale's notes on how to do a release. src/easytimer-v[1-2]/{*.elf,*.ihx,*.map} \ src/telebt-v[3-4].0/{*.elf,*.ihx,*.map} \ src/teledongle-v3.0/{*.elf,*.ihx,*.map} \ - src/telegps-v[1-3].0/{*.elf,*.ihx,*.map} \ + src/telegps-v[1-4].0/{*.elf,*.ihx,*.map} \ src/telemega-v[1-6].0/{*.elf,*.ihx,*.map} \ src/telemetrum-v[2-4].0/{*.elf,*.ihx,*.map} \ src/telemini-v3.0/{*.elf,*.ihx,*.map} \ @@ -136,7 +136,7 @@ These are Bdale's notes on how to do a release. src/easytimer-v[1-2]/flash-loader/*.elf \ src/telebt-v[3-4].0/flash-loader/{*.elf,*.bin,*.map} \ src/teledongle-v3.0/flash-loader/*.elf \ - src/telegps-v[1-3].0/flash-loader/{*.elf,*.bin,*.map} \ + src/telegps-v[1-4].0/flash-loader/{*.elf,*.bin,*.map} \ src/telemega-v[1-6].0/flash-loader/*.elf \ src/telemetrum-v[2-4].0/flash-loader/*.elf \ src/telemini-v3.0/flash-loader/{*.elf,*.bin,*.map} \ diff --git a/altosui/Makefile.am b/altosui/Makefile.am index de60fc5c..750a85ac 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -162,7 +162,8 @@ FIRMWARE_ETIMER=$(FIRMWARE_ETIMER_1) $(FIRMWARE_ETIMER_2) FIRMWARE_TGPS_1_0=$(top_srcdir)/src/telegps-v1.0/telegps-v1.0-$(VERSION).ihx FIRMWARE_TGPS_2_0=$(top_srcdir)/src/telegps-v2.0/telegps-v2.0-$(VERSION).ihx FIRMWARE_TGPS_3_0=$(top_srcdir)/src/telegps-v3.0/telegps-v3.0-$(VERSION).ihx -FIRMWARE_TGPS=$(FIRMWARE_TGPS_1_0) $(FIRMWARE_TGPS_2_0) $(FIRMWARE_TGPS_3_0) +FIRMWARE_TGPS_4_0=$(top_srcdir)/src/telegps-v4.0/telegps-v4.0-$(VERSION).ihx +FIRMWARE_TGPS=$(FIRMWARE_TGPS_1_0) $(FIRMWARE_TGPS_2_0) $(FIRMWARE_TGPS_3_0) $(FIRMWARE_TGPS_4_0) FIRMWARE_TLCO_2_0=$(top_srcdir)/src/telelco-v2.0/telelco-v2.0-$(VERSION).ihx FIRMWARE_TLCO=$(FIRMWARE_TLCO_2_0) diff --git a/altosui/altos-windows.nsi.in b/altosui/altos-windows.nsi.in index 39f609a3..1d938e25 100644 --- a/altosui/altos-windows.nsi.in +++ b/altosui/altos-windows.nsi.in @@ -127,6 +127,7 @@ Section "Firmware" File "../src/telegps-v1.0/telegps-v1.0-${VERSION}.ihx" File "../src/telegps-v2.0/telegps-v2.0-${VERSION}.ihx" File "../src/telegps-v3.0/telegps-v3.0-${VERSION}.ihx" + File "../src/telegps-v4.0/telegps-v4.0-${VERSION}.ihx" File "../src/teledongle-v3.0/teledongle-v3.0-${VERSION}.ihx" File "../src/telebt-v3.0/telebt-v3.0-${VERSION}.ihx" File "../src/telebt-v4.0/telebt-v4.0-${VERSION}.ihx" diff --git a/src/Makefile b/src/Makefile index b3a3066c..411956cf 100644 --- a/src/Makefile +++ b/src/Makefile @@ -35,6 +35,7 @@ ARMM3DIRS=\ telegps-v1.0 telegps-v1.0/flash-loader \ telegps-v2.0 telegps-v2.0/flash-loader \ telegps-v3.0 telegps-v3.0/flash-loader \ + telegps-v4.0 telegps-v4.0/flash-loader \ telelco-v0.2 telelco-v0.2/flash-loader \ telelco-v0.2-cc1200 telelco-v0.2-cc1200/flash-loader \ telelco-v0.3 telelco-v0.3/flash-loader \ diff --git a/src/telegps-v4.0/Makefile b/src/telegps-v4.0/Makefile new file mode 100644 index 00000000..0b1535c6 --- /dev/null +++ b/src/telegps-v4.0/Makefile @@ -0,0 +1,88 @@ +# +# AltOS build +# +# + +TOPDIR=.. + +include $(TOPDIR)/stmf0/Makefile.defs + +INC = \ + ao.h \ + ao_arch.h \ + ao_arch_funcs.h \ + ao_pins.h \ + ao_product.h \ + ao_tracker.h \ + ao_task.h \ + ao_cc1200.h \ + ao_fec.h \ + stm32f0.h \ + Makefile + + +ALTOS_SRC = \ + ao_adc_stm.c \ + ao_led_stmf0.c \ + 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.c \ + ao_mutex.c \ + ao_freq.c \ + ao_dma_stm.c \ + ao_spi_stm.c \ + ao_usb_stm.c \ + ao_exti_stm.c \ + ao_serial_stm.c \ + ao_gps_ublox.c \ + ao_gps_show.c \ + ao_cc1200.c \ + ao_aprs.c \ + ao_tracker.c \ + ao_telemetry.c \ + ao_storage.c \ + ao_m25.c \ + ao_log.c \ + ao_log_gps.c \ + ao_distance.c \ + ao_sqrt.c \ + ao_data.c \ + ao_convert_volt.c \ + $(SAMPLE_PROFILE) + +PRODUCT=TeleGPS-v4.0 +PRODUCT_DEF=-DTELEGPS +IDPRODUCT=0x0025 + +CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) $(PROFILE_DEF) + +PROGNAME=telegps-v4.0 +PROG=$(PROGNAME)-$(VERSION).elf +HEX=$(PROGNAME)-$(VERSION).ihx + +SRC=$(ALTOS_SRC) ao_telegps.c +OBJ=$(SRC:.c=.o) + +all: $(PROG) $(HEX) + +$(PROG): Makefile $(OBJ) altos.ld + $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) -Wl,-Map=$(PROGNAME)-$(VERSION).map + +$(OBJ): $(INC) + +distclean: clean + +clean: + rm -f *.o ao_serial_stm.h $(PROGNAME)-*.elf $(PROGNAME)-*.ihx $(PROGNAME)-*.map + rm -f ao_product.h + +install: + +uninstall: diff --git a/src/telegps-v4.0/ao_pins.h b/src/telegps-v4.0/ao_pins.h new file mode 100644 index 00000000..a5ea6ea4 --- /dev/null +++ b/src/telegps-v4.0/ao_pins.h @@ -0,0 +1,170 @@ +/* + * Copyright © 2024 Bdale Garbee + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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 LED_PORT_ENABLE STM_RCC_AHBENR_IOPBEN +#define LED_PORT (&stm_gpiob) +#define LED_PIN_GREEN 5 +#define AO_LED_GREEN (1 << LED_PIN_GREEN) +#define AO_LED_PANIC AO_LED_GREEN +#define AO_LED_GPS_LOCK AO_LED_GREEN + +#define LEDS_AVAILABLE (AO_LED_GREEN) + +#define AO_STACK_SIZE 512 + +#define IS_FLASH_LOADER 0 +#define HAS_BEEP 0 + +#define AO_HSE 16000000 +#define AO_RCC_CFGR_PLLMUL STM_RCC_CFGR_PLLMUL_3 +#define AO_RCC_CFGR2_PLLDIV STM_RCC_CFGR2_PREDIV_1 +#define AO_PLLMUL 3 +#define AO_PLLDIV 1 + +/* HCLK = 48MHz */ +#define AO_AHB_PRESCALER 1 +#define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1 + +/* APB = 48MHz */ +#define AO_APB_PRESCALER 1 +#define AO_RCC_CFGR_PPRE_DIV STM_RCC_CFGR_PPRE_DIV_1 + +#define HAS_USB 1 +#define AO_USB_DIRECTIO 0 +#define AO_PA11_PA12_RMP 1 +#define HAS_USB_CONNECT 1 +#define AO_USB_CONNECT_PORT (&stm_gpiob) +#define AO_USB_CONNECT_PIN 3 + +#define IS_FLASH_LOADER 0 + +/* ADC */ + +#define HAS_ADC 1 +#define AO_ADC_PIN0_PORT (&stm_gpiob) +#define AO_ADC_PIN0_PIN 1 +#define AO_ADC_PIN0_CH 9 + +#define AO_ADC_RCC_AHBENR ((1 << STM_RCC_AHBENR_IOPBEN)) + +#define ao_telemetry_battery_convert(a) ((a) << 3) + +#define AO_NUM_ADC 1 + +#define AO_DATA_RING 4 + +/* + * Voltage divider on ADC battery sampler + */ +#define AO_BATTERY_DIV_PLUS 56 /* 5.6k */ +#define AO_BATTERY_DIV_MINUS 100 /* 10k */ + +/* + * ADC reference in decivolts + */ +#define AO_ADC_REFERENCE_DV 33 + +struct ao_adc { + int16_t v_batt; +}; + +#define AO_ADC_DUMP(p) \ + printf("tick: %5lu batt: %5d\n", \ + (p)->tick, \ + (p)->adc.v_batt) + +/* SPI */ +#define HAS_SPI_1 1 +#define HAS_SPI_2 0 +#define SPI_1_PA5_PA6_PA7 1 +#define SPI_1_PB3_PB4_PB5 0 +#define SPI_1_OSPEEDR STM_OSPEEDR_HIGH + +/* Flash */ + +#define M25_MAX_CHIPS 1 +#define AO_M25_SPI_CS_PORT (&stm_gpiob) +#define AO_M25_SPI_CS_MASK (1 << 0) +#define AO_M25_SPI_BUS AO_SPI_1_PA5_PA6_PA7 + +/* Serial */ +#define HAS_SERIAL_1 0 +#define SERIAL_1_PB6_PB7 1 +#define USE_SERIAL_1_STDIN 0 + +#define HAS_SERIAL_2 1 +#define SERIAL_2_PA2_PA3 1 +#define USE_SERIAL_2_STDIN 0 +#define USE_SERIAL_2_FLOW 0 +#define USE_SERIAL_2_SW_FLOW 0 + +#define ao_gps_getchar ao_serial2_getchar +#define ao_gps_putchar ao_serial2_putchar +#define ao_gps_set_speed ao_serial2_set_speed + +#define HAS_EEPROM 1 +#define USE_INTERNAL_FLASH 0 +#define HAS_RADIO 1 +#define HAS_TELEMETRY 1 +#define HAS_RDF 1 +#define HAS_APRS 1 + +#define HAS_GPS 1 +#define HAS_FLIGHT 0 +#define HAS_LOG 1 +#define FLIGHT_LOG_APPEND 1 +#define HAS_TRACKER 1 +#define LOG_ADC 0 + +#define AO_CONFIG_DEFAULT_APRS_INTERVAL 0 +#define AO_CONFIG_DEFAULT_RADIO_POWER 0xc0 +#define AO_LOG_FORMAT AO_LOG_FORMAT_TELEGPS + +/* + * GPS + */ + +#define AO_SERIAL_SPEED_UBLOX AO_SERIAL_SPEED_9600 +#define AO_UBLOX_VERSION 10 + +/* + * Radio (cc1200) + */ + +/* gets pretty close to 434.550 */ + +#define AO_RADIO_CAL_DEFAULT 5695733 + +#define AO_FEC_DEBUG 0 +#define AO_CC1200_SPI_CS_PORT (&stm_gpioa) +#define AO_CC1200_SPI_CS_PIN 1 +#define AO_CC1200_SPI_BUS AO_SPI_1_PA5_PA6_PA7 +#define AO_CC1200_SPI stm_spi1 + +#define AO_CC1200_INT_PORT (&stm_gpioa) +#define AO_CC1200_INT_PIN 4 + +#define AO_CC1200_INT_GPIO 2 +#define AO_CC1200_INT_GPIO_IOCFG CC1200_IOCFG2 + +#define HAS_BOOT_RADIO 0 + +#endif /* _AO_PINS_H_ */ diff --git a/src/telegps-v4.0/ao_telegps.c b/src/telegps-v4.0/ao_telegps.c new file mode 100644 index 00000000..1ba67f67 --- /dev/null +++ b/src/telegps-v4.0/ao_telegps.c @@ -0,0 +1,59 @@ +/* + * Copyright © 2013 Keith Packard + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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 +#include +#include +#include + +int +main(void) +{ + ao_clock_init(); + ao_task_init(); + ao_cmd_init(); + ao_config_init(); + + ao_led_init(); + ao_led_on(LEDS_AVAILABLE); + + /* internal systems */ + ao_timer_init(); + ao_dma_init(); + ao_exti_init(); + + /* SoC hardware */ + ao_adc_init(); + ao_serial_init(); + ao_spi_init(); + ao_usb_init(); + + /* External hardware */ + ao_storage_init(); + ao_radio_init(); + ao_gps_init(); + + /* Services */ + ao_log_init(); + ao_telemetry_init(); + ao_tracker_init(); + + ao_led_off(LEDS_AVAILABLE); + + ao_start_scheduler(); +} diff --git a/src/telegps-v4.0/flash-loader/.gitignore b/src/telegps-v4.0/flash-loader/.gitignore new file mode 100644 index 00000000..7bbed045 --- /dev/null +++ b/src/telegps-v4.0/flash-loader/.gitignore @@ -0,0 +1,2 @@ +*.elf +*.bin diff --git a/src/telegps-v4.0/flash-loader/Makefile b/src/telegps-v4.0/flash-loader/Makefile new file mode 100644 index 00000000..499d9762 --- /dev/null +++ b/src/telegps-v4.0/flash-loader/Makefile @@ -0,0 +1,8 @@ +# +# AltOS flash loader build +# +# + +TOPDIR=../.. +HARDWARE=telegps-v4.0 +include $(TOPDIR)/stmf0/Makefile-flash.defs diff --git a/src/telegps-v4.0/flash-loader/ao_pins.h b/src/telegps-v4.0/flash-loader/ao_pins.h new file mode 100644 index 00000000..c7bf4e72 --- /dev/null +++ b/src/telegps-v4.0/flash-loader/ao_pins.h @@ -0,0 +1,36 @@ +/* + * Copyright © 2024 Bdale Garbee + * + * 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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 + +/* Pin 5 on debug connector */ + +#define AO_BOOT_PIN 1 +#define AO_BOOT_APPLICATION_GPIO stm_gpiob +#define AO_BOOT_APPLICATION_PIN 6 +#define AO_BOOT_APPLICATION_VALUE 1 +#define AO_BOOT_APPLICATION_MODE AO_EXTI_MODE_PULL_UP + +#define HAS_USB 1 +#define AO_USB_DIRECTIO 0 +#define AO_PA11_PA12_RMP 1 + +#endif /* _AO_PINS_H_ */ diff --git a/telegps/Makefile.am b/telegps/Makefile.am index 552abea7..f8e2cf15 100644 --- a/telegps/Makefile.am +++ b/telegps/Makefile.am @@ -114,7 +114,8 @@ FIRMWARE_TBT=$(FIRMWARE_TBT_3_0) $(FIRMWARE_TBT_4_0) FIRMWARE_TGPS_1_0=$(top_srcdir)/src/telegps-v1.0/telegps-v1.0-$(VERSION).ihx FIRMWARE_TGPS_2_0=$(top_srcdir)/src/telegps-v2.0/telegps-v2.0-$(VERSION).ihx FIRMWARE_TGPS_3_0=$(top_srcdir)/src/telegps-v3.0/telegps-v3.0-$(VERSION).ihx -FIRMWARE_TGPS=$(FIRMWARE_TGPS_1_0) $(FIRMWARE_TGPS_2_0) $(FIRMWARE_TGPS_3_0) +FIRMWARE_TGPS_4_0=$(top_srcdir)/src/telegps-v4.0/telegps-v4.0-$(VERSION).ihx +FIRMWARE_TGPS=$(FIRMWARE_TGPS_1_0) $(FIRMWARE_TGPS_2_0) $(FIRMWARE_TGPS_3_0) $(FIRMWARE_TGPS_4_0) FIRMWARE=$(FIRMWARE_TGPS) $(FIRMWARE_TD) $(FIRMWARE_TBT) diff --git a/telegps/telegps-windows.nsi.in b/telegps/telegps-windows.nsi.in index c7fb452c..4e686857 100644 --- a/telegps/telegps-windows.nsi.in +++ b/telegps/telegps-windows.nsi.in @@ -123,6 +123,7 @@ Section "TeleGPS, TeleDongle and TeleBT Firmware" File "../src/telegps-v1.0/telegps-v1.0-${VERSION}.ihx" File "../src/telegps-v2.0/telegps-v2.0-${VERSION}.ihx" File "../src/telegps-v3.0/telegps-v3.0-${VERSION}.ihx" + File "../src/telegps-v4.0/telegps-v4.0-${VERSION}.ihx" File "../src/teledongle-v3.0/teledongle-v3.0-${VERSION}.ihx" File "../src/telebt-v3.0/telebt-v3.0-${VERSION}.ihx" File "../src/telebt-v4.0/telebt-v4.0-${VERSION}.ihx" -- 2.47.2