From: Keith Packard Date: Sat, 12 Aug 2017 03:45:25 +0000 (-0400) Subject: Merge remote-tracking branch 'origin/master' X-Git-Tag: 1.8~6 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=5fdce5b4a70ae59f8ac1ca10d9fadbbbd62412f3;hp=f1bbf1bd18d52a084af714a022b12bfc3c76374c Merge remote-tracking branch 'origin/master' --- diff --git a/Makefile.am b/Makefile.am index 4145946e..2fdbd109 100644 --- a/Makefile.am +++ b/Makefile.am @@ -53,6 +53,7 @@ fat_altos = \ src/easymini-v1.0/easymini-v1.0-$(VERSION).ihx \ src/telebt-v1.0/telebt-v1.0-$(VERSION).ihx \ src/telebt-v3.0/telebt-v3.0-$(VERSION).ihx \ + src/telebt-v4.0/telebt-v4.0-$(VERSION).ihx \ src/teledongle-v0.2/teledongle-v0.2-$(VERSION).ihx \ src/teledongle-v3.0/teledongle-v3.0-$(VERSION).ihx \ src/telegps-v1.0/telegps-v1.0-$(VERSION).ihx \ diff --git a/ao-bringup/turnon_telebt b/ao-bringup/turnon_telebt index 509814d3..912ba459 100755 --- a/ao-bringup/turnon_telebt +++ b/ao-bringup/turnon_telebt @@ -1,10 +1,10 @@ #!/bin/sh -if [ -x /usr/bin/ao-flash-stm ]; then - FLASH_STM=/usr/bin/ao-flash-stm +if [ -x /usr/bin/dfu-util ]; then + DFU_UTIL=/usr/bin/dfu-util else - echo "Can't find ao-flash-stm! Aborting." - exit 1 + echo "Can't find dfu-util! Aborting." + exit 1 fi if [ -x /usr/bin/ao-usbload ]; then @@ -14,38 +14,52 @@ else exit 1 fi -VERSION=3.0 +VERSION=4.0 REPO=~/altusmetrumllc/Binaries +PRODUCT=TeleBT -echo "TeleBT v$VERSION Turn-On and Calibration Program" -echo "Copyright 2015 by Bdale Garbee. Released under GPL v2" +echo "$PRODUCT v$VERSION Turn-On and Calibration Program" +echo "Copyright 2017 by Bdale Garbee. Released under GPL v3+" echo echo "Expectations:" -echo "\tTeleBT v$VERSION powered from USB" -echo "\t\twith ST-Link-V2 cabled to debug header" +echo "\t$PRODUCT v$VERSION attached by USB" echo "\t\twith coax from UHF to frequency counter" echo -echo -n "TeleBT-$VERSION serial number: " -read SERIAL -echo $FLASH_STM +case $# in + 1) + SERIAL="$1" + echo "$PRODUCT-$VERSION serial number: $SERIAL" + ;; + 0) + echo -n "$PRODUCT-$VERSION serial number: " + read SERIAL + ;; + *) + echo "Usage: $0 " 1>&2 + exit 1; + ;; +esac + +FLASH_FILE=$REPO/loaders/telebt-v$VERSION-altos-flash-*.bin +ALTOS_FILE=$REPO/telebt-v$VERSION-*.elf -$FLASH_STM $REPO/loaders/telebt-v$VERSION*.elf || exit 1 +$DFU_UTIL -a 0 -s 0x08000000:leave -D $FLASH_FILE || exit 1 -sleep 5 +sleep 2 -$USBLOAD --serial=$SERIAL $REPO/telebt-v$VERSION*.elf || exit 1 +$USBLOAD --serial=$SERIAL $ALTOS_FILE || exit 1 -sleep 5 +sleep 3 -dev=`ao-list | awk '/TeleBT-v'"$VERSION"'/ { print $3; exit(0); }'` +dev=`ao-list | awk '/'"$PRODUCT"'-v'"$VERSION"'/ { print $3; exit(0); }'` case "$dev" in /dev/tty*) - echo "TeleBT found on $dev" + echo "$PRODUCT found on $dev" ;; *) - echo 'No TeleBT-v'"$VERSION"' found' + echo 'No '"$PRODUCT"'-v'"$VERSION"' found' exit 1 ;; esac @@ -65,6 +79,15 @@ else exit 1 fi -echo "TeleBT-v$VERSION $SERIAL is ready to ship" +echo -n "checking BTLE functionality... " +btdev=`sudo timeout -s SIGINT 5s hcitool lescan | awk -F \- '/TeleBT/ { print $2 }'` +if [ "$btdev" = "$SERIAL" ]; then + echo "working!" +else + echo "device not found" + exit 1 +fi + +echo "$PRODUCT-v$VERSION $SERIAL is ready to ship" exit $? diff --git a/ao-bringup/turnon_telebt_v3 b/ao-bringup/turnon_telebt_v3 new file mode 100755 index 00000000..509814d3 --- /dev/null +++ b/ao-bringup/turnon_telebt_v3 @@ -0,0 +1,70 @@ +#!/bin/sh + +if [ -x /usr/bin/ao-flash-stm ]; then + FLASH_STM=/usr/bin/ao-flash-stm +else + echo "Can't find ao-flash-stm! Aborting." + exit 1 +fi + +if [ -x /usr/bin/ao-usbload ]; then + USBLOAD=/usr/bin/ao-usbload +else + echo "Can't find ao-usbload! Aborting." + exit 1 +fi + +VERSION=3.0 +REPO=~/altusmetrumllc/Binaries + +echo "TeleBT v$VERSION Turn-On and Calibration Program" +echo "Copyright 2015 by Bdale Garbee. Released under GPL v2" +echo +echo "Expectations:" +echo "\tTeleBT v$VERSION powered from USB" +echo "\t\twith ST-Link-V2 cabled to debug header" +echo "\t\twith coax from UHF to frequency counter" +echo +echo -n "TeleBT-$VERSION serial number: " +read SERIAL + +echo $FLASH_STM + +$FLASH_STM $REPO/loaders/telebt-v$VERSION*.elf || exit 1 + +sleep 5 + +$USBLOAD --serial=$SERIAL $REPO/telebt-v$VERSION*.elf || exit 1 + +sleep 5 + +dev=`ao-list | awk '/TeleBT-v'"$VERSION"'/ { print $3; exit(0); }'` + +case "$dev" in +/dev/tty*) + echo "TeleBT found on $dev" + ;; +*) + echo 'No TeleBT-v'"$VERSION"' found' + exit 1 + ;; +esac + +echo 'E 0' > $dev + +SERIAL=$SERIAL ./cal-freq $dev + +echo 'E 1' > $dev + +echo -n "checking BlueTooth functionality... " +btdev=`hcitool scan | awk -F \- '/TeleBT/ { print $2 }'` +if [ "$btdev" = "$SERIAL" ]; then + echo "working!" +else + echo "device not found" + exit 1 +fi + +echo "TeleBT-v$VERSION $SERIAL is ready to ship" + +exit $? diff --git a/src/Makefile b/src/Makefile index 4e5dac58..25e43a0e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -41,6 +41,7 @@ ARMM3DIRS=\ teledongle-v3.0 teledongle-v3.0/flash-loader \ teleballoon-v2.0 \ telebt-v3.0 telebt-v3.0/flash-loader \ + telebt-v4.0 telebt-v4.0/flash-loader \ telelcotwo-v0.1 telelcotwo-v0.1/flash-loader \ telefiretwo-v0.1 telefiretwo-v0.1/flash-loader \ diff --git a/src/kernel/ao_log_fireone.c b/src/kernel/ao_log_fireone.c new file mode 100644 index 00000000..1a82673d --- /dev/null +++ b/src/kernel/ao_log_fireone.c @@ -0,0 +1,145 @@ +/* + * Copyright © 2017 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. + */ + +#include "ao.h" +#include +#include +#include + +static __xdata struct ao_log_firetwo log; + +__code uint8_t ao_log_format = AO_LOG_FORMAT_TELEFIRETWO; + +static uint8_t +ao_log_csum(__xdata uint8_t *b) __reentrant +{ + uint8_t sum = 0x5a; + uint8_t i; + + for (i = 0; i < sizeof (struct ao_log_firetwo); i++) + sum += *b++; + return -sum; +} + +uint8_t +ao_log_firetwo(__xdata struct ao_log_firetwo *log) __reentrant +{ + uint8_t wrote = 0; + /* set checksum */ + log->csum = 0; + log->csum = ao_log_csum((__xdata uint8_t *) log); + ao_mutex_get(&ao_log_mutex); { + if (ao_log_current_pos >= ao_log_end_pos && ao_log_running) + ao_log_stop(); + if (ao_log_running) { + wrote = 1; + ao_storage_write(ao_log_current_pos, + log, + sizeof (struct ao_log_firetwo)); + ao_log_current_pos += sizeof (struct ao_log_firetwo); + } + } ao_mutex_put(&ao_log_mutex); + return wrote; +} + +static uint8_t +ao_log_dump_check_data(void) +{ + if (ao_log_csum((uint8_t *) &log) != 0) + return 0; + return 1; +} + +#if HAS_ADC +static __data uint8_t ao_log_data_pos; + +/* a hack to make sure that ao_log_metrums fill the eeprom block in even units */ +typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_firetwo))] ; +#endif + +void +ao_log(void) +{ + uint16_t ao_flight_state = ao_flight_startup; + + ao_storage_setup(); + + do { + ao_log_scan(); + + while (!ao_log_running) + ao_sleep(&ao_log_running); + + log.type = AO_LOG_FLIGHT; + log.tick = ao_time(); + log.u.flight.flight = ao_flight_number; + ao_log_firetwo(&log); + + /* Write the whole contents of the ring to the log + * when starting up. + */ + ao_log_data_pos = ao_data_ring_next(ao_data_head); + ao_log_state = ao_flight_startup; + for (;;) { + /* Write samples to EEPROM */ + while (ao_log_data_pos != ao_data_head) { + log.tick = ao_data_ring[ao_log_data_pos].tick; + log.type = AO_LOG_SENSOR; + log.u.sensor.pressure = ao_data_ring[ao_log_data_pos].adc.pressure; + log.u.sensor.thrust = ao_data_ring[ao_log_data_pos].adc.thrust; + // for (i = 0; i < 4; i++) { + // log.u.sensor.thermistor[i] = ao_data_ring[ao_log_data_pos].sensor.thermistor[i]; + // } + ao_log_firetwo(&log); + ao_log_data_pos = ao_data_ring_next(ao_log_data_pos); + } + /* Write state change to EEPROM */ + if (ao_flight_state != ao_log_state) { + ao_log_state = ao_flight_state; + log.type = AO_LOG_STATE; + log.tick = ao_time(); + log.u.state.state = ao_log_state; + log.u.state.reason = 0; + ao_log_firetwo(&log); + + if (ao_log_state == ao_flight_landed) + ao_log_stop(); + } + + ao_log_flush(); + + if (!ao_log_running) break; + + /* Wait for a while */ + ao_delay(AO_MS_TO_TICKS(100)); + } + } while (ao_log_running); +} + +uint16_t +ao_log_flight(uint8_t slot) +{ + if (!ao_storage_read(ao_log_pos(slot), + &log, + sizeof (struct ao_log_firetwo))) + return 0; + + if (ao_log_dump_check_data() && log.type == AO_LOG_FLIGHT) + return log.u.flight.flight; + return 0; +} diff --git a/src/kernel/ao_log_firetwo.c b/src/kernel/ao_log_firetwo.c deleted file mode 100644 index 1a82673d..00000000 --- a/src/kernel/ao_log_firetwo.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright © 2017 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. - */ - -#include "ao.h" -#include -#include -#include - -static __xdata struct ao_log_firetwo log; - -__code uint8_t ao_log_format = AO_LOG_FORMAT_TELEFIRETWO; - -static uint8_t -ao_log_csum(__xdata uint8_t *b) __reentrant -{ - uint8_t sum = 0x5a; - uint8_t i; - - for (i = 0; i < sizeof (struct ao_log_firetwo); i++) - sum += *b++; - return -sum; -} - -uint8_t -ao_log_firetwo(__xdata struct ao_log_firetwo *log) __reentrant -{ - uint8_t wrote = 0; - /* set checksum */ - log->csum = 0; - log->csum = ao_log_csum((__xdata uint8_t *) log); - ao_mutex_get(&ao_log_mutex); { - if (ao_log_current_pos >= ao_log_end_pos && ao_log_running) - ao_log_stop(); - if (ao_log_running) { - wrote = 1; - ao_storage_write(ao_log_current_pos, - log, - sizeof (struct ao_log_firetwo)); - ao_log_current_pos += sizeof (struct ao_log_firetwo); - } - } ao_mutex_put(&ao_log_mutex); - return wrote; -} - -static uint8_t -ao_log_dump_check_data(void) -{ - if (ao_log_csum((uint8_t *) &log) != 0) - return 0; - return 1; -} - -#if HAS_ADC -static __data uint8_t ao_log_data_pos; - -/* a hack to make sure that ao_log_metrums fill the eeprom block in even units */ -typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_firetwo))] ; -#endif - -void -ao_log(void) -{ - uint16_t ao_flight_state = ao_flight_startup; - - ao_storage_setup(); - - do { - ao_log_scan(); - - while (!ao_log_running) - ao_sleep(&ao_log_running); - - log.type = AO_LOG_FLIGHT; - log.tick = ao_time(); - log.u.flight.flight = ao_flight_number; - ao_log_firetwo(&log); - - /* Write the whole contents of the ring to the log - * when starting up. - */ - ao_log_data_pos = ao_data_ring_next(ao_data_head); - ao_log_state = ao_flight_startup; - for (;;) { - /* Write samples to EEPROM */ - while (ao_log_data_pos != ao_data_head) { - log.tick = ao_data_ring[ao_log_data_pos].tick; - log.type = AO_LOG_SENSOR; - log.u.sensor.pressure = ao_data_ring[ao_log_data_pos].adc.pressure; - log.u.sensor.thrust = ao_data_ring[ao_log_data_pos].adc.thrust; - // for (i = 0; i < 4; i++) { - // log.u.sensor.thermistor[i] = ao_data_ring[ao_log_data_pos].sensor.thermistor[i]; - // } - ao_log_firetwo(&log); - ao_log_data_pos = ao_data_ring_next(ao_log_data_pos); - } - /* Write state change to EEPROM */ - if (ao_flight_state != ao_log_state) { - ao_log_state = ao_flight_state; - log.type = AO_LOG_STATE; - log.tick = ao_time(); - log.u.state.state = ao_log_state; - log.u.state.reason = 0; - ao_log_firetwo(&log); - - if (ao_log_state == ao_flight_landed) - ao_log_stop(); - } - - ao_log_flush(); - - if (!ao_log_running) break; - - /* Wait for a while */ - ao_delay(AO_MS_TO_TICKS(100)); - } - } while (ao_log_running); -} - -uint16_t -ao_log_flight(uint8_t slot) -{ - if (!ao_storage_read(ao_log_pos(slot), - &log, - sizeof (struct ao_log_firetwo))) - return 0; - - if (ao_log_dump_check_data() && log.type == AO_LOG_FLIGHT) - return log.u.flight.flight; - return 0; -} diff --git a/src/telebt-v4.0/.gitignore b/src/telebt-v4.0/.gitignore index 892c3acc..d1cf2326 100644 --- a/src/telebt-v4.0/.gitignore +++ b/src/telebt-v4.0/.gitignore @@ -1,3 +1,4 @@ ao_product.h -ao_serial_lpc.h +*.bin +*.ihx *.elf diff --git a/src/telefireone-v1.0/Makefile b/src/telefireone-v1.0/Makefile index 87d5d477..53f088cb 100644 --- a/src/telefireone-v1.0/Makefile +++ b/src/telefireone-v1.0/Makefile @@ -55,18 +55,18 @@ ALTOS_SRC = \ ao_pad.c \ ao_radio_cmac_cmd.c \ ao_log.c \ - ao_log_firetwo.c + ao_log_fireone.c PRODUCT_SRC = \ - ao_telefiretwo.c + ao_telefireone.c -PRODUCT=TeleFireTwo-v1.0 -PRODUCT_DEF=-DTELEFIRETWO_V_1_0 +PRODUCT=TeleFireOne-v1.0 +PRODUCT_DEF=-DTELEFIREONE_V_1_0 IDPRODUCT=0x000f CFLAGS = $(PRODUCT_DEF) $(STM_CFLAGS) $(PROFILE_DEF) -Os -g -PROGNAME = telefiretwo-v1.0 +PROGNAME = telefireone-v1.0 PROG = $(PROGNAME)-$(VERSION).elf HEX = $(PROGNAME)-$(VERSION).ihx diff --git a/src/telefireone-v1.0/ao_telefireone.c b/src/telefireone-v1.0/ao_telefireone.c new file mode 100644 index 00000000..115b3e91 --- /dev/null +++ b/src/telefireone-v1.0/ao_telefireone.c @@ -0,0 +1,73 @@ +/* + * Copyright © 2012 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 +#include +#include + +static void +set_logging(void) +{ + ao_cmd_hex(); + ao_log_running = ao_cmd_lex_i; + ao_wakeup(&ao_log_running); +} + +__code struct ao_cmds ao_firetwo_cmds[] = { + { set_logging, "L <0 off, 1 on>\0Log sensors to flash" }, + { 0, NULL }, +}; + +void +main(void) +{ + ao_clock_init(); + + ao_led_init(LEDS_AVAILABLE); + + ao_task_init(); + + ao_timer_init(); + ao_spi_init(); + ao_dma_init(); + ao_exti_init(); + + ao_cmd_register(&ao_firetwo_cmds[0]); + ao_cmd_init(); + + ao_adc_init(); + + ao_eeprom_init(); + ao_storage_init(); + ao_log_init(); + + ao_radio_init(); + + ao_usb_init(); + + ao_config_init(); + + ao_pad_init(); + +// ao_radio_cmac_cmd_init(); + + ao_start_scheduler(); +} diff --git a/src/telefireone-v1.0/ao_telefiretwo.c b/src/telefireone-v1.0/ao_telefiretwo.c deleted file mode 100644 index 115b3e91..00000000 --- a/src/telefireone-v1.0/ao_telefiretwo.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright © 2012 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 -#include -#include - -static void -set_logging(void) -{ - ao_cmd_hex(); - ao_log_running = ao_cmd_lex_i; - ao_wakeup(&ao_log_running); -} - -__code struct ao_cmds ao_firetwo_cmds[] = { - { set_logging, "L <0 off, 1 on>\0Log sensors to flash" }, - { 0, NULL }, -}; - -void -main(void) -{ - ao_clock_init(); - - ao_led_init(LEDS_AVAILABLE); - - ao_task_init(); - - ao_timer_init(); - ao_spi_init(); - ao_dma_init(); - ao_exti_init(); - - ao_cmd_register(&ao_firetwo_cmds[0]); - ao_cmd_init(); - - ao_adc_init(); - - ao_eeprom_init(); - ao_storage_init(); - ao_log_init(); - - ao_radio_init(); - - ao_usb_init(); - - ao_config_init(); - - ao_pad_init(); - -// ao_radio_cmac_cmd_init(); - - ao_start_scheduler(); -}