[Tinyos-beta-commits] CVS: tinyos-1.x/beta/platform/pxa27x PXA27XPowerModes.h, NONE, 1.1 PXA27XPowerModes.nc, NONE, 1.1 PXA27XPowerModesM.nc, NONE, 1.1 Sleep.nc, NONE, 1.1 SleepC.nc, NONE, 1.1 SleepM.nc, NONE, 1.1 HPLInit.nc, 1.8, 1.9 PXA27XUSBClient.h, 1.2, 1.3

Lama Nachman lnachman at users.sourceforge.net
Tue Oct 18 14:22:55 PDT 2005


Update of /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2257

Modified Files:
	HPLInit.nc PXA27XUSBClient.h 
Added Files:
	PXA27XPowerModes.h PXA27XPowerModes.nc PXA27XPowerModesM.nc 
	Sleep.nc SleepC.nc SleepM.nc 
Log Message:
Added sleep support and low power modes


--- NEW FILE: PXA27XPowerModes.h ---

/*									tab:4
 *
 *
 * "Copyright (c) 2000-2002 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */
/*									tab:4
 *  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.  By
 *  downloading, copying, installing or using the software you agree to
 *  this license.  If you do not agree to this license, do not download,
 *  install, copy or use the software.
 *
 *  Intel Open Source License 
 *
 *  Copyright (c) 2002 Intel Corporation 
 *  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 Intel Corporation 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 INTEL OR ITS
 *  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.
 * 
 * 
 */
/*
 *
 * Authors:  Lama Nachman
 *
 */

#ifndef PXA27XPOWERMODES_H
#define PXA27XPOWERMODES_H

#define DEEP_SLEEP_MODE 1
#define SLEEP_MODE 2
#define STANDBY_MODE 3
#define DEEP_IDLE_MODE 4
#define IDLE_MODE 5
#define NORAML_MODE 6

#endif //Power Modes

--- NEW FILE: PXA27XPowerModes.nc ---
/*									tab:4
 *  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.  By
 *  downloading, copying, installing or using the software you agree to
 *  this license.  If you do not agree to this license, do not download,
 *  install, copy or use the software.
 *
 *  Intel Open Source License 
 *
 *  Copyright (c) 2002 Intel Corporation 
 *  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 Intel Corporation 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 INTEL OR ITS
 *  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.
 * 
 */

/*
 *
 * Authors:	Lama Nachman
 */

interface PXA27XPowerModes {
  /*
   * Switch the power mode of the PXA to the desired mode
   *
   * @param targetMode This can be any of the tPowerModes enum values 
   *
   * @return none
   */
  command void SwitchMode(uint8_t targeMode);
  
}

--- NEW FILE: PXA27XPowerModesM.nc ---
/*									tab:4
 *  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.  By
 *  downloading, copying, installing or using the software you agree to
 *  this license.  If you do not agree to this license, do not download,
 *  install, copy or use the software.
 *
 *  Intel Open Source License 
 *
 *  Copyright (c) 2005 Intel Corporation 
 *  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 Intel Corporation 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 INTEL OR ITS
 *  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 Lama Nachman
*/

#include "PXA27XPowerModes.h"

module PXA27XPowerModesM {
  provides interface PXA27XPowerModes;
}


implementation
{

  void DisablePeripherals() {
    /*
     * TODO : Should have a better way of doing this. Start/Stop peripherals
     * using the stop function?
     */ 
    
    // Disable UARTs
    STIER &= ~IER_UUE;
    BTIER &= ~IER_UUE;
    FFIER &= ~IER_UUE;

    // Kill SPI ports
    SSCR0_1 &= ~SSCR0_SSE;
    SSCR0_2 &= ~SSCR0_SSE;
    SSCR0_3 &= ~SSCR0_SSE;

    // Disable USB Client
    UDCCR &= ~UDCCR_UDE;

    // Disable I2C (Standard & PWR)
    ICR &= ~ICR_IUE;
    PICR &= ~ICR_IUE;

    // Disable OS Timers
    OMCR4 &= ~(OMCR_CRES(7));
    OMCR5 &= ~(OMCR_CRES(7));
    OMCR6 &= ~(OMCR_CRES(7));
    OMCR7 &= ~(OMCR_CRES(7));
    OMCR8 &= ~(OMCR_CRES(7));
    OMCR9 &= ~(OMCR_CRES(7));
    OMCR10 &= ~(OMCR_CRES(7));
    OMCR11 &= ~(OMCR_CRES(7));
   
    // TODO : Do I2S, AC97, SDIO, USB host, MSL, etc
  }

  // TODO : This should be split to imote2/pxa specific sections
  void EnterDeepSleep() {

    // Enable wakeup from PMIC (GPIO 1, R & F edges) and RTC, TODO : add radio?
    PWER |= PWER_WERTC;
    PWER |= PWER_WE1;
    PFER |= PWER_WE1;
    PRER |= PRER_RE1;
    PFER |= PFER_RE1;

    // TODO: Set desired GPIO state

    // Set PSLR register to not retain state
    PSLR &= ~(PSLR_SL_R3 | PSLR_SL_R2 | PSLR_SL_R1 | PSLR_SL_R0);
    PSLR &= ~(PSLR_SL_PI(3));
  
    // Set minimum delay for PWR_DEL and SYS_DEL
    //PSLR &= ~(PSLR_SYS_DEL(0xf));
    //PSLR &= ~(PSLR_PWR_DEL(0xf));

    // Enable 32K OSC just in case it wasn't enabled
    OSCC |= OSCC_OON;

    // Disable linear regulator
    PCFR = PCFR & ~PCFR_L1_EN;

    // Disable the 13 MHz OSC and wait for status 
    PCFR = PCFR | PCFR_OPDE;
    while ((OSCC & OSCC_OOK) == 0);
    
    // Enable deep-sleep DC-DC convertor
    PCFR = PCFR | PCFR_DC_EN; 

    // Switch to deep sleep mode
    asm volatile (
                  "mcr p14, 0, %0, c7, c0, 0"
                  :
                  : "r" (7)
                  );  
    while(1);
  }

  command void PXA27XPowerModes.SwitchMode(uint8_t targetMode) {
    switch (targetMode) {
      case DEEP_SLEEP_MODE:
        // Shutdown all LDOs that are not controlled by the sleep signal
        EnterDeepSleep();
        break;
      default:
        break;
    }
  }
}

--- NEW FILE: Sleep.nc ---
/*									tab:4
 *  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.  By
 *  downloading, copying, installing or using the software you agree to
 *  this license.  If you do not agree to this license, do not download,
 *  install, copy or use the software.
 *
 *  Intel Open Source License 
 *
 *  Copyright (c) 2002 Intel Corporation 
 *  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 Intel Corporation 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 INTEL OR ITS
 *  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.
 * 
 */

/*
 *
 * Authors:	Lama Nachman
 */

interface Sleep {
  /*
   * Put the mote in deep sleep mode for the specified amount of time in
   *   seconds.  This is an application override, so even if there are 
   *   timer events scheduled, they will be ignored and the mote will not
   *   come out of deep sleep until the specified time expires.
   *   Note, all state will be lost and the mote will reset when it comes
   *   out of deep sleep.
   *
   * @param sleepTime in seconds
   *
   * @return none
   */
  command result_t goToDeepSleep(uint32_t sleepTime);
  
}

--- NEW FILE: SleepC.nc ---
/*									tab:4
 * "Copyright (c) 2000-2003 The Regents of the University  of California.  
 * All rights reserved.
 *
 * Permission to use, copy, modify, and distribute this software and its
 * documentation for any purpose, without fee, and without written agreement is
 * hereby granted, provided that the above copyright notice, the following
 * two paragraphs and the author appear in all copies of this software.
 * 
 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
 * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
 * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
 * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 * 
 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
 * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
 * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
 * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 * Copyright (c) 2002-2003 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.
 */

configuration SleepC {
    provides interface Sleep;
}

implementation {
    components PXA27XPowerModesM, SleepM, PMICC;
    Sleep = SleepM;
    SleepM.PXA27XPowerModes -> PXA27XPowerModesM;
    SleepM.PMIC -> PMICC;
}

--- NEW FILE: SleepM.nc ---
/*									tab:4
 *  IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.  By
 *  downloading, copying, installing or using the software you agree to
 *  this license.  If you do not agree to this license, do not download,
 *  install, copy or use the software.
 *
 *  Intel Open Source License 
 *
 *  Copyright (c) 2005 Intel Corporation 
 *  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 Intel Corporation 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 INTEL OR ITS
 *  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 Lama Nachman
*/

#include "PXA27XPowerModes.h"

module SleepM {
  provides interface Sleep;
  uses interface PXA27XPowerModes;
  uses interface PMIC;
}


implementation
{

  command result_t Sleep.goToDeepSleep(uint32_t sleepTime) {

    // Setup RTC alarm for required period, TODO: Separate out RTC module
    RTSR |= RTSR_ALE;
    RTAR = RCNR + sleepTime;

    // Disable other RTC timers
    RTSR &= ~RTSR_PICE;
    RTSR &= ~RTSR_SWCE;

    // Switch power mode  
    call PMIC.shutDownLDOs();	// TODO : Move this out
    call PXA27XPowerModes.SwitchMode(DEEP_SLEEP_MODE);
  }
}

Index: HPLInit.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/HPLInit.nc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** HPLInit.nc	26 Sep 2005 02:18:58 -0000	1.8
--- HPLInit.nc	18 Oct 2005 21:22:53 -0000	1.9
***************
*** 88,91 ****
--- 88,92 ----
      HPLClock,
      PMICC,
+     SettingsC,
      Main;
    
***************
*** 95,98 ****
--- 96,100 ----
    Main.StdControl->HPLClock;
    Main.StdControl->PMICC;
+   Main.StdControl->SettingsC;
  }
  

Index: PXA27XUSBClient.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/platform/pxa27x/PXA27XUSBClient.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PXA27XUSBClient.h	2 Sep 2005 23:25:52 -0000	1.2
--- PXA27XUSBClient.h	18 Oct 2005 21:22:53 -0000	1.3
***************
*** 23,27 ****
  
  //UDCCR
! #define UDCCR_UDE 0
  #define UDCCR_EMCE 3
  #define UDCCR_SMAC 4
--- 23,27 ----
  
  //UDCCR
! //#define UDCCR_UDE 0	// defined in pxa27x_registers.h , should move all	
  #define UDCCR_EMCE 3
  #define UDCCR_SMAC 4



More information about the Tinyos-beta-commits mailing list