diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/ao.h | 199 | ||||
| -rw-r--r-- | src/core/ao_aes.h | 69 | ||||
| -rw-r--r-- | src/core/ao_btm.h | 36 | ||||
| -rw-r--r-- | src/core/ao_companion.h | 51 | ||||
| -rw-r--r-- | src/core/ao_lcd.h | 60 | ||||
| -rw-r--r-- | src/core/ao_log_telescience.c | 2 | ||||
| -rw-r--r-- | src/core/ao_packet.h | 88 | ||||
| -rw-r--r-- | src/drivers/ao_pyro_slave.c | 5 | ||||
| -rw-r--r-- | src/drivers/ao_science_slave.c | 1 | ||||
| -rw-r--r-- | src/product/Makefile.telelaunch | 2 | ||||
| -rw-r--r-- | src/teleterra-v0.2/ao_pins.h | 1 | 
11 files changed, 323 insertions, 191 deletions
diff --git a/src/core/ao.h b/src/core/ao.h index 28d0ba87..27b9c5c4 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -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 index 00000000..7f67374d --- /dev/null +++ b/src/core/ao_aes.h @@ -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 index 00000000..484e5d7f --- /dev/null +++ b/src/core/ao_btm.h @@ -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 index 00000000..47e0acf5 --- /dev/null +++ b/src/core/ao_companion.h @@ -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 index 00000000..f7e1391a --- /dev/null +++ b/src/core/ao_lcd.h @@ -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_ */ diff --git a/src/core/ao_log_telescience.c b/src/core/ao_log_telescience.c index 31eda381..ae045281 100644 --- a/src/core/ao_log_telescience.c +++ b/src/core/ao_log_telescience.c @@ -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 index 00000000..618ccda4 --- /dev/null +++ b/src/core/ao_packet.h @@ -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_ */ diff --git a/src/drivers/ao_pyro_slave.c b/src/drivers/ao_pyro_slave.c index 5ef42b5a..5a8ab922 100644 --- a/src/drivers/ao_pyro_slave.c +++ b/src/drivers/ao_pyro_slave.c @@ -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; diff --git a/src/drivers/ao_science_slave.c b/src/drivers/ao_science_slave.c index fa9db98b..a86b5151 100644 --- a/src/drivers/ao_science_slave.c +++ b/src/drivers/ao_science_slave.c @@ -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; diff --git a/src/product/Makefile.telelaunch b/src/product/Makefile.telelaunch index 8aab50e0..688ac5f3 100644 --- a/src/product/Makefile.telelaunch +++ b/src/product/Makefile.telelaunch @@ -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 \ diff --git a/src/teleterra-v0.2/ao_pins.h b/src/teleterra-v0.2/ao_pins.h index 2bea4e04..bcabdfee 100644 --- a/src/teleterra-v0.2/ao_pins.h +++ b/src/teleterra-v0.2/ao_pins.h @@ -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  | 
