#ifndef _PWR_SLEEP_H
#define _PWR_SLEEP_H

#include "include.h"

#define BT_WAKEUP_INTERVAL      (50000 / 312)

// 关机模式
#define POWEROFF_WK_IO          POWEROFF_WAKEUP_PB5
#define POWEROFF_WK_LEVEL       POWEROFF_WK_LEVEL_L

// 睡眠模式
#define SLEEP_WK_IO             WAKEUP_PORT_PB5
#define SLEEP_WK_EDGE           WAKE_EDGE_FALLING

// 开启定时唤醒功能
#define TIMED_WK_EN             1

typedef enum {
    WAKEUP_PORT_PA7         = 0x00,//16
    WAKEUP_PORT_PB1         = 0x01,
    WAKEUP_PORT_PB2         = 0x02,
    WAKEUP_PORT_PB3         = 0x03,
    WAKEUP_PORT_PB4         = 0x04,
    WAKEUP_PORT_PB5         = 0x05,//21
    WAKEUP_PORT_INT_FALL    = 0x06,//22
    WAKEUP_PORT_INT_RISE    = 0x07,//23
} WAKEUP_PORT_SEL;

typedef enum {
    WAKE_EDGE_RISING        = 0x00,
    WAKE_EDGE_FALLING       = 0x01,
} WAKEUP_EDGE_SEL;

typedef enum {
    POWEROFF_WAKEUP_VUSB    = 0x01,
    POWEROFF_WAKEUP_ALARM   = 0x02,
    POWEROFF_WAKEUP_PB0     = 0x04,
    POWEROFF_WAKEUP_PB1     = 0x08,
    POWEROFF_WAKEUP_PB2     = 0x10,
    POWEROFF_WAKEUP_PB5     = 0x20,
} PWOEROFF_WAKEUP_SEL;

typedef enum {
    POWEROFF_WK_LEVEL_L     = 0x00,
    POWEROFF_WK_LEVEL_H     = 0x01,
} POWEROFF_WK_LEVEL_SEL;

void sleep_enter(void);
void pwrdwn_enter(void);
void pwr_on_check(void);

#endif // _PWR_SLEEP_H
