[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/atm128 Atm128Power.h, 1.1.2.3, 1.1.2.4 HplAtm128UartC.nc, 1.1.2.4, 1.1.2.5 HplAtm128UartP.nc, 1.1.2.3, 1.1.2.4 McuSleepC.nc, 1.1.2.5, 1.1.2.6

David Gay idgay at users.sourceforge.net
Fri Sep 22 12:12:16 PDT 2006


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv12361

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	Atm128Power.h HplAtm128UartC.nc HplAtm128UartP.nc McuSleepC.nc 
Log Message:
changes from head


Index: Atm128Power.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/Atm128Power.h,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** Atm128Power.h	27 Jan 2006 23:13:22 -0000	1.1.2.3
--- Atm128Power.h	22 Sep 2006 19:12:14 -0000	1.1.2.4
***************
*** 30,43 ****
  //================== ATmega128 Power Management ==========================
  
- /* Sleep modes */
- enum {
-   ATM128_SLEEP_IDLE = 0, 
-   ATM128_SLEEP_ADC,
-   ATM128_SLEEP_POWER_DOWN,
-   ATM128_SLEEP_POWER_SAVE,
-   ATM128_SLEEP_STANDBY = 3,             //!< enable standby bit (sm2)
-   ATM128_SLEEP_EXTENDED_STANDBY = 4,    //!< enable standby bit (sm2)
- };
- 
  /* MCU Control Register */
  typedef struct
--- 30,33 ----

Index: HplAtm128UartC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/HplAtm128UartC.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** HplAtm128UartC.nc	21 Jun 2006 16:59:18 -0000	1.1.2.4
--- HplAtm128UartC.nc	22 Sep 2006 19:12:14 -0000	1.1.2.5
***************
*** 49,53 ****
  implementation
  {
!   components HplAtm128UartP, PlatformC;
  
    Uart0Init = HplAtm128UartP.Uart0Init;
--- 49,53 ----
  implementation
  {
!   components HplAtm128UartP, PlatformC, McuSleepC;
  
    Uart0Init = HplAtm128UartP.Uart0Init;
***************
*** 62,64 ****
--- 62,65 ----
  
    HplAtm128UartP.Atm128Calibrate -> PlatformC;
+   HplAtm128UartP.McuPowerState -> McuSleepC;
  }

Index: HplAtm128UartP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/HplAtm128UartP.nc,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -d -r1.1.2.3 -r1.1.2.4
*** HplAtm128UartP.nc	21 Jun 2006 16:59:18 -0000	1.1.2.3
--- HplAtm128UartP.nc	22 Sep 2006 19:12:14 -0000	1.1.2.4
***************
*** 45,49 ****
      interface SerialByteComm as Uart1;
    }
!   uses interface Atm128Calibrate;
  }
  implementation
--- 45,52 ----
      interface SerialByteComm as Uart1;
    }
!   uses {
!     interface Atm128Calibrate;
!     interface McuPowerState;
!   }
  }
  implementation
***************
*** 76,79 ****
--- 79,83 ----
      ctrl.bits.txen  = 1;
      UCSR0B = ctrl.flat;
+     call McuPowerState.update();
      return SUCCESS;
    }
***************
*** 85,88 ****
--- 89,93 ----
      ctrl.bits.txen  = 0;
      UCSR0B = ctrl.flat;
+     call McuPowerState.update();
      return SUCCESS;
    }
***************
*** 94,97 ****
--- 99,103 ----
      ctrl.bits.rxen  = 1;
      UCSR0B = ctrl.flat;
+     call McuPowerState.update();
      return SUCCESS;
    }
***************
*** 103,106 ****
--- 109,113 ----
      ctrl.bits.rxen  = 0;
      UCSR0B = ctrl.flat;
+     call McuPowerState.update();
      return SUCCESS;
    }
***************
*** 133,136 ****
--- 140,144 ----
      ctrl.bits.txen  = 1;
      UCSR1B = ctrl.flat;
+     call McuPowerState.update();
      return SUCCESS;
    }
***************
*** 142,145 ****
--- 150,154 ----
      ctrl.bits.txen  = 0;
      UCSR1B = ctrl.flat;
+     call McuPowerState.update();
      return SUCCESS;
    }
***************
*** 151,154 ****
--- 160,164 ----
      ctrl.bits.rxen  = 1;
      UCSR1B = ctrl.flat;
+     call McuPowerState.update();
      return SUCCESS;
    }
***************
*** 160,163 ****
--- 170,174 ----
      ctrl.bits.rxen  = 0;
      UCSR1B = ctrl.flat;
+     call McuPowerState.update();
      return SUCCESS;
    }

Index: McuSleepC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/McuSleepC.nc,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -C2 -d -r1.1.2.5 -r1.1.2.6
*** McuSleepC.nc	25 Apr 2006 23:49:14 -0000	1.1.2.5
--- McuSleepC.nc	22 Sep 2006 19:12:14 -0000	1.1.2.6
***************
*** 49,66 ****
  implementation {
    /* There is no dirty bit management because the sleep mode depends on
!      the amount of time remaining in timer0. */
  
    /* Note that the power values are maintained in an order
     * based on their active components, NOT on their values.
     * Look at atm128hardware.h and page 42 of the ATmeg128
!    * manual (figure 17).*/
    const_uint8_t atm128PowerBits[ATM128_POWER_DOWN + 1] = {
!     0,
!     (1 << SM0),
!     (1 << SM2) | (1 << SM1) | (1 << SM0),
!     (1 << SM1) | (1 << SM0),
!     (1 << SM2) | (1 << SM1),
!     (1 << SM1)};
!     
    mcu_power_t getPowerState() {
      uint8_t diff;
--- 49,67 ----
  implementation {
    /* There is no dirty bit management because the sleep mode depends on
!      the amount of time remaining in timer0. Note also that the
!      sleep cost depends typically depends on waiting for ASSR to clear. */
  
    /* Note that the power values are maintained in an order
     * based on their active components, NOT on their values.
     * Look at atm128hardware.h and page 42 of the ATmeg128
!    * manual (table 17).*/
    const_uint8_t atm128PowerBits[ATM128_POWER_DOWN + 1] = {
!     0,				/* idle */
!     (1 << SM0),			/* adc */
!     (1 << SM2) | (1 << SM1) | (1 << SM0), /* ext standby */
!     (1 << SM1) | (1 << SM0),	/* power save */
!     (1 << SM2) | (1 << SM1),	/* standby */
!     (1 << SM1)};		/* power down */
! 
    mcu_power_t getPowerState() {
      uint8_t diff;
***************
*** 91,100 ****
      // How soon for the timer to go off?
      else if (TIMSK & (1 << OCIE0 | 1 << TOIE0)) {
!       // force waiting for timer0 update (overflow glitches otherwise)
!       TCCR0 = TCCR0;
        while (ASSR & (1 << TCN0UB | 1 << OCR0UB | 1 << TCR0UB))
  	;
        diff = OCR0 - TCNT0;
!       if (diff < 16 || TCNT0 > 240) 
  	return ATM128_POWER_EXT_STANDBY;
        return ATM128_POWER_SAVE;
--- 92,104 ----
      // How soon for the timer to go off?
      else if (TIMSK & (1 << OCIE0 | 1 << TOIE0)) {
!       // need to wait for timer 0 updates propagate before sleeping
!       // (we don't need to worry about reentering sleep mode too early,
!       // as the wake ups from timer0 wait at least one TOSC1 cycle
!       // anyway - see the stabiliseTimer0 function in HplAtm128Timer0AsyncC)
        while (ASSR & (1 << TCN0UB | 1 << OCR0UB | 1 << TCR0UB))
  	;
        diff = OCR0 - TCNT0;
!       if (diff < EXT_STANDBY_T0_THRESHOLD ||
! 	  TCNT0 > 256 - EXT_STANDBY_T0_THRESHOLD) 
  	return ATM128_POWER_EXT_STANDBY;
        return ATM128_POWER_SAVE;



More information about the Tinyos-2-commits mailing list