This should make the board actually work now.
Signed-off-by: Keith Packard <keithp@keithp.com>
#define SPI_SLAVE_PIN_0_3 1
#define SPI_SLAVE_PIN_2_5 0
+
+ #define IS_COMPANION 1
#endif
#ifdef TELEPYRO
#define DISABLE_HELP 1
#define HAS_STORAGE_DEBUG 0
#define IS_COMPANION 1
+ #define HAS_ORIENT 0
#define ao_storage_pos_t uint16_t
#define AVR_VCC_5V 0
#define SPI_SLAVE_PIN_0_3 1
#define SPI_SLAVE_PIN_2_5 0
+
+ #define AO_PYRO_NUM 8
+
+ #define AO_PYRO_PORT_0 B
+ #define AO_PYRO_PIN_0 5
+
+ #define AO_PYRO_PORT_1 B
+ #define AO_PYRO_PIN_1 6
+
+ #define AO_PYRO_PORT_2 B
+ #define AO_PYRO_PIN_2 7
+
+ #define AO_PYRO_PORT_3 C
+ #define AO_PYRO_PIN_3 6
+
+ #define AO_PYRO_PORT_4 C
+ #define AO_PYRO_PIN_4 7
+
+ #define AO_PYRO_PORT_5 D
+ #define AO_PYRO_PIN_5 5
+
+ #define AO_PYRO_PORT_6 D
+ #define AO_PYRO_PIN_6 3
+
+ #define AO_PYRO_PORT_7 D
+ #define AO_PYRO_PIN_7 2
+
#endif
#define AO_M25_SPI_CS_PORT SPI_CS_PORT
#include <ao_sample.h>
#include <ao_flight.h>
+#if IS_COMPANION
+#include <ao_companion.h>
+#define ao_accel ao_companion_command.accel
+#define ao_speed ao_companion_command.speed
+#define ao_height ao_companion_command.height
+#define ao_flight_state ao_companion_command.flight_state
+#define ao_motor_number ao_companion_command.motor_number
+#endif
+
#define ao_lowbit(x) ((x) & (-x))
/*
ao_delay(AO_MS_TO_TICKS(50));
}
+uint8_t ao_pyro_wakeup;
+
static void
ao_pyro(void)
{
ao_sleep(&ao_flight_state);
for (;;) {
- ao_delay(AO_MS_TO_TICKS(100));
+ ao_alarm(AO_MS_TO_TICKS(100));
+ ao_sleep(&ao_pyro_wakeup);
+ ao_clear_alarm();
for (p = 0; p < AO_PYRO_NUM; p++) {
pyro = &ao_config.pyro[p];
uint8_t fired;
};
+extern uint8_t ao_pyro_wakeup;
+
void
ao_pyro_set(void);
#include <ao.h>
#include <ao_product.h>
#include <ao_companion.h>
+#include <ao_flight.h>
+#include <ao_pyro.h>
struct ao_companion_command ao_companion_command;
.channels = AO_TELEPYRO_NUM_ADC,
};
+struct ao_config ao_config;
+
+extern volatile __data uint16_t ao_tick_count;
+uint16_t ao_boost_tick;
+
void ao_spi_slave(void)
{
if (!ao_spi_slave_recv((uint8_t *) &ao_companion_command,
AO_TELEPYRO_NUM_ADC * sizeof (uint16_t));
break;
case AO_COMPANION_NOTIFY:
+ /* Can't use ao_time because we have interrupts suspended */
+ if (ao_companion_command.flight_state < ao_flight_boost && ao_companion_command.flight_state >= ao_flight_boost)
+ ao_boost_tick = ao_tick_count;
+ ao_wakeup(&ao_pyro_wakeup);
break;
default:
return;
ao_spi_slave_init();
ao_usb_init();
ao_adc_init();
+ ao_storage_init();
+ ao_config_init();
+ ao_pyro_init();
ao_start_scheduler();
return 0;
}