GPIO.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /********************************************************************************
  2. **** Copyright (C), 2020, Fortior Technology Co., Ltd. ****
  3. ********************************************************************************
  4. * File Name : GPIO.c
  5. * Author : Bruce HW&RD
  6. * Date : 2020-10-15
  7. * Description : .C file function description
  8. * Version : 1.0
  9. * Function List :
  10. *
  11. * Record :
  12. * 1.Date : 2020-10-15
  13. * Author : Bruce HW&RD
  14. * Modification: Created file
  15. ********************************************************************************/
  16. #include "FU68xx_5.h"
  17. #include <Myproject.h>
  18. void GPIO_Init(void)
  19. {
  20. SetBit(P4_OE , P42);//电子膨胀阀驱动IO-A P4_OE = P42;
  21. GP42 = 0;
  22. /*交流风机--输出*/
  23. // GP44 = 0;
  24. SetBit(P4_OE , P44);//电子膨胀阀驱动IO-A P4_OE = P42;??
  25. GP44 = 0;
  26. /*继电器相关 -- 输出*/
  27. /*PTC_RELAY*/
  28. // GP51 = 0;
  29. SetBit(P5_OE , P51);
  30. GP51 = 0;
  31. /*DJR*/
  32. // GP04 = 0;
  33. SetBit(P0_OE , P04);
  34. SetBit(P0_PU , P04);
  35. GP04 = 0;
  36. /*4WAY*/
  37. // GP01 = 0;
  38. SetBit(P0_OE , P01);
  39. GP01 = 0;
  40. SetBit(P0_OE , P07);//电子膨胀阀驱动IO-D P0_OE = P07;
  41. GP07 = 0;
  42. SetBit(P0_OE , P00);//电子膨胀阀驱动IO-D P0_OE = P07;
  43. GP00 = 0;
  44. SetBit(P1_OE , P10);//电子膨胀阀驱动IO-C P1_OE = P10;
  45. GP10 = 0;
  46. SetBit(P4_OE , P41);//电子膨胀阀驱动IO-B P4_OE = P41;
  47. GP41 = 0;
  48. SetBit(P1_OE , P11);//电子膨胀阀驱动IO-C P1_OE = P10;
  49. GP11 = 0;
  50. /*LED*/
  51. // GP22 = 0;
  52. SetBit(P0_OE , P03);
  53. GP03 = 0;
  54. }
  55. /*****************************************************************************
  56. * Function : INT0_Init
  57. * Description : INT0初始化
  58. * Input : void
  59. * Output : None
  60. * Return :
  61. * Others :
  62. * Record
  63. * 1.Date : 20201015
  64. * Author : Bruce HW&RD
  65. * Modification: Created function
  66. *****************************************************************************/
  67. void INT0_Init(void)
  68. {
  69. /*EXTI Input Pin 配置 ---------------------------------------- */
  70. ClrBit(P0_OE , PIN2); // config P00 as input,配置P0.0为硬件过流FO端口
  71. ClrBit(P0_PU , PIN2); // 0:disable pull up, 1:enable P10 pull up
  72. SetReg(LVSR , EXT0CFG0 | EXT0CFG1 | EXT0CFG2 , EXT0CFG1); //外部中断0配置
  73. IF0 = 0; // clear P00 interrupt flag
  74. // 00: rising edge interrupt,01: failing edge interrupt,1x: edge-change mode interrupt
  75. IT01 = 0;
  76. IT00 = 1;
  77. SetBit(EVT_FILT , INT0_MOE_EN); //INT0中断关闭MOE使能
  78. /*----------------------------------------------------------------------------------
  79. 母线电流保护时间滤波宽度
  80. 00-不滤波
  81. 01-6cpu clock
  82. 10-12cpu clock
  83. 11-24cpu clock
  84. -----------------------------------------------------------------------------------*/
  85. SetBit(EVT_FILT , EFDIV1);
  86. ClrBit(EVT_FILT , EFDIV0);
  87. /*---------------------------------------------------------------------------
  88. 外部中断优先级配置及芯片中断总使能
  89. PX01-PX00,中断优先级控制值从0-3依次表示优先级从最低到最高,共4级优化级控制
  90. EX0,外部中断0使能
  91. EA,芯片中断总使能
  92. 外部中断是否有滤波的配置,决定于选择硬件保护触发信号源,外部中断0或者比较器3中断。
  93. 若选择了比较器3中断,则外部中断无法进行滤波配置
  94. --------------------------------------------------------------------------*/
  95. SetBit(IP0 , PX01);//优先级
  96. SetBit(IP0 , PX00);
  97. EX0 = 1; // 使能外部中断0, POO位外部中断输入硬件
  98. EA = 1; // 使能全局中断
  99. }
  100. void INT1_Init(void)
  101. {
  102. ClrBit(P1_OE, P12); // config P11 as input
  103. ClrBit(P1_PU, P12); // diasable P11 Pull Up
  104. SetBit(P1_IE, P12); // config P11 as input
  105. ClrBit(P1_IF, P12);
  106. IT11 = 0;
  107. IT10 = 1; // 00: rising edge interrupt,01: failing edge interrupt,1x: edge-change mode interrupt
  108. SetBit(IP0 , PX11);//优先级
  109. SetBit(IP0 , PX10);
  110. EX1 = 1; // 使能外部中断1, P11位外部中断输入硬件
  111. }
  112. /*Value--定时时间,单位ms,最小定时时间8ms,最大定时1800ms*/
  113. void WatchDogConfig(uint32 value, uint8 Status)
  114. {
  115. SetReg(CCFG1, WDT_EN, (Status ? WDT_EN : 0x00));
  116. WDT_ARR = ((uint16)(65532-value*32768/1000) >> 8);
  117. ClrBit(WDT_CR, WDTF);
  118. SetBit(WDT_CR, WDTRF);
  119. }