Both_Way_Comm_SY8833/TP3310_Demo.si4project/Backup/sleep(1218).c

131 lines
3.2 KiB
C

/*
******************************************************************************
*
* @file sleep.c
* @brief sleep module
*
*
* @version 1.0
* @date 2023/03/22 17:35:40
* @author Alex Xu
*
* Copyright (c) 2013-2099,Tkplusemi Technology Co.,Ltd.
* All Rights Reserved
*
* History:
* Revision Date Author Desc
* 1.0.0 2023/03/22 Alex build this file
******************************************************************************
*/
#include "sleep.h"
#include "led.h"
#include "system.h"
#include "vox_module.h"
#include "discharge_module.h"
#include "charger_module.h"
#include "bat.h"
#include "hall.h"
#include "gpio.h"
#include "sys_tim.h"
#if SLEEP_ENABLE
/******************************************************************************\
Macro definitions
\******************************************************************************/
/******************************************************************************\
Variables definitions
\******************************************************************************/
uint8_t Decnt_SleepDelay = 0;
bit Enter_Sleep_Cnt_Restart_Flag = 0;
/******************************************************************************\
Functions definitions
\******************************************************************************/
/*
*******************************************************************************
* void WakeUp_Init_Set(void)
*
* Description : 系统唤醒源使能设置,系统初始化调用。
*
*
* Arguments : NONE
* Returns : NONE
* Notes : NONE
*
*******************************************************************************
*/
void WakeUp_Init_Set(void)
{
//set wakeup
SFRADDR = WKUP_EN0;
SFRDATA = 0xE4; //wake0 up enable.
SFRADDR = WKUP_EN1;
SFRDATA = 0xFF; //wake1 up enable.
SFRADDR = WKUP_EN3;
SFRDATA = 0xFF; //wake3 up enable.bat low,Timer,VOX loadin\loadon wake up.
}
/*
*******************************************************************************
* bool Check_Require_Sleep(void )
*
* Description : 查询休眠唤醒源标志位函数。
*
* Arguments : None
* Returns : None
* Notes : bool Flag
*
*******************************************************************************
*/
bool Check_Require_Sleep(void )
{
if(Protect_Type_Flg || gIrq_Event_Type)
{
#ifdef _DEBUG_SLEEP
printf("Pro_Type(0x%x)(Event_Type:0x%x).\r\n",(uint16_t)Protect_Type_Flg, (uint16_t)gIrq_Event_Type);
#endif
/*处理对应的保护和中断唤醒事件。*/
return false;
}
return true;
}
/*
*******************************************************************************
* void Enter_Sleep(void)
*
* Description : 进入休眠函数。
*
* Arguments : None
* Returns : None
* Notes : None
*
*******************************************************************************
*/
void Enter_Sleep(void)
{
InSleep_Handler(); //Disable All IRQ
PCON |= 0x02; //Enter StandbyMode, Only int0 or int1 can wake up system
OutSleep_Handler(); //Enable IRQ
}
#endif