20260324
This commit is contained in:
77
IAPV1.1/Driver/exti/exti_io.c
Normal file
77
IAPV1.1/Driver/exti/exti_io.c
Normal file
@ -0,0 +1,77 @@
|
||||
#include "bsp.h"
|
||||
#include "exti_io.h"
|
||||
|
||||
void WakeUp_EXIT_Config( void )
|
||||
{
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
NVIC_InitTypeDef NVIC_InitStructure;
|
||||
EXTI_InitTypeDef EXTI_InitStructure;
|
||||
//enable GPIOA Clock
|
||||
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
|
||||
// config PA10 as input floating
|
||||
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
|
||||
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN; //very import
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
//enable syscfg clock
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
|
||||
// connect EXTI0 line to PA0 pin
|
||||
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOA, EXTI_PinSource0);
|
||||
|
||||
//config EXTI10 Line
|
||||
EXTI_InitStructure.EXTI_Line = EXTI_Line0;
|
||||
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
|
||||
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising;
|
||||
EXTI_InitStructure.EXTI_LineCmd = ENABLE;
|
||||
EXTI_Init(&EXTI_InitStructure);
|
||||
|
||||
// enable and set EXTI0 interrupu to the lowest priority
|
||||
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
|
||||
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x01;
|
||||
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x00;
|
||||
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
|
||||
NVIC_Init(&NVIC_InitStructure);
|
||||
PWR_WakeUpPinCmd(PWR_WakeUpPin_1,ENABLE);
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD>WKUP<55>ŵ<EFBFBD><C5B5>ź<EFBFBD>
|
||||
//<2F><><EFBFBD><EFBFBD>ֵ1:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>3s<33><73><EFBFBD><EFBFBD>
|
||||
// 0:<3A><><EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
|
||||
u8 Check_WKUP(void)
|
||||
{
|
||||
u8 t=0; //<2F><>¼<EFBFBD><C2BC><EFBFBD>µ<EFBFBD>ʱ<EFBFBD><CAB1>
|
||||
|
||||
while(1)
|
||||
{
|
||||
if(WKUP_KD)
|
||||
{
|
||||
t++; //<2F>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
delay_ms(30);
|
||||
if(t>=100) //<2F><><EFBFBD>³<EFBFBD><C2B3><EFBFBD>3<EFBFBD><33><EFBFBD><EFBFBD>
|
||||
{
|
||||
|
||||
return 1; //<2F><><EFBFBD><EFBFBD>3s<33><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
}
|
||||
}else
|
||||
{
|
||||
|
||||
return 0; //<2F><><EFBFBD>²<EFBFBD><C2B2><EFBFBD>3<EFBFBD><33>
|
||||
}
|
||||
}
|
||||
}
|
||||
void EXTI0_IRQHandler( void )
|
||||
{
|
||||
EXTI_ClearITPendingBit(EXTI_Line10); //Clear the EXTI line 10 pending bit
|
||||
if(Check_WKUP()==0)//<2F>ػ<EFBFBD>?
|
||||
{
|
||||
Wake_Up_Flag=0;
|
||||
PWR_EnterSTANDBYMode(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>STANDBY<42><59>ģʽ
|
||||
}else
|
||||
{
|
||||
Wake_Up_Flag=1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
14
IAPV1.1/Driver/exti/exti_io.h
Normal file
14
IAPV1.1/Driver/exti/exti_io.h
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef _exti_io_H
|
||||
#define _exti_io_H
|
||||
|
||||
#include "bsp.h"
|
||||
|
||||
#include "stm32l1xx_exti.h"
|
||||
#include "stm32l1xx_syscfg.h"
|
||||
|
||||
#define WKUP_KD PAin(0) //PA0 <20><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7>ⲿWK_UP<55><50><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
extern u8 Wake_Up_Flag;
|
||||
u8 Check_WKUP(void);
|
||||
void WakeUp_EXIT_Config( void );
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user