From 560bc5db8469b8e254e6f74109284a08a0fccfb5 Mon Sep 17 00:00:00 2001 From: scipio Date: Sun, 8 Apr 2007 01:17:12 +0000 Subject: [PATCH] Include I2C in sleep calculation, and base SPI off of SPE, not SPIE; it may be enabled but not with interrupts. It would be a weird use case, but it is possible. --- tos/chips/atm128/McuSleepC.nc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tos/chips/atm128/McuSleepC.nc b/tos/chips/atm128/McuSleepC.nc index 6418f739..badcfed0 100644 --- a/tos/chips/atm128/McuSleepC.nc +++ b/tos/chips/atm128/McuSleepC.nc @@ -74,14 +74,15 @@ implementation { return ATM128_POWER_IDLE; } // SPI (Radio stack on mica/micaZ - else if (bit_is_set(SPCR, SPIE)) { + else if (bit_is_set(SPCR, SPE)) { return ATM128_POWER_IDLE; } - // UARTs are active - else if (UCSR0B & (1 << TXCIE | 1 << RXCIE)) { // UART + // A UART is active + else if ((UCSR0B | UCSR1B) & (1 << TXCIE | 1 << RXCIE)) { // UART return ATM128_POWER_IDLE; } - else if (UCSR1B & (1 << TXCIE | 1 << RXCIE)) { // UART + // I2C (Two-wire) is active + else if (bit_is_set(TWCR, TWEN)){ return ATM128_POWER_IDLE; } // ADC is enabled -- 2.39.2