#define ao_fifo_full(f) ((((f).insert + 1) & (AO_FIFO_SIZE-1)) == (f).remove)
#define ao_fifo_empty(f) ((f).insert == (f).remove)
-/*
- * ao_packet.c
- *
- * Packet-based command interface
- */
-
-#define AO_PACKET_MAX 64
-#define AO_PACKET_SYN (uint8_t) 0xff
-
-struct ao_packet {
- uint8_t addr;
- uint8_t len;
- uint8_t seq;
- uint8_t ack;
- uint8_t d[AO_PACKET_MAX];
- uint8_t callsign[AO_MAX_CALLSIGN];
-};
-
-struct ao_packet_recv {
- struct ao_packet packet;
- int8_t rssi;
- uint8_t status;
-};
-
-extern __xdata struct ao_packet_recv ao_rx_packet;
-extern __xdata struct ao_packet ao_tx_packet;
-extern __xdata struct ao_task ao_packet_task;
-extern __xdata uint8_t ao_packet_enable;
-extern __xdata uint8_t ao_packet_master_sleeping;
-extern __pdata uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used;
-
-void
-ao_packet_send(void);
-
-uint8_t
-ao_packet_recv(void);
-
-void
-ao_packet_flush(void);
-
-void
-ao_packet_putchar(char c) __reentrant;
-
-char
-ao_packet_pollchar(void) __critical;
-
-/* ao_packet_master.c */
-
-void
-ao_packet_master_init(void);
-
-/* ao_packet_slave.c */
-
-void
-ao_packet_slave_start(void);
-
-void
-ao_packet_slave_stop(void);
-
-void
-ao_packet_slave_init(uint8_t enable);
-
-/* ao_btm.c */
-
-/* If bt_link is on P2, this interrupt is shared by USB, so the USB
- * code calls this function. Otherwise, it's a regular ISR.
- */
-
-void
-ao_btm_isr(void)
-#if BT_LINK_ON_P1
- __interrupt 15
+#if PACKET_HAS_MASTER || PACKET_HAS_SLAVE
+#include <ao_packet.h>
#endif
- ;
-
-void
-ao_btm_init(void);
-
-/* ao_companion.c */
-
-#define AO_COMPANION_SETUP 1
-#define AO_COMPANION_FETCH 2
-#define AO_COMPANION_NOTIFY 3
-
-struct ao_companion_command {
- uint8_t command;
- uint8_t flight_state;
- uint16_t tick;
- uint16_t serial;
- uint16_t flight;
-};
-
-struct ao_companion_setup {
- uint16_t board_id;
- uint16_t board_id_inverse;
- uint8_t update_period;
- uint8_t channels;
-};
-
-extern __pdata uint8_t ao_companion_running;
-extern __xdata uint8_t ao_companion_mutex;
-extern __xdata struct ao_companion_command ao_companion_command;
-extern __xdata struct ao_companion_setup ao_companion_setup;
-extern __xdata uint16_t ao_companion_data[AO_COMPANION_MAX_CHANNELS];
-
-void
-ao_companion_init(void);
-
-/* ao_lcd.c */
-
-void
-ao_lcd_putchar(uint8_t d);
-
-void
-ao_lcd_putstring(char *string);
-
-void
-ao_lcd_contrast_set(uint8_t contrast);
-
-void
-ao_lcd_clear(void);
-
-void
-ao_lcd_cursor_on(void);
-
-void
-ao_lcd_cursor_off(void);
-
-#define AO_LCD_ADDR(row,col) ((row << 6) | (col))
-
-void
-ao_lcd_goto(uint8_t addr);
-
-void
-ao_lcd_start(void);
-
-void
-ao_lcd_init(void);
-
-/* ao_lcd_port.c */
-
-void
-ao_lcd_port_put_nibble(uint8_t rs, uint8_t d);
-
-void
-ao_lcd_port_init(void);
-
-/* ao_aes.c */
-extern __xdata uint8_t ao_aes_mutex;
+#if HAS_BTM
+#include <ao_btm.h>
+#endif
-/* AES keys and blocks are 128 bits */
+#if HAS_COMPANION
+#include <ao_companion.h>
+#endif
-enum ao_aes_mode {
- ao_aes_mode_cbc_mac
-};
+#if HAS_LCD
+#include <ao_lcd.h>
+#endif
#if HAS_AES
-void
-ao_aes_isr(void) __interrupt 4;
+#include <ao_aes.h>
#endif
-void
-ao_aes_set_mode(enum ao_aes_mode mode);
-
-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 {
--- /dev/null
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef _AO_AES_H_
+#define _AO_AES_H_
+
+/* ao_aes.c */
+
+extern __xdata uint8_t ao_aes_mutex;
+
+/* AES keys and blocks are 128 bits */
+
+enum ao_aes_mode {
+ ao_aes_mode_cbc_mac
+};
+
+#if HAS_AES
+void
+ao_aes_isr(void) __interrupt 4;
+#endif
+
+void
+ao_aes_set_mode(enum ao_aes_mode mode);
+
+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);
+
+#endif /* _AO_AES_H_ */
--- /dev/null
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef _AO_BTM_H_
+#define _AO_BTM_H_
+
+/* ao_btm.c */
+
+/* If bt_link is on P2, this interrupt is shared by USB, so the USB
+ * code calls this function. Otherwise, it's a regular ISR.
+ */
+
+void
+ao_btm_isr(void)
+#if BT_LINK_ON_P1
+ __interrupt 15
+#endif
+ ;
+void
+ao_btm_init(void);
+
+#endif /* _AO_BTM_H_ */
--- /dev/null
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef _AO_COMPANION_H_
+#define _AO_COMPANION_H_
+
+/* ao_companion.c */
+
+#define AO_COMPANION_SETUP 1
+#define AO_COMPANION_FETCH 2
+#define AO_COMPANION_NOTIFY 3
+
+struct ao_companion_command {
+ uint8_t command;
+ uint8_t flight_state;
+ uint16_t tick;
+ uint16_t serial;
+ uint16_t flight;
+};
+
+struct ao_companion_setup {
+ uint16_t board_id;
+ uint16_t board_id_inverse;
+ uint8_t update_period;
+ uint8_t channels;
+};
+
+extern __pdata uint8_t ao_companion_running;
+extern __xdata uint8_t ao_companion_mutex;
+extern __xdata struct ao_companion_command ao_companion_command;
+extern __xdata struct ao_companion_setup ao_companion_setup;
+extern __xdata uint16_t ao_companion_data[AO_COMPANION_MAX_CHANNELS];
+
+void
+ao_companion_init(void);
+
+#endif /* _AO_COMPANION_H_ */
--- /dev/null
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef _AO_LCD_H_
+#define _AO_LCD_H_
+
+/* ao_lcd.c */
+
+void
+ao_lcd_putchar(uint8_t d);
+
+void
+ao_lcd_putstring(char *string);
+
+void
+ao_lcd_contrast_set(uint8_t contrast);
+
+void
+ao_lcd_clear(void);
+
+void
+ao_lcd_cursor_on(void);
+
+void
+ao_lcd_cursor_off(void);
+
+#define AO_LCD_ADDR(row,col) ((row << 6) | (col))
+
+void
+ao_lcd_goto(uint8_t addr);
+
+void
+ao_lcd_start(void);
+
+void
+ao_lcd_init(void);
+
+/* ao_lcd_port.c */
+
+void
+ao_lcd_port_put_nibble(uint8_t rs, uint8_t d);
+
+void
+ao_lcd_port_init(void);
+
+#endif /* _AO_LCD_H_ */
#include "ao.h"
#include "ao_product.h"
+#include "ao_log.h"
+#include "ao_companion.h"
static uint8_t ao_log_adc_pos;
--- /dev/null
+/*
+ * Copyright © 2012 Keith Packard <keithp@keithp.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#ifndef _AO_PACKET_H_
+#define _AO_PACKET_H_
+
+/*
+ * ao_packet.c
+ *
+ * Packet-based command interface
+ */
+
+#define AO_PACKET_MAX 64
+#define AO_PACKET_SYN (uint8_t) 0xff
+
+struct ao_packet {
+ uint8_t addr;
+ uint8_t len;
+ uint8_t seq;
+ uint8_t ack;
+ uint8_t d[AO_PACKET_MAX];
+ uint8_t callsign[AO_MAX_CALLSIGN];
+};
+
+struct ao_packet_recv {
+ struct ao_packet packet;
+ int8_t rssi;
+ uint8_t status;
+};
+
+extern __xdata struct ao_packet_recv ao_rx_packet;
+extern __xdata struct ao_packet ao_tx_packet;
+extern __xdata struct ao_task ao_packet_task;
+extern __xdata uint8_t ao_packet_enable;
+extern __xdata uint8_t ao_packet_master_sleeping;
+extern __pdata uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used;
+
+void
+ao_packet_send(void);
+
+uint8_t
+ao_packet_recv(void);
+
+void
+ao_packet_flush(void);
+
+void
+ao_packet_putchar(char c) __reentrant;
+
+char
+ao_packet_pollchar(void) __critical;
+
+#if PACKET_HAS_MASTER
+/* ao_packet_master.c */
+
+void
+ao_packet_master_init(void);
+#endif
+
+#if PACKET_HAS_SLAVE
+/* ao_packet_slave.c */
+
+void
+ao_packet_slave_start(void);
+
+void
+ao_packet_slave_stop(void);
+
+void
+ao_packet_slave_init(uint8_t enable);
+
+#endif
+
+#endif /* _AO_PACKET_H_ */
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
*/
-#include "ao.h"
-#include "ao_product.h"
+#include <ao.h>
+#include <ao_product.h>
+#include <ao_companion.h>
struct ao_companion_command ao_companion_command;
#include "ao.h"
#include "ao_product.h"
#include "ao_flight.h"
+#include "ao_companion.h"
struct ao_companion_command ao_companion_command;
ao_ignite.c \
ao_intflash.c \
ao_led.c \
- ao_packet.c \
- ao_packet_slave.c \
ao_radio.c \
ao_radio_cmac.c \
ao_romconfig.c \
#define HAS_GPS 1
#define HAS_SERIAL_1 1
#define HAS_ADC 0
+ #define HAS_LCD 1
#define HAS_EEPROM 1
#define HAS_LOG 1
#define USE_INTERNAL_FLASH 0