projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos: rename ao_viterbi.c to ao_fec_rx.c
[fw/altos]
/
src
/
test
/
ao_flight_test.c
diff --git
a/src/test/ao_flight_test.c
b/src/test/ao_flight_test.c
index 921d44e7264566eb1bc22d2d3128c228be23973e..baf2ad1dcea2f2dd3f5b4368a29fd5ffba427c0c 100644
(file)
--- a/
src/test/ao_flight_test.c
+++ b/
src/test/ao_flight_test.c
@@
-26,9
+26,10
@@
#define AO_HERTZ 100
#define AO_HERTZ 100
-#define AO_ADC_RING 64
-#define ao_adc_ring_next(n) (((n) + 1) & (AO_ADC_RING - 1))
-#define ao_adc_ring_prev(n) (((n) - 1) & (AO_ADC_RING - 1))
+#define HAS_ADC 1
+#define AO_DATA_RING 64
+#define ao_data_ring_next(n) (((n) + 1) & (AO_DATA_RING - 1))
+#define ao_data_ring_prev(n) (((n) - 1) & (AO_DATA_RING - 1))
#define AO_M_TO_HEIGHT(m) ((int16_t) (m))
#define AO_MS_TO_SPEED(ms) ((int16_t) ((ms) * 16))
#define AO_M_TO_HEIGHT(m) ((int16_t) (m))
#define AO_MS_TO_SPEED(ms) ((int16_t) ((ms) * 16))
@@
-38,7
+39,6
@@
* One set of samples read from the A/D converter
*/
struct ao_adc {
* One set of samples read from the A/D converter
*/
struct ao_adc {
- uint16_t tick; /* tick when the sample was read */
int16_t accel; /* accelerometer */
int16_t pres; /* pressure sensor */
int16_t pres_real; /* unclipped */
int16_t accel; /* accelerometer */
int16_t pres; /* pressure sensor */
int16_t pres_real; /* unclipped */
@@
-54,6
+54,8
@@
struct ao_adc {
#define __code
#define __reentrant
#define __code
#define __reentrant
+#include <ao_data.h>
+
#define to_fix16(x) ((int16_t) ((x) * 65536.0 + 0.5))
#define to_fix32(x) ((int32_t) ((x) * 65536.0 + 0.5))
#define from_fix(x) ((x) >> 16)
#define to_fix16(x) ((int16_t) ((x) * 65536.0 + 0.5))
#define to_fix32(x) ((int32_t) ((x) * 65536.0 + 0.5))
#define from_fix(x) ((x) >> 16)
@@
-90,8
+92,8
@@
extern enum ao_flight_state ao_flight_state;
#define FALSE 0
#define TRUE 1
#define FALSE 0
#define TRUE 1
-
struct ao_adc ao_adc_ring[AO_ADC
_RING];
-
uint8_t ao_adc
_head;
+
volatile struct ao_data ao_data_ring[AO_DATA
_RING];
+
volatile uint8_t ao_data
_head;
int ao_summary = 0;
#define ao_led_on(l)
int ao_summary = 0;
#define ao_led_on(l)
@@
-110,7
+112,7
@@
enum ao_igniter {
ao_igniter_main = 1
};
ao_igniter_main = 1
};
-struct ao_
adc ao_adc
_static;
+struct ao_
data ao_data
_static;
int drogue_height;
double drogue_time;
int drogue_height;
double drogue_time;
@@
-124,7
+126,7
@@
static int32_t ao_k_height;
void
ao_ignite(enum ao_igniter igniter)
{
void
ao_ignite(enum ao_igniter igniter)
{
- double time = (double) (ao_
adc
_static.tick + tick_offset) / 100;
+ double time = (double) (ao_
data
_static.tick + tick_offset) / 100;
if (igniter == ao_igniter_drogue) {
drogue_time = time;
if (igniter == ao_igniter_drogue) {
drogue_time = time;
@@
-184,6
+186,7
@@
struct ao_config {
int16_t accel_plus_g;
int16_t accel_minus_g;
uint8_t pad_orientation;
int16_t accel_plus_g;
int16_t accel_minus_g;
uint8_t pad_orientation;
+ uint16_t apogee_lockout;
};
#define AO_PAD_ORIENTATION_ANTENNA_UP 0
};
#define AO_PAD_ORIENTATION_ANTENNA_UP 0
@@
-220,8
+223,8
@@
int ao_sample_prev_tick;
uint16_t prev_tick;
#include "ao_kalman.c"
uint16_t prev_tick;
#include "ao_kalman.c"
-#include "ao_sample.c"
-#include "ao_flight.c"
+#include "ao_sample
_mm
.c"
+#include "ao_flight
_mm
.c"
#define to_double(f) ((f) / 65536.0)
#define to_double(f) ((f) / 65536.0)
@@
-281,19
+284,19
@@
ao_insert(void)
{
double time;
{
double time;
- ao_
adc_ring[ao_adc_head] = ao_adc
_static;
- ao_
adc_head = ao_adc_ring_next(ao_adc
_head);
+ ao_
data_ring[ao_data_head] = ao_data
_static;
+ ao_
data_head = ao_data_ring_next(ao_data
_head);
if (ao_flight_state != ao_flight_startup) {
if (ao_flight_state != ao_flight_startup) {
- double height = ao_pres_to_altitude(ao_
adc_stati
c.pres_real) - ao_ground_height;
- double accel = ((ao_flight_ground_accel - ao_
adc_stati
c.accel) * GRAVITY * 2.0) /
+ double height = ao_pres_to_altitude(ao_
data_static.ad
c.pres_real) - ao_ground_height;
+ double accel = ((ao_flight_ground_accel - ao_
data_static.ad
c.accel) * GRAVITY * 2.0) /
(ao_config.accel_minus_g - ao_config.accel_plus_g);
if (!tick_offset)
(ao_config.accel_minus_g - ao_config.accel_plus_g);
if (!tick_offset)
- tick_offset = -ao_
adc
_static.tick;
- if ((prev_tick - ao_
adc
_static.tick) > 0x400)
+ tick_offset = -ao_
data
_static.tick;
+ if ((prev_tick - ao_
data
_static.tick) > 0x400)
tick_offset += 65536;
tick_offset += 65536;
- prev_tick = ao_
adc
_static.tick;
- time = (double) (ao_
adc
_static.tick + tick_offset) / 100;
+ prev_tick = ao_
data
_static.tick;
+ time = (double) (ao_
data
_static.tick + tick_offset) / 100;
if (ao_test_max_height < height) {
ao_test_max_height = height;
if (ao_test_max_height < height) {
ao_test_max_height = height;
@@
-473,7
+476,7
@@
int16(uint8_t *bytes, int off)
void
ao_sleep(void *wchan)
{
void
ao_sleep(void *wchan)
{
- if (wchan == &ao_
adc
_head) {
+ if (wchan == &ao_
data
_head) {
char type;
uint16_t tick;
uint16_t a, b;
char type;
uint16_t tick;
uint16_t a, b;
@@
-489,7
+492,7
@@
ao_sleep(void *wchan)
for (;;) {
if (ao_records_read > 2 && ao_flight_state == ao_flight_startup)
{
for (;;) {
if (ao_records_read > 2 && ao_flight_state == ao_flight_startup)
{
- ao_
adc_stati
c.accel = ao_flight_ground_accel;
+ ao_
data_static.ad
c.accel = ao_flight_ground_accel;
ao_insert();
return;
}
ao_insert();
return;
}
@@
-500,7
+503,7
@@
ao_sleep(void *wchan)
printf ("no more data, exiting simulation\n");
ao_test_exit();
}
printf ("no more data, exiting simulation\n");
ao_test_exit();
}
- ao_
adc
_static.tick += 10;
+ ao_
data
_static.tick += 10;
ao_insert();
return;
}
ao_insert();
return;
}
@@
-523,6
+526,9
@@
ao_sleep(void *wchan)
ao_config.accel_minus_g = atoi(words[5]);
} else if (nword >= 4 && strcmp(words[0], "Main") == 0) {
ao_config.main_deploy = atoi(words[2]);
ao_config.accel_minus_g = atoi(words[5]);
} else if (nword >= 4 && strcmp(words[0], "Main") == 0) {
ao_config.main_deploy = atoi(words[2]);
+ } else if (nword >= 3 && strcmp(words[0], "Apogee") == 0 &&
+ strcmp(words[1], "lockout:") == 0) {
+ ao_config.apogee_lockout = atoi(words[2]);
} else if (nword >= 36 && strcmp(words[0], "CALL") == 0) {
tick = atoi(words[10]);
if (!ao_flight_started) {
} else if (nword >= 36 && strcmp(words[0], "CALL") == 0) {
tick = atoi(words[10]);
if (!ao_flight_started) {
@@
-635,19
+641,19
@@
ao_sleep(void *wchan)
case 'S':
break;
case 'A':
case 'S':
break;
case 'A':
- ao_
adc
_static.tick = tick;
- ao_
adc_stati
c.accel = a;
- ao_
adc_stati
c.pres_real = b;
+ ao_
data
_static.tick = tick;
+ ao_
data_static.ad
c.accel = a;
+ ao_
data_static.ad
c.pres_real = b;
if (b < AO_MIN_BARO_VALUE)
b = AO_MIN_BARO_VALUE;
if (b < AO_MIN_BARO_VALUE)
b = AO_MIN_BARO_VALUE;
- ao_
adc_stati
c.pres = b;
+ ao_
data_static.ad
c.pres = b;
ao_records_read++;
ao_insert();
return;
case 'T':
ao_records_read++;
ao_insert();
return;
case 'T':
- ao_
adc
_static.tick = tick;
- ao_
adc_stati
c.temp = a;
- ao_
adc_stati
c.v_batt = b;
+ ao_
data
_static.tick = tick;
+ ao_
data_static.ad
c.temp = a;
+ ao_
data_static.ad
c.v_batt = b;
break;
case 'D':
case 'G':
break;
case 'D':
case 'G':