Hi Eric,

Thank you for your time. No, my code is not on github. I just downloaded
and installed tinyprod last week and all the files I have are EXACTLY the
same as in tinyprod except for 3 changes I've made so far. I will post the
3 files I changed here:

1. PlatformLedP.nc (in tinyos-2.x/tos/platforms/surf/hardware/leds) --->
changed LED pins as my LEDs are connected to P1.7 (red), P3.6 (green) and
P3.7 (orange).

*************************************************************************************************************************************************************************

/*
 * Copyright (c) 2009-2010 People Power Company
 * All rights reserved.
 *
 * This open source code was developed with funding from People Power
Company
 *
 * 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 copyright holders 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 HOLDER 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.
 */

/**
 * Implement the LED-relevant interfaces for the SuRF platform.
 *
 * Traditionally, the PlatformLedsC component has exported named
 * GeneralIO interfaces, which are subsequently used in a LedsP
 * implementation to support the Leds interface.  Whether an LED is
 * active-high or active-low is platform specific, and therefore
 * should not be delegated to a supposedly platform-dependent
 * component.
 *
 * We need to implement the LED functionality here.  But we're in the
 * platform-specific file, so we know we're using an MSP430.  There's
 * no point in trying to use generic GeneralIO interfaces to interact
 * with the registers.  Eliminating them, while using a table to
 * identify LED positions, drops the code size by about 64 bytes and
 * makes the interface cleaner.
 *
 * @author Peter A. Bigot <[email protected]>
 */

module PlatformLedP {
  provides {
    interface Init;
    interface Leds;
    interface Led[uint8_t led_id];
    interface MultiLed;
  }
} implementation {

#include "PlatformLed.h"

  /**
   * Layout of the relevant portions of an MSP430XV2 digital IO port
   * bank.
   */
  typedef struct port_t {
      uint16_t pxin;            /* 0x00: Input */
      uint16_t pxout;           /* 0x02: Output */
      uint16_t pxdir;           /* 0x04: Direction */
      uint16_t pxren;           /* 0x06: Resistor Enable */
      uint16_t pxds;            /* 0x08: Drive Strength */
      uint16_t pxsel;           /* 0x0A: Port Select */
  } port_t;

  /** Required information to specify a digital pin that controls an LED */
  typedef struct led_t {
    volatile port_t* port;
    uint16_t bit;
  } led_t;

  /*
   * @TODO@ When msp430-libc is corrected, reference PAIN and PBIN, to
   * make it more clear that we're operating on the 16-bit interface
   * to the ports.
   */

  const static led_t leds[] = {
#if defined(SURF_REV_BLOCK_A)
    { (port_t*)P3IN_, 1 << 1 }, // Green
    { (port_t*)P3IN_, 1 << 2 }, // Red

#elif defined(SURF_REV_A)
    //{ (port_t*)P1IN_, 1 << 0 }, // Blue
    //{ (port_t*)P1IN_, 1 << 1 }, // White
    { (port_t*)P1IN_, 1 << 7 }, // Red
    { (port_t*)P3IN_, 1 << 6 }, // (Yellow) Green
    { (port_t*)P3IN_, 1 << 7 }, // (Green) Orange

#else
    { (port_t*)P3IN_, 1 << 0 }, // Green
    { (port_t*)P3IN_, 1 << 1 }, // Red
    { (port_t*)P3IN_, 1 << 2 }, // White
    { (port_t*)P3IN_, 1 << 3 }, // Orange
    { (port_t*)P3IN_, 1 << 4 }, // Blue
#endif        /* SURF_REV_BLOCK_A */
  };

  static const int nleds = sizeof(leds) / sizeof(*leds);

  command error_t Init.init() {
    atomic {
      int li;

      for (li = 0; li < nleds; ++li) {
        const led_t* lp = leds + li;
        lp->port->pxout &= ~lp->bit;
        lp->port->pxdir |= lp->bit;
      }
    }
    return SUCCESS;
  }

  void _LEDon (uint8_t led_id) {
    if(led_id < nleds) {
      const led_t* lp = leds + led_id;
      atomic lp->port->pxout |= lp->bit;
    }
  }

  void _LEDoff (uint8_t led_id) {
    if(led_id < nleds) {
      const led_t* lp = leds + led_id;
      atomic lp->port->pxout &= ~lp->bit;
    }
  }

  void _LEDtoggle (uint8_t led_id) {
    if (led_id < nleds) {
      const led_t* lp = leds + led_id;
      atomic lp->port->pxout ^= lp->bit;
    }
  }

  unsigned int _LEDread () {
    unsigned int val = 0;
    int li;

    for (li = 0; li < nleds; ++li) {
      const led_t* lp = leds + li;
      val |= (!! (lp->port->pxout & lp->bit)) << li;
    }
    return val;
  }

  void _LEDwrite (unsigned int value) {
    int li;

    for (li = 0; li < nleds; ++li) {
      if (value & (1 << li)) {
        _LEDon(li);
      } else {
        _LEDoff(li);
      }
    }
  }

  /*
   * I don't think we'd save much space by not implementing the legacy
   * interface always, so rather than complicate compilation let's
   * always support it.
   */
  async command void Leds.led0Off ()      { _LEDoff(0); }
  async command void Leds.led0On ()       { _LEDon(0); }
  async command void Leds.led0Toggle ()   { _LEDtoggle(0); }
  async command void Leds.led1Off ()      { _LEDoff(1); }
  async command void Leds.led1On ()       { _LEDon(1); }
  async command void Leds.led1Toggle ()   { _LEDtoggle(1); }
  async command void Leds.led2Off ()      { _LEDoff(2); }
  async command void Leds.led2On ()       { _LEDon(2); }
  async command void Leds.led2Toggle ()   { _LEDtoggle(2); }
  async command uint8_t Leds.get ()       { return _LEDread(); }
  async command void Leds.set (uint8_t v) { _LEDwrite(v); }

  async command unsigned int MultiLed.get ()            { return
_LEDread(); }
  async command void MultiLed.set (unsigned int value)  { _LEDwrite(value);
}
  async command void MultiLed.on (unsigned int led_id)  { _LEDon(led_id); }
  async command void MultiLed.off (unsigned int led_id) { _LEDoff(led_id); }

  async command void MultiLed.setSingle (unsigned int led_id, bool on) {
    if (on) { _LEDon(led_id); }
    else    { _LEDoff(led_id); }
  }

  async command void MultiLed.toggle (unsigned int led_id) {
_LEDtoggle(led_id); }
  async command void Led.on[uint8_t led_id] ()             { call
MultiLed.on(led_id); }
  async command void Led.off[uint8_t led_id] ()            { call
MultiLed.off(led_id); }
  async command void Led.set[uint8_t led_id] (bool on)     { call
MultiLed.setSingle(led_id, on); }
  async command void Led.toggle[uint8_t led_id] ()         { call
MultiLed.toggle(led_id); }
}

*************************************************************************************************************************************************************************
*************************************************************************************************************************************************************************

2. PlatformsPinsP.nc (in tinyos-2.x/tos/platforms/surf/hardware/pins) ->
changed RX and TX UART pins as mine are connected to P2.0 and P2.1.

*************************************************************************************************************************************************************************

/*
 * Copyright (c) 2009-2010 People Power Company
 * All rights reserved.
 *
 * This open source code was developed with funding from People Power
Company
 *
 * 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 copyright holders 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 HOLDER 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.
 */

/**
 * @author David Moss
 * @author Peter A. Bigot <[email protected]>
 */

module PlatformPinsP {
  provides {
    interface Init;
  }
}

implementation {

  command error_t Init.init() {
    atomic {

#if defined(__msp430_have_port1) || defined(__MSP430_HAS_PORT1__) ||
defined(__MSP430_HAS_PORT1_R__)
      P1DIR = 0xFF;
      P1OUT = 0x0;

//also define these PINS::

/*PMAPPWD = PMAPPW;                         // Get write-access to port
mapping regs
  P2MAP1 = PM_UCA0TXD;                      // Map UCA0TXD output to P2.1
    //P2MAP0 = PM_UCA0RXD;                      // Map UCA0TXD output to
P2.1
  PMAPPWD = 0;                              // Lock port mapping registers


  P2DIR |= BIT1;                            // Set P2.1 as TX output
  P2SEL |= BIT1;                            // Select P2.1 UART function*/


#endif

#if defined(__msp430_have_port2) || defined(__MSP430_HAS_PORT2__) ||
defined(__MSP430_HAS_PORT2_R__)
      P2DIR = 0xFF;
      P2OUT = 0x0;
#endif

#if defined(__msp430_have_port3) || defined(__MSP430_HAS_PORT3__) ||
defined(__MSP430_HAS_PORT3_R__)
      P3DIR = 0xFF;
      P3OUT = 0x0;
#endif

#if defined(__msp430_have_port4) || defined(__MSP430_HAS_PORT4__) ||
defined(__MSP430_HAS_PORT4_R__)
      P4DIR = 0xFF;
      P4OUT = 0x0;
#endif

#if defined(__msp430_have_port5) || defined(__MSP430_HAS_PORT5__) ||
defined(__MSP430_HAS_PORT5_R__)
      P5DIR = 0xFF;
      P5OUT = 0x0;
#endif

#if defined(__msp430_have_port6) || defined(__MSP430_HAS_PORT6__) ||
defined(__MSP430_HAS_PORT6_R__)
      P6DIR = 0xFF;
      P6OUT = 0x0;
#endif

#if defined(__msp430_have_port7) || defined(__MSP430_HAS_PORT7__) ||
defined(__MSP430_HAS_PORT7_R__)
      P7DIR = 0xFF;
      P7OUT = 0x0;
#endif

#if defined(__msp430_have_port8) || defined(__MSP430_HAS_PORT8__) ||
defined(__MSP430_HAS_PORT8_R__)
      P8DIR = 0xFF;
      P8OUT = 0x0;
#endif

#if defined(__msp430_have_port9) || defined(__MSP430_HAS_PORT9__) ||
defined(__MSP430_HAS_PORT9_R__)
      P9DIR = 0xFF;
      P9OUT = 0x0;
#endif

#if defined(__msp430_have_port10) || defined(__MSP430_HAS_PORT10__) ||
defined(__MSP430_HAS_PORT10_R__)
      P10DIR = 0xFF;
      P10OUT = 0x0;
#endif

#if defined(__msp430_have_port11) || defined(__MSP430_HAS_PORT11__) ||
defined(__MSP430_HAS_PORT11_R__)
      P11DIR = 0xFF;
      P11OUT = 0x0;
#endif

#if defined(__msp430_have_portJ) || defined(__MSP430_HAS_PORTJ__) ||
defined(__MSP430_HAS_PORTJ_R__)
      PJDIR = 0xFF;
      PJOUT = 0x0;
#endif

#if defined(SURF_REV_A) /* Disabled: these specific setting sare defaults,
but others might not be */
      PMAPPWD = PMAPPW;                         // Get write-access to port
mapping regs
      //P1MAP5 = PM_UCA0RXD;                      // Map UCA0RXD output to
P1.5
      //P1MAP6 = PM_UCA0TXD;                      // Map UCA0TXD output to
P1.6
    P2MAP0 = PM_UCA0RXD;                      // Map UCA0RXD output to P2.0
          P2MAP1 = PM_UCA0TXD;                      // Map UCA0TXD output
to P2.1
      PMAPPWD = 0;                              // Lock port mapping
registers
#endif

    }
    return SUCCESS;
  }
}

*************************************************************************************************************************************************************************
*************************************************************************************************************************************************************************

3. surf.target (in tinyos-2.x/support/make) -> set REV A as default

*************************************************************************************************************************************************************************

# Target definition for the People Power Company Sensor Ultra Radio
Frequency
# development board.

# Unless otherwise specified, assume revision B2 of the SuRF board
SURF_REV ?= A
HAS_FLASH ?= 1

#IAR_MCU_GROUP = cc430x513x
#IAR_LINKER_XCL = lnkcc430F5137.xcl

PLATFORM ?= surf
MSP_MCU = cc430f5137
PFLAGS += -DSURF_REV_$(SURF_REV)
PFLAGS += -DPLATFORM_HAS_FLASH=$(HAS_FLASH)

MSP_BSL ?= cc430-bsl
MSP_BSL_FLAGS += --surf

$(call TOSMake_include_platform,msp)
$(call TOSMake_include_platform,surf)

surf: $(BUILD_DEPS)
        @:

*************************************************************************************************************************************************************************
*************************************************************************************************************************************************************************

Regards
Jorge


On Mon, Jun 3, 2013 at 6:06 PM, Eric Decker <[email protected]> wrote:

>
> Too hard to debug this out of context.
>
> Is your code up on github?
>
> Send me a pointer and I'll look at it.
>
> I maintain the msp430 code in tinyos and in particular the x5 extensions
> in tinyprod.
>
>
>
> On Mon, Jun 3, 2013 at 8:22 AM, Jorge Silva <[email protected]>wrote:
>
>> Hi,
>>
>> I have a CC430f5137 based custom mote on which I've been able to compile
>> the Blink example, by setting the SURF platform as REV A (I'm using
>> Tinyprod). For Blink to work I had to change the LED pins, as the LEDs on
>> the SURF REV A board are connected to P1.0, P1.1, P1.2, P3.6 and 3.7.
>> I changed these to match my mote (my mote has LEDs connected to P1.7,
>> P3.6 and P3.7) in the PlatformLedP.nc file (in
>> tos/platforms/surf/hardware/leds) as follows:
>>
>> #elif defined(SURF_REV_A)
>>     //{ (port_t*)P1IN_, 1 << 0 }, // Blue
>>     //{ (port_t*)P1IN_, 1 << 1 }, // White
>>     { (port_t*)P1IN_, 1 << 7 }, // Red on my mote
>>     { (port_t*)P3IN_, 1 << 6 }, // Green on my mote
>>     { (port_t*)P3IN_, 1 << 7 }, // Orange on my mote
>>
>> Now I'm trying to get UART working but my FTDI cable's RX and TX pins are
>> connected to pins P2.0 and P2.1, respectively, and not to the default P1.5
>> and P1.6 pins. Hence, I made the following changes to the PlatformsPinsP.nc
>> file (in tos/platforms/surf/hardware/pins) to reflect this difference:
>>
>> //#if 0 /* Disabled:These specific setting sare defaults, but others
>> might not be */
>> #if defined(SURF_REV_A)
>>     PMAPPWD = PMAPPW;                         // Get write-access to port
>> mapping regs
>>     //P1MAP5 = PM_UCA0RXD;                      // Map UCA0RXD output to
>> P1.5
>>     //P1MAP6 = PM_UCA0TXD;                      // Map UCA0TXD output to
>> P1.6
>>     P2MAP0 = PM_UCA0RXD;                    // Map UCA0RXD output to P2.0
>>     P2MAP1 = PM_UCA0TXD;                    // Map UCA0TXD output to P2.1
>>     PMAPPWD = 0;                              // Lock port mapping
>> registers
>> #endif
>>
>> These two are the only files I've changed.
>> Flashing the TestSerial app to my mote does not produce any output when
>> "java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:115200" is run.
>> It hangs at "serial@/dev/ttyUSB0:115200: resynchronising" and nothing
>> happens.
>> If I use Putty with TestSerial running on my mote, I can see a sequence
>> of bytes being periodically displayed on Putty (they are unreadable, which
>> is expected) so I'm assuming the serial connection is fine.
>>
>> I tested the SerialTest app on a TelosB mote and "java
>> net.tinyos.tools.Listen -comm serial@/dev/ttyUSB0:115200" works 100%, so
>> I'm assuming my Java config is correct.
>>
>> And I know the serial connection is working 100% OUTSIDE TinyOS as I have
>> tested it with a UART CC430f5137 sample
>> C code from TI, by using:
>>
>> P2MAP1 = PM_UCA0TXD;         // Map UCA0TXD output to P2.1
>> P2DIR |= BIT1;                          // Set P2.1 as TX output
>> P2SEL |= BIT1;                         // Select P2.1 UART function
>>
>> Any ideas as to what is causing this issue?
>> Thanks!
>>
>> Regards
>> Jorge
>>
>> _______________________________________________
>> Tinyos-help mailing list
>> [email protected]
>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>>
>
>
>
> --
> Eric B. Decker
> Senior (over 50 :-) Researcher
>
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to