From: Keith Packard Date: Sat, 2 Apr 2011 02:35:22 +0000 (-0700) Subject: Merge branch 'telemini' into telebt X-Git-Tag: 0.9.3~66 X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=commitdiff_plain;h=f28efe271f9670473249574f6bcf6e160fe58c7b;hp=835ab3a8c2741a09b27de58c37439a193c9919ce Merge branch 'telemini' into telebt --- 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 # @@ -229,6 +237,24 @@ TNANO_BASE_SRC = \ $(TNANO_TASK_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 # diff --git a/src/ao.h b/src/ao.h index 89109fd9..9b375894 100644 --- a/src/ao.h +++ b/src/ao.h @@ -403,6 +403,14 @@ ao_cmd_register(__code struct ao_cmds *cmds); void ao_cmd_init(void); +#if HAS_CMD_FILTER +/* + * Provided by an external module to filter raw command lines + */ +uint8_t +ao_cmd_filter(void); +#endif + /* * ao_dma.c */ @@ -903,6 +911,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 +924,24 @@ 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; +void +ao_serial_drain(void) __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); @@ -1154,13 +1178,21 @@ struct ao_stdio { char (*pollchar)(void); void (*putchar)(char c) __reentrant; void (*flush)(void); + uint8_t echo; }; +extern __xdata struct ao_stdio ao_stdios[]; +extern __data int8_t ao_cur_stdio; +extern __data int8_t ao_num_stdios; + void flush(void); extern __xdata uint8_t ao_stdin_ready; +uint8_t +ao_echo(void); + void ao_add_stdio(char (*pollchar)(void), void (*putchar)(char) __reentrant, @@ -1332,4 +1364,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..c7024ed3 --- /dev/null +++ b/src/ao_btm.c @@ -0,0 +1,267 @@ +/* + * Copyright © 2011 Keith Packard + * + * 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_running; +uint8_t ao_btm_stdio; +__xdata uint8_t ao_btm_connected; +uint8_t ao_btm_chat; + +__xdata char ao_btm_buffer[1024]; +int ao_btm_ptr; + +#define AO_BTM_MAX_REPLY 16 +__xdata char ao_btm_reply[AO_BTM_MAX_REPLY]; + +extern volatile __xdata struct ao_fifo ao_usart1_rx_fifo; + +/* + * Read a line of data from the serial port, truncating + * it after a few characters. + */ + +uint8_t +ao_btm_get_line(void) +{ + uint8_t ao_btm_reply_len = 0; + char c; + + for (;;) { + + while ((c = ao_serial_pollchar()) != AO_READ_AGAIN) { + if (ao_btm_reply_len < sizeof (ao_btm_reply)) + ao_btm_reply[ao_btm_reply_len++] = c; + if (ao_btm_ptr < sizeof (ao_btm_buffer)) + ao_btm_buffer[ao_btm_ptr++] = c; + if (c == '\r' || c == '\n') + goto done; + } + for (c = 0; c < 10; c++) { + ao_delay(AO_MS_TO_TICKS(10)); + if (!ao_fifo_empty(ao_usart1_rx_fifo)) + break; + } + if (c == 10) + goto done; + } +done: + for (c = ao_btm_reply_len; c < sizeof (ao_btm_reply);) + ao_btm_reply[c++] = '\0'; + return ao_btm_reply_len; +} + +/* + * Drain the serial port completely + */ +void +ao_btm_drain() +{ + while (ao_btm_get_line()) + ; +} + +void +ao_btm_echo(uint8_t echo) +{ + ao_stdios[ao_btm_stdio].echo = echo; +} + +/* + * A command line pre-processor to detect connect/disconnect messages + * and update the internal state + */ + +uint8_t +ao_cmd_filter(void) +{ + ao_cmd_lex(); + while (ao_cmd_lex_c != '\n') { + if (ao_match_word("CONNECT")) { + ao_btm_connected = 1; + ao_btm_echo(1); + ao_wakeup(&ao_btm_connected); + return 1; + } + if (ao_match_word("DISCONNECT")) { + ao_btm_connected = 0; + ao_btm_echo(0); + ao_wakeup(&ao_btm_connected); + return 1; + } + if (ao_match_word("ERROR")) + return 1; + if (ao_match_word("OK")) + return 1; + ao_cmd_lex(); + } + ao_cmd_status = 0; + return !ao_btm_connected; +} + +/* + * A wrapper for ao_serial_pollchar that + * doesn't return any characters while we're + * initializing the bluetooth device + */ +char +ao_btm_pollchar(void) +{ + char c; + if (!ao_btm_running) + return AO_READ_AGAIN; + c = ao_serial_pollchar(); + if (c != AO_READ_AGAIN) + if (ao_btm_ptr < sizeof (ao_btm_buffer)) + ao_btm_buffer[ao_btm_ptr++] = c; + return c; +} + +/* + * Wait for the bluetooth device to return + * status from the previously executed command + */ +uint8_t +ao_btm_wait_reply(void) +{ + for (;;) { + ao_btm_get_line(); + if (!strcmp(ao_btm_reply, "OK")) + return 1; + if (!strcmp(ao_btm_reply, "ERROR")) + return -1; + if (ao_btm_reply[0] == '\0') + return 0; + } +} + +void +ao_btm_cmd(__code char *cmd) +{ + ao_cur_stdio = ao_btm_stdio; + printf(cmd); + ao_btm_wait_reply(); +} + +/* + * A thread to initialize the bluetooth device and + * hang around to blink the LED when connected + */ +void +ao_btm(void) +{ + ao_serial_set_speed(AO_SERIAL_SPEED_19200); + ao_add_stdio(ao_btm_pollchar, + ao_serial_putchar, + NULL); + ao_btm_stdio = ao_num_stdios - 1; + ao_cur_stdio = ao_btm_stdio; + ao_btm_echo(0); + ao_btm_drain(); + ao_delay(AO_SEC_TO_TICKS(1)); + printf("+++"); + ao_btm_drain(); + ao_delay(AO_SEC_TO_TICKS(1)); + printf("\r"); + ao_btm_drain(); + ao_btm_cmd("ATQ0\r"); + ao_btm_cmd("ATE0\r"); + ao_btm_cmd("ATH\r"); + ao_delay(AO_SEC_TO_TICKS(1)); + ao_btm_cmd("ATC0\r"); + ao_btm_cmd("ATL4\r"); + ao_serial_set_speed(AO_SERIAL_SPEED_57600); + ao_btm_drain(); + printf("ATN=TeleBT-%d\r", ao_serial_number); + ao_btm_wait_reply(); + ao_btm_running = 1; + for (;;) { + while (!ao_btm_connected && !ao_btm_chat) + ao_sleep(&ao_btm_connected); + if (ao_btm_chat) { + ao_btm_running = 0; + while (ao_btm_chat) { + char c; + c = ao_serial_pollchar(); + if (c != AO_READ_AGAIN) + ao_usb_putchar(c); + else { + ao_usb_flush(); + ao_sleep(&ao_usart1_rx_fifo); + } + } + ao_btm_running = 1; + } + while (ao_btm_connected) { + ao_led_for(AO_LED_GREEN, AO_MS_TO_TICKS(20)); + ao_delay(AO_SEC_TO_TICKS(3)); + } + } +} + +__xdata struct ao_task ao_btm_task; + +/* + * Connect directly to the bluetooth device, mostly + * useful for testing + */ +static void +ao_btm_forward(void) +{ + char c; + + ao_btm_chat = 1; + ao_wakeup(&ao_btm_connected); + ao_usb_flush(); + while ((c = ao_usb_getchar()) != '~') { + if (c == '\n') c = '\r'; + ao_serial_putchar(c); + } + ao_btm_chat = 0; + while (!ao_btm_running) { + ao_wakeup(&ao_usart1_rx_fifo); + ao_delay(AO_MS_TO_TICKS(10)); + } +} + +/* + * Dump everything received from the bluetooth device during startup + */ +static void +ao_btm_dump(void) +{ + int i; + + for (i = 0; i < ao_btm_ptr; i++) + putchar(ao_btm_buffer[i]); + putchar('\n'); +} + +__code struct ao_cmds ao_btm_cmds[] = { + { ao_btm_forward, "B\0BTM serial link." }, + { ao_btm_dump, "d\0Dump btm buffer." }, + { 0, NULL }, +}; + +void +ao_btm_init (void) +{ + ao_serial_init(); + ao_serial_set_speed(AO_SERIAL_SPEED_19200); + ao_add_task(&ao_btm_task, ao_btm, "bt"); + ao_cmd_register(&ao_btm_cmds[0]); +} diff --git a/src/ao_cmd.c b/src/ao_cmd.c index 6007773c..c738a3e0 100644 --- a/src/ao_cmd.c +++ b/src/ao_cmd.c @@ -21,7 +21,6 @@ __xdata uint16_t ao_cmd_lex_i; __xdata uint32_t ao_cmd_lex_u32; __xdata char ao_cmd_lex_c; __xdata enum ao_cmd_status ao_cmd_status; -static __xdata uint8_t lex_echo; #define CMD_LEN 32 @@ -41,7 +40,7 @@ static void readline(void) { __xdata char c; - if (lex_echo) + if (ao_echo()) put_string("> "); cmd_len = 0; for (;;) { @@ -50,7 +49,7 @@ readline(void) /* backspace/delete */ if (c == '\010' || c == '\177') { if (cmd_len != 0) { - if (lex_echo) + if (ao_echo()) put_string("\010 \010"); --cmd_len; } @@ -60,7 +59,7 @@ readline(void) /* ^U */ if (c == '\025') { while (cmd_len != 0) { - if (lex_echo) + if (ao_echo()) put_string("\010 \010"); --cmd_len; } @@ -72,18 +71,18 @@ readline(void) c = '\n'; if (c == '\n') { - if (lex_echo) + if (ao_echo()) putchar('\n'); break; } if (cmd_len >= CMD_LEN - 2) { - if (lex_echo) + if (ao_echo()) putchar('\007'); continue; } cmd_line[cmd_len++] = c; - if (lex_echo) + if (ao_echo()) putchar(c); } cmd_line[cmd_len++] = '\n'; @@ -198,7 +197,8 @@ static void echo(void) { ao_cmd_hex(); - lex_echo = ao_cmd_lex_i != 0; + if (ao_cmd_status == ao_cmd_success) + ao_stdios[ao_cur_stdio].echo = ao_cmd_lex_i != 0; } static void @@ -272,9 +272,13 @@ ao_cmd(void) __code struct ao_cmds * __xdata cs; void (*__xdata func)(void); - lex_echo = 1; for (;;) { readline(); +#if HAS_CMD_FILTER + if (ao_cmd_filter()) + continue; + cmd_i = 0; +#endif ao_cmd_lex(); ao_cmd_white(); c = ao_cmd_lex_c; diff --git a/src/ao_packet_master.c b/src/ao_packet_master.c index 069bc5df..e721ffba 100644 --- a/src/ao_packet_master.c +++ b/src/ao_packet_master.c @@ -26,7 +26,7 @@ ao_packet_getchar(void) __critical break; if (ao_packet_master_sleeping) ao_wakeup(&ao_packet_master_sleeping); - ao_usb_flush(); + flush(); ao_sleep(&ao_stdin_ready); } return c; @@ -39,7 +39,7 @@ ao_packet_echo(void) __reentrant while (ao_packet_enable) { c = ao_packet_getchar(); if (c != AO_READ_AGAIN) - ao_usb_putchar(c); + putchar(c); } ao_exit(); } @@ -112,7 +112,7 @@ ao_packet_forward(void) __reentrant ao_set_monitor(0); ao_add_task(&ao_packet_task, ao_packet_master, "master"); ao_add_task(&ao_packet_echo_task, ao_packet_echo, "echo"); - while ((c = ao_usb_getchar()) != '~') { + while ((c = getchar()) != '~') { if (c == '\r') c = '\n'; ao_packet_putchar(c); } diff --git a/src/ao_pins.h b/src/ao_pins.h index 30f2decc..ed42df8b 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,30 @@ #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_CMD_FILTER 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 +302,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..9c0b798d 100644 --- a/src/ao_serial.c +++ b/src/ao_serial.c @@ -26,6 +26,9 @@ 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 + ao_wakeup(&ao_stdin_ready); +#endif } static __xdata uint8_t ao_serial_tx1_started; @@ -50,8 +53,6 @@ ao_serial_tx1_isr(void) __interrupt 14 ao_wakeup(&ao_usart1_tx_fifo); } -static __pdata serial_echo; - char ao_serial_getchar(void) __critical { @@ -59,16 +60,21 @@ ao_serial_getchar(void) __critical while (ao_fifo_empty(ao_usart1_rx_fifo)) ao_sleep(&ao_usart1_rx_fifo); ao_fifo_remove(ao_usart1_rx_fifo, c); - if (serial_echo) { - printf("%02x ", ((int) c) & 0xff); - if (c >= ' ') - putchar(c); - putchar('\n'); - flush(); - } return c; } +#if USE_SERIAL_STDIN +char +ao_serial_pollchar(void) __critical +{ + char c; + if (ao_fifo_empty(ao_usart1_rx_fifo)) + return AO_READ_AGAIN; + ao_fifo_remove(ao_usart1_rx_fifo,c); + return c; +} +#endif + void ao_serial_putchar(char c) __critical { @@ -78,25 +84,13 @@ ao_serial_putchar(char c) __critical ao_serial_tx1_start(); } -static void +void ao_serial_drain(void) __critical { while (!ao_fifo_empty(ao_usart1_tx_fifo)) ao_sleep(&ao_usart1_tx_fifo); } -static void -monitor_serial(void) -{ - ao_cmd_hex(); - serial_echo = ao_cmd_lex_i != 0; -} - -__code struct ao_cmds ao_serial_cmds[] = { - { monitor_serial, "M \0Monitor serial data" }, - { 0, NULL }, -}; - static const struct { uint8_t baud; uint8_t gcr; @@ -109,6 +103,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 @@ -121,6 +119,7 @@ ao_serial_set_speed(uint8_t speed) ao_serial_drain(); if (speed > AO_SERIAL_SPEED_57600) return; + U1UCR |= UxUCR_FLUSH; U1BAUD = ao_serial_speeds[speed].baud; U1GCR = ao_serial_speeds[speed].gcr; } @@ -131,7 +130,8 @@ ao_serial_init(void) /* Set up the USART pin assignment */ PERCFG = (PERCFG & ~PERCFG_U1CFG_ALT_MASK) | PERCFG_U1CFG_ALT_2; - /* ee has already set the P2SEL bits */ + P2SEL = (P2SEL & ~(P2SEL_PRI3P1_MASK | P2SEL_PRI2P1_MASK)) | + (P2SEL_PRI3P1_USART1 | P2SEL_PRI2P1_USART1); /* Make the USART pins be controlled by the USART */ P1SEL |= (1 << 6) | (1 << 7); @@ -145,7 +145,7 @@ ao_serial_init(void) /* Reasonable serial parameters */ U1UCR = (UxUCR_FLUSH | UxUCR_FLOW_DISABLE | - UxUCR_D9_ODD_PARITY | + UxUCR_D9_EVEN_PARITY | UxUCR_BIT9_8_BITS | UxUCR_PARITY_DISABLE | UxUCR_SPB_1_STOP_BIT | @@ -154,6 +154,4 @@ ao_serial_init(void) IEN0 |= IEN0_URX1IE; IEN2 |= IEN2_UTX1IE; - - ao_cmd_register(&ao_serial_cmds[0]); } diff --git a/src/ao_stdio.c b/src/ao_stdio.c index 6e1f5eff..ec3b6607 100644 --- a/src/ao_stdio.c +++ b/src/ao_stdio.c @@ -21,25 +21,25 @@ * 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; -static __data int8_t ao_num_stdios; +__xdata struct ao_stdio ao_stdios[AO_NUM_STDIOS]; +__data int8_t ao_cur_stdio; +__data int8_t ao_num_stdios; void putchar(char c) { if (c == '\n') - (*stdios[ao_cur_stdio].putchar)('\r'); - (*stdios[ao_cur_stdio].putchar)(c); + (*ao_stdios[ao_cur_stdio].putchar)('\r'); + (*ao_stdios[ao_cur_stdio].putchar)(c); } void flush(void) { - if (stdios[ao_cur_stdio].flush) - stdios[ao_cur_stdio].flush(); + if (ao_stdios[ao_cur_stdio].flush) + ao_stdios[ao_cur_stdio].flush(); } __xdata uint8_t ao_stdin_ready; @@ -51,7 +51,7 @@ getchar(void) __reentrant __critical int8_t stdio = ao_cur_stdio; for (;;) { - c = stdios[stdio].pollchar(); + c = ao_stdios[stdio].pollchar(); if (c != AO_READ_AGAIN) break; if (++stdio == ao_num_stdios) @@ -63,6 +63,12 @@ getchar(void) __reentrant __critical return c; } +uint8_t +ao_echo(void) +{ + return ao_stdios[ao_cur_stdio].echo; +} + void ao_add_stdio(char (*pollchar)(void), void (*putchar)(char), @@ -70,8 +76,9 @@ ao_add_stdio(char (*pollchar)(void), { if (ao_num_stdios == AO_NUM_STDIOS) ao_panic(AO_PANIC_STDIO); - stdios[ao_num_stdios].pollchar = pollchar; - stdios[ao_num_stdios].putchar = putchar; - stdios[ao_num_stdios].flush = flush; + ao_stdios[ao_num_stdios].pollchar = pollchar; + ao_stdios[ao_num_stdios].putchar = putchar; + ao_stdios[ao_num_stdios].flush = flush; + ao_stdios[ao_num_stdios].echo = 1; ao_num_stdios++; } 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 + * + * 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/cc1111.h b/src/cc1111.h index effb1a68..a72d7416 100644 --- a/src/cc1111.h +++ b/src/cc1111.h @@ -565,14 +565,19 @@ sfr at 0xF5 P2SEL; #define P2SEL_PRI3P1_MASK (1 << 6) #define P2SEL_PRI2P1_USART1 (0 << 5) #define P2SEL_PRI2P1_TIMER3 (1 << 5) +#define P2SEL_PRI2P1_MASK (1 << 5) #define P2SEL_PRI1P1_TIMER1 (0 << 4) #define P2SEL_PRI1P1_TIMER4 (1 << 4) +#define P2SEL_PRI1P1_MASK (1 << 4) #define P2SEL_PRI0P1_USART0 (0 << 3) #define P2SEL_PRI0P1_TIMER1 (1 << 3) +#define P2SEL_PRI0P1_MASK (1 << 3) #define P2SEL_SELP2_4_GPIO (0 << 2) #define P2SEL_SELP2_4_PERIPHERAL (1 << 2) +#define P2SEL_SELP2_4_MASK (1 << 2) #define P2SEL_SELP2_3_GPIO (0 << 1) #define P2SEL_SELP2_3_PERIPHERAL (1 << 1) +#define P2SEL_SELP2_3_MASK (1 << 1) #define P2SEL_SELP2_0_GPIO (0 << 0) #define P2SEL_SELP2_0_PERIPHERAL (1 << 0) #define P2SEL_SELP2_0_MASK (1 << 0) 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