/******************************************************************************** **** Copyright (C), 2020, Fortior Technology Co., Ltd. **** ******************************************************************************** * File Name : GPIO.c * Author : Bruce HW&RD * Date : 2020-10-15 * Description : .C file function description * Version : 1.0 * Function List : * * Record : * 1.Date : 2020-10-15 * Author : Bruce HW&RD * Modification: Created file ********************************************************************************/ #include "FU68xx_5.h" #include void GPIO_Init(void) { SetBit(P4_OE , P42);//电子膨胀阀驱动IO-A P4_OE = P42; GP42 = 0; /*交流风机--输出*/ // GP44 = 0; SetBit(P4_OE , P44);//电子膨胀阀驱动IO-A P4_OE = P42;?? GP44 = 0; /*继电器相关 -- 输出*/ /*PTC_RELAY*/ // GP51 = 0; SetBit(P5_OE , P51); GP51 = 0; /*DJR*/ // GP04 = 0; SetBit(P0_OE , P04); SetBit(P0_PU , P04); GP04 = 0; /*4WAY*/ // GP01 = 0; SetBit(P0_OE , P01); GP01 = 0; SetBit(P0_OE , P07);//电子膨胀阀驱动IO-D P0_OE = P07; GP07 = 0; SetBit(P0_OE , P00);//电子膨胀阀驱动IO-D P0_OE = P07; GP00 = 0; SetBit(P1_OE , P10);//电子膨胀阀驱动IO-C P1_OE = P10; GP10 = 0; SetBit(P4_OE , P41);//电子膨胀阀驱动IO-B P4_OE = P41; GP41 = 0; SetBit(P1_OE , P11);//电子膨胀阀驱动IO-C P1_OE = P10; GP11 = 0; /*LED*/ // GP22 = 0; SetBit(P0_OE , P03); GP03 = 0; } /***************************************************************************** * Function : INT0_Init * Description : INT0初始化 * Input : void * Output : None * Return : * Others : * Record * 1.Date : 20201015 * Author : Bruce HW&RD * Modification: Created function *****************************************************************************/ void INT0_Init(void) { /*EXTI Input Pin 配置 ---------------------------------------- */ ClrBit(P0_OE , PIN2); // config P00 as input,配置P0.0为硬件过流FO端口 ClrBit(P0_PU , PIN2); // 0:disable pull up, 1:enable P10 pull up SetReg(LVSR , EXT0CFG0 | EXT0CFG1 | EXT0CFG2 , EXT0CFG1); //外部中断0配置 IF0 = 0; // clear P00 interrupt flag // 00: rising edge interrupt,01: failing edge interrupt,1x: edge-change mode interrupt IT01 = 0; IT00 = 1; SetBit(EVT_FILT , INT0_MOE_EN); //INT0中断关闭MOE使能 /*---------------------------------------------------------------------------------- 母线电流保护时间滤波宽度 00-不滤波 01-6cpu clock 10-12cpu clock 11-24cpu clock -----------------------------------------------------------------------------------*/ SetBit(EVT_FILT , EFDIV1); ClrBit(EVT_FILT , EFDIV0); /*--------------------------------------------------------------------------- 外部中断优先级配置及芯片中断总使能 PX01-PX00,中断优先级控制值从0-3依次表示优先级从最低到最高,共4级优化级控制 EX0,外部中断0使能 EA,芯片中断总使能 外部中断是否有滤波的配置,决定于选择硬件保护触发信号源,外部中断0或者比较器3中断。 若选择了比较器3中断,则外部中断无法进行滤波配置 --------------------------------------------------------------------------*/ SetBit(IP0 , PX01);//优先级 SetBit(IP0 , PX00); EX0 = 1; // 使能外部中断0, POO位外部中断输入硬件 EA = 1; // 使能全局中断 } void INT1_Init(void) { ClrBit(P1_OE, P12); // config P11 as input ClrBit(P1_PU, P12); // diasable P11 Pull Up SetBit(P1_IE, P12); // config P11 as input ClrBit(P1_IF, P12); IT11 = 0; IT10 = 1; // 00: rising edge interrupt,01: failing edge interrupt,1x: edge-change mode interrupt SetBit(IP0 , PX11);//优先级 SetBit(IP0 , PX10); EX1 = 1; // 使能外部中断1, P11位外部中断输入硬件 } /*Value--定时时间,单位ms,最小定时时间8ms,最大定时1800ms*/ void WatchDogConfig(uint32 value, uint8 Status) { SetReg(CCFG1, WDT_EN, (Status ? WDT_EN : 0x00)); WDT_ARR = ((uint16)(65532-value*32768/1000) >> 8); ClrBit(WDT_CR, WDTF); SetBit(WDT_CR, WDTRF); }