summaryrefslogtreecommitdiff
path: root/fw/fe310/eos/dev/pwr.c
blob: 06a76d8752ec498b18fd280e8ddb9cfb9df4e579 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdlib.h>
#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"

#include "eve.h"
#include "lcd.h"
#include "ctp.h"
#include "net.h"
#include "flash.h"
#include "aon.h"

#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
        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();
    if (rv) EOS_LOG(EOS_LOG_ERR, "PWR SLEEP: LCD SLEEP ERR:%d\n", rv);

    rv = eos_ctp_sleep();
    if (rv) EOS_LOG(EOS_LOG_ERR, "PWR SLEEP: CTP SLEEP ERR:%d\n", rv);

    rv = eos_eve_sleep();
    if (rv) EOS_LOG(EOS_LOG_ERR, "PWR SLEEP: EVE SLEEP ERR:%d\n", rv);

    eos_evtq_set_loopf(pwr_sleep_rdy);

    rv = eos_net_sleep();
    if (rv) EOS_LOG(EOS_LOG_ERR, "PWR SLEEP: NET SLEEP REQ ERR:%d\n", rv);
}