diff options
| -rw-r--r-- | src/Makefile | 1 | ||||
| -rw-r--r-- | src/Makefile.proto | 26 | ||||
| -rw-r--r-- | src/ao.h | 20 | ||||
| -rw-r--r-- | src/ao_btm.c | 72 | ||||
| -rw-r--r-- | src/ao_pins.h | 35 | ||||
| -rw-r--r-- | src/ao_serial.c | 42 | ||||
| -rw-r--r-- | src/ao_stdio.c | 2 | ||||
| -rw-r--r-- | src/ao_telebt.c | 41 | ||||
| -rw-r--r-- | src/telebt-v0.0/.gitignore | 2 | ||||
| -rw-r--r-- | src/telebt-v0.0/.sdcdbrc | 1 | ||||
| -rw-r--r-- | src/telebt-v0.0/Makefile.defs | 8 | 
11 files changed, 248 insertions, 2 deletions
| diff --git a/src/Makefile b/src/Makefile index a5dec57b..d83ec668 100644 --- a/src/Makefile +++ b/src/Makefile @@ -10,6 +10,7 @@ SUBDIRS=\  	telemetrum-v1.1 telemetrum-v1.0 \  	teledongle-v0.2 teledongle-v0.1 \  	telemini-v0.1 telenano-v0.1 \ +	telebt-v0.0 \  	telemetrum-v0.1-sky telemetrum-v0.1-sirf \  	tidongle test diff --git a/src/Makefile.proto b/src/Makefile.proto index 5aad445f..ca68edbc 100644 --- a/src/Makefile.proto +++ b/src/Makefile.proto @@ -136,12 +136,20 @@ M25_DRIVER_SRC = \  #  SIRF_DRIVER_SRC = \  	ao_gps_sirf.c +  #  # Skytraq driver source  #  SKY_DRIVER_SRC = \  	ao_gps_skytraq.c + +# +# BTM-182 driver source +# +BTM_DRIVER_SRC = \ +	ao_btm.c +  #  # Tasks run on TeleMetrum  # @@ -230,6 +238,24 @@ TNANO_BASE_SRC = \  	$(TNANO_MAIN_SRC)  # +# Sources for TeleDongle +# + +TBT_MAIN_SRC = \ +	ao_telebt.c + +TBT_BASE_SRC = \ +	$(ALTOS_SRC) \ +	$(ALTOS_DRIVER_SRC) \ +	$(TELE_RECEIVER_SRC) \ +	$(TELE_COMMON_SRC) \ +	$(SERIAL_DRIVER_SRC) \ +	$(USB_DRIVER_SRC) \ +	$(BTM_DRIVER_SRC) \ +	$(DBG_SRC) \ +	$(TBT_MAIN_SRC) + +#  # TI Dongle sources  #  TI_MAIN_SRC = \ @@ -903,6 +903,10 @@ ao_dbg_init(void);  #endif  #if HAS_SERIAL_1 +#ifndef USE_SERIAL_STDIN +#error Please define USE_SERIAL_STDIN +#endif +  void  ao_serial_rx1_isr(void) __interrupt 3; @@ -912,12 +916,21 @@ ao_serial_tx1_isr(void) __interrupt 14;  char  ao_serial_getchar(void) __critical; +#if USE_SERIAL_STDIN +char +ao_serial_pollchar(void) __critical; + +void +ao_serial_set_stdin(uint8_t stdin); +#endif +  void  ao_serial_putchar(char c) __critical;  #define AO_SERIAL_SPEED_4800	0  #define AO_SERIAL_SPEED_9600	1 -#define AO_SERIAL_SPEED_57600	2 +#define AO_SERIAL_SPEED_19200	2 +#define AO_SERIAL_SPEED_57600	3  void  ao_serial_set_speed(uint8_t speed); @@ -1332,4 +1345,9 @@ ao_packet_slave_stop(void);  void  ao_packet_slave_init(uint8_t enable); +/* ao_btm.c */ + +void +ao_btm_init(void); +  #endif /* _AO_H_ */ diff --git a/src/ao_btm.c b/src/ao_btm.c new file mode 100644 index 00000000..224d3e81 --- /dev/null +++ b/src/ao_btm.c @@ -0,0 +1,72 @@ +/* + * Copyright © 2011 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. + */ + +#include "ao.h" + +uint8_t	ao_btm_enable; +extern volatile __xdata struct ao_fifo	ao_usart1_rx_fifo; + +void +ao_btm(void) +{ +	char	c; +	while (ao_btm_enable) { +		c = ao_serial_pollchar(); +		if (c != AO_READ_AGAIN) +			ao_usb_putchar(c); +		else { +			ao_usb_flush(); +			ao_sleep(&ao_usart1_rx_fifo); +		} +	} +	ao_exit(); +} + +__xdata struct ao_task	ao_btm_task; + +static void +ao_btm_forward(void) +{ +	char c; +	ao_btm_enable = 1; +	flush(); +	ao_add_task(&ao_btm_task, ao_btm, "btm"); + +	while ((c = ao_usb_getchar()) != '~') { +		if (c == '\n') c = '\r'; +		ao_serial_putchar(c); +	} +	ao_btm_enable = 0; +	while (ao_btm_task.wchan) { +		ao_wakeup(&ao_usart1_rx_fifo); +		ao_delay(AO_MS_TO_TICKS(10)); +	} +} + +__code struct ao_cmds ao_btm_cmds[] = { +	{ ao_btm_forward,	"B <data>\0BTM serial link." }, +	{ 0, NULL }, +}; + + +void +ao_btm_init (void) +{ +	ao_serial_init(); +	ao_serial_set_speed(AO_SERIAL_SPEED_19200); +	ao_cmd_register(&ao_btm_cmds[0]); +} diff --git a/src/ao_pins.h b/src/ao_pins.h index 30f2decc..a4ebd63b 100644 --- a/src/ao_pins.h +++ b/src/ao_pins.h @@ -25,6 +25,7 @@  	#define HAS_GPS			1  	#define HAS_SERIAL_1		1  	#define HAS_ADC			1 +	#define USE_SERIAL_STDIN	0  	#define HAS_EEPROM		1  	#define USE_INTERNAL_FLASH	0  	#define HAS_DBG			1 @@ -49,6 +50,7 @@  	#define HAS_BEEP		1  	#define HAS_GPS			1  	#define HAS_SERIAL_1		1 +	#define USE_SERIAL_STDIN	0  	#define HAS_ADC			1  	#define HAS_EEPROM		1  	#define USE_INTERNAL_FLASH	0 @@ -77,6 +79,7 @@  	#define HAS_USB			1  	#define HAS_BEEP		0  	#define HAS_SERIAL_1		0 +	#define USE_SERIAL_STDIN	0  	#define HAS_ADC			0  	#define HAS_DBG			1  	#define HAS_EEPROM		0 @@ -100,6 +103,7 @@  	#define HAS_BEEP		0  	#define HAS_GPS			0  	#define HAS_SERIAL_1		0 +	#define USE_SERIAL_STDIN	0  	#define HAS_ADC			1  	#define HAS_EEPROM		1  	#define USE_INTERNAL_FLASH	1 @@ -123,6 +127,7 @@  	#define HAS_BEEP		0  	#define HAS_GPS			0  	#define HAS_SERIAL_1		0 +	#define USE_SERIAL_STDIN	0  	#define HAS_ADC			1  	#define HAS_EEPROM		1  	#define USE_INTERNAL_FLASH	1 @@ -146,6 +151,7 @@  	#define HAS_BEEP		1  	#define HAS_GPS			1  	#define HAS_SERIAL_1		1 +	#define USE_SERIAL_STDIN	0  	#define HAS_ADC			1  	#define HAS_DBG			0  	#define HAS_EEPROM		1 @@ -172,6 +178,7 @@  	#define HAS_USB			1  	#define HAS_BEEP		0  	#define HAS_SERIAL_1		0 +	#define USE_SERIAL_STDIN	0  	#define HAS_ADC			0  	#define HAS_DBG			0  	#define HAS_EEPROM		0 @@ -194,6 +201,7 @@  	#define HAS_USB			1  	#define HAS_BEEP		0  	#define HAS_SERIAL_1		0 +	#define USE_SERIAL_STDIN	0  	#define HAS_ADC			0  	#define HAS_DBG			1  	#define HAS_EEPROM		0 @@ -210,6 +218,29 @@  	#define HAS_IGNITE		0  #endif +#if defined(TELEBT_V_0_0) +	#define HAS_FLIGHT		0 +	#define HAS_USB			1 +	#define HAS_BEEP		0 +	#define HAS_SERIAL_1		1 +	#define USE_SERIAL_STDIN	1 +	#define HAS_ADC			0 +	#define HAS_DBG			1 +	#define HAS_EEPROM		0 +	#define DBG_ON_P1 		0 +	#define DBG_ON_P0 		1 +	#define IGNITE_ON_P2		0 +	#define IGNITE_ON_P0		0 +	#define PACKET_HAS_MASTER	1 +	#define PACKET_HAS_SLAVE	0 +	#define AO_LED_RED		2 +	#define AO_LED_GREEN		1 +	#define LEDS_AVAILABLE		(AO_LED_RED|AO_LED_GREEN) +	#define SPI_CS_ON_P1		1 +	#define SPI_CS_ON_P0		0 +	#define HAS_IGNITE		0 +#endif +  #if DBG_ON_P1  	#define DBG_CLOCK	(1 << 4)	/* mi0 */ @@ -270,6 +301,10 @@  #error Please define HAS_SERIAL_1  #endif +#ifndef USE_SERIAL_STDIN +#error Please define USE_SERIAL_STDIN +#endif +  #ifndef HAS_ADC  #error Please define HAS_ADC  #endif diff --git a/src/ao_serial.c b/src/ao_serial.c index dd383fca..b8e9d2bf 100644 --- a/src/ao_serial.c +++ b/src/ao_serial.c @@ -20,12 +20,20 @@  volatile __xdata struct ao_fifo	ao_usart1_rx_fifo;  volatile __xdata struct ao_fifo	ao_usart1_tx_fifo; +#if USE_SERIAL_STDIN +__pdata uint8_t	ao_serial_stdin; +#endif +  void  ao_serial_rx1_isr(void) __interrupt 3  {  	if (!ao_fifo_full(ao_usart1_rx_fifo))  		ao_fifo_insert(ao_usart1_rx_fifo, U1DBUF);  	ao_wakeup(&ao_usart1_rx_fifo); +#if USE_SERIAL_STDIN +	if (ao_serial_stdin) +		ao_wakeup(&ao_stdin_ready); +#endif  }  static __xdata uint8_t ao_serial_tx1_started; @@ -69,6 +77,29 @@ ao_serial_getchar(void) __critical  	return c;  } +#if USE_SERIAL_STDIN +char +ao_serial_pollchar(void) __critical +{ +	char	c; +#if 0 +	if (!ao_serial_stdin) +		return AO_READ_AGAIN; +#endif +	if (ao_fifo_empty(ao_usart1_rx_fifo)) +		return AO_READ_AGAIN; +	ao_fifo_remove(ao_usart1_rx_fifo,c); +	return c; +} + +void +ao_serial_set_stdin(uint8_t stdin) +{ +	ao_serial_stdin = stdin; +} + +#endif +  void  ao_serial_putchar(char c) __critical  { @@ -109,6 +140,10 @@ static const struct {  		/* .baud = */ 163,  		/* .gcr  = */ (8 << UxGCR_BAUD_E_SHIFT) | UxGCR_ORDER_LSB  	}, +	/* [AO_SERIAL_SPEED_19200] = */ { +		/* .baud = */ 163, +		/* .gcr  = */ (9 << UxGCR_BAUD_E_SHIFT) | UxGCR_ORDER_LSB +	},  	/* [AO_SERIAL_SPEED_57600] = */ {  		/* .baud = */ 59,  		/* .gcr =  */ (11 << UxGCR_BAUD_E_SHIFT) | UxGCR_ORDER_LSB @@ -156,4 +191,11 @@ ao_serial_init(void)  	IEN2 |= IEN2_UTX1IE;  	ao_cmd_register(&ao_serial_cmds[0]); +#if 0 +#if USE_SERIAL_STDIN +	ao_add_stdio(ao_serial_pollchar, +		     ao_serial_putchar, +		     NULL); +#endif +#endif  } diff --git a/src/ao_stdio.c b/src/ao_stdio.c index 6e1f5eff..c7080ec1 100644 --- a/src/ao_stdio.c +++ b/src/ao_stdio.c @@ -21,7 +21,7 @@   * Basic I/O functions to support SDCC stdio package   */ -#define AO_NUM_STDIOS	2 +#define AO_NUM_STDIOS	(HAS_USB + PACKET_HAS_SLAVE + USE_SERIAL_STDIN)  static __xdata struct ao_stdio stdios[AO_NUM_STDIOS];  static __data int8_t ao_cur_stdio; diff --git a/src/ao_telebt.c b/src/ao_telebt.c new file mode 100644 index 00000000..295f0cec --- /dev/null +++ b/src/ao_telebt.c @@ -0,0 +1,41 @@ +/* + * Copyright © 2011 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. + */ + +#include "ao.h" + +void +main(void) +{ +	ao_clock_init(); + +	/* Turn on the LED until the system is stable */ +	ao_led_init(LEDS_AVAILABLE); +	ao_led_on(AO_LED_RED); +	ao_timer_init(); +	ao_cmd_init(); +	ao_usb_init(); +	ao_monitor_init(AO_LED_GREEN, TRUE); +	ao_rssi_init(AO_LED_RED); +	ao_radio_init(); +	ao_packet_master_init(); +	ao_btm_init(); +#if HAS_DBG +	ao_dbg_init(); +#endif +	ao_config_init(); +	ao_start_scheduler(); +} diff --git a/src/telebt-v0.0/.gitignore b/src/telebt-v0.0/.gitignore new file mode 100644 index 00000000..1acfbfcc --- /dev/null +++ b/src/telebt-v0.0/.gitignore @@ -0,0 +1,2 @@ +telebt-* +ao_product.h diff --git a/src/telebt-v0.0/.sdcdbrc b/src/telebt-v0.0/.sdcdbrc new file mode 100644 index 00000000..710b4a2f --- /dev/null +++ b/src/telebt-v0.0/.sdcdbrc @@ -0,0 +1 @@ +--directory=.. diff --git a/src/telebt-v0.0/Makefile.defs b/src/telebt-v0.0/Makefile.defs new file mode 100644 index 00000000..f0bb5e0c --- /dev/null +++ b/src/telebt-v0.0/Makefile.defs @@ -0,0 +1,8 @@ +PROG = telebt-v0.0-$(VERSION).ihx + +SRC = \ +	$(TBT_BASE_SRC) + +PRODUCT=TeleBT-v0.0 +PRODUCT_DEF=-DTELEBT_V_0_0 +IDPRODUCT=0x000e | 
