From: Bdale Garbee Date: Fri, 21 Jul 2017 23:43:38 +0000 (-0600) Subject: clean up telefireone name references X-Git-Tag: 1.8~6^2~3 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=0cbfa444a9f9159cb509bb47ca5590fc1d709f64 clean up telefireone name references --- 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/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(); -}