summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/dev/pwr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fw/fe310/eos/dev/pwr.c')
-rw-r--r--fw/fe310/eos/dev/pwr.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/fw/fe310/eos/dev/pwr.c b/fw/fe310/eos/dev/pwr.c
index c6537cb..06a76d8 100644
--- a/fw/fe310/eos/dev/pwr.c
+++ b/fw/fe310/eos/dev/pwr.c
@@ -2,6 +2,8 @@
#include <stdint.h>
#include "eos.h"
+#include "log.h"
+#include "event.h"
#include "soc/pwr.h"
#include "eve/eve.h"
#include "eve/eve_touch_engine.h"
@@ -15,34 +17,33 @@
#include "pwr.h"
+static void pwr_sleep_rdy(void) {
+ if ((eos_evtq_len() == 0) && eos_net_sleep_rdy()) {
+ eos_eve_save2aon();
+ eos_net_save2aon();
+ eos_flash_norm();
#ifdef EOS_DEBUG
-#include <stdio.h>
+ EOS_LOG(EOS_LOG_INFO, "PWR SLEEP\n");
+ eos_sleep(100);
#endif
+ eos_pwr_sleep();
+ }
+}
void eos_pwr_sys_sleep(void) {
int rv;
rv = eos_lcd_sleep();
-#ifdef EOS_DEBUG
- if (rv) printf("PWR SLEEP: LCD SLEEP ERR:%d\n", rv);
-#endif
+ if (rv) EOS_LOG(EOS_LOG_ERR, "PWR SLEEP: LCD SLEEP ERR:%d\n", rv);
rv = eos_ctp_sleep();
-#ifdef EOS_DEBUG
- if (rv) printf("PWR SLEEP: CTP SLEEP ERR:%d\n", rv);
-#endif
+ if (rv) EOS_LOG(EOS_LOG_ERR, "PWR SLEEP: CTP SLEEP ERR:%d\n", rv);
rv = eos_eve_sleep();
-#ifdef EOS_DEBUG
- if (rv) printf("PWR SLEEP: EVE SLEEP ERR:%d\n", rv);
-#endif
-
- rv = eos_net_sleep(1000);
-#ifdef EOS_DEBUG
- if (rv) printf("PWR SLEEP: NET SLEEP ERR:%d\n", rv);
-#endif
+ if (rv) EOS_LOG(EOS_LOG_ERR, "PWR SLEEP: EVE SLEEP ERR:%d\n", rv);
- eos_flash_norm();
+ eos_evtq_set_loopf(pwr_sleep_rdy);
- eos_pwr_sleep();
+ rv = eos_net_sleep();
+ if (rv) EOS_LOG(EOS_LOG_ERR, "PWR SLEEP: NET SLEEP REQ ERR:%d\n", rv);
}