Compare commits

...

4 Commits

  1. 2
      source/app/app_config.c
  2. 16
      source/app/main.c
  3. 58
      source/app/task_appstatus.c
  4. 3
      source/app/task_appstatus.h
  5. 4
      source/app/task_keystatus.h
  6. 2
      source/bsp/bsp_WT2605B.c
  7. 3
      source/bsp/bsp_key.c
  8. 2
      source/bsp/bsp_key.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

16
source/app/main.c

@ -15,6 +15,9 @@ void L0_MCU_init(void)
L1_tick_init();
//开启全局中断
EA = 1;
// 外部中断初始化
INT0_Init();
// 定时器初始化
L0_timer0_Init();
//G初始化
@ -75,6 +78,9 @@ void main(void)
//任务初始化
L0_TASK_init();
// // // 禁用不需要的唤醒源
// WAKE_CLKO = 0x00; // 关闭所有特殊唤醒源
// // 获取mcu id
// L0_id_get_rom(G.mcu_id);
// L0_uart0_sendstr("MCU_ID = ");
@ -100,11 +106,11 @@ void main(void)
{
s_nos_tick.t1s_heartbeat = 0;//置0清空
L0_uart0_uc('.');
L0_uart0_sendstr("ADC = ");
L0_uart0_ushex(_s_task_adc.adc_val[_s_task_adc.index]);
L0_uart0_0d0a();
L0_uart0_sendstr("Vin = ");
L0_uart0_ushex(G.Vin);
// L0_uart0_sendstr("ADC = ");
// L0_uart0_ushex(_s_task_adc.adc_val[_s_task_adc.index]);
// L0_uart0_0d0a();
// L0_uart0_sendstr("Vin = ");
// L0_uart0_ushex(G.Vin);
// i++;
// if (i == 3)
// {

58
source/app/task_appstatus.c

@ -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;
}

3
source/app/task_appstatus.h

@ -21,4 +21,7 @@ extern void L3_task_AppStatus_init(void);
extern void L3_task_appstatus_handler(S_TASK_APPSTATUS *s);
extern void PowerOff_judge();
extern void INT0_Init(void);
extern void Enter_PowerDown(void);
#endif // #ifndef

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

2
source/bsp/bsp_WT2605B.c

@ -171,7 +171,7 @@ void L2_WT2605B_init()
// 初始4.2V控制引脚P03
// 1 开启 0 关闭
D_HighI_P0(BITN3);
L2_WT2605B_ON();
L2_WT2605B_OFF();
// 初始化音量
L2_WT2605B_VolumeControl(G.volume);

3
source/bsp/bsp_key.c

@ -4,7 +4,8 @@ void L2_key_init()
{
D_stdIO_P2(BITN1);
D_stdIO_P2(BITN0);//准双向口
D_stdIO_P0(BITN2);
// D_stdIO_P0(BITN2);
D_stdIO_P3(BITN2);
//初始化为高电平
Key1 = Key2 = Key3 = 1;

2
source/bsp/bsp_key.h

@ -9,7 +9,7 @@
#define Key1 P21 //音量增大
#define Key2 P20 //音量减小
#define Key3 P02 //开关机
#define Key3 P32 //开关机
// #define Key (key1 && key2 && key3)

Loading…
Cancel
Save