return ATM128_POWER_IDLE;
}
// UARTs are active
- else if (UCSR0B & (1 << TXCIE0 | 1 << RXCIE0)) { // UART
+ else if (UCSR0B & (1 << TXCIE0 | 1 << RXCIE0 | 1 << UDRIE0)) { // UART
return ATM128_POWER_IDLE;
}
- else if (UCSR1B & (1 << TXCIE1 | 1 << RXCIE1)) { // UART
+ else if (UCSR1B & (1 << TXCIE1 | 1 << RXCIE1 | 1 << UDRIE1)) { // UART
return ATM128_POWER_IDLE;
}
// I2C (Two-wire) is active
SMCR =
(SMCR & 0xf0) | 1 << SE | read_uint8_t(&atm128PowerBits[powerState]);
sei();
- asm volatile ("sleep");
+ // All of memory may change at this point...
+ asm volatile ("sleep" : : : "memory");
cli();
CLR_BIT(SMCR, SE);