Files
TXH1.0/User/Pulse_InPut/Pluse_InPut.c
T
2026-04-27 16:55:02 +08:00

161 lines
5.8 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "config.h"
/****************************************************
函数名:Pluse_InPut_IO_Configuration
功能 Pluse_InPut部分用到的IO初始化
参数 :无
返回值:无
****************************************************/
void Pluse_InPut_IO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure; //定义GOIP配置结构体
RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOD| RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOG, ENABLE);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_Init(GPIOE, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOG, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_DOWN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
GPIO_ResetBits(GPIOA,GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2);
GPIO_SetBits(GPIOD,GPIO_Pin_14 | GPIO_Pin_15);
GPIO_SetBits(GPIOE,GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13);
GPIO_ResetBits(GPIOE,GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7);
GPIO_SetBits(GPIOG,GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7);
GPIO_SetBits(GPIOA,GPIO_Pin_10);
if(Key1 == 1)
{
TXHData.BoardType = 1; //新主板,带屏幕的
}
else
TXHData.BoardType = 0;
}
/****************************************************
函数名:Pluse_InPut_EXTI_Configuration
功能 :中断配置(掉电检测)
参数 :无
返回值:无
****************************************************/
void Pluse_InPut_EXTI_Configuration(void)
{
EXTI_InitTypeDef EXTI_InitStructure; //定义中断配置结构体
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);//使能 SYSCFG 时钟
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource0);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource1);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource8);
SYSCFG_EXTILineConfig(EXTI_PortSourceGPIOE, EXTI_PinSource9);
/* 配置 EXTI_Line0 */
EXTI_InitStructure.EXTI_Line = EXTI_Line0;//LINE0
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//中断事件
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; //下降沿触发
EXTI_InitStructure.EXTI_LineCmd = ENABLE;//使能 LINE10
EXTI_Init(&EXTI_InitStructure);//
/* 配置 EXTI_Line1 */
EXTI_InitStructure.EXTI_Line = EXTI_Line1;//LINE1
EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;//中断事件
EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Rising_Falling; //下降沿触发
EXTI_InitStructure.EXTI_LineCmd = ENABLE;//使能 LINE10
EXTI_Init(&EXTI_InitStructure);//
}
void Pluse_InPut_NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
// NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;//外部中断 11
// NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x03;//抢占优先级 0
// NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;//响应优先级 2
// NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//使能外部中断通道
// NVIC_Init(&NVIC_InitStructure);//配置 NVIC
/***************************断电检测****************************/
NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;//外部中断 0
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x03;//抢占优先级 0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;//响应优先级 2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//使能外部中断通道
NVIC_Init(&NVIC_InitStructure);//配置 NVIC
NVIC_InitStructure.NVIC_IRQChannel = EXTI1_IRQn;//外部中断 1
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x03;//抢占优先级 0
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0x01;//响应优先级 2
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;//使能外部中断通道
NVIC_Init(&NVIC_InitStructure);//配置 NVIC
}
void Pluse_InPut_Init(void)
{
Pluse_InPut_IO_Configuration();
delay_ms(100);
Pluse_InPut_EXTI_Configuration();
Pluse_InPut_NVIC_Configuration();
if(POS_Wireless == SWF_ON)
{
if(POS_URL == SWF_ON)
TXHData.POS_Info.ConnectType = POS_Connect_Typ_Cloud_Tast;
else
TXHData.POS_Info.ConnectType = POS_Connect_Typ_Cloud;
TXHData.POS_Info.NetType = ~((POS_NetTypeH << 1) | POS_NetTypeL);
TXHData.POS_Info.NetType &= 0x03;
}
else
{
TXHData.POS_Info.ConnectType = POS_Connect_Typ_Station;
}
if(POS_Monitor == SWF_ON)
TXHData.POS_MonitorModel = 1;
else
TXHData.POS_MonitorModel = 0;
TXHData.HardwareVersion = ((HV4 << 4) | (HV3 << 3) | (HV2 << 2) | (HV1 << 1) | HV0) + 24;//最高位1表示小板。0表示标准版
}
void Pluse_InPut_IRQHandler(void)
{
u8 i = 0;
/****************拉断开关1***************/
if(EXTI_GetITStatus(EXTI_Line8) != RESET)
{
EXTI_ClearITPendingBit(EXTI_Line8);
}
/****************拉断开关2***************/
if(EXTI_GetITStatus(EXTI_Line9) != RESET)
{
EXTI_ClearITPendingBit(EXTI_Line9);
}
/****************掉电检测***************/
if(EXTI_GetITStatus(EXTI_Line0) != RESET)
{
TXHData.PowerDown.Flag.Power10V = 1 - PowerLow10V;
EXTI_ClearITPendingBit(EXTI_Line10);
}
if(EXTI_GetITStatus(EXTI_Line1) != RESET)
{
TXHData.PowerDown.Flag.Power7V = 1 - PowerLow7V;
EXTI_ClearITPendingBit(EXTI_Line10);
}
}