From: Keith Packard Date: Wed, 11 May 2011 15:16:29 +0000 (-0700) Subject: Merge branch 'telebt' into telescience X-Git-Tag: 0.9.3~40 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=fef945e36c2397dd39b68995ed8d2ab81a4d24cd;hp=4c6fddf6f6ea7247291272af39966ab94260fb01;p=fw%2Faltos Merge branch 'telebt' into telescience --- diff --git a/ao-bringup/turnon_telebt b/ao-bringup/turnon_telebt new file mode 100755 index 00000000..3b8bd3e4 --- /dev/null +++ b/ao-bringup/turnon_telebt @@ -0,0 +1,48 @@ +#!/bin/sh + +if [ -x ../ao-tools/ao-load/ao-load ]; then + AOLOAD=../ao-tools/ao-load/ao-load +elif [ -x /usr/bin/ao-load ]; then + AOLOAD=/usr/bin/ao-load +else + echo "Can't find ao-load! Aborting." + exit 1 +fi + +if [ -x ../ao-tools/ao-rawload/ao-rawload ]; then + RAWLOAD=../ao-tools/ao-rawload/ao-rawload +elif [ -x /usr/bin/ao-rawload ]; then + RAWLOAD=/usr/bin/ao-rawload +else + echo "Can't find ao-rawload! Aborting." + exit 1 +fi + +echo "TeleBT v0.1 Turn-On and Calibration Program" +echo "Copyright 2011 by Bdale Garbee. Released under GPL v2" +echo +echo "Expectations:" +echo "\tTeleBT v0.1 powered from USB" +echo "\t\twith TeleDonle (on /dev/ttyACM0) cabled to debug header" +echo "\t\twith coax from SMA to frequency counter" +echo +echo -n "TeleBT serial number: " +read SERIAL + +echo $RAWLOAD + +$RAWLOAD -D 100 -r ao_led_blink.ihx +echo "LEDs should be blinking" +sleep 5 + +$RAWLOAD -D 100 -r ao_radio_xmit.ihx +echo -n "Generating RF carrier. Please enter measured frequency: " +read FREQ + +CAL_VALUE=`nickle -e "floor(434.55 / $FREQ * 1186611 + 0.5)"` + +echo "Programming flash with cal value " $CAL_VALUE +$AOLOAD -D 100 --cal $CAL_VALUE /usr/share/altos/telebt-v0.1*.ihx $SERIAL + +echo "Serial number "$SERIAL" programmed with RF cal value "$CAL_VALUE +echo "Unplug and replug USB, cu to the board, confirm freq and record power" diff --git a/debian/changelog b/debian/changelog index 63d75356..fe01210d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -altos (0.9.1) unstable; urgency=low +altos (0.9.1.telemini.1) unstable; urgency=low [ Keith Packard ] * ao-load: fix usage message to note that '=' is required for options @@ -13,7 +13,7 @@ altos (0.9.1) unstable; urgency=low [ Bdale Garbee ] * tie bringup scripts to Bdale's bench TeleDongle - -- Bdale Garbee Fri, 18 Feb 2011 23:55:58 -0700 + -- Bdale Garbee Fri, 01 Apr 2011 20:02:12 -0600 altos (0.9) unstable; urgency=low diff --git a/src/Makefile b/src/Makefile index d83ec668..3eec3980 100644 --- a/src/Makefile +++ b/src/Makefile @@ -10,7 +10,7 @@ SUBDIRS=\ telemetrum-v1.1 telemetrum-v1.0 \ teledongle-v0.2 teledongle-v0.1 \ telemini-v0.1 telenano-v0.1 \ - telebt-v0.0 \ + telebt-v0.0 telebt-v0.1 \ telemetrum-v0.1-sky telemetrum-v0.1-sirf \ tidongle test diff --git a/src/Makefile.proto b/src/Makefile.proto index ca68edbc..c86de823 100644 --- a/src/Makefile.proto +++ b/src/Makefile.proto @@ -238,7 +238,7 @@ TNANO_BASE_SRC = \ $(TNANO_MAIN_SRC) # -# Sources for TeleDongle +# Sources for TeleBluetooth # TBT_MAIN_SRC = \ @@ -255,6 +255,13 @@ TBT_BASE_SRC = \ $(DBG_SRC) \ $(TBT_MAIN_SRC) +TBT_V_0_1_SRC = \ + $(TBT_BASE_SRC) \ + $(SPI_DRIVER_SRC) \ + $(M25_DRIVER_SRC) \ + $(BEEP_DRIVER_SRC) \ + ao_log_telem.c + # # TI Dongle sources # diff --git a/src/ao.h b/src/ao.h index 226f9a22..600c488a 100644 --- a/src/ao.h +++ b/src/ao.h @@ -1367,9 +1367,17 @@ ao_packet_slave_init(uint8_t enable); /* ao_btm.c */ -/* Shared by USB, so the USB code calls this function */ +/* 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); +ao_btm_isr(void) +#if BT_LINK_ON_P1 + __interrupt 15 +#endif + ; + void ao_btm_init(void); diff --git a/src/ao_btm.c b/src/ao_btm.c index db0ff6b0..44155ec1 100644 --- a/src/ao_btm.c +++ b/src/ao_btm.c @@ -166,6 +166,10 @@ ao_btm(void) */ ao_delay(AO_SEC_TO_TICKS(3)); +#if HAS_BEEP + ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200)); +#endif + /* * The first time we connect, the BTM-180 comes up at 19200 baud. * After that, it will remember and come up at 57600 baud. So, see @@ -208,26 +212,50 @@ ao_btm(void) __xdata struct ao_task ao_btm_task; +#if BT_LINK_ON_P2 +#define BT_PICTL_ICON PICTL_P2ICON +#define BT_PIFG P2IFG +#define BT_PDIR P2DIR +#define BT_PINP P2INP +#define BT_IEN2_PIE IEN2_P2IE +#endif +#if BT_LINK_ON_P1 +#define BT_PICTL_ICON PICTL_P1ICON +#define BT_PIFG P1IFG +#define BT_PDIR P1DIR +#define BT_PINP P1INP +#define BT_IEN2_PIE IEN2_P1IE +#endif + void ao_btm_check_link() __critical { - if (P2_1) { + /* Check the pin and configure the interrupt detector to wait for the + * pin to flip the other way + */ + if (BT_LINK_PIN) { ao_btm_connected = 0; - PICTL |= PICTL_P2ICON; + PICTL |= BT_PICTL_ICON; } else { ao_btm_connected = 1; - PICTL &= ~PICTL_P2ICON; + PICTL &= ~BT_PICTL_ICON; } } void ao_btm_isr(void) +#if BT_LINK_ON_P1 + __interrupt 15 +#endif { - if (P2IFG & (1 << 1)) { +#if BT_LINK_ON_P1 + P1IF = 0; +#endif + if (BT_PIFG & (1 << BT_LINK_PIN_INDEX)) { ao_btm_check_link(); ao_wakeup(&ao_btm_connected); } - P2IFG = 0; + BT_PIFG = 0; } void @@ -236,18 +264,39 @@ ao_btm_init (void) ao_serial_init(); ao_serial_set_speed(AO_SERIAL_SPEED_19200); +#if BT_LINK_ON_P1 + /* + * Configure ser reset line + */ + + P1_6 = 0; + P1DIR |= (1 << 6); +#endif + /* * Configure link status line */ - /* Set P2_1 to input, pull-down */ - P2DIR &= ~(1 << 1); - P2INP |= P2INP_MDP2_1_TRISTATE; + /* Set pin to input */ + BT_PDIR &= ~(1 << BT_LINK_PIN_INDEX); + + /* Set pin to tri-state */ + BT_PINP |= (1 << BT_LINK_PIN_INDEX); - /* Enable P2 interrupts */ - IEN2 |= IEN2_P2IE; + /* Enable interrupts */ + IEN2 |= BT_IEN2_PIE; + + /* Check current pin state */ ao_btm_check_link(); + +#if BT_LINK_ON_P2 + /* Eable the pin interrupt */ PICTL |= PICTL_P2IEN; +#endif +#if BT_LINK_ON_P1 + /* Enable pin interrupt */ + P1IEN |= (1 << BT_LINK_PIN_INDEX); +#endif ao_add_task(&ao_btm_task, ao_btm, "bt"); } diff --git a/src/ao_log_telem.c b/src/ao_log_telem.c new file mode 100644 index 00000000..1b472efe --- /dev/null +++ b/src/ao_log_telem.c @@ -0,0 +1,30 @@ +/* + * 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 +ao_log_write_erase(uint8_t pos) +{ + (void) pos; +} + +uint8_t +ao_log_present(void) +{ + return 0; +} diff --git a/src/ao_pins.h b/src/ao_pins.h index 324d7827..4a03ca50 100644 --- a/src/ao_pins.h +++ b/src/ao_pins.h @@ -241,6 +241,45 @@ #define SPI_CS_ON_P1 1 #define SPI_CS_ON_P0 0 #define HAS_IGNITE 0 + #define BT_LINK_ON_P2 1 + #define BT_LINK_ON_P1 0 + #define BT_LINK_PIN_INDEX 7 + #define BT_LINK_PIN P2_1 +#endif + +#if defined(TELEBT_V_0_1) + #define HAS_FLIGHT 0 + #define HAS_USB 1 + #define HAS_BEEP 1 + #define HAS_SERIAL_1 1 + #define HAS_SERIAL_1_ALT_1 1 + #define HAS_SERIAL_1_ALT_2 0 + #define HAS_SERIAL_1_HW_FLOW 1 + #define USE_SERIAL_STDIN 1 + #define HAS_ADC 0 + #define HAS_DBG 1 + #define HAS_EEPROM 1 + #define USE_INTERNAL_FLASH 0 + #define HAS_BTM 1 + #define DBG_ON_P1 1 + #define DBG_ON_P0 0 + #define IGNITE_ON_P2 0 + #define IGNITE_ON_P0 0 + #define PACKET_HAS_MASTER 1 + #define PACKET_HAS_SLAVE 0 + #define AO_LED_RED 1 + #define AO_LED_GREEN 2 + #define LEDS_AVAILABLE (AO_LED_RED|AO_LED_GREEN) + #define SPI_CS_ON_P1 1 + #define SPI_CS_ON_P0 0 + #define M25_CS_MASK 0x04 /* CS0 is P1_2 */ + #define M25_MAX_CHIPS 1 + #define HAS_ACCEL 0 + #define HAS_IGNITE 0 + #define BT_LINK_ON_P2 0 + #define BT_LINK_ON_P1 1 + #define BT_LINK_PIN_INDEX 7 + #define BT_LINK_PIN P1_7 #endif #if DBG_ON_P1 diff --git a/src/ao_serial.c b/src/ao_serial.c index 9c0b798d..2e7dad7b 100644 --- a/src/ao_serial.c +++ b/src/ao_serial.c @@ -127,6 +127,18 @@ ao_serial_set_speed(uint8_t speed) void ao_serial_init(void) { +#if HAS_SERIAL_1_ALT_1 + /* Set up the USART pin assignment */ + PERCFG = (PERCFG & ~PERCFG_U1CFG_ALT_MASK) | PERCFG_U1CFG_ALT_1; + + P2DIR = (P2DIR & ~P2DIR_PRIP0_MASK) | P2DIR_PRIP0_USART1_USART0; + + /* Make the USART pins be controlled by the USART */ + P0SEL |= (1 << 5) | (1 << 4); +#if HAS_SERIAL_1_HW_FLOW + P0SEL |= (1 << 3) | (1 << 2); +#endif +#else /* Set up the USART pin assignment */ PERCFG = (PERCFG & ~PERCFG_U1CFG_ALT_MASK) | PERCFG_U1CFG_ALT_2; @@ -135,6 +147,8 @@ ao_serial_init(void) /* Make the USART pins be controlled by the USART */ P1SEL |= (1 << 6) | (1 << 7); + P1SEL |= (1 << 5) | (1 << 4); +#endif /* UART mode with receiver enabled */ U1CSR = (UxCSR_MODE_UART | UxCSR_RE); @@ -144,7 +158,11 @@ ao_serial_init(void) /* Reasonable serial parameters */ U1UCR = (UxUCR_FLUSH | +#if HAS_SERIAL_1_HW_FLOW + UxUCR_FLOW_ENABLE | +#else UxUCR_FLOW_DISABLE | +#endif UxUCR_D9_EVEN_PARITY | UxUCR_BIT9_8_BITS | UxUCR_PARITY_DISABLE | diff --git a/src/ao_telebt.c b/src/ao_telebt.c index 295f0cec..8e77c4d9 100644 --- a/src/ao_telebt.c +++ b/src/ao_telebt.c @@ -26,7 +26,14 @@ main(void) ao_led_init(LEDS_AVAILABLE); ao_led_on(AO_LED_RED); ao_timer_init(); +#if HAS_BEEP + ao_beep_init(); +#endif ao_cmd_init(); +#if HAS_EEPROM + ao_spi_init(); + ao_storage_init(); +#endif ao_usb_init(); ao_monitor_init(AO_LED_GREEN, TRUE); ao_rssi_init(AO_LED_RED); diff --git a/src/ao_usb.c b/src/ao_usb.c index ece6756a..e4b7938d 100644 --- a/src/ao_usb.c +++ b/src/ao_usb.c @@ -46,7 +46,6 @@ void ao_usb_isr(void) __interrupt 6 { USBIF = 0; - IRCON2 &= ~IRCON2_USBIF; ao_usb_iif |= USBIIF; if (ao_usb_iif & 1) ao_wakeup(&ao_usb_task); @@ -59,8 +58,10 @@ ao_usb_isr(void) __interrupt 6 if (USBCIF & USBCIF_RSTIF) ao_usb_set_interrupts(); #if HAS_BTM +#if BT_LINK_ON_P2 ao_btm_isr(); #endif +#endif } struct ao_usb_setup { diff --git a/src/cc1111.h b/src/cc1111.h index a07490e5..5b018cb5 100644 --- a/src/cc1111.h +++ b/src/cc1111.h @@ -589,6 +589,12 @@ sfr at 0xFD P0DIR; sfr at 0xFE P1DIR; sfr at 0xFF P2DIR; +#define P2DIR_PRIP0_USART0_USART1 (0 << 6) +#define P2DIR_PRIP0_USART1_USART0 (1 << 6) +#define P2DIR_PRIP0_TIMER1_01_USART1 (2 << 6) +#define P2DIR_PRIP0_TIMER1_2_USART0 (3 << 6) +#define P2DIR_PRIP0_MASK (3 << 6) + sfr at 0x8F P0INP; /* Select between tri-state and pull up/down diff --git a/src/telebt-v0.1/.gitignore b/src/telebt-v0.1/.gitignore new file mode 100644 index 00000000..1acfbfcc --- /dev/null +++ b/src/telebt-v0.1/.gitignore @@ -0,0 +1,2 @@ +telebt-* +ao_product.h diff --git a/src/telebt-v0.1/.sdcdbrc b/src/telebt-v0.1/.sdcdbrc new file mode 100644 index 00000000..710b4a2f --- /dev/null +++ b/src/telebt-v0.1/.sdcdbrc @@ -0,0 +1 @@ +--directory=.. diff --git a/src/telebt-v0.1/Makefile b/src/telebt-v0.1/Makefile new file mode 100644 index 00000000..d8867b19 --- /dev/null +++ b/src/telebt-v0.1/Makefile @@ -0,0 +1 @@ +include ../Makefile.proto diff --git a/src/telebt-v0.1/Makefile.defs b/src/telebt-v0.1/Makefile.defs new file mode 100644 index 00000000..50657c83 --- /dev/null +++ b/src/telebt-v0.1/Makefile.defs @@ -0,0 +1,8 @@ +PROG = telebt-v0.1-$(VERSION).ihx + +SRC = \ + $(TBT_V_0_1_SRC) + +PRODUCT=TeleBT-v0.1 +PRODUCT_DEF=-DTELEBT_V_0_1 +IDPRODUCT=0x000e