summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2013-04-22 17:20:51 -0500
committerKeith Packard <keithp@keithp.com>2013-04-22 17:20:51 -0500
commit33c3b2c57d0d4285b75d4dcf7ca67ad19da08c86 (patch)
treea9ff47afab29fe141dcd1da0ca276b367f911cb6 /src/core
parent1a84db819a359be39be51c9105039ab28c9fc894 (diff)
parent90b0db1ae53182c94bf12d661446fc369d916366 (diff)
Merge branch 'master' into stm-flash
Conflicts: ao-tools/ao-stmload/ao-stmload.c
Diffstat (limited to 'src/core')
-rw-r--r--src/core/ao.h43
-rw-r--r--src/core/ao_config.c63
-rw-r--r--src/core/ao_fec_rx.c2
-rw-r--r--src/core/ao_gps_report_mega.c1
-rw-r--r--src/core/ao_log.h5
-rw-r--r--src/core/ao_log_mega.c4
-rw-r--r--src/core/ao_telemetry.c5
7 files changed, 116 insertions, 7 deletions
diff --git a/src/core/ao.h b/src/core/ao.h
index 7ff49dd5..548e8738 100644
--- a/src/core/ao.h
+++ b/src/core/ao.h
@@ -65,6 +65,7 @@
#define AO_PANIC_STACK 12 /* Stack overflow */
#define AO_PANIC_SPI 13 /* SPI communication failure */
#define AO_PANIC_CRASH 14 /* Processor crashed */
+#define AO_PANIC_BUFIO 15 /* Mis-using bufio API */
#define AO_PANIC_SELF_TEST_CC1120 0x40 | 1 /* Self test failure */
#define AO_PANIC_SELF_TEST_HMC5883 0x40 | 2 /* Self test failure */
#define AO_PANIC_SELF_TEST_MPU6000 0x40 | 3 /* Self test failure */
@@ -93,7 +94,7 @@ extern volatile __data AO_TICK_TYPE ao_tick_count;
#define AO_SEC_TO_TICKS(s) ((s) * AO_HERTZ)
/* Returns the current time in ticks */
-uint16_t
+AO_TICK_TYPE
ao_time(void);
/* Suspend the current task until ticks time has passed */
@@ -517,17 +518,28 @@ extern __xdata uint8_t ao_radio_dma;
#define AO_RADIO_STATUS_CRC_OK AO_FEC_DECODE_CRC_OK
#endif
+#ifndef HAS_RADIO_RECV
+#define HAS_RADIO_RECV HAS_RADIO
+#endif
+#ifndef HAS_RADIO_XMIT
+#define HAS_RADIO_XMIT HAS_RADIO
+#endif
+
void
ao_radio_general_isr(void) ao_arch_interrupt(16);
+#if HAS_RADIO_XMIT
void
ao_radio_send(const __xdata void *d, uint8_t size) __reentrant;
+#endif
+#if HAS_RADIO_RECV
uint8_t
ao_radio_recv(__xdata void *d, uint8_t size) __reentrant;
void
ao_radio_recv_abort(void);
+#endif
void
ao_radio_test(uint8_t on);
@@ -535,7 +547,26 @@ ao_radio_test(uint8_t on);
typedef int16_t (*ao_radio_fill_func)(uint8_t *buffer, int16_t len);
void
-ao_radio_send_lots(ao_radio_fill_func fill);
+ao_radio_send_aprs(ao_radio_fill_func fill);
+
+/*
+ * ao_radio_pa
+ */
+
+#if HAS_RADIO_AMP
+void
+ao_radio_pa_on(void);
+
+void
+ao_radio_pa_off(void);
+
+void
+ao_radio_pa_init(void);
+#else
+#define ao_radio_pa_on()
+#define ao_radio_pa_off()
+#define ao_radio_pa_init()
+#endif
/*
* Compute the packet length as follows:
@@ -687,7 +718,7 @@ extern __xdata uint8_t ao_force_freq;
#endif
#define AO_CONFIG_MAJOR 1
-#define AO_CONFIG_MINOR 13
+#define AO_CONFIG_MINOR 14
#define AO_AES_LEN 16
@@ -715,6 +746,12 @@ struct ao_config {
struct ao_pyro pyro[AO_PYRO_NUM]; /* minor version 12 */
#endif
uint16_t aprs_interval; /* minor version 13 */
+#if HAS_RADIO_POWER
+ uint8_t radio_power; /* minor version 14 */
+#endif
+#if HAS_RADIO_AMP
+ uint8_t radio_amp; /* minor version 14 */
+#endif
};
#define AO_IGNITE_MODE_DUAL 0
diff --git a/src/core/ao_config.c b/src/core/ao_config.c
index 0aac16a6..73608a55 100644
--- a/src/core/ao_config.c
+++ b/src/core/ao_config.c
@@ -47,6 +47,8 @@ __xdata uint8_t ao_config_mutex;
#define AO_CONFIG_DEFAULT_FLIGHT_LOG_MAX ((uint32_t) 192 * (uint32_t) 1024)
#endif
#endif
+#define AO_CONFIG_DEFAULT_RADIO_POWER 0x60
+#define AO_CONFIG_DEFAULT_RADIO_AMP 0
#if HAS_EEPROM
static void
@@ -141,6 +143,14 @@ _ao_config_get(void)
#endif
if (minor < 13)
ao_config.aprs_interval = 0;
+#if HAS_RADIO_POWER
+ if (minor < 14)
+ ao_config.radio_power = AO_CONFIG_DEFAULT_RADIO_POWER;
+ #endif
+#if HAS_RADIO_AMP
+ if (minor < 14)
+ ao_config.radio_amp = AO_CONFIG_DEFAULT_RADIO_AMP;
+#endif
ao_config.minor = AO_CONFIG_MINOR;
ao_config_dirty = 1;
}
@@ -210,6 +220,7 @@ ao_config_callsign_set(void) __reentrant
}
#if HAS_RADIO
+
void
ao_config_frequency_show(void) __reentrant
{
@@ -227,7 +238,9 @@ ao_config_frequency_set(void) __reentrant
ao_config.frequency = ao_cmd_lex_u32;
ao_config_set_radio();
_ao_config_edit_finish();
+#if HAS_RADIO_RECV
ao_radio_recv_abort();
+#endif
}
#endif
@@ -521,6 +534,48 @@ ao_config_aprs_set(void)
#endif /* HAS_APRS */
+#if HAS_RADIO_AMP
+
+void
+ao_config_radio_amp_show(void)
+{
+ printf ("Radio amp setting: %d\n", ao_config.radio_amp);
+}
+
+void
+ao_config_radio_amp_set(void)
+{
+ ao_cmd_decimal();
+ if (ao_cmd_status != ao_cmd_success)
+ return;
+ _ao_config_edit_start();
+ ao_config.radio_amp = ao_cmd_lex_i;
+ _ao_config_edit_finish();
+}
+
+#endif
+
+#if HAS_RADIO_POWER
+
+void
+ao_config_radio_power_show(void)
+{
+ printf ("Radio power setting: %d\n", ao_config.radio_power);
+}
+
+void
+ao_config_radio_power_set(void)
+{
+ ao_cmd_decimal();
+ if (ao_cmd_status != ao_cmd_success)
+ return;
+ _ao_config_edit_start();
+ ao_config.radio_power = ao_cmd_lex_i;
+ _ao_config_edit_finish();
+}
+
+#endif
+
struct ao_config_var {
__code char *str;
void (*set)(void) __reentrant;
@@ -554,6 +609,14 @@ __code struct ao_config_var ao_config_vars[] = {
ao_config_radio_enable_set, ao_config_radio_enable_show },
{ "f <cal>\0Radio calib (cal = rf/(xtal/2^16))",
ao_config_radio_cal_set, ao_config_radio_cal_show },
+#if HAS_RADIO_POWER
+ { "p <setting>\0Radio power setting (0-255)",
+ ao_config_radio_power_set, ao_config_radio_power_show },
+#endif
+#if HAS_RADIO_AMP
+ { "d <setting>\0Radio amplifier setting (0-3)",
+ ao_config_radio_amp_set, ao_config_radio_amp_show },
+#endif
#endif /* HAS_RADIO */
#if HAS_ACCEL
{ "a <+g> <-g>\0Accel calib (0 for auto)",
diff --git a/src/core/ao_fec_rx.c b/src/core/ao_fec_rx.c
index 072a9e90..c4f5559a 100644
--- a/src/core/ao_fec_rx.c
+++ b/src/core/ao_fec_rx.c
@@ -18,7 +18,7 @@
#include <ao_fec.h>
#include <stdio.h>
-#ifdef MEGAMETRUM
+#ifdef TELEMEGA
#include <ao.h>
#endif
diff --git a/src/core/ao_gps_report_mega.c b/src/core/ao_gps_report_mega.c
index 47891cab..e3af4307 100644
--- a/src/core/ao_gps_report_mega.c
+++ b/src/core/ao_gps_report_mega.c
@@ -16,6 +16,7 @@
*/
#include "ao.h"
+#include "ao_log.h"
void
ao_gps_report_mega(void)
diff --git a/src/core/ao_log.h b/src/core/ao_log.h
index 036d6f2d..a68a40dd 100644
--- a/src/core/ao_log.h
+++ b/src/core/ao_log.h
@@ -43,7 +43,7 @@ extern __pdata enum ao_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_TELEMEGA 5 /* 32 byte typed telemega records */
#define AO_LOG_FORMAT_NONE 127 /* No log at all */
extern __code uint8_t ao_log_format;
@@ -268,4 +268,7 @@ ao_log_data(__xdata struct ao_log_record *log) __reentrant;
uint8_t
ao_log_mega(__xdata struct ao_log_mega *log) __reentrant;
+void
+ao_log_flush(void);
+
#endif /* _AO_LOG_H_ */
diff --git a/src/core/ao_log_mega.c b/src/core/ao_log_mega.c
index e03687ad..abf953a6 100644
--- a/src/core/ao_log_mega.c
+++ b/src/core/ao_log_mega.c
@@ -23,7 +23,7 @@
static __xdata uint8_t ao_log_mutex;
static __xdata struct ao_log_mega log;
-__code uint8_t ao_log_format = AO_LOG_FORMAT_MEGAMETRUM;
+__code uint8_t ao_log_format = AO_LOG_FORMAT_TELEMEGA;
static uint8_t
ao_log_csum(__xdata uint8_t *b) __reentrant
@@ -171,6 +171,8 @@ ao_log(void)
}
#endif
+ ao_log_flush();
+
/* Wait for a while */
ao_delay(AO_MS_TO_TICKS(100));
diff --git a/src/core/ao_telemetry.c b/src/core/ao_telemetry.c
index 8d440e15..03aa48d8 100644
--- a/src/core/ao_telemetry.c
+++ b/src/core/ao_telemetry.c
@@ -16,6 +16,7 @@
*/
#include "ao.h"
+#include "ao_log.h"
#include "ao_product.h"
static __pdata uint16_t ao_telemetry_interval;
@@ -28,7 +29,7 @@ static __pdata uint16_t ao_aprs_time;
#include <ao_aprs.h>
#endif
-#if defined(MEGAMETRUM)
+#if defined(TELEMEGA)
#define AO_SEND_MEGA 1
#endif
@@ -306,12 +307,14 @@ ao_telemetry(void)
#ifdef AO_SEND_ALL_BARO
ao_send_baro();
#endif
+#if HAS_FLIGHT
#ifdef AO_SEND_MEGA
ao_send_mega_sensor();
ao_send_mega_data();
#else
ao_send_sensor();
#endif
+#endif
#if HAS_COMPANION
if (ao_companion_running)