void task_powerdown_init() { //Lower F_CPU ClockSetSource(x2MHz); //disable other oscilators OSC.CTRL = 0b00000001; buttons_deinit(); uart_stop(); _delay_ms(10); turnoff_subsystems(); uart_low_speed(); _delay_ms(10); DEBUG(" *** POWER DOWN INIT ***\n"); test_memory(); //we do not want to enter sleep powerdown_loop_break = false; powerdown_lock.Lock(); task_timer_setup(false); SD_EN_OFF; DEBUG("Using low speed uart\n"); }
void task_powerdown_stop() { //Reinit all devices DEBUG("Restarting all devices\n"); uart_stop(); Setup(); task_timer_setup(); DEBUG("Restoring full speed uart\n"); powerdown_lock.Unlock(); }
void task_init() { task_timer_setup(); USB_CONNECTED_IRQ_ON; powerdown_lock.Unlock(); //if ftest is not done if (!cfg_factory_passed()) task_set(TASK_ACTIVE); //if is USB connected go directly to USB task if ((usb_state = USB_CONNECTED)) task_set(TASK_USB); wdt_init(wdt_2s); }
void powerdown_sleep() { _delay_ms(31); task_timer_stop(); do { //allow rtc irq handler but do not wake up time_rtc_irq = false; //rtc irq set time_rtc_irq to true if executed SystemPowerSave(); if (time_rtc_irq) wdt_reset(); } while (time_rtc_irq == true); //start task timer in low speed mode task_timer_setup(false); }