|
|
@ -10,7 +10,49 @@ |
|
|
|
#include "../app/task_Adc.h" |
|
|
|
#include "../app/task_w600.h" |
|
|
|
#include "../bsp/bsp_wifi.h" |
|
|
|
#include "../bsp/bsp_key.h" |
|
|
|
|
|
|
|
|
|
|
|
// 外部中断初始化P3.2
|
|
|
|
void INT0_Init(void) |
|
|
|
{ |
|
|
|
D_stdIO_P3(BITN2); |
|
|
|
IT0 = 1; // 下降沿触发
|
|
|
|
EX0 = 1; // 使能INT0
|
|
|
|
} |
|
|
|
|
|
|
|
// 掉电模式函数
|
|
|
|
void Enter_PowerDown(void) |
|
|
|
{ |
|
|
|
// 禁用所有唤醒源
|
|
|
|
P0IE = 0x00; |
|
|
|
P1IE = 0x00; |
|
|
|
P2IE = 0x00; |
|
|
|
P3IE = 0x00; |
|
|
|
P4IE = 0x00; |
|
|
|
P5IE = 0x00; |
|
|
|
|
|
|
|
PCON |= 0x02; // 执行PD指令
|
|
|
|
// PCON |= 0x01; // 执行IDL指令
|
|
|
|
_nop_(); //掉电模式被唤醒后,MCU 首先会执行此语句
|
|
|
|
//然后再进入中断服务程序
|
|
|
|
_nop_(); |
|
|
|
|
|
|
|
// MCU被唤醒后,绿灯亮起
|
|
|
|
L2_GREEN_LED_ON(); |
|
|
|
if(L2_ReadKey3() == Key_Down) |
|
|
|
{ |
|
|
|
Lc_delay_ms(1000); |
|
|
|
if(L2_ReadKey3() == Key_Down) |
|
|
|
{ |
|
|
|
Lc_delay_ms(1000); |
|
|
|
if(L2_ReadKey3() == Key_Down) |
|
|
|
{ |
|
|
|
R.app_status = POW_ON_WAIT; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
S_TASK_APPSTATUS _s_task_appstatus; |
|
|
|
|
|
|
@ -71,6 +113,9 @@ void L3_task_appstatus_handler(S_TASK_APPSTATUS *s) |
|
|
|
Lc_delay_ms(5000); |
|
|
|
// 语音模块关闭
|
|
|
|
L2_WT2605B_OFF(); |
|
|
|
// MCU进入掉电模式
|
|
|
|
Enter_PowerDown(); |
|
|
|
|
|
|
|
} |
|
|
|
else if (s->status == POW_ON_WAIT) |
|
|
|
{ |
|
|
@ -161,3 +206,16 @@ void PowerOff_judge() |
|
|
|
L0_uart0_0d0a(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 外部中断0服务函数
|
|
|
|
void INT0_Isr() interrupt 0 |
|
|
|
{ |
|
|
|
// 无需任何操作,中断仅用于唤醒MCU
|
|
|
|
// 唤醒后程序从Enter_PowerDown()中 PCON |= 0x02; 后的指令继续执行
|
|
|
|
P0IE = 0xFF; |
|
|
|
P1IE = 0xFF; |
|
|
|
P2IE = 0xFF; |
|
|
|
P3IE = 0xFF; |
|
|
|
P4IE = 0xFF; |
|
|
|
P5IE = 0xFF; |
|
|
|
} |