From 8c755f52db40bb845ab236ff400f35888053e616 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 27 Apr 2017 23:52:29 -0700 Subject: altos: Adapt micro log to MicroPeak V3 Allow use of regular serial API for sending data. Allow application to specify different storage size. Signed-off-by: Keith Packard --- src/kernel/ao_log_micro.c | 5 +++++ src/kernel/ao_log_micro.h | 2 ++ 2 files changed, 7 insertions(+) (limited to 'src/kernel') diff --git a/src/kernel/ao_log_micro.c b/src/kernel/ao_log_micro.c index aa0f5c76..d6f9c5a8 100644 --- a/src/kernel/ao_log_micro.c +++ b/src/kernel/ao_log_micro.c @@ -19,7 +19,12 @@ #include #include #include +#ifndef ao_async_byte #include +#else +#include +#endif +#include static uint16_t ao_log_offset = STARTING_LOG_OFFSET; diff --git a/src/kernel/ao_log_micro.h b/src/kernel/ao_log_micro.h index ec5cf3ed..f0243028 100644 --- a/src/kernel/ao_log_micro.h +++ b/src/kernel/ao_log_micro.h @@ -23,7 +23,9 @@ #define PA_MIN_OFFSET 4 #define N_SAMPLES_OFFSET 8 #define STARTING_LOG_OFFSET 10 +#ifndef MAX_LOG_OFFSET #define MAX_LOG_OFFSET 512 +#endif void ao_log_micro_save(void); -- cgit v1.2.3 From 75c26a26e905e3d4f141badfcb6ec6995ed58213 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 27 Apr 2017 23:59:27 -0700 Subject: altos: Add 100ms constants for baro Kalman filter MicroPeak v2 uses this rate. Signed-off-by: Keith Packard --- src/kernel/ao_microkalman.c | 32 +++++++++++++++++++++++++++----- src/util/make-kalman | 3 ++- 2 files changed, 29 insertions(+), 6 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/ao_microkalman.c b/src/kernel/ao_microkalman.c index ff543cc4..3cfb87cc 100644 --- a/src/kernel/ao_microkalman.c +++ b/src/kernel/ao_microkalman.c @@ -32,10 +32,32 @@ #include +#ifndef AO_MK_STEP_96MS +#define AO_MK_STEP_96MS 1 + +#endif + +#if AO_MK_STEP_100MS +#define AO_MK_TIME_STEP 0.1 + +#define AO_K0_10 AO_MK2_BARO_K0_10 +#define AO_K1_10 AO_MK2_BARO_K1_10 +#define AO_K2_10 AO_MK2_BARO_K2_10 +#endif + +#if AO_MK_STEP_96MS +#define AO_MK_TIME_STEP 0.096 + +#define AO_K0_10 AO_MK_BARO_K0_10 +#define AO_K1_10 AO_MK_BARO_K1_10 +#define AO_K2_10 AO_MK_BARO_K2_10 +#endif + /* Basic time step (96ms) */ -#define AO_MK_STEP to_fix_v(0.096) +#define AO_MK_STEP to_fix_v(AO_MK_TIME_STEP) + /* step ** 2 / 2 */ -#define AO_MK_STEP_2_2 to_fix_v(0.004608) +#define AO_MK_STEP_2_2 to_fix_v(AO_MK_TIME_STEP * AO_MK_TIME_STEP / 2.0) uint32_t ao_k_pa; /* 24.8 fixed point */ int32_t ao_k_pa_speed; /* 16.16 fixed point */ @@ -66,9 +88,9 @@ ao_microkalman_correct(void) e = pa - from_fix8(ao_k_pa); - ao_k_pa += fix16_to_fix8((int32_t) e * AO_MK_BARO_K0_10); - ao_k_pa_speed += (int32_t) e * AO_MK_BARO_K1_10; - ao_k_pa_accel += (int32_t) e * AO_MK_BARO_K2_10; + ao_k_pa += fix16_to_fix8((int32_t) e * AO_K0_10); + ao_k_pa_speed += (int32_t) e * AO_K1_10; + ao_k_pa_accel += (int32_t) e * AO_K2_10; ao_pa = from_fix8(ao_k_pa); ao_pa_speed = from_fix(ao_k_pa_speed); ao_pa_accel = from_fix(ao_k_pa_accel); diff --git a/src/util/make-kalman b/src/util/make-kalman index 580a4515..c630e9cb 100644 --- a/src/util/make-kalman +++ b/src/util/make-kalman @@ -40,4 +40,5 @@ nickle kalman.5c -p AO_BARO -c baro -t 0.01 $SIGMA_BARO nickle kalman.5c -p AO_BARO -c baro -t 0.1 $SIGMA_BARO nickle kalman.5c -p AO_BARO -c baro -t 1 $SIGMA_BARO -nickle kalman_micro.5c -p AO_MK_BARO -c baro -t 0.096 $SIGMA_MICRO \ No newline at end of file +nickle kalman_micro.5c -p AO_MK_BARO -c baro -t 0.096 $SIGMA_MICRO +nickle kalman_micro.5c -p AO_MK2_BARO -c baro -t 0.1 $SIGMA_MICRO -- cgit v1.2.3 From 4d4675cbadcb0ab9df8f6d5155797dca400315c0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 28 Apr 2017 00:00:11 -0700 Subject: altos: Add header file for ao_report_micro.c Defines the functions in this file. Signed-off-by: Keith Packard --- src/kernel/ao_report_micro.c | 1 + src/kernel/ao_report_micro.h | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 src/kernel/ao_report_micro.h (limited to 'src/kernel') diff --git a/src/kernel/ao_report_micro.c b/src/kernel/ao_report_micro.c index af68457d..9c7afdc5 100644 --- a/src/kernel/ao_report_micro.c +++ b/src/kernel/ao_report_micro.c @@ -17,6 +17,7 @@ */ #include +#include #define mid(time) ao_led_for(AO_LED_REPORT, time) #define pause(time) ao_delay(time) diff --git a/src/kernel/ao_report_micro.h b/src/kernel/ao_report_micro.h new file mode 100644 index 00000000..bd6c0622 --- /dev/null +++ b/src/kernel/ao_report_micro.h @@ -0,0 +1,21 @@ +/* + * Copyright © 2017 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. + */ + +#ifndef _AO_REPORT_MICRO_H_ +#define _AO_REPORT_MICRO_H_ + +void +ao_report_altitude(void); + +#endif /* _AO_REPORT_MICRO_H_ */ -- cgit v1.2.3 From 34fda7bff76d59bcfbcec6a44275829c45e42189 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 30 Apr 2017 17:34:08 -0700 Subject: src/kernel: Add GPS lock blink LED to tracker code Blinks an LED briefly once every three seconds when GPS is locked. Signed-off-by: Keith Packard --- src/kernel/ao_tracker.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/kernel') diff --git a/src/kernel/ao_tracker.c b/src/kernel/ao_tracker.c index 4abd309a..46278530 100644 --- a/src/kernel/ao_tracker.c +++ b/src/kernel/ao_tracker.c @@ -164,6 +164,25 @@ ao_tracker(void) } } +#ifdef AO_LED_GPS_LOCK + +static struct ao_task ao_gps_lock_task; + +static void +ao_gps_lock(void) +{ + for (;;) { + if ((gps_data.flags & (AO_GPS_VALID|AO_GPS_COURSE_VALID)) == + (AO_GPS_VALID|AO_GPS_COURSE_VALID)) + { + ao_led_for(AO_LED_GPS_LOCK, AO_MS_TO_TICKS(20)); + } + ao_delay(AO_SEC_TO_TICKS(3)); + } +} +#endif + + static uint8_t erasing_current; void @@ -222,4 +241,7 @@ ao_tracker_init(void) #endif ao_cmd_register(&ao_tracker_cmds[0]); ao_add_task(&ao_tracker_task, ao_tracker, "tracker"); +#ifdef AO_LED_GPS_LOCK + ao_add_task(&ao_gps_lock_task, ao_gps_lock, "gps lock"); +#endif } -- cgit v1.2.3 From ec963d358895ae46af63d2a6e9a32bdfb4d631c0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 30 Apr 2017 17:35:28 -0700 Subject: altos/kernel: Allow TeleGPS v2 to scale battery in telem TeleGPS v2 uses the STMF0 processor instead of the LPC11, which means the ADC range is different. As the raw ADC value was getting sent to represent battery voltage in the config packet, we need to scale that for the different processor. This patch allows that to happen. Signed-off-by: Keith Packard --- src/kernel/ao_telemetry.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/kernel') diff --git a/src/kernel/ao_telemetry.c b/src/kernel/ao_telemetry.c index fa817824..a4c73a86 100644 --- a/src/kernel/ao_telemetry.c +++ b/src/kernel/ao_telemetry.c @@ -296,6 +296,10 @@ static __pdata int8_t ao_telemetry_config_max; static __pdata int8_t ao_telemetry_config_cur; static __pdata uint16_t ao_telemetry_flight_number; +#ifndef ao_telemetry_battery_convert +#define ao_telemetry_battery_convert(a) (a) +#endif + static void ao_send_configuration(void) { @@ -308,7 +312,7 @@ ao_send_configuration(void) telemetry.configuration.config_minor = AO_CONFIG_MINOR; #if AO_idProduct_NUMBER == 0x25 && HAS_ADC /* TeleGPS gets battery voltage instead of apogee delay */ - telemetry.configuration.apogee_delay = ao_data_ring[ao_data_ring_prev(ao_data_head)].adc.v_batt; + telemetry.configuration.apogee_delay = ao_telemetry_battery_convert(ao_data_ring[ao_data_ring_prev(ao_data_head)].adc.v_batt); #else telemetry.configuration.apogee_delay = ao_config.apogee_delay; telemetry.configuration.main_deploy = ao_config.main_deploy; -- cgit v1.2.3 From e76d543a203f210683cb77df2b9bbff1a9f4b381 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 4 May 2017 22:04:57 -0700 Subject: altos: Make CDC ACM 'line coding' public This allows other systems to see what baud rate the host has requested. Signed-off-by: Keith Packard --- src/avr/ao_usb_avr.c | 2 +- src/cc1111/ao_usb.c | 2 +- src/kernel/ao_usb.h | 2 ++ src/lpc/ao_usb_lpc.c | 2 +- src/stm/ao_usb_stm.c | 2 +- src/stmf0/ao_usb_stm.c | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/kernel') diff --git a/src/avr/ao_usb_avr.c b/src/avr/ao_usb_avr.c index 08950a97..41d3c1be 100644 --- a/src/avr/ao_usb_avr.c +++ b/src/avr/ao_usb_avr.c @@ -136,7 +136,7 @@ ISR(USB_GEN_vect) } -__xdata static struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; +struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; /* Walk through the list of descriptors and find a match */ diff --git a/src/cc1111/ao_usb.c b/src/cc1111/ao_usb.c index 7d363c08..259f6512 100644 --- a/src/cc1111/ao_usb.c +++ b/src/cc1111/ao_usb.c @@ -112,7 +112,7 @@ ao_usb_ep0_flush(void) USBCS0 = cs0; } -__xdata static struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; +__xdata struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; /* Walk through the list of descriptors and find a match */ diff --git a/src/kernel/ao_usb.h b/src/kernel/ao_usb.h index cdea5178..936d939b 100644 --- a/src/kernel/ao_usb.h +++ b/src/kernel/ao_usb.h @@ -155,6 +155,8 @@ struct ao_usb_line_coding { uint8_t data_bits; } ; +extern __xdata struct ao_usb_line_coding ao_usb_line_coding; + extern __pdata uint8_t ao_usb_running; #endif /* _AO_USB_H_ */ diff --git a/src/lpc/ao_usb_lpc.c b/src/lpc/ao_usb_lpc.c index 5c13eb4b..c50e7528 100644 --- a/src/lpc/ao_usb_lpc.c +++ b/src/lpc/ao_usb_lpc.c @@ -477,7 +477,7 @@ ao_usb_ep0_in_start(uint16_t max) ao_usb_ep0_flush(); } -static struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; +struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; /* Walk through the list of descriptors and find a match */ diff --git a/src/stm/ao_usb_stm.c b/src/stm/ao_usb_stm.c index 33e0617c..595bddac 100644 --- a/src/stm/ao_usb_stm.c +++ b/src/stm/ao_usb_stm.c @@ -598,7 +598,7 @@ ao_usb_ep0_in_start(uint16_t max) ao_usb_ep0_flush(); } -static struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; +struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; /* Walk through the list of descriptors and find a match */ diff --git a/src/stmf0/ao_usb_stm.c b/src/stmf0/ao_usb_stm.c index 652b3b6c..59aed3aa 100644 --- a/src/stmf0/ao_usb_stm.c +++ b/src/stmf0/ao_usb_stm.c @@ -655,7 +655,7 @@ ao_usb_ep0_in_start(uint16_t max) ao_usb_ep0_flush(); } -static struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; +struct ao_usb_line_coding ao_usb_line_coding = {115200, 0, 0, 8}; #if AO_USB_DEVICE_ID_SERIAL static uint8_t ao_usb_serial[2 + 48]; -- cgit v1.2.3 From 3b4e3189211801c6f8f41c5d08c5a8551f28976c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 4 May 2017 22:06:16 -0700 Subject: altos: Move 'ao_force_freq' to ao_config.c Instead of having to add it to each product using this variable. Signed-off-by: Keith Packard --- src/kernel/ao_config.c | 4 ++++ src/product/ao_telemini.c | 2 -- src/telemini-v2.0/ao_telemini.c | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/ao_config.c b/src/kernel/ao_config.c index 5dda1c85..25634ffc 100644 --- a/src/kernel/ao_config.c +++ b/src/kernel/ao_config.c @@ -35,6 +35,10 @@ __pdata uint8_t ao_config_loaded; __pdata uint8_t ao_config_dirty; __xdata uint8_t ao_config_mutex; +#if HAS_FORCE_FREQ +__xdata uint8_t ao_force_freq; +#endif + #ifndef AO_CONFIG_DEFAULT_APRS_INTERVAL #define AO_CONFIG_DEFAULT_APRS_INTERVAL 0 #endif diff --git a/src/product/ao_telemini.c b/src/product/ao_telemini.c index b192763d..14414a48 100644 --- a/src/product/ao_telemini.c +++ b/src/product/ao_telemini.c @@ -19,8 +19,6 @@ #include "ao.h" #include "ao_pins.h" -__xdata uint8_t ao_force_freq; - void main(void) { diff --git a/src/telemini-v2.0/ao_telemini.c b/src/telemini-v2.0/ao_telemini.c index 68bc3dfe..a9ee423c 100644 --- a/src/telemini-v2.0/ao_telemini.c +++ b/src/telemini-v2.0/ao_telemini.c @@ -20,8 +20,6 @@ #include "ao_pins.h" #include -__xdata uint8_t ao_force_freq; - void main(void) { -- cgit v1.2.3 From f753ad3b9d0f3dc9794e5dd097063aab6cf9bdc4 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Thu, 27 Apr 2017 12:57:49 -0600 Subject: telefiretwo: don't try to record pre-burn sensor values in FLIGHT record --- altoslib/AltosEepromRecordFireTwo.java | 4 +--- src/kernel/ao_log.h | 4 +--- src/kernel/ao_log_firetwo.c | 4 ---- 3 files changed, 2 insertions(+), 10 deletions(-) (limited to 'src/kernel') diff --git a/altoslib/AltosEepromRecordFireTwo.java b/altoslib/AltosEepromRecordFireTwo.java index dd9e34e1..809247c7 100644 --- a/altoslib/AltosEepromRecordFireTwo.java +++ b/altoslib/AltosEepromRecordFireTwo.java @@ -27,8 +27,6 @@ public class AltosEepromRecordFireTwo extends AltosEepromRecord { /* AO_LOG_FLIGHT elements */ public int flight() { return data16(0); } - public int idle_pres() { return data16(2); } - public int idle_thrust() { return data16(4); } /* AO_LOG_STATE elements */ public int state() { return data16(0); } @@ -76,7 +74,7 @@ public class AltosEepromRecordFireTwo extends AltosEepromRecord { switch (cmd()) { case AltosLib.AO_LOG_FLIGHT: state.set_flight(flight()); - state.set_ground_pressure(adc_to_pa(idle_pres())); + state.set_ground_pressure(0.0); state.set_accel_g(0, -1); break; case AltosLib.AO_LOG_STATE: diff --git a/src/kernel/ao_log.h b/src/kernel/ao_log.h index a2f2c6ca..5c568c99 100644 --- a/src/kernel/ao_log.h +++ b/src/kernel/ao_log.h @@ -309,9 +309,7 @@ struct ao_log_firetwo { /* AO_LOG_FLIGHT */ struct { uint16_t flight; /* 4 */ - uint16_t idle_pressure; /* 6 */ - uint16_t idle_thrust; /* 8 */ - } flight; /* 16 */ + } flight; /* 6 */ /* AO_LOG_STATE */ struct { uint16_t state; /* 4 */ diff --git a/src/kernel/ao_log_firetwo.c b/src/kernel/ao_log_firetwo.c index 4b42abe4..1a82673d 100644 --- a/src/kernel/ao_log_firetwo.c +++ b/src/kernel/ao_log_firetwo.c @@ -75,8 +75,6 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_firetwo))] ; void ao_log(void) { - uint16_t ao_idle_pressure = 0; // write code to capture pre-test values someday - uint16_t ao_idle_thrust = 0; uint16_t ao_flight_state = ao_flight_startup; ao_storage_setup(); @@ -89,8 +87,6 @@ ao_log(void) log.type = AO_LOG_FLIGHT; log.tick = ao_time(); - log.u.flight.idle_pressure = ao_idle_pressure; - log.u.flight.idle_thrust = ao_idle_thrust; log.u.flight.flight = ao_flight_number; ao_log_firetwo(&log); -- cgit v1.2.3 From 2a05849c3bf8c1617409237be48802dd6fc6255b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 11 Jun 2017 22:34:11 -0700 Subject: altos: HMC5883 output order is X Z Y Re-label everything to have the correct names. This doesn't actually change the code at all, so the eeprom and telemetry is all compatible. Matching changes on the host side will be required to actually process the data correctly, of course. Signed-off-by: Keith Packard --- src/drivers/ao_hmc5883.c | 6 ++---- src/drivers/ao_hmc5883.h | 2 +- src/kernel/ao_log.h | 4 ++-- src/kernel/ao_log_mega.c | 2 +- src/kernel/ao_telemetry.c | 2 +- src/kernel/ao_telemetry.h | 4 ++-- 6 files changed, 9 insertions(+), 11 deletions(-) (limited to 'src/kernel') diff --git a/src/drivers/ao_hmc5883.c b/src/drivers/ao_hmc5883.c index 9f1131d6..c33aa536 100644 --- a/src/drivers/ao_hmc5883.c +++ b/src/drivers/ao_hmc5883.c @@ -143,10 +143,8 @@ static struct ao_task ao_hmc5883_task; static void ao_hmc5883_show(void) { - struct ao_data sample; - ao_data_get(&sample); - printf ("X: %d Y: %d Z: %d missed irq: %lu\n", - sample.hmc5883.x, sample.hmc5883.y, sample.hmc5883.z, ao_hmc5883_missed_irq); + printf ("X: %d Z: %d Y: %d missed irq: %lu\n", + ao_hmc5883_current.x, ao_hmc5883_current.z, ao_hmc5883_current.y, ao_hmc5883_missed_irq); } static const struct ao_cmds ao_hmc5883_cmds[] = { diff --git a/src/drivers/ao_hmc5883.h b/src/drivers/ao_hmc5883.h index 78637b02..b90733df 100644 --- a/src/drivers/ao_hmc5883.h +++ b/src/drivers/ao_hmc5883.h @@ -77,7 +77,7 @@ #define HMC5883_ID_C 12 struct ao_hmc5883_sample { - int16_t x, y, z; + int16_t x, z, y; }; extern struct ao_hmc5883_sample ao_hmc5883_current; diff --git a/src/kernel/ao_log.h b/src/kernel/ao_log.h index 5c568c99..241ba7d7 100644 --- a/src/kernel/ao_log.h +++ b/src/kernel/ao_log.h @@ -252,8 +252,8 @@ struct ao_log_mega { int16_t gyro_y; /* 20 */ int16_t gyro_z; /* 22 */ int16_t mag_x; /* 24 */ - int16_t mag_y; /* 26 */ - int16_t mag_z; /* 28 */ + int16_t mag_z; /* 26 */ + int16_t mag_y; /* 28 */ int16_t accel; /* 30 */ } sensor; /* 32 */ /* AO_LOG_TEMP_VOLT */ diff --git a/src/kernel/ao_log_mega.c b/src/kernel/ao_log_mega.c index a0212198..b86abe7a 100644 --- a/src/kernel/ao_log_mega.c +++ b/src/kernel/ao_log_mega.c @@ -135,8 +135,8 @@ ao_log(void) #endif #if HAS_HMC5883 log.u.sensor.mag_x = ao_data_ring[ao_log_data_pos].hmc5883.x; - log.u.sensor.mag_y = ao_data_ring[ao_log_data_pos].hmc5883.y; log.u.sensor.mag_z = ao_data_ring[ao_log_data_pos].hmc5883.z; + log.u.sensor.mag_y = ao_data_ring[ao_log_data_pos].hmc5883.y; #endif log.u.sensor.accel = ao_data_accel(&ao_data_ring[ao_log_data_pos]); ao_log_mega(&log); diff --git a/src/kernel/ao_telemetry.c b/src/kernel/ao_telemetry.c index a4c73a86..2ae1e41b 100644 --- a/src/kernel/ao_telemetry.c +++ b/src/kernel/ao_telemetry.c @@ -160,8 +160,8 @@ ao_send_mega_sensor(void) #if HAS_HMC5883 telemetry.mega_sensor.mag_x = packet->hmc5883.x; - telemetry.mega_sensor.mag_y = packet->hmc5883.y; telemetry.mega_sensor.mag_z = packet->hmc5883.z; + telemetry.mega_sensor.mag_y = packet->hmc5883.y; #endif ao_telemetry_send(); diff --git a/src/kernel/ao_telemetry.h b/src/kernel/ao_telemetry.h index 45aaeb07..23e3ed7d 100644 --- a/src/kernel/ao_telemetry.h +++ b/src/kernel/ao_telemetry.h @@ -198,8 +198,8 @@ struct ao_telemetry_mega_sensor { int16_t gyro_z; /* 24 */ int16_t mag_x; /* 26 */ - int16_t mag_y; /* 28 */ - int16_t mag_z; /* 30 */ + int16_t mag_z; /* 28 */ + int16_t mag_y; /* 30 */ /* 32 */ }; -- cgit v1.2.3 From 9454756f54312381927cb9faf1c4a6f5d8271034 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 11 Jun 2017 22:43:57 -0700 Subject: altos: Create separate log format for EasyMini v2.0 The ADC in the STM32F0 is different than the LPC, with a range of 0-4095 instead of 0-32767. Signed-off-by: Keith Packard --- src/easymini-v1.0/ao_pins.h | 2 +- src/easymini-v2.0/ao_pins.h | 2 +- src/kernel/ao_log.h | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src/kernel') diff --git a/src/easymini-v1.0/ao_pins.h b/src/easymini-v1.0/ao_pins.h index 5983bb9e..45c6891d 100644 --- a/src/easymini-v1.0/ao_pins.h +++ b/src/easymini-v1.0/ao_pins.h @@ -42,7 +42,7 @@ #define PACKET_HAS_SLAVE 0 -#define AO_LOG_FORMAT AO_LOG_FORMAT_EASYMINI +#define AO_LOG_FORMAT AO_LOG_FORMAT_EASYMINI1 /* USART */ diff --git a/src/easymini-v2.0/ao_pins.h b/src/easymini-v2.0/ao_pins.h index c141d1a6..2ec0e90b 100644 --- a/src/easymini-v2.0/ao_pins.h +++ b/src/easymini-v2.0/ao_pins.h @@ -44,7 +44,7 @@ #define AO_PA11_PA12_RMP 1 #define AO_USB_FORCE_IDLE 1 -#define AO_LOG_FORMAT AO_LOG_FORMAT_EASYMINI +#define AO_LOG_FORMAT AO_LOG_FORMAT_EASYMINI2 #define HAS_BOOT_RADIO 0 diff --git a/src/kernel/ao_log.h b/src/kernel/ao_log.h index 241ba7d7..aca669db 100644 --- a/src/kernel/ao_log.h +++ b/src/kernel/ao_log.h @@ -45,7 +45,7 @@ extern __pdata enum ao_flight_state ao_log_state; #define AO_LOG_FORMAT_TELEMETRY 3 /* 32 byte ao_telemetry records */ #define AO_LOG_FORMAT_TELESCIENCE 4 /* 32 byte typed telescience records */ #define AO_LOG_FORMAT_TELEMEGA_OLD 5 /* 32 byte typed telemega records */ -#define AO_LOG_FORMAT_EASYMINI 6 /* 16-byte MS5607 baro only, 3.0V supply */ +#define AO_LOG_FORMAT_EASYMINI1 6 /* 16-byte MS5607 baro only, 3.0V supply */ #define AO_LOG_FORMAT_TELEMETRUM 7 /* 16-byte typed telemetrum records */ #define AO_LOG_FORMAT_TELEMINI2 8 /* 16-byte MS5607 baro only, 3.3V supply, cc1111 SoC */ #define AO_LOG_FORMAT_TELEGPS 9 /* 32 byte telegps records */ @@ -53,6 +53,7 @@ extern __pdata enum ao_flight_state ao_log_state; #define AO_LOG_FORMAT_DETHERM 11 /* 16-byte MS5607 baro only, no ADC */ #define AO_LOG_FORMAT_TELEMINI3 12 /* 16-byte MS5607 baro only, 3.3V supply, stm32f042 SoC */ #define AO_LOG_FORMAT_TELEFIRETWO 13 /* 32-byte test stand data */ +#define AO_LOG_FORMAT_EASYMINI2 14 /* 16-byte MS5607 baro only, 3.3V supply, stm32f042 SoC */ #define AO_LOG_FORMAT_NONE 127 /* No log at all */ extern __code uint8_t ao_log_format; -- cgit v1.2.3 From 0cbfa444a9f9159cb509bb47ca5590fc1d709f64 Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Fri, 21 Jul 2017 17:43:38 -0600 Subject: clean up telefireone name references --- src/kernel/ao_log_fireone.c | 145 ++++++++++++++++++++++++++++++++++ src/kernel/ao_log_firetwo.c | 145 ---------------------------------- src/telefireone-v1.0/Makefile | 10 +-- src/telefireone-v1.0/ao_telefireone.c | 73 +++++++++++++++++ src/telefireone-v1.0/ao_telefiretwo.c | 73 ----------------- 5 files changed, 223 insertions(+), 223 deletions(-) create mode 100644 src/kernel/ao_log_fireone.c delete mode 100644 src/kernel/ao_log_firetwo.c create mode 100644 src/telefireone-v1.0/ao_telefireone.c delete mode 100644 src/telefireone-v1.0/ao_telefiretwo.c (limited to 'src/kernel') 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(); -} -- cgit v1.2.3