Browse Source

feature: 1.解决唤醒MCU需要按两次才能开机的问题 2.完善外部中断处理函数,解决唤醒MCU后WiFi模块不工作的问题

v4-temp-lowpower
Zhangwen 4 months ago
parent
commit
2efb5dac5e
  1. 2
      source/app/app_config.c
  2. 1
      source/app/main.c
  3. 37
      source/app/task_appstatus.c
  4. 4
      source/app/task_keystatus.c
  5. 4
      source/app/task_keystatus.h

2
source/app/app_config.c

@ -22,7 +22,7 @@ void L3_param_init(void)
G.volume = 0x15;
//U8 i;
G.debug = 0;
G.debug = 1;
//station模式状态
G.st_status = 0; //0:none 1:wifi_ok 2:tcp_connect_ok
//station模式sid

1
source/app/main.c

@ -106,7 +106,6 @@ void main(void)
{
s_nos_tick.t1s_heartbeat = 0;//置0清空
L0_uart0_uc('.');
L0_uart0_uchex(R.app_status);
// L0_uart0_sendstr("ADC = ");
// L0_uart0_ushex(_s_task_adc.adc_val[_s_task_adc.index]);
// L0_uart0_0d0a();

37
source/app/task_appstatus.c

@ -10,6 +10,8 @@
#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)
@ -29,14 +31,28 @@ void Enter_PowerDown(void)
P3IE = 0x00;
P4IE = 0x00;
P5IE = 0x00;
// 只使能P3.2唤醒
// P3IE = 0x04;
PCON |= 0x02; // 执行PD指令
// PCON |= 0x01; // 执行IDL指令
_nop_(); //掉电模式被唤醒后,MCU 首先会执行此语句
//然后再进入中断服务程序
_nop_();
_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;
@ -97,12 +113,9 @@ void L3_task_appstatus_handler(S_TASK_APPSTATUS *s)
Lc_delay_ms(5000);
// 语音模块关闭
L2_WT2605B_OFF();
// MCU进入掉电模式
Enter_PowerDown();
// 唤醒后绿灯亮起
L2_GREEN_LED_ON();
}
else if (s->status == POW_ON_WAIT)
{
@ -198,5 +211,11 @@ void PowerOff_judge()
void INT0_Isr() interrupt 0
{
// 无需任何操作,中断仅用于唤醒MCU
// 唤醒后程序从Enter_PowerDown()后的指令继续执行
// 唤醒后程序从Enter_PowerDown()中 PCON |= 0x02; 后的指令继续执行
P0IE = 0xFF;
P1IE = 0xFF;
P2IE = 0xFF;
P3IE = 0xFF;
P4IE = 0xFF;
P5IE = 0xFF;
}

4
source/app/task_keystatus.c

@ -44,7 +44,6 @@ void L3_task_keystatus_handler(S_TASK_KEYSTATUS *s)
TTSS_Task_step(D_task_KEY_DETECT)
if(L2_ReadKey3() == Key_Down)
{
L0_uart0_uc('!');
R.Operate_time = D_sys_now;
if (s->Key3_Down_Begin_Time == 0)
{
@ -56,17 +55,14 @@ void L3_task_keystatus_handler(S_TASK_KEYSTATUS *s)
// L0_uart0_ulhex(diff);
if (diff >= LongKey_PWR_MSeconds/JIFFIES && s->Key3_handled == 0)
{
L0_uart0_uc('@');
if (R.app_status == POW_OFF)
{
L0_uart0_uc('#');
R.app_status = POW_ON_WAIT;
s->Key3_Down_Begin_Time = 0;
s->Key3_handled = 1;
}
else
{
L0_uart0_uc('$');
R.app_status = POW_OFF;
s->Key3_Down_Begin_Time = 0;
s->Key3_handled = 1;

4
source/app/task_keystatus.h

@ -17,8 +17,8 @@
#include "../ctask/task.h"
#define LongKey_PWR_MSeconds 3000
#define LongKey_WIFICONF_MSeconds 2000
#define LongKey_PWR_MSeconds 2000 //长按2s开机
#define LongKey_WIFICONF_MSeconds 2000 //长按2s配网
typedef struct _s_task_keystatus

Loading…
Cancel
Save