board.c 添加长按IO配置和4秒/8秒配置:
/************************** PWR wakeup config ****************************/
//#define PORT_VCC33_CTRL_IO IO_PORTA_03 //VCC33 DCDC控制引脚,该引脚控制DCDC器件输出的3.3V连接芯片HPVDD、VDDIO、VDD33
#define PORT_WAKEUP_IO IO_PORTB_01 //软关机和休眠唤醒引脚
#define PORT_WAKEUP_NUM (PORT_WAKEUP_IO/IO_GROUP_NUM)//默认:0-7:GPIOA-GPIOH, 可以指定0-7组
//软关机硬件唤醒IO相关配置
static const struct port_wakeup port0 = {
.edge = FALLING_EDGE, //唤醒方式选择,可选:上升沿\下降沿
.attribute = BLUETOOTH_RESUME, //保留参数
.iomap = PORT_WAKEUP_IO, //唤醒口选择
.low_power = POWER_SLEEP_WAKEUP|POWER_OFF_WAKEUP, //低功耗IO或睡眠唤醒,不需要写0
};
//正常工作长按复位IO配置
static const struct long_press lpres_port = {
.enable = TRUE, //是否使用长按复位,TRUE为使能,FALSE则禁能
.use_sec4 = TRUE, //enable = TRUE , use_sec4: TRUE --> 4 sec , FALSE --> 8 sec
.edge = FALLING_EDGE, //长按方式,可选:FALLING_EDGE / RISING_EDGE --> 低电平/高电平
.iomap = PORT_WAKEUP_IO, //长按复位IO和IO唤醒共用一个IO
};
//保留参数,无需更改
static const struct sub_wakeup sub_wkup = {
.attribute = BLUETOOTH_RESUME,
};
//保留参数,无需更改
static const struct charge_wakeup charge_wkup = {
.attribute = BLUETOOTH_RESUME,
};
//唤醒参数配置
static const struct wakeup_param wk_param = {
.port[0] = NULL,//当需要IO唤醒,详情soft_power_off例子
.sub = &sub_wkup,
.charge = &charge_wkup,
.lpres = &lpres_port,//当使用正常工作时可长按复位功能,详情longpress例子
};
//电源初始化
static void board_power_init(void)
{
power_wakeup_init(&wk_param);//唤醒参数初始化,包括长按复位
}