2018-09-05 02:39:50 +02:00
|
|
|
/*
|
2019-09-05 13:35:58 +02:00
|
|
|
* Copyright (C) 2019 Gunar Schorcht
|
2018-09-05 02:39:50 +02:00
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup cpu_esp8266
|
|
|
|
* @ingroup drivers_periph_pm
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Implementation of power management functions
|
|
|
|
*
|
|
|
|
* @author Gunar Schorcht <gunar@schorcht.net>
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2020-10-22 11:34:00 +02:00
|
|
|
#define ENABLE_DEBUG 0
|
2018-09-05 02:39:50 +02:00
|
|
|
#include "debug.h"
|
|
|
|
|
|
|
|
#include "sdk/sdk.h"
|
|
|
|
#include "syscalls.h"
|
|
|
|
|
|
|
|
void pm_set_lowest(void)
|
|
|
|
{
|
2020-03-19 13:59:45 +01:00
|
|
|
DEBUG("%s enter to sleep @%u\n", __func__, system_get_time());
|
2018-09-05 02:39:50 +02:00
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
/* reset system watchdog timer */
|
|
|
|
system_wdt_feed();
|
2018-09-05 02:39:50 +02:00
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
#ifndef MODULE_ESP_QEMU
|
2018-09-05 02:39:50 +02:00
|
|
|
/* passive wait for interrupt to leave lowest power mode */
|
|
|
|
__asm__ volatile ("waiti 0");
|
|
|
|
#endif
|
2019-09-05 13:35:58 +02:00
|
|
|
|
2020-03-19 13:59:45 +01:00
|
|
|
DEBUG("%s exit from sleep @%u\n", __func__, system_get_time());
|
2019-09-05 13:35:58 +02:00
|
|
|
|
|
|
|
/* reset system watchdog timer */
|
|
|
|
system_wdt_feed();
|
2018-09-05 02:39:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void pm_off(void)
|
|
|
|
{
|
2020-03-19 13:59:45 +01:00
|
|
|
DEBUG("%s\n", __func__);
|
2018-09-05 02:39:50 +02:00
|
|
|
system_deep_sleep(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void pm_reboot(void)
|
|
|
|
{
|
2020-03-19 13:59:45 +01:00
|
|
|
DEBUG("%s\n", __func__);
|
|
|
|
|
|
|
|
#ifdef MODULE_PERIPH_RTT
|
|
|
|
/* save counters */
|
|
|
|
extern void rtt_save_counter(void);
|
|
|
|
rtt_save_counter();
|
|
|
|
#endif
|
2018-09-05 02:39:50 +02:00
|
|
|
|
|
|
|
/* shut down WIFI and call system_restart_local after timer */
|
|
|
|
system_restart ();
|
|
|
|
}
|