summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ao_adc.h5
-rw-r--r--src/core/ao_config.c33
-rw-r--r--src/core/ao_kalman.c3
-rw-r--r--src/core/ao_log.c3
-rw-r--r--src/core/ao_log.h62
-rw-r--r--src/core/ao_sample.h19
6 files changed, 106 insertions, 19 deletions
diff --git a/src/core/ao_adc.h b/src/core/ao_adc.h
index db5bfab3..8ec740c4 100644
--- a/src/core/ao_adc.h
+++ b/src/core/ao_adc.h
@@ -18,13 +18,11 @@
#ifndef _AO_ADC_H_
#define _AO_ADC_H_
-
-
/*
* One set of samples read from the A/D converter or telemetry
*/
-
+#if AO_ADC_RING
/*
* ao_adc.c
*/
@@ -42,6 +40,7 @@ extern volatile __data uint8_t ao_adc_head;
#if HAS_ACCEL_REF
extern volatile __xdata uint16_t ao_accel_ref[AO_ADC_RING];
#endif
+#endif
/* Trigger a conversion sequence (called from the timer interrupt) */
void
diff --git a/src/core/ao_config.c b/src/core/ao_config.c
index 55fb8590..55ec9f40 100644
--- a/src/core/ao_config.c
+++ b/src/core/ao_config.c
@@ -16,6 +16,9 @@
*/
#include "ao.h"
+#include "ao_log.h"
+#include <ao_sample.h>
+#include <ao_data.h>
__xdata struct ao_config ao_config;
__pdata uint8_t ao_config_loaded;
@@ -64,11 +67,13 @@ ao_config_put(void)
}
#endif
+#if HAS_RADIO
void
ao_config_set_radio(void)
{
ao_config.radio_setting = ao_freq_to_set(ao_config.frequency, ao_config.radio_cal);
}
+#endif /* HAS_RADIO */
static void
_ao_config_get(void)
@@ -100,8 +105,10 @@ _ao_config_get(void)
ao_config.accel_minus_g = 0;
}
/* Fixups for minor version 3 */
+#if HAS_RADIO
if (ao_config.minor < 3)
ao_config.radio_cal = ao_radio_cal;
+#endif
/* Fixups for minor version 4 */
if (ao_config.minor < 4)
ao_config.flight_log_max = AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX;
@@ -121,7 +128,9 @@ _ao_config_get(void)
ao_config.minor = AO_CONFIG_MINOR;
ao_config_dirty = 1;
}
+#if HAS_RADIO
ao_config_set_radio();
+#endif
ao_config_loaded = 1;
}
@@ -176,6 +185,7 @@ ao_config_callsign_set(void) __reentrant
_ao_config_edit_finish();
}
+#if HAS_RADIO
void
ao_config_frequency_show(void) __reentrant
{
@@ -195,6 +205,7 @@ ao_config_frequency_set(void) __reentrant
_ao_config_edit_finish();
ao_radio_recv_abort();
}
+#endif
#if HAS_FLIGHT
@@ -232,7 +243,7 @@ ao_config_accel_calibrate_auto(char *orientation) __reentrant
{
uint16_t i;
int32_t accel_total;
- uint8_t cal_adc_ring;
+ uint8_t cal_data_ring;
printf("Orient antenna %s and press a key...", orientation);
flush();
@@ -241,12 +252,14 @@ ao_config_accel_calibrate_auto(char *orientation) __reentrant
puts("Calibrating..."); flush();
i = ACCEL_CALIBRATE_SAMPLES;
accel_total = 0;
- cal_adc_ring = ao_sample_adc;
+ cal_data_ring = ao_sample_data;
while (i) {
- ao_sleep(DATA_TO_XDATA(&ao_sample_adc));
- while (i && cal_adc_ring != ao_sample_adc) {
- accel_total += (int32_t) ao_adc_ring[cal_adc_ring].accel;
- cal_adc_ring = ao_adc_ring_next(cal_adc_ring);
+ ao_sleep(DATA_TO_XDATA(&ao_sample_data));
+ while (i && cal_data_ring != ao_sample_data) {
+ int16_t accel = ao_data_accel(&ao_data_ring[cal_data_ring]);
+ printf ("accel %d\n", accel);
+ accel_total += (int32_t) ao_data_accel(&ao_data_ring[cal_data_ring]);
+ cal_data_ring = ao_data_ring_next(cal_data_ring);
i--;
}
}
@@ -320,6 +333,7 @@ ao_config_apogee_lockout_set(void) __reentrant
#endif /* HAS_FLIGHT */
+#if HAS_RADIO
void
ao_config_radio_cal_show(void) __reentrant
{
@@ -337,6 +351,7 @@ ao_config_radio_cal_set(void) __reentrant
ao_config_set_radio();
_ao_config_edit_finish();
}
+#endif
#if HAS_LOG
void
@@ -413,6 +428,7 @@ ao_config_pad_orientation_set(void) __reentrant
}
#endif
+#if HAS_RADIO
void
ao_config_radio_enable_show(void) __reentrant
{
@@ -429,6 +445,7 @@ ao_config_radio_enable_set(void) __reentrant
ao_config.radio_enable = ao_cmd_lex_i;
_ao_config_edit_finish();
}
+#endif /* HAS_RADIO */
#if HAS_AES
void
@@ -481,18 +498,22 @@ __code struct ao_config_var ao_config_vars[] = {
{ "L <seconds>\0Apogee detect lockout (s)",
ao_config_apogee_lockout_set, ao_config_apogee_lockout_show, },
#endif /* HAS_FLIGHT */
+#if HAS_RADIO
{ "F <freq>\0Frequency (kHz)",
ao_config_frequency_set, ao_config_frequency_show },
{ "c <call>\0Callsign (8 char max)",
ao_config_callsign_set, ao_config_callsign_show },
{ "e <0 disable, 1 enable>\0Enable telemetry and RDF",
ao_config_radio_enable_set, ao_config_radio_enable_show },
+#endif /* HAS_RADIO */
#if HAS_ACCEL
{ "a <+g> <-g>\0Accel calib (0 for auto)",
ao_config_accel_calibrate_set,ao_config_accel_calibrate_show },
#endif /* HAS_ACCEL */
+#if HAS_RADIO
{ "f <cal>\0Radio calib (cal = rf/(xtal/2^16))",
ao_config_radio_cal_set, ao_config_radio_cal_show },
+#endif /* HAS_RADIO */
#if HAS_LOG
{ "l <size>\0Flight log size (kB)",
ao_config_log_set, ao_config_log_show },
diff --git a/src/core/ao_kalman.c b/src/core/ao_kalman.c
index ee01949e..68725f69 100644
--- a/src/core/ao_kalman.c
+++ b/src/core/ao_kalman.c
@@ -17,10 +17,13 @@
#ifndef AO_FLIGHT_TEST
#include "ao.h"
+#include "ao_flight.h"
#endif
+#include "ao_sample.h"
#include "ao_kalman.h"
+
static __pdata int32_t ao_k_height;
static __pdata int32_t ao_k_speed;
static __pdata int32_t ao_k_accel;
diff --git a/src/core/ao_log.c b/src/core/ao_log.c
index db60707d..d696625e 100644
--- a/src/core/ao_log.c
+++ b/src/core/ao_log.c
@@ -16,12 +16,13 @@
*/
#include "ao.h"
+#include <ao_log.h>
__pdata uint32_t ao_log_current_pos;
__pdata uint32_t ao_log_end_pos;
__pdata uint32_t ao_log_start_pos;
__xdata uint8_t ao_log_running;
-__pdata enum flight_state ao_log_state;
+__pdata enum ao_flight_state ao_log_state;
__xdata uint16_t ao_flight_number;
__code uint8_t ao_log_format = AO_LOG_FORMAT_FULL;
diff --git a/src/core/ao_log.h b/src/core/ao_log.h
index 611c00d5..e585750f 100644
--- a/src/core/ao_log.h
+++ b/src/core/ao_log.h
@@ -18,6 +18,8 @@
#ifndef _AO_LOG_H_
#define _AO_LOG_H_
+#include <ao_flight.h>
+
/*
* ao_log.c
*/
@@ -32,7 +34,7 @@ extern __pdata uint32_t ao_log_current_pos;
extern __pdata uint32_t ao_log_end_pos;
extern __pdata uint32_t ao_log_start_pos;
extern __xdata uint8_t ao_log_running;
-extern __pdata enum flight_state ao_log_state;
+extern __pdata enum ao_flight_state ao_log_state;
/* required functions from the underlying log system */
@@ -41,6 +43,7 @@ extern __pdata enum flight_state ao_log_state;
#define AO_LOG_FORMAT_TINY 2 /* two byte state/baro records */
#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_MEGAMETRUM 5 /* 32 byte typed megametrum records */
#define AO_LOG_FORMAT_NONE 127 /* No log at all */
extern __code uint8_t ao_log_format;
@@ -189,8 +192,65 @@ struct ao_log_record {
} u;
};
+struct ao_log_mega {
+ char type; /* 0 */
+ uint8_t csum; /* 1 */
+ uint16_t tick; /* 2 */
+ union { /* 4 */
+ struct {
+ uint16_t flight; /* 4 */
+ int16_t ground_accel; /* 6 */
+ uint32_t ground_pres; /* 8 */
+ uint32_t ground_temp; /* 12 */
+ } flight; /* 16 */
+ struct {
+ uint16_t state;
+ uint16_t reason;
+ } state;
+ struct {
+ uint32_t pres; /* 4 */
+ uint32_t temp; /* 8 */
+ int16_t accel_x; /* 12 */
+ int16_t accel_y; /* 14 */
+ int16_t accel_z; /* 16 */
+ int16_t gyro_x; /* 18 */
+ int16_t gyro_y; /* 20 */
+ int16_t gyro_z; /* 22 */
+ } sensor; /* 24 */
+ struct {
+ int16_t v_batt; /* 4 */
+ int16_t v_pbatt; /* 8 */
+ int16_t n_sense; /* 10 */
+ int16_t sense[10]; /* 12 */
+ } volt; /* 32 */
+ struct {
+ int32_t latitude; /* 4 */
+ int32_t longitude; /* 8 */
+ int16_t altitude; /* 12 */
+ uint8_t hour; /* 14 */
+ uint8_t minute; /* 15 */
+ uint8_t second; /* 16 */
+ uint8_t flags; /* 17 */
+ uint8_t year; /* 18 */
+ uint8_t month; /* 19 */
+ uint8_t day; /* 20 */
+ uint8_t pad; /* 21 */
+ } gps; /* 22 */
+ struct {
+ uint16_t channels; /* 4 */
+ struct {
+ uint8_t svid;
+ uint8_t c_n;
+ } sats[12]; /* 6 */
+ } gps_sat; /* 30 */
+ } u;
+};
+
/* Write a record to the eeprom log */
uint8_t
ao_log_data(__xdata struct ao_log_record *log) __reentrant;
+uint8_t
+ao_log_mega(__xdata struct ao_log_mega *log) __reentrant;
+
#endif /* _AO_LOG_H_ */
diff --git a/src/core/ao_sample.h b/src/core/ao_sample.h
index fb0e69e8..189b2019 100644
--- a/src/core/ao_sample.h
+++ b/src/core/ao_sample.h
@@ -18,6 +18,8 @@
#ifndef _AO_SAMPLE_H_
#define _AO_SAMPLE_H_
+#include <ao_data.h>
+
/*
* ao_sample.c
*/
@@ -88,21 +90,22 @@
#define AO_MSS_TO_ACCEL(mss) ((int16_t) ((mss) * 16))
extern __pdata uint16_t ao_sample_tick; /* time of last data */
-extern __pdata int16_t ao_sample_pres; /* most recent pressure sensor reading */
-extern __pdata int16_t ao_sample_alt; /* MSL of ao_sample_pres */
-extern __pdata int16_t ao_sample_height; /* AGL of ao_sample_pres */
+extern __pdata pres_t ao_sample_pres; /* most recent pressure sensor reading */
+extern __pdata alt_t ao_sample_alt; /* MSL of ao_sample_pres */
+extern __pdata alt_t ao_sample_height; /* AGL of ao_sample_pres */
extern __data uint8_t ao_sample_adc; /* Ring position of last processed sample */
+extern __data uint8_t ao_sample_data; /* Ring position of last processed sample */
#if HAS_ACCEL
-extern __pdata int16_t ao_sample_accel; /* most recent accel sensor reading */
+extern __pdata accel_t ao_sample_accel; /* most recent accel sensor reading */
#endif
-extern __pdata int16_t ao_ground_pres; /* startup pressure */
-extern __pdata int16_t ao_ground_height; /* MSL of ao_ground_pres */
+extern __pdata pres_t ao_ground_pres; /* startup pressure */
+extern __pdata alt_t ao_ground_height; /* MSL of ao_ground_pres */
#if HAS_ACCEL
-extern __pdata int16_t ao_ground_accel; /* startup acceleration */
-extern __pdata int16_t ao_accel_2g; /* factory accel calibration */
+extern __pdata accel_t ao_ground_accel; /* startup acceleration */
+extern __pdata accel_t ao_accel_2g; /* factory accel calibration */
extern __pdata int32_t ao_accel_scale; /* sensor to m/s² conversion */
#endif