GPIO.c 4.7 KB

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