[Tinyos-2-commits] [tinyos-main] r5737 committed - ucmini: improved platform initialization

tinyos-main at googlecode.com tinyos-main at googlecode.com
Tue Sep 13 16:24:05 PDT 2011


Revision: 5737
Author:   mmaroti
Date:     Tue Sep 13 16:22:58 2011
Log:      ucmini: improved platform initialization
http://code.google.com/p/tinyos-main/source/detail?r=5737

Added:
  /trunk/tos/chips/atm128rfa1/adc/Atm128AdcC.nc
Modified:
  /trunk/tos/chips/atm128rfa1/McuInitC.nc
  /trunk/tos/chips/atm128rfa1/McuInitP.nc
  /trunk/tos/platforms/ucmini/PlatformC.nc
  /trunk/tos/platforms/ucmini/PlatformP.nc

=======================================
--- /dev/null
+++ /trunk/tos/chips/atm128rfa1/adc/Atm128AdcC.nc	Tue Sep 13 16:22:58 2011
@@ -0,0 +1,78 @@
+/// $Id: Atm128AdcC.nc,v 1.7 2010-06-29 22:07:43 scipio Exp $
+
+/*
+ * Copyright (c) 2004-2005 Crossbow Technology, Inc.  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 Crossbow Technology 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.
+ *
+ * Copyright (c) 2005 Intel Corporation
+ * All rights reserved.
+ *
+ * This file is distributed under the terms in the attached INTEL-LICENSE
+ * file. If you do not find these files, copies can be found by writing to
+ * Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
+ * 94704.  Attention:  Intel License Inquiry.
+ */
+
+#include "Atm128Adc.h"
+
+/**
+ * HAL for the Atmega128 A/D conversion susbsystem.
+ *
+ * @author Hu Siquan <husq at xbow.com>
+ * @author David Gay
+ */
+
+configuration Atm128AdcC
+{
+  provides {
+    interface Resource[uint8_t client];
+    interface Atm128AdcSingle;
+    interface Atm128AdcMultiple;
+  }
+  uses interface ResourceConfigure[uint8_t client];
+}
+implementation
+{
+  components Atm128AdcP, HplAtm128AdcC, McuInitC, MainC,
+    new RoundRobinArbiterC(UQ_ATM128ADC_RESOURCE) as AdcArbiter,
+    new AsyncStdControlPowerManagerC() as PM;
+
+  Resource = AdcArbiter;
+  ResourceConfigure = AdcArbiter;
+  Atm128AdcSingle = Atm128AdcP;
+  Atm128AdcMultiple = Atm128AdcP;
+
+  McuInitC.AdcInit -> Atm128AdcP;
+
+  Atm128AdcP.HplAtm128Adc -> HplAtm128AdcC;
+  Atm128AdcP.Atm128Calibrate -> PlatformC;
+
+  PM.AsyncStdControl -> Atm128AdcP;
+  PM.ResourceDefaultOwner -> AdcArbiter;
+}
=======================================
--- /trunk/tos/chips/atm128rfa1/McuInitC.nc	Sun Sep  4 02:04:37 2011
+++ /trunk/tos/chips/atm128rfa1/McuInitC.nc	Tue Sep 13 16:22:58 2011
@@ -34,26 +34,29 @@

  configuration McuInitC @safe()
  {
-	provides interface Init;
+	provides interface Init @exactlyonce();

  	uses
  	{
  		interface Init as TimerInit;
+		interface Init as AdcInit;
  	}
  }

  implementation
  {
-	components McuInitP, MeasureClockC;
+	components McuInitP, MeasureClockC, RFA1RadioOffP;

  	Init = McuInitP.Init;
  	TimerInit = McuInitP.TimerInit;
-
+	AdcInit = McuInitP.AdcInit;
+
+	McuInitP.RadioInit -> RFA1RadioOffP;
  	McuInitP.MeasureClock -> MeasureClockC;

  #ifdef TOGGLE_ON_SLEEP
-	// this is a HACK, but becasue of some compiling issues
-	// we cannot make McuInitC into a configuration
+	// this is a HACK, but becasue of some compiling issues we
+	// cannot make McuSleepC into a configuration, so we wire here
  	components McuSleepC, LedsC;
  	McuSleepC.Leds -> LedsC;
  #endif
=======================================
--- /trunk/tos/chips/atm128rfa1/McuInitP.nc	Sun Sep  4 02:04:37 2011
+++ /trunk/tos/chips/atm128rfa1/McuInitP.nc	Tue Sep 13 16:22:58 2011
@@ -41,6 +41,8 @@
  	{
  		interface Init as MeasureClock;
  		interface Init as TimerInit;
+		interface Init as AdcInit;
+		interface Init as RadioInit;
  	}
  }

@@ -75,23 +77,23 @@
  	command error_t Init.init()
  	{
  		error_t ok;
-		//workaround for errata 38.5.1 in datasheet
-		if(VERSION_NUM==3){//revision c (1.1)
-			DRTRAM0|=1<<ENDRT;
-			DRTRAM1|=1<<ENDRT;
-			DRTRAM2|=1<<ENDRT;
-			DRTRAM3|=1<<ENDRT;
+		// workaround for errata 38.5.1 in datasheet
+		if( VERSION_NUM==3 ){ //revision c (1.1)
+			DRTRAM0 |= 1<<ENDRT;
+			DRTRAM1 |= 1<<ENDRT;
+			DRTRAM2 |= 1<<ENDRT;
+			DRTRAM3 |= 1<<ENDRT;
  		}

  		ok = systemClockInit();
  		ok = ecombine(ok, call MeasureClock.init());
  		ok = ecombine(ok, call TimerInit.init());
+		ok = ecombine(ok, call AdcInit.init());
+		ok = ecombine(ok, call RadioInit.init());

  		return ok;
  	}

-	default command error_t TimerInit.init()
-	{
-		return SUCCESS;
-	}
-}
+	default command error_t TimerInit.init() { return SUCCESS; }
+	default command error_t AdcInit.init() { return SUCCESS; }
+}
=======================================
--- /trunk/tos/platforms/ucmini/PlatformC.nc	Sun Sep  4 02:04:37 2011
+++ /trunk/tos/platforms/ucmini/PlatformC.nc	Tue Sep 13 16:22:58 2011
@@ -37,19 +37,25 @@
    provides
    {
      interface Init;
-    // TODO: this should be moved to McuInit, but HplAtm128UartC wants it  
here
-    interface Atm128Calibrate;
+    interface Atm128Calibrate; // TODO: should be moved to McuInitC
    }

-  uses
-  {
-    interface Init as LedsInit;
-  }
-
+  uses interface Init as LedsInit;
  }
  implementation
  {
-  components PlatformP, McuInitC, MeasureClockC, RFA1RadioOffP,  
Stm25pOffC, Atm128AdcP, HplAtm128AdcC;
+  //initialization
+  components PlatformP, McuInitC, MeasureClockC;
+  Init = PlatformP;
+  LedsInit = PlatformP.LedsInit;
+  PlatformP.McuInit -> McuInitC;
+  Atm128Calibrate = MeasureClockC;
+
+  //turning off unused components
+  components Stm25pOffC;
+  PlatformP.Stm25pInit -> Stm25pOffC;
+
+  //voltage measuring circuit
    components HplAtm128GeneralIOC;
    #if UCMINI_REV==49
      PlatformP.Voltmeter -> HplAtm128GeneralIOC.PortF0;
@@ -61,17 +67,6 @@
      PlatformP.VMeasureBridge -> HplAtm128GeneralIOC.PortF0;
    #endif

-  Init = PlatformP;
-  Atm128Calibrate = MeasureClockC;
-
-  LedsInit = PlatformP.LedsInit;
-  PlatformP.McuInit -> McuInitC;
-  Atm128AdcP.HplAtm128Adc -> HplAtm128AdcC;
-  PlatformP.ADCInit -> Atm128AdcP.Init;
-
-   PlatformP.RadioInit -> RFA1RadioOffP.RFA1RadioOff;
-   PlatformP.Stm25pInit -> Stm25pOffC.Stm25pOff;
-
    #ifndef DISABLE_SERIAL_AUTO
      components SerialAutoControlC;
    #endif
=======================================
--- /trunk/tos/platforms/ucmini/PlatformP.nc	Tue Sep 13 15:45:52 2011
+++ /trunk/tos/platforms/ucmini/PlatformP.nc	Tue Sep 13 16:22:58 2011
@@ -42,13 +42,11 @@
    {
      interface Init as McuInit;
      interface Init as LedsInit;
-    interface Init as RadioInit;
      interface Init as Stm25pInit;
-    interface Init as ADCInit;
+
      #if UCMINI_REV==49
        interface GeneralIO as Voltmeter;
-    #endif
-    #if (UCMINI_REV!=49)
+    #else
        interface GeneralIO as VBattADC;
        interface GeneralIO as VMeasureBridge;
      #endif
@@ -60,31 +58,27 @@
    command error_t Init.init()
    {
      error_t ok;
+
+    //disable the voltage measuring circuit
      #if UCMINI_REV==49
        call Voltmeter.set();
-    #endif
-
-    #if (UCMINI_REV!=49)
+    #else
        call VMeasureBridge.makeOutput();
        call VMeasureBridge.set();
        call VBattADC.set();
        call VBattADC.makeOutput();
      #endif

+    //disable jtag
      MCUCR |= 1<<JTD;
      MCUCR |= 1<<JTD;

      ok = call McuInit.init();
-    ok = ecombine(ok, call LedsInit.init());
-    ok = ecombine(ok, call RadioInit.init());
      ok = ecombine(ok, call Stm25pInit.init());
-    ok = ecombine(ok, call ADCInit.init());
+    ok = ecombine(ok, call LedsInit.init());

      return ok;
    }

-  default command error_t LedsInit.init()
-  {
-    return SUCCESS;
-  }
-}
+  default command error_t LedsInit.init() { return SUCCESS; }
+}


More information about the Tinyos-2-commits mailing list