altos: Pull more interfaces out of ao.h and move to separate files
authorKeith Packard <keithp@keithp.com>
Fri, 13 Apr 2012 16:39:20 +0000 (09:39 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 14 Apr 2012 21:04:29 +0000 (14:04 -0700)
This moves the aes, btm, companion, lcd and packet interfaces out of ao.h

Signed-off-by: Keith Packard <keithp@keithp.com>
src/core/ao.h
src/core/ao_aes.h [new file with mode: 0644]
src/core/ao_btm.h [new file with mode: 0644]
src/core/ao_companion.h [new file with mode: 0644]
src/core/ao_lcd.h [new file with mode: 0644]
src/core/ao_log_telescience.c
src/core/ao_packet.h [new file with mode: 0644]
src/drivers/ao_pyro_slave.c
src/drivers/ao_science_slave.c
src/product/Makefile.telelaunch
src/teleterra-v0.2/ao_pins.h

index 28d0ba872cb441a186231b77c1012932e5885060..27b9c5c469717112161a72ecdb498a4098bb6ed8 100644 (file)
@@ -900,201 +900,26 @@ struct ao_fifo {
 #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 {
diff --git a/src/core/ao_aes.h b/src/core/ao_aes.h
new file mode 100644 (file)
index 0000000..7f67374
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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_ */
diff --git a/src/core/ao_btm.h b/src/core/ao_btm.h
new file mode 100644 (file)
index 0000000..484e5d7
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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_ */
diff --git a/src/core/ao_companion.h b/src/core/ao_companion.h
new file mode 100644 (file)
index 0000000..47e0acf
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * 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_ */
diff --git a/src/core/ao_lcd.h b/src/core/ao_lcd.h
new file mode 100644 (file)
index 0000000..f7e1391
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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_ */
index 31eda381d775a9d393c3c5a591816ce09858e56c..ae045281080debfb778ca30ac7e8e860907bf806 100644 (file)
@@ -17,6 +17,8 @@
 
 #include "ao.h"
 #include "ao_product.h"
+#include "ao_log.h"
+#include "ao_companion.h"
 
 static uint8_t ao_log_adc_pos;
 
diff --git a/src/core/ao_packet.h b/src/core/ao_packet.h
new file mode 100644 (file)
index 0000000..618ccda
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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_ */
index 5ef42b5ac61296b19a7a9f5774196b38a57d4ae5..5a8ab9223b095bc7bd83380a07ce0d4393cdd9db 100644 (file)
@@ -15,8 +15,9 @@
  * 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;
 
index fa9db98bad80315b6806c74512b3c2ff76ab0f70..a86b51518637d973af9026c3aebd4bbd62446b32 100644 (file)
@@ -18,6 +18,7 @@
 #include "ao.h"
 #include "ao_product.h"
 #include "ao_flight.h"
+#include "ao_companion.h"
 
 struct ao_companion_command    ao_companion_command;
 
index 8aab50e045891745d9b0fd8068a9b3bf58316e7f..688ac5f35cd91aeb7c509b1f92d79450afb79507 100644 (file)
@@ -39,8 +39,6 @@ CC1111_SRC = \
        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 \
index 2bea4e04bca273ce066805b46855c16cbbc4ec12..bcabdfeeeea7cf46bee584b67046385e49dc5514 100644 (file)
@@ -25,6 +25,7 @@
        #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