1 Star 0 Fork 1

gl_21/BT_00253_BYD_FAN

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
POWER_CTR.C 3.77 KB
一键复制 编辑 原始数据 按行查看 历史
董永文 提交于 2024-05-18 11:54 . 上车OK
#include "sys_api.h"
SLEEP_STRUCT sleep;
u8 time_wakeup_flag=0x00;
void LPTIMNVIC_Config(FunctionalState Cmd);
void Sleep_ctr(void)//
{
#if SLEEP_EN
if( sleep.sleep_en)
{
Output[STB_OUT].GPIOx->PBSC=Output[STB_OUT].PIN;
Output[M_5V_EN].GPIOx->PBC=Output[M_5V_EN].PIN;
}
#endif
}
void EXit_Sleep(void)
{
sleep.sleep_en=0X00;
sleep.sleep_time_ms=0x00;
EXTI->IMASK&=~(1<<15);
EXTI->IMASK&=~(1<<5);
if(sleep.sleep_en==0)
{
sleep.sleep_en=0X00;
mcu_iwdg_clr();
system_init();
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
#if CAN_EN
can_sleepflag=0x00;
_rCanTx.StopsendTime=0x00;
_rCanTx.stopsend=FALSE;
#endif
sleep.sleep_interrupt = 0x00;
SysTick->CTRL |= SysTick_CTRL_ENABLE_Msk;
}
//B4 B3 C11 C10 B5
void Exit_Config(void)
{
NVIC_InitType NVIC_InitStructure;
EXTI_InitType EXTI_InitStructure;
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_PWR, ENABLE);
GPIO_ConfigEXTILine(GPIOB_PORT_SOURCE, GPIO_PIN_SOURCE15); //PA5
GPIO_ConfigEXTILine(GPIOA_PORT_SOURCE, GPIO_PIN_SOURCE5); //PB15
NVIC_Init(&NVIC_InitStructure);
EXTI_DeInit();
/*Set key input interrupt priority*/
NVIC_InitStructure.NVIC_IRQChannel = EXTI4_15_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/*Configure key EXTI line*/
EXTI_InitStructure.EXTI_Line = EXTI_LINE5;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; // EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_InitPeripheral(&EXTI_InitStructure);
EXTI_InitStructure.EXTI_Line = EXTI_LINE5;
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; // EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_InitPeripheral(&EXTI_InitStructure);
EXTI->IMASK&=~(1<<5);
EXTI->IMASK&=~(1<<15);
/* Enable the LSI source */
RCC_EnableLsi(ENABLE);
LPTIMNVIC_Config(ENABLE);
RCC_ConfigLPTIMClk(RCC_LPTIMCLK_SRC_LSI);
RCC_EnableAPB1PeriphClk(RCC_APB1_PERIPH_LPTIM,ENABLE);
/* Enable interrupt */
LPTIM_SetPrescaler(LPTIM,LPTIM_PRESCALER_DIV1);
LPTIM_EnableIT_CMPM(LPTIM);
/* config lptim ARR and compare register */
LPTIM_Enable(LPTIM);
LPTIM_SetAutoReload(LPTIM,35000);
LPTIM_SetCompare(LPTIM,0);
LPTIM_StartCounter(LPTIM,LPTIM_OPERATING_MODE_CONTINUOUS);
}
void LPTIMNVIC_Config(FunctionalState Cmd)
{
EXTI_InitType EXTI_InitStructure;
NVIC_InitType NVIC_InitStructure;
EXTI_ClrITPendBit(EXTI_LINE23);
EXTI_InitStructure.EXTI_Line = EXTI_LINE23;
#ifdef __TEST_SEVONPEND_WFE_NVIC_DIS__
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Event;
#else
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
#endif
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
EXTI_InitPeripheral(&EXTI_InitStructure);
/* Enable the RTC Alarm Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = LPTIM_TIM6_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelCmd = Cmd;
NVIC_Init(&NVIC_InitStructure);
}
void DBG_init(void)
{
#if SYS_RUN
DBG_ConfigPeriph(DBG_STOP , ENABLE);
DBG_ConfigPeriph(DBG_TIM1_STOP , ENABLE);
DBG_ConfigPeriph(DBG_TIM3_STOP , ENABLE);
DBG_ConfigPeriph(DBG_TIM4_STOP , ENABLE);
DBG_ConfigPeriph(DBG_CAN_STOP , ENABLE);
DBG_ConfigPeriph(DBG_IWDG_STOP , ENABLE);
#endif
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gl__twentyone/bt_00253_-byd_-fan.git
git@gitee.com:gl__twentyone/bt_00253_-byd_-fan.git
gl__twentyone
bt_00253_-byd_-fan
BT_00253_BYD_FAN
main

搜索帮助