summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
5fd869b)
Signed-off-by: Keith Packard <keithp@keithp.com>
-volatile __xdata struct ao_adc ao_adc_ring[AO_ADC_RING];
-volatile __data uint8_t ao_adc_head;
+volatile __xdata struct ao_data ao_data_ring[AO_DATA_RING];
+volatile __data uint8_t ao_data_head;
#ifdef TELESCIENCE
const uint8_t adc_channels[AO_LOG_TELESCIENCE_NUM_ADC] = {
#ifdef TELESCIENCE
const uint8_t adc_channels[AO_LOG_TELESCIENCE_NUM_ADC] = {
/* Must read ADCL first or the value there will be lost */
value = ADCL;
value |= (ADCH << 8);
/* Must read ADCL first or the value there will be lost */
value = ADCL;
value |= (ADCH << 8);
- ao_adc_ring[ao_adc_head].adc[ao_adc_channel] = value;
+ ao_data_ring[ao_data_head].adc.adc[ao_adc_channel] = value;
if (++ao_adc_channel < NUM_ADC)
ao_adc_start();
else {
ADCSRA = ADCSRA_INIT;
if (++ao_adc_channel < NUM_ADC)
ao_adc_start();
else {
ADCSRA = ADCSRA_INIT;
- ao_adc_ring[ao_adc_head].tick = ao_time();
- ao_adc_head = ao_adc_ring_next(ao_adc_head);
- ao_wakeup((void *) &ao_adc_head);
+ ao_data_ring[ao_data_head].tick = ao_time();
+ ao_data_head = ao_data_ring_next(ao_data_head);
+ ao_wakeup((void *) &ao_data_head);
ao_cpu_sleep_disable = 0;
}
}
ao_cpu_sleep_disable = 0;
}
}
-ao_adc_get(__xdata struct ao_adc *packet)
+ao_data_get(__xdata struct ao_data *packet)
- uint8_t i = ao_adc_ring_prev(ao_adc_head);
- memcpy(packet, (void *) &ao_adc_ring[i], sizeof (struct ao_adc));
+ uint8_t i = ao_data_ring_prev(ao_data_head);
+ memcpy(packet, (void *) &ao_data_ring[i], sizeof (struct ao_data));
}
static void
ao_adc_dump(void) __reentrant
{
}
static void
ao_adc_dump(void) __reentrant
{
- static __xdata struct ao_adc packet;
+ static __xdata struct ao_data packet;
#ifdef TELEPYRO
printf("ADMUX: %02x\n", ADMUX);
printf("ADCSRA: %02x\n", ADCSRA);
#ifdef TELEPYRO
printf("ADMUX: %02x\n", ADMUX);
printf("ADCSRA: %02x\n", ADCSRA);
#endif
printf("tick: %5u", packet.tick);
for (i = 0; i < NUM_ADC; i++)
#endif
printf("tick: %5u", packet.tick);
for (i = 0; i < NUM_ADC; i++)
- printf (" %2d: %5u", i, packet.adc[i]);
+ printf (" %2d: %5u", i, packet.adc.adc[i]);
#define AO_TELESCIENCE_NUM_ADC 12
struct ao_adc {
#define AO_TELESCIENCE_NUM_ADC 12
struct ao_adc {
- uint16_t tick; /* tick when the sample was read */
uint16_t adc[AO_TELESCIENCE_NUM_ADC]; /* samples */
};
uint16_t adc[AO_TELESCIENCE_NUM_ADC]; /* samples */
};
#include "ao_log.h"
#include "ao_companion.h"
#include "ao_log.h"
#include "ao_companion.h"
-static uint8_t ao_log_adc_pos;
+static uint8_t ao_log_data_pos;
__code uint8_t ao_log_format = AO_LOG_FORMAT_TELESCIENCE;
__code uint8_t ao_log_format = AO_LOG_FORMAT_TELESCIENCE;
/* Write the whole contents of the ring to the log
* when starting up.
*/
/* Write the whole contents of the ring to the log
* when starting up.
*/
- ao_log_adc_pos = ao_adc_ring_next(ao_adc_head);
+ ao_log_data_pos = ao_data_ring_next(ao_data_head);
ao_log_single_write_data.telescience.type = AO_LOG_TELESCIENCE_DATA;
while (ao_log_running) {
/* Write samples to EEPROM */
ao_log_single_write_data.telescience.type = AO_LOG_TELESCIENCE_DATA;
while (ao_log_running) {
/* Write samples to EEPROM */
- while (ao_log_adc_pos != ao_adc_head) {
- ao_log_single_write_data.telescience.tick = ao_adc_ring[ao_log_adc_pos].tick;
- memcpy(&ao_log_single_write_data.telescience.adc, (void *) ao_adc_ring[ao_log_adc_pos].adc,
+ while (ao_log_data_pos != ao_data_head) {
+ ao_log_single_write_data.telescience.tick = ao_data_ring[ao_log_data_pos].tick;
+ memcpy(&ao_log_single_write_data.telescience.adc, (void *) ao_data_ring[ao_log_data_pos].adc.adc,
AO_LOG_TELESCIENCE_NUM_ADC * sizeof (uint16_t));
ao_log_telescience_csum();
ao_log_single_write();
AO_LOG_TELESCIENCE_NUM_ADC * sizeof (uint16_t));
ao_log_telescience_csum();
ao_log_single_write();
- ao_log_adc_pos = ao_adc_ring_next(ao_log_adc_pos);
+ ao_log_data_pos = ao_data_ring_next(ao_log_data_pos);
}
/* Wait for more ADC data to arrive */
}
/* Wait for more ADC data to arrive */
- ao_sleep((void *) &ao_adc_head);
+ ao_sleep((void *) &ao_data_head);
}
memset(&ao_log_single_write_data.telescience.adc, '\0', sizeof (ao_log_single_write_data.telescience.adc));
}
}
memset(&ao_log_single_write_data.telescience.adc, '\0', sizeof (ao_log_single_write_data.telescience.adc));
}
#endif
#define USE_SERIAL_STDIN (USE_SERIAL_0_STDIN + \
#endif
#define USE_SERIAL_STDIN (USE_SERIAL_0_STDIN + \
- USE_SERIAL_1_STDIN | \
- USE_SERIAL_2_STDIN | \
- USE_SERIAL_3_STDIN | \
- USE_SERIAL_4_STDIN | \
- USE_SERIAL_5_STDIN | \
- USE_SERIAL_6_STDIN | \
- USE_SERIAL_7_STDIN | \
- USE_SERIAL_8_STDIN | \
+ USE_SERIAL_1_STDIN + \
+ USE_SERIAL_2_STDIN + \
+ USE_SERIAL_3_STDIN + \
+ USE_SERIAL_4_STDIN + \
+ USE_SERIAL_5_STDIN + \
+ USE_SERIAL_6_STDIN + \
+ USE_SERIAL_7_STDIN + \
+ USE_SERIAL_8_STDIN + \
USE_SERIAL_9_STDIN)
#define AO_NUM_STDIOS (HAS_USB + PACKET_HAS_SLAVE + USE_SERIAL_STDIN)
USE_SERIAL_9_STDIN)
#define AO_NUM_STDIOS (HAS_USB + PACKET_HAS_SLAVE + USE_SERIAL_STDIN)
sizeof (ao_telescience_setup));
break;
case AO_COMPANION_FETCH:
sizeof (ao_telescience_setup));
break;
case AO_COMPANION_FETCH:
- ao_spi_slave_send((uint8_t *) &ao_adc_ring[ao_adc_ring_prev(ao_adc_head)].adc,
+ ao_spi_slave_send((uint8_t *) &ao_data_ring[ao_data_ring_prev(ao_data_head)].adc,
AO_LOG_TELESCIENCE_NUM_ADC * sizeof (uint16_t));
break;
case AO_COMPANION_NOTIFY:
AO_LOG_TELESCIENCE_NUM_ADC * sizeof (uint16_t));
break;
case AO_COMPANION_NOTIFY:
-ao_flight_test: ao_flight_test.c ao_host.h ao_flight.c ao_sample.c ao_kalman.c altitude.h ao_kalman.h
+ao_flight_test: ao_flight_test.c ao_host.h ao_flight_mm.c ao_sample_mm.c ao_kalman.c altitude.h ao_kalman.h
-ao_flight_test_noisy_accel: ao_flight_test.c ao_host.h ao_flight.c ao_sample.c ao_kalman.c altitude.h ao_kalman.h
+ao_flight_test_noisy_accel: ao_flight_test.c ao_host.h ao_flight_mm.c ao_sample_mm.c ao_kalman.c altitude.h ao_kalman.h
cc -DNOISY_ACCEL=1 $(CFLAGS) -o $@ $<
ao_flight_test_baro: ao_flight_test.c ao_host.h ao_flight.c ao_sample.c ao_kalman.c altitude.h ao_kalman.h
cc -DNOISY_ACCEL=1 $(CFLAGS) -o $@ $<
ao_flight_test_baro: ao_flight_test.c ao_host.h ao_flight.c ao_sample.c ao_kalman.c altitude.h ao_kalman.h
-#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))
* 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 */
#define __code
#define __reentrant
#define __code
#define __reentrant
#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)
#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)
-struct ao_adc ao_adc_static;
+struct ao_data ao_data_static;
int drogue_height;
double drogue_time;
int drogue_height;
double drogue_time;
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;
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)
- 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_static.pres_real) - ao_ground_height;
- double accel = ((ao_flight_ground_accel - ao_adc_static.accel) * GRAVITY * 2.0) /
+ double height = ao_pres_to_altitude(ao_data_static.adc.pres_real) - ao_ground_height;
+ double accel = ((ao_flight_ground_accel - ao_data_static.adc.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)
- 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;
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;
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_static.accel = ao_flight_ground_accel;
+ ao_data_static.adc.accel = ao_flight_ground_accel;
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;
case 'S':
break;
case 'A':
case 'S':
break;
case 'A':
- ao_adc_static.tick = tick;
- ao_adc_static.accel = a;
- ao_adc_static.pres_real = b;
+ ao_data_static.tick = tick;
+ ao_data_static.adc.accel = a;
+ ao_data_static.adc.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_static.pres = b;
+ ao_data_static.adc.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_static.temp = a;
- ao_adc_static.v_batt = b;
+ ao_data_static.tick = tick;
+ ao_data_static.adc.temp = a;
+ ao_data_static.adc.v_batt = b;
break;
case 'D':
case 'G':
break;
case 'D':
case 'G':