]> oss.titaniummirror.com Git - tinyos-2.x.git/commitdiff
baudrates revisited
authorandreaskoepke <andreaskoepke>
Wed, 5 Mar 2008 11:14:00 +0000 (11:14 +0000)
committerandreaskoepke <andreaskoepke>
Wed, 5 Mar 2008 11:14:00 +0000 (11:14 +0000)
tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyC.nc
tos/platforms/eyesIFX/byte_radio/Uart4b6bPhyP.nc
tos/platforms/eyesIFX/byte_radio/UartManchPhyP.nc
tos/platforms/eyesIFX/byte_radio/code4b6b.h
tos/platforms/eyesIFX/byte_radio/manchester.h [new file with mode: 0644]
tos/platforms/eyesIFX/chips/msp430/Msp430DcoSpec.h
tos/platforms/eyesIFX/chips/tda5250/eyesIFXBaudrates.h [new file with mode: 0644]
tos/platforms/eyesIFX/chips/tda5250/tda5250BusResourceSettings.h
tos/platforms/eyesIFX/chips/tda5250/tda5250RegDefaultSettings.h
tos/platforms/eyesIFX/eyesIFXSerialP.nc

index fe2fb3beba885a130f10e9466747b26b0055a7d2..4e794f3e323a44e2864c84f1897c36668c3946a5 100644 (file)
@@ -64,4 +64,10 @@ implementation
     UartPhyControl = Uart4b6bPhyP;
     
     Uart4b6bPhyP.RxByteTimer -> RxByteTimer;
+    
+#ifdef UART_DEBUG
+    components new SerialDebugC() as SD;
+    Uart4b6bPhyP.SerialDebug -> SD;
+#endif
+
 }
index 4b830dfe733777e4f5dd04c50743ef5bf68361fb..dce79576a1fb2df597f2cebc611ac65ccf759a65 100644 (file)
@@ -47,10 +47,21 @@ module Uart4b6bPhyP {
     uses {
         interface RadioByteComm;
         interface Alarm<T32khz, uint16_t> as RxByteTimer;
+#ifdef UART_DEBUG
+        interface SerialDebug;
+#endif
     }
 }
 implementation
 {
+#ifdef UART_DEBUG
+    void sdDebug(uint16_t p) {
+        call SerialDebug.putPlace(p);
+    }
+#else
+    void sdDebug(uint16_t p) {};
+#endif
+
     /* Module Definitions  */
     typedef enum {
         STATE_PREAMBLE,
@@ -72,7 +83,7 @@ implementation
     /* constants */
     enum {
         PREAMBLE_LENGTH=2,
-        BYTE_TIME=21,
+        BYTE_TIME=ENCODED_32KHZ_BYTE_TIME+3,
         PREAMBLE_BYTE=0x55,
         SYNC_BYTE=0xFF,
         SFD_BYTE=0x83,
@@ -96,6 +107,9 @@ implementation
             numPreambles = PREAMBLE_LENGTH;
             byteTime = BYTE_TIME;
         }
+#ifdef UART_DEBUG
+        call SerialDebug.putShortDesc("U4b6bP");
+#endif
         return SUCCESS;
     }
     
@@ -123,8 +137,9 @@ implementation
         call RxByteTimer.stop();
         if(phyState >= STATE_DATA_HIGH) {
             signal PhyPacketRx.recvFooterDone(FAIL);
+            sdDebug(10);
         }
-        phyState = STATE_PREAMBLE; 
+        phyState = STATE_PREAMBLE;
     }
 
     async event void RxByteTimer.fired() {
@@ -182,6 +197,7 @@ implementation
         phyState = STATE_PREAMBLE;
         call RxByteTimer.stop();
         signal PhyPacketRx.recvFooterDone(SUCCESS);
+        sdDebug(20);
     }
 
     
index 0b39150e5c7797c645332f4ee96c1b058a897d06..c52a9f5c6fa3a5f1406ce78b717dd342f03b68fb 100644 (file)
@@ -75,7 +75,7 @@ implementation
     } phyState_t;
 
 #define PREAMBLE_LENGTH   2
-#define BYTE_TIME         21
+#define BYTE_TIME         TDA5250_32KHZ_BYTE_TIME
 #define PREAMBLE_BYTE     0x55
 #define SYNC_BYTE         0xFF
 #define SFD_BYTE          0x50
index f376f86bd635f5d5412d1fb8bcf7506ccb9ffad9..d504f829f21e4e023abb7de079c66d2ec9a36af2 100644 (file)
@@ -38,7 +38,8 @@
 #define CODE_4B_6B_H
 
 enum {
-    ILLEGAL_CODE = 0xff
+    ILLEGAL_CODE = 0xff,
+    ENCODED_32KHZ_BYTE_TIME = 3*TDA5250_32KHZ_BYTE_TIME/2
 };
 
 const uint8_t nibbleToSixBit[] = {
diff --git a/tos/platforms/eyesIFX/byte_radio/manchester.h b/tos/platforms/eyesIFX/byte_radio/manchester.h
new file mode 100644 (file)
index 0000000..2585ff1
--- /dev/null
@@ -0,0 +1,170 @@
+/* -*- mode:c++; indent-tabs-mode: nil -*-
+ * Copyright (c) 2006, Technische Universitaet Berlin
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ *   this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universitaet Berlin nor the names
+ *   of its contributors may be used to endorse or promote products derived
+ *   from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * - Description ---------------------------------------------------------
+ * provide functions to encode/decode a manchester stream
+ * - Revision -------------------------------------------------------------
+ * $Revision$
+ * $Date$
+ * @author Andreas Koepke <koepke@tkn.tu-berlin.de>
+ * ========================================================================
+ */
+
+enum {
+    ILLEGAL_CODE = 0xff,
+    ENCODED_32KHZ_BYTE_TIME = 2*TDA5250_32KHZ_BYTE_TIME
+};
+
+const uint8_t nibbleToManchesterByte[] = {
+    0x55,
+    0x56,
+    0x59,
+    0x5a,
+    0x65,
+    0x66,
+    0x69,
+    0x6a,
+    0x95,
+    0x96,
+    0x99,
+    0x9a,
+    0xa5,
+    0xa6,
+    0xa9,
+    0xaa
+};
+
+const uint8_t manchesterByteToNibble[] = {
+    0x0,
+    0x1,
+    0xff,
+    0xff,
+    0x2,
+    0x3,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0x4,
+    0x5,
+    0xff,
+    0xff,
+    0x6,
+    0x7,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0x8,
+    0x9,
+    0xff,
+    0xff,
+    0xa,
+    0xb,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xff,
+    0xc,
+    0xd,
+    0xff,
+    0xff,
+    0xe,
+    0xf
+};
+
+uint8_t manchesterEncodeNibble(uint8_t nib) 
+{
+    return nibbleToManchesterByte[nib];
+}
+
+uint8_t manchesterDecodeByte(uint8_t b) 
+{
+    uint8_t dec;
+    
+    if(b < 0x55) {
+        dec = 0xff;
+    }
+    else if(b > 0xaa) {
+        dec = 0xff;
+    }
+    else {
+        dec = manchesterByteToNibble[b - 0x55];
+    }
+    return dec;
+}
index ae6c97c8eb383aa1f7b7f203628b56db771e4f29..54f17cc0beb2efb6070328933e916c638465ad5a 100644 (file)
@@ -40,6 +40,6 @@
 #ifndef MS430DCOSPEC_H
 #define MS430DCOSPEC_H
 
-#define TARGET_DCO_KHZ 3906 // the target MCLK clock rate in binary kHz (4 000 000 Hz)
+#define TARGET_DCO_KHZ 3926 // the target MCLK clock rate in binary kHz (4 020 000 Hz)
 #define ACLK_KHZ 32 // the ACLK rate in binary kHz
 #endif
diff --git a/tos/platforms/eyesIFX/chips/tda5250/eyesIFXBaudrates.h b/tos/platforms/eyesIFX/chips/tda5250/eyesIFXBaudrates.h
new file mode 100644 (file)
index 0000000..2863240
--- /dev/null
@@ -0,0 +1,68 @@
+/* auto generated from tda5250BusResourceSettings.h using the following perl script: 
+
+#!/usr/bin/perl -w
+use strict;
+my $state = "START";
+my $br;
+while(<>) {
+    if(/UBR_1MHZ_/) {
+       ($br) = /UBR_1MHZ_(\d+)/;
+       if($state eq "START") {
+           print '#if ';
+           $state = "MIDDLE";
+       }
+       else {
+           print '#elif ';
+       }
+       print 'TDA5250_UART_BAUDRATE == ', $br,"\n";
+       print '#define TDA5250_UART_UBR UBR_1MHZ_', $br, "\n";
+       print '#define TDA5250_UART_UMCTL UMCTL_1MHZ_', $br, "\n";
+    }
+}
+print '#endif',"\n"
+
+*/
+
+#if TDA5250_UART_BAUDRATE == 35108
+#define TDA5250_UART_UBR UBR_1MHZ_35108
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_35108
+#elif TDA5250_UART_BAUDRATE == 10240
+#define TDA5250_UART_UBR UBR_1MHZ_10240
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_10240
+#elif TDA5250_UART_BAUDRATE == 10922
+#define TDA5250_UART_UBR UBR_1MHZ_10922
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_10922
+#elif TDA5250_UART_BAUDRATE == 11702
+#define TDA5250_UART_UBR UBR_1MHZ_11702
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_11702
+#elif TDA5250_UART_BAUDRATE == 12603
+#define TDA5250_UART_UBR UBR_1MHZ_12603
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_12603
+#elif TDA5250_UART_BAUDRATE == 13653
+#define TDA5250_UART_UBR UBR_1MHZ_13653
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_13653
+#elif TDA5250_UART_BAUDRATE == 14894
+#define TDA5250_UART_UBR UBR_1MHZ_14894
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_14894
+#elif TDA5250_UART_BAUDRATE == 16384
+#define TDA5250_UART_UBR UBR_1MHZ_16384
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_16384
+#elif TDA5250_UART_BAUDRATE == 18204
+#define TDA5250_UART_UBR UBR_1MHZ_18204
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_18204
+#elif TDA5250_UART_BAUDRATE == 20480
+#define TDA5250_UART_UBR UBR_1MHZ_20480
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_20480
+#elif TDA5250_UART_BAUDRATE == 23405
+#define TDA5250_UART_UBR UBR_1MHZ_23405
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_23405
+#elif TDA5250_UART_BAUDRATE == 27306
+#define TDA5250_UART_UBR UBR_1MHZ_27306
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_27306
+#elif TDA5250_UART_BAUDRATE == 32768
+#define TDA5250_UART_UBR UBR_1MHZ_32768
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_32768
+#elif TDA5250_UART_BAUDRATE == 40960
+#define TDA5250_UART_UBR UBR_1MHZ_40960
+#define TDA5250_UART_UMCTL UMCTL_1MHZ_40960
+#endif
index a4ab9cc1e9eb25b3ae7f245db43f6f728b56f4ee..9093ba4b41aeab34f60f042b13c7502ce0beb56f 100644 (file)
@@ -40,12 +40,39 @@ enum {
     TDA5250_UART_BUS_ID = unique(MSP430_UARTO_BUS)
 };
 
+/* frequency of crystal: 18089580 Hz,
+   divide by 18 -> 1004976 Hz */
+
+#ifndef TDA5250_UART_BAUDRATE
+#define TDA5250_UART_BAUDRATE 40960U
+#endif
+
 enum {
-    // real milli seconds
-    UBR_1MHZ_23405=0x002A,  UMCTL_1MHZ_23405=0xDD, // 23405 bit/s
-    UBR_1MHZ_35108=0x001C,  UMCTL_1MHZ_35108=0xAA, // 35108 bit/s    
+    /** for reference, not recommended for new experiments */
+    UBR_1MHZ_35108=0x001C,  UMCTL_1MHZ_35108=0xAA, // 35108 bit/s
+
+    /** use real frequency, use only settings that result in an even byte time */
+    UBR_1MHZ_10240=0x0062,  UMCTL_1MHZ_10240=0x08, // 10240 bit/s
+    UBR_1MHZ_10922=0x005C,  UMCTL_1MHZ_10922=0x00, // 10922 bit/s
+    UBR_1MHZ_11702=0x0055,  UMCTL_1MHZ_11702=0xEF, // 11702 bit/s
+    UBR_1MHZ_12603=0x004F,  UMCTL_1MHZ_12603=0xDD, // 12603 bit/s
+    UBR_1MHZ_13653=0x0049,  UMCTL_1MHZ_13653=0xB5, // 13653 bit/s
+    UBR_1MHZ_14894=0x0043,  UMCTL_1MHZ_14894=0xAA, // 14894 bit/s
+    UBR_1MHZ_16384=0x003D,  UMCTL_1MHZ_16384=0x92, // 16384 bit/s
+    UBR_1MHZ_18204=0x0037,  UMCTL_1MHZ_18204=0x84, // 18204 bit/s
+    UBR_1MHZ_20480=0x0031,  UMCTL_1MHZ_20480=0x80, // 20480 bit/s
+    UBR_1MHZ_23405=0x002A,  UMCTL_1MHZ_23405=0x7F, // 23405 bit/s
+    UBR_1MHZ_27306=0x0024,  UMCTL_1MHZ_27306=0x7B, // 27306 bit/s
+    UBR_1MHZ_32768=0x001E,  UMCTL_1MHZ_32768=0x5B, // 32768 bit/s
+    UBR_1MHZ_40960=0x0018,  UMCTL_1MHZ_40960=0x55, // 40960 bit/s
 };
 
-msp430_uart_union_config_t tda5250_uart_config = { {ubr: UBR_1MHZ_35108, umctl: UMCTL_1MHZ_35108, ssel: 0x02, pena: 0, pev: 0, spb: 0, clen: 1, listen: 0, mm: 0, ckpl: 0, urxse: 0, urxeie:0, urxwie: 0, urxe: 1, utxe: 0} };
+#include "eyesIFXBaudrates.h"
+
+msp430_uart_union_config_t tda5250_uart_config = { {ubr: TDA5250_UART_UBR, umctl: TDA5250_UART_UMCTL, ssel: 0x02, pena: 0, pev: 0, spb: 0, clen: 1, listen: 0, mm: 0, ckpl: 0, urxse: 0, urxeie:0, urxwie: 0, urxe: 1, utxe: 0} };
+
+enum {
+    TDA5250_32KHZ_BYTE_TIME = (32768UL*10)/TDA5250_UART_BAUDRATE
+};
 
 #endif
index 561ecb5c47901791046484d2d7f8c5786bcdad95..b15f3a51a353f9e64ac82577e1403447ce3f4adc 100644 (file)
@@ -71,7 +71,7 @@
 // choose one
 #define INITIAL_RF_POWER RF_HITX_DAMPING_0dB
 
-#define TDA5250_REG_DEFAULT_SETTING_CONFIG           FULL_RANGE
+#define TDA5250_REG_DEFAULT_SETTING_CONFIG           MED_RANGE_LP
 #define TDA5250_REG_DEFAULT_SETTING_FSK              0x0A0C
 #define TDA5250_REG_DEFAULT_SETTING_XTAL_TUNING      0x0012
 #define TDA5250_REG_DEFAULT_SETTING_LPF              0x98 
index 933b288e4e934ebb65fdeb1048f0f3c9f942e974..4d946689819584c1b8923e07e478ba4856252e97 100644 (file)
@@ -5,8 +5,7 @@ module eyesIFXSerialP {
 }
 implementation {
   enum {
-     // true mega hertz
-     UBR_1MHZ_57601=0x0011,  UMCTL_1MHZ_57601=0x52 // 57600 bit/s
+     UBR_1MHZ_57601=0x0011,  UMCTL_1MHZ_57601=0xAA // 57600 bit/s
   };                        
 
   msp430_uart_union_config_t msp430_uart_eyes_config = { {ubr: UBR_1MHZ_57601, umctl: UMCTL_1MHZ_57601, ssel: 0x02, pena: 0, pev: 0, spb: 0, clen: 1, listen: 0, mm: 0, ckpl: 0, urxse: 0, urxeie: 1, urxwie: 0, urxe: 1, utxe: 1} };