You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
2.6 KiB

4 years ago
////////////////////////////////////////////////////////////////////////////
///@copyright Copyright (c) 2017, 传控科技 All rights reserved.
///-------------------------------------------------------------------------
/// @file APP_POWER.c
/// @brief APP_POWER driver app 电源管理
///-------------------------------------------------------------------------
/// @version 1.0
/// @author CC
/// @date 20170122
/// @note cc_AS_stc01
//////////////////////////////////////////////////////////////////////////////
/******************************************************************************/
/***************************** Include Files **********************************/
/******************************************************************************/
//#include "app_Gsensor.h"
#include "bsp_power.h"
ts_task_power_ ts_task_power;
void L1_app_POWER_init(void)
{
DL0_WDT_init();
//L0_INT4_OPEN();
}
/// INT1 和INT0可以可以终止掉电状态 这样唤醒后执行进入掉电模式语句的吓一条
/// p32
//// SENSINT2 ccSensor_CG_V02_m08_debug p3.3 int 1 pin14
//// gsensor 的中断给出来 cpu被唤醒 开始工作
//// int4 只有下降沿中断
void L0_sensor_active(void) interrupt D_sensor_active_isrNo
{
NOP(); NOP(); NOP();
//L0_INT4_CLEAR();
BITN_1(DR_who_wakeup, DRB_who_wakeup_action);
NOP(); NOP(); NOP();
}
#if 0
while (1)
{
/// P31 = 0;
/// NOP(); NOP(); NOP(); NOP(); NOP();///22m 5个 100ns 一个20ns
D_cam_led_on();///400us
// L0_delay_1us();
Lc_delay_ms(gRccUs01);///300--200ms
D_cam_led_off();
P31 = 1;
/// NOP(); NOP(); NOP(); NOP(); NOP();
//L0_delay_1us();
Lc_delay_ms(900);//100--70ms
}
void L1_app_POWER_handle(void)
{
//// fixme: 需要调试
/**********************
if(1 == s_mu_b.power)
{
s_mu_b.power = 0;
if(INT1)///___/```
{// 催眠cpu
L0_uart0_uc('`');
//给主循环传递标志
s_mu_b.work = 0;
}else
{// 唤醒cpu/// ```\____
L0_uart0_uc('L');
s_mu_b.work = 1;
}
}
if(P30)///___/```
{//
// L0_uart0_uc('`');
}else
{// 唤醒cpu/// ```\____
L0_uart0_uc('L');
s_mu_b.work = 1;
}
************************/
if(1 == ts_task_power.power)
{
ts_task_power.power = 0;
///L0_uart0_uc('L');
}
}
if(0 == s_mu_b.work)
{/// step 1: 关闭一些耗电的东西
/// fixme: vcc1 因为下载的原因需要 改进
/// vcc1 ch340e Uart4.txd
// L2_power_AS_OFF();
/// L0_mcu_mode_powerdown();
/// L2_power_AS_ON();
//// step : 打开电源
}
void Int0_Routine(void) interrupt D_ISR_int1
{
s_mu_b.power = 1;
}
#endif