X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fmsp430%2FMcuSleepC.nc;h=64c87a7e2ec226cb4133dcb704dac82257c08b35;hb=337d0b13acf569c2640b3ed7b7f5c7cec35d7ddd;hp=dd9f5e1767e8ddda4a1388942761d97b27bf5705;hpb=1a329382c4f4556fd52d85f4e3f4a67e54911682;p=tinyos-2.x.git diff --git a/tos/chips/msp430/McuSleepC.nc b/tos/chips/msp430/McuSleepC.nc index dd9f5e17..64c87a7e 100644 --- a/tos/chips/msp430/McuSleepC.nc +++ b/tos/chips/msp430/McuSleepC.nc @@ -52,9 +52,7 @@ implementation { mcu_power_t powerState = MSP430_POWER_ACTIVE; /* 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).*/ + * based on their active components, NOT on their values.*/ // NOTE: This table should be in progmem. const uint16_t msp430PowerBits[MSP430_POWER_LPM4 + 1] = { 0, // ACTIVE @@ -81,20 +79,25 @@ implementation { #endif ) pState = MSP430_POWER_LPM1; - // ADC12 check - if (ADC12CTL1 & ADC12BUSY){ - if (!(ADC12CTL0 & MSC) && ((TACTL & TASSEL_3) == TASSEL_2)) - pState = MSP430_POWER_LPM1; - else - switch (ADC12CTL1 & ADC12SSEL_3) { - case ADC12SSEL_2: - pState = MSP430_POWER_ACTIVE; - break; - case ADC12SSEL_3: - pState = MSP430_POWER_LPM1; - break; - } + +#ifdef __msp430_have_adc12 + // ADC12 check, pre-condition: pState != MSP430_POWER_ACTIVE + if (ADC12CTL0 & ADC12ON){ + if (ADC12CTL1 & ADC12SSEL_2){ + // sample or conversion operation with MCLK or SMCLK + if (ADC12CTL1 & ADC12SSEL_1) + pState = MSP430_POWER_LPM1; + else + pState = MSP430_POWER_ACTIVE; + } else if ((ADC12CTL1 & SHS0) && ((TACTL & TASSEL_3) == TASSEL_2)){ + // Timer A is used as sample-and-hold source and SMCLK sources Timer A + // (Timer A interrupts are always disabled when it is used by the + // ADC subsystem, that's why the Timer check above is not enough) + pState = MSP430_POWER_LPM1; + } } +#endif + return pState; }