UartPhyControl = Uart4b6bPhyP;
Uart4b6bPhyP.RxByteTimer -> RxByteTimer;
+
+#ifdef UART_DEBUG
+ components new SerialDebugC() as SD;
+ Uart4b6bPhyP.SerialDebug -> SD;
+#endif
+
}
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,
/* constants */
enum {
PREAMBLE_LENGTH=2,
- BYTE_TIME=21,
+ BYTE_TIME=ENCODED_32KHZ_BYTE_TIME+3,
PREAMBLE_BYTE=0x55,
SYNC_BYTE=0xFF,
SFD_BYTE=0x83,
numPreambles = PREAMBLE_LENGTH;
byteTime = BYTE_TIME;
}
+#ifdef UART_DEBUG
+ call SerialDebug.putShortDesc("U4b6bP");
+#endif
return SUCCESS;
}
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() {
phyState = STATE_PREAMBLE;
call RxByteTimer.stop();
signal PhyPacketRx.recvFooterDone(SUCCESS);
+ sdDebug(20);
}
} 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
#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[] = {
--- /dev/null
+/* -*- 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_BY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{
+ dec = 0xff;
+ }
+ else {
+ dec = manchesterByteToNibble[b - 0x55];
+ }
+ return dec;
+}
#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
--- /dev/null
+/* 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
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
// 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
}
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} };