Merge branch 'telebt' into telescience
authorKeith Packard <keithp@keithp.com>
Wed, 11 May 2011 15:16:29 +0000 (08:16 -0700)
committerKeith Packard <keithp@keithp.com>
Wed, 11 May 2011 15:16:29 +0000 (08:16 -0700)
16 files changed:
ao-bringup/turnon_telebt [new file with mode: 0755]
debian/changelog
src/Makefile
src/Makefile.proto
src/ao.h
src/ao_btm.c
src/ao_log_telem.c [new file with mode: 0644]
src/ao_pins.h
src/ao_serial.c
src/ao_telebt.c
src/ao_usb.c
src/cc1111.h
src/telebt-v0.1/.gitignore [new file with mode: 0644]
src/telebt-v0.1/.sdcdbrc [new file with mode: 0644]
src/telebt-v0.1/Makefile [new file with mode: 0644]
src/telebt-v0.1/Makefile.defs [new file with mode: 0644]

diff --git a/ao-bringup/turnon_telebt b/ao-bringup/turnon_telebt
new file mode 100755 (executable)
index 0000000..3b8bd3e
--- /dev/null
@@ -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"
index 63d75356cdbf6364fed6cfa77d2adce53264c556..fe01210ddaeb7e68671106bcc4ebba044ebe9923 100644 (file)
@@ -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 <bdale@gag.com>  Fri, 18 Feb 2011 23:55:58 -0700
+ -- Bdale Garbee <bdale@gag.com>  Fri, 01 Apr 2011 20:02:12 -0600
 
 altos (0.9) unstable; urgency=low
 
index d83ec668b8e3a9a8a4fd6d9629100e15842fc18d..3eec3980f6ce9aff2da1fdb0f34ba4a5100194e6 100644 (file)
@@ -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
 
index ca68edbcba016322c3f80db92f8ac8fbe489c32f..c86de8236c096ef1bc00f605b7bdca3a812eb282 100644 (file)
@@ -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
 #
index 226f9a2248dd0425ebed6bf27593d245ce796384..600c488a00f98aed631f5a717429690e162e4c57 100644 (file)
--- 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);
index db0ff6b09371508a67c806856e7ec21b4c2b27c3..44155ec142aa934863daa384500726f503a3af09 100644 (file)
@@ -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 (file)
index 0000000..1b472ef
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * 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
+ao_log_write_erase(uint8_t pos)
+{
+       (void) pos;
+}
+
+uint8_t
+ao_log_present(void)
+{
+       return 0;
+}
index 324d78273daaca46c9900446ade5299a1a5d2ed8..4a03ca508ae9ab628ce17d554ec37c7c502b6243 100644 (file)
        #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
index 9c0b798daf674cfcd894fe07db4eefa4c7cab236..2e7dad7bb8f9c7da774de4dd8f763b66779743c9 100644 (file)
@@ -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 |
index 295f0cec8e3d30accce1fc58dd2d050c5582245b..8e77c4d9b2e41949e7e109216f8480d077b4e830 100644 (file)
@@ -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);
index ece6756a030c05bd104e1507a78879bafd54acac..e4b7938d8e85215fdabfc37be02b0e3c9e1386cb 100644 (file)
@@ -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 {
index a07490e52bc2ffa697cb2580e4506e1713735db0..5b018cb5168cd41020d0896017fab894353f76b3 100644 (file)
@@ -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 (file)
index 0000000..1acfbfc
--- /dev/null
@@ -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 (file)
index 0000000..710b4a2
--- /dev/null
@@ -0,0 +1 @@
+--directory=..
diff --git a/src/telebt-v0.1/Makefile b/src/telebt-v0.1/Makefile
new file mode 100644 (file)
index 0000000..d8867b1
--- /dev/null
@@ -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 (file)
index 0000000..50657c8
--- /dev/null
@@ -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