/* sleep(timer) - sets the microcontroller to the lowest consumption sleep mode * * It sets the microcontroller to the lowest consumption sleep mode. It enables watchdog interruption to be able to * wake up the microcontroller after 'timer' time. * * 'timer' --> it specifies the time before the watchdog activates the interruption. Possible values are: * WTD_16MS 0 * WTD_32MS 1 * WTD_64MS 2 * WTD_128MS 3 * WTD_250MS 4 * WTD_500MS 5 * WTD_1S 6 * WTD_2S 7 * WTD_4S 8 * WTD_8S 9 * * It switches off all the switches on the Waspmote board. * * It returns nothing. */ void WaspPWR::sleep(uint8_t timer, uint8_t option) { switchesOFF(option); set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); setWatchdog(WTD_ON,timer); sleep_mode(); sleep_disable(); switchesON(option); }
/* sleep(timer) - sets the microcontroller to the lowest consumption sleep mode * * It sets the microcontroller to the lowest consumption sleep mode. It enables watchdog interruption to be able to * wake up the microcontroller after 'timer' time. * * 'timer' --> it specifies the time before the watchdog activates the interruption. Possible values are: * WTD_16MS 0 * WTD_32MS 1 * WTD_64MS 2 * WTD_128MS 3 * WTD_250MS 4 * WTD_500MS 5 * WTD_1S 6 * WTD_2S 7 * WTD_4S 8 * WTD_8S 9 * * It switches off all the switches on the Waspmote board. * * It returns nothing. */ void WaspPWR::sleep(uint8_t timer, uint8_t option) { uint8_t retries=0; // Switch off both multiplexers in UART_0 and UART_1 Utils.muxOFF(); // set the XBee monitorization pin to zero pinMode(XBEE_MON,OUTPUT); digitalWrite(XBEE_MON,LOW); // switch on and off the RTC so as to unset RTC interruption signal RTC.ON(); RTC.OFF(); // switches off depending on the option selected switchesOFF(option); // mandatory delay to wait for MUX_RX stabilization // after switching off the sensor boards delay(100); // make sure interruption pin is LOW before entering a low power state // if not the interruption will never come while(digitalRead(MUX_RX)==HIGH) { // clear all detected interruption signals delay(1); PWR.clearInterruptionPin(); retries++; if(retries>10) { return (void)0; } } set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); // set watchdog timer to cause interruption for selected time setWatchdog(WTD_ON,timer); sleep_mode(); sleep_disable(); if( intFlag & RTC_INT ) { RTC.ON(); RTC.clearAlarmFlag(); RTC.OFF(); } //~ switchesON(option); }
/* sleep(timer) - sets the microcontroller to the lowest consumption sleep mode * * It sets the microcontroller to the lowest consumption sleep mode. It enables watchdog interruption to be able to * wake up the microcontroller after 'timer' time. * * 'timer' --> it specifies the time before the watchdog activates the interruption. Possible values are: * WTD_16MS 0 * WTD_32MS 1 * WTD_64MS 2 * WTD_128MS 3 * WTD_250MS 4 * WTD_500MS 5 * WTD_1S 6 * WTD_2S 7 * WTD_4S 8 * WTD_8S 9 * * It switches off all the switches on the MakeSuremote board. * * It returns nothing. */ void MakeSurePWR::sleep(uint8_t timer, uint8_t option) { uint8_t retries=0; // Switch off both multiplexers in UART_0 and UART_1 when // no interruption is expected through the UART1 if( !(option & UART1_OFF) ) { // keep multiplexer on } else { Utils.muxOFF(); } delay(100); RTC.ON(); pinMode(XBEE_MON,INPUT); digitalWrite(XBEE_MON,LOW); switchesOFF(option); pinMode(I2C_SDA,OUTPUT); digitalWrite(I2C_SDA,LOW); pinMode(I2C_SCL,OUTPUT); digitalWrite(I2C_SCL,LOW); // make sure interruption pin is LOW before entering a low power state // if not the interruption will never come while(digitalRead(MUX_RX)==HIGH) { // clear all detected interruption signals delay(1); PWR.clearInt(); retries++; if(retries>10) { return (void)0; } } set_sleep_mode(SLEEP_MODE_PWR_DOWN); sleep_enable(); setWatchdog(WTD_ON,timer); sleep_mode(); sleep_disable(); switchesON(option); }