void
ao_alarm(uint16_t delay);
+/* Clear any pending alarm */
+void
+ao_clear_alarm(void);
+
/* Yield the processor to another task */
void
ao_yield(void) ao_arch_naked_declare;
void
ao_cmd_white(void);
+int8_t
+ao_cmd_hexchar(char c);
+
+void
+ao_cmd_hexbyte(void);
+
void
ao_cmd_hex(void);
extern __xdata uint8_t ao_log_running;
extern __pdata enum flight_state ao_log_state;
-#define AO_LOG_TELESCIENCE_START ((uint8_t) 's')
-#define AO_LOG_TELESCIENCE_DATA ((uint8_t) 'd')
-
-#define AO_LOG_TELESCIENCE_NUM_ADC 12
-
-struct ao_log_telescience {
- uint8_t type;
- uint8_t csum;
- uint16_t tick;
- uint16_t tm_tick;
- uint8_t tm_state;
- uint8_t unused;
- uint16_t adc[AO_LOG_TELESCIENCE_NUM_ADC];
-};
-
-extern struct ao_log_telescience ao_log_store;
-
/* required functions from the underlying log system */
#define AO_LOG_FORMAT_UNKNOWN 0 /* unknown; altosui will have to guess */
extern const char const * const ao_state_names[];
+#define AO_MONITOR_RING 8
+
+union ao_monitor {
+ struct ao_telemetry_raw_recv raw;
+ struct ao_telemetry_orig_recv orig;
+ struct ao_telemetry_tiny_recv tiny;
+};
+
+extern __xdata union ao_monitor ao_monitor_ring[AO_MONITOR_RING];
+
+#define ao_monitor_ring_next(n) (((n) + 1) & (AO_MONITOR_RING - 1))
+
+extern __data uint8_t ao_monitor_head;
+
void
ao_monitor(void);
ao_igniter_open, /* open circuit detected */
};
+struct ao_ignition {
+ uint8_t request;
+ uint8_t fired;
+ uint8_t firing;
+};
+
+extern __xdata struct ao_ignition ao_ignition[2];
+
enum ao_igniter_status
ao_igniter_status(enum ao_igniter igniter);
*/
#define AO_CONFIG_MAJOR 1
-#define AO_CONFIG_MINOR 8
+#define AO_CONFIG_MINOR 9
+#define AO_AES_LEN 16
struct ao_config {
uint8_t major;
uint8_t pad_orientation; /* minor version 6 */
uint32_t radio_setting; /* minor version 7 */
uint8_t radio_enable; /* minor version 8 */
+ uint8_t aes_key[AO_AES_LEN]; /* minor version 9 */
};
#define AO_IGNITE_MODE_DUAL 0
__xdata uint8_t ao_aes_mutex;
+/* AES keys and blocks are 128 bits */
+
enum ao_aes_mode {
ao_aes_mode_cbc_mac
};
void
ao_aes_set_key(__xdata uint8_t *in);
+void
+ao_aes_zero_iv(void);
+
void
ao_aes_run(__xdata uint8_t *in,
__xdata uint8_t *out);
void
ao_aes_init(void);
+/* ao_radio_cmac.c */
+
+int8_t
+ao_radio_cmac_send(__xdata void *packet, uint8_t len) __reentrant;
+
+#define AO_RADIO_CMAC_OK 0
+#define AO_RADIO_CMAC_LEN_ERROR -1
+#define AO_RADIO_CMAC_CRC_ERROR -2
+#define AO_RADIO_CMAC_MAC_ERROR -3
+#define AO_RADIO_CMAC_TIMEOUT -4
+
+int8_t
+ao_radio_cmac_recv(__xdata void *packet, uint8_t len, uint16_t timeout) __reentrant;
+
+void
+ao_radio_cmac_init(void);
+
+/* ao_launch.c */
+
+struct ao_launch_command {
+ uint16_t tick;
+ uint16_t serial;
+ uint8_t cmd;
+ uint8_t channel;
+ uint16_t unused;
+};
+
+#define AO_LAUNCH_QUERY 1
+
+struct ao_launch_query {
+ uint16_t tick;
+ uint16_t serial;
+ uint8_t channel;
+ uint8_t valid;
+ uint8_t arm_status;
+ uint8_t igniter_status;
+};
+
+#define AO_LAUNCH_ARM 2
+#define AO_LAUNCH_FIRE 3
+
+void
+ao_launch_init(void);
+
+/*
+ * ao_log_single.c
+ */
+
+#define AO_LOG_TELESCIENCE_START ((uint8_t) 's')
+#define AO_LOG_TELESCIENCE_DATA ((uint8_t) 'd')
+
+#define AO_LOG_TELESCIENCE_NUM_ADC 12
+
+struct ao_log_telescience {
+ uint8_t type;
+ uint8_t csum;
+ uint16_t tick;
+ uint16_t tm_tick;
+ uint8_t tm_state;
+ uint8_t unused;
+ uint16_t adc[AO_LOG_TELESCIENCE_NUM_ADC];
+};
+
+#define AO_LOG_SINGLE_SIZE 32
+
+union ao_log_single {
+ struct ao_log_telescience telescience;
+ union ao_telemetry_all telemetry;
+ uint8_t bytes[AO_LOG_SINGLE_SIZE];
+};
+
+extern __xdata union ao_log_single ao_log_single_write_data;
+extern __xdata union ao_log_single ao_log_single_read_data;
+
+void
+ao_log_single_extra_query(void);
+
+void
+ao_log_single_list(void);
+
+void
+ao_log_single_main(void);
+
+uint8_t
+ao_log_single_write(void);
+
+uint8_t
+ao_log_single_read(uint32_t pos);
+
+void
+ao_log_single_start(void);
+
+void
+ao_log_single_stop(void);
+
+void
+ao_log_single_restart(void);
+
+void
+ao_log_single_set(void);
+
+void
+ao_log_single_delete(void);
+
+void
+ao_log_single_init(void);
+
+void
+ao_log_single(void);
+
#endif /* _AO_H_ */