Esempio n. 1
0
/*********************************************************************************************************
** Function name:           wakeUp
** Descriptions:            wakeUp
*********************************************************************************************************/
void xadow::wakeUp()
{
#if defined(__AVR_ATmega32U4__)
    power_adc_enable();
    power_usart0_enable();
    power_spi_enable();
    power_twi_enable();
    power_timer1_enable();
    power_timer2_enable();
    power_timer3_enable();
    power_usart1_enable();
    power_usb_enable();
#endif
}
Esempio n. 2
0
void	Low_Power::idle(Period_t period, ADC_t adc,
                        Timer4_t timer4, Timer3_t timer3,
                        Timer1_t timer1, Timer0_t timer0,
                        SPI_t spi, USART1_t usart1,	TWI_t twi, usb_t usb)
{
    if (adc == ADC_OFF)
    {
        ADCSRA &= ~(1 << ADEN);
        power_adc_disable();
    }

    if (timer4 == TIMER4_OFF)	power_timer4_disable();
    if (timer3 == TIMER3_OFF)	power_timer3_disable();
    if (timer1 == TIMER1_OFF)	power_timer1_disable();
    if (timer0 == TIMER0_OFF)	power_timer0_disable();
    if (spi == SPI_OFF)				power_spi_disable();
    if (usart1 == USART1_OFF)	power_usart1_disable();
    if (twi == TWI_OFF)				power_twi_disable();
    if (usb == USB_OFF)				power_usb_disable();

    if (period != SLEEP_FOREVER)
    {
        wdt_enable(period);
        WDTCSR |= (1 << WDIE);
    }

    lowPowerBodOn(SLEEP_MODE_IDLE);

    if (adc == ADC_OFF)
    {
        power_adc_enable();
        ADCSRA |= (1 << ADEN);
    }

    if (timer4 == TIMER4_OFF)	power_timer4_enable();
    if (timer3 == TIMER3_OFF)	power_timer3_enable();
    if (timer1 == TIMER1_OFF)	power_timer1_enable();
    if (timer0 == TIMER0_OFF)	power_timer0_enable();
    if (spi == SPI_OFF)				power_spi_enable();
    if (usart1 == USART1_OFF)	power_usart1_enable();
    if (twi == TWI_OFF)				power_twi_enable();
    if (usb == USB_OFF)				power_usb_enable();
}
Esempio n. 3
0
void	Low_Power::idle(Period_t period, ADC_t adc, Timer5_t timer5,
                        Timer4_t timer4, Timer3_t timer3, Timer2_t timer2,
                        Timer1_t timer1, Timer0_t timer0, SPI_t spi,
                        USART3_t usart3, USART2_t usart2, USART1_t usart1,
                        USART0_t usart0, TWI_t twi)
{
    // Temporary clock source variable
    unsigned char clockSource = 0;

    if (timer2 == TIMER2_OFF)
    {
        if (TCCR2B & CS22) clockSource |= (1 << CS22);
        if (TCCR2B & CS21) clockSource |= (1 << CS21);
        if (TCCR2B & CS20) clockSource |= (1 << CS20);

        // Remove the clock source to shutdown Timer2
        TCCR2B &= ~(1 << CS22);
        TCCR2B &= ~(1 << CS21);
        TCCR2B &= ~(1 << CS20);

        power_timer2_disable();
    }

    if (adc == ADC_OFF)
    {
        ADCSRA &= ~(1 << ADEN);
        power_adc_disable();
    }

    if (timer5 == TIMER5_OFF)	power_timer5_disable();
    if (timer4 == TIMER4_OFF)	power_timer4_disable();
    if (timer3 == TIMER3_OFF)	power_timer3_disable();
    if (timer1 == TIMER1_OFF)	power_timer1_disable();
    if (timer0 == TIMER0_OFF)	power_timer0_disable();
    if (spi == SPI_OFF)			  power_spi_disable();
    if (usart3 == USART3_OFF)	power_usart3_disable();
    if (usart2 == USART2_OFF)	power_usart2_disable();
    if (usart1 == USART1_OFF)	power_usart1_disable();
    if (usart0 == USART0_OFF)	power_usart0_disable();
    if (twi == TWI_OFF)			  power_twi_disable();

    if (period != SLEEP_FOREVER)
    {
        wdt_enable(period);
        WDTCSR |= (1 << WDIE);
    }

    lowPowerBodOn(SLEEP_MODE_IDLE);

    if (adc == ADC_OFF)
    {
        power_adc_enable();
        ADCSRA |= (1 << ADEN);
    }

    if (timer2 == TIMER2_OFF)
    {
        if (clockSource & CS22) TCCR2B |= (1 << CS22);
        if (clockSource & CS21) TCCR2B |= (1 << CS21);
        if (clockSource & CS20) TCCR2B |= (1 << CS20);

        power_timer2_enable();
    }

    if (timer5 == TIMER5_OFF)	power_timer5_enable();
    if (timer4 == TIMER4_OFF)	power_timer4_enable();
    if (timer3 == TIMER3_OFF)	power_timer3_enable();
    if (timer1 == TIMER1_OFF)	power_timer1_enable();
    if (timer0 == TIMER0_OFF)	power_timer0_enable();
    if (spi == SPI_OFF)			  power_spi_enable();
    if (usart3 == USART3_OFF)	power_usart3_enable();
    if (usart2 == USART2_OFF)	power_usart2_enable();
    if (usart1 == USART1_OFF)	power_usart1_enable();
    if (usart0 == USART0_OFF)	power_usart0_enable();
    if (twi == TWI_OFF)			  power_twi_enable();
}