gpio.lst 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. C51 COMPILER V9.60.7.0 GPIO 11/21/2025 17:21:11 PAGE 1
  2. C51 COMPILER V9.60.7.0, COMPILATION OF MODULE GPIO
  3. OBJECT MODULE PLACED IN .\Objects\gpio.obj
  4. COMPILER INVOKED BY: d:\Keil_v5\C51\BIN\C51.EXE ..\..\..\..\driver\src\gpio.c OBJECTADVANCED OPTIMIZE(9,SPEED) BROWSE OR
  5. -DER NOAREGS MODC2 INCDIR(..\..\..\..\driver\inc;..\..\..\..\mcu;..\..\..\..\middleware\log;..\..\..\..\middleware\delay;
  6. -..\..\..\..\middleware\rf_basis) DEBUG PRINT(.\Listings\gpio.lst) TABS(2) OBJECT(.\Objects\gpio.obj)
  7. line level source
  8. 1 /**
  9. 2 ************************************************************************
  10. 3 * @file gpio.c
  11. 4 * @author Panchip Team
  12. 5 * @version V0.5
  13. 6 * @date 2024-04-28
  14. 7 * @brief This file provides all the gpio firmware functions.
  15. 8 * @note
  16. 9 * Copyright (C) 2024 Panchip Technology Corp. All rights reserved.
  17. 10 ****************************************************************************
  18. 11 */
  19. 12
  20. 13 #include "gpio.h"
  21. 14
  22. 15 /** @addtogroup PAN262x_Std_Driver
  23. 16 * @{
  24. 17 */
  25. 18
  26. 19 /** @defgroup GPIO
  27. 20 * @brief GPIO driver modules
  28. 21 * @{
  29. 22 */
  30. 23
  31. 24 /** @defgroup GPIO_Private_Functions
  32. 25 * @{
  33. 26 */
  34. 27
  35. 28 code GpioInOutCfg_t GpioInOutCfg[GPIO_MODE_MAX] = {
  36. 29 /* Dien Doen */
  37. 30 {ENABLE, DISABLE}, // GPIO_MODE_INPUT
  38. 31 {ENABLE, ENABLE}, // GPIO_MODE_OUTPUT_PP
  39. 32 {ENABLE, ENABLE}, // GPIO_MODE_OUTPUT_OD
  40. 33 {DISABLE, DISABLE} // GPIO_MODE_ANALOG
  41. 34 };
  42. 35
  43. 36 /**
  44. 37 * @brief This function initializes GPIO_P1x/GPIO_P3x
  45. 38 * @param Port
  46. 39 * @arg GPIO_P10
  47. 40 * @arg GPIO_P11
  48. 41 * @arg GPIO_P12
  49. 42 * @arg GPIO_P13
  50. 43 * @arg GPIO_P14
  51. 44 * @arg GPIO_P15
  52. 45 * @arg GPIO_P16
  53. 46 * @arg GPIO_P30
  54. 47 * @arg GPIO_P31
  55. 48 * @arg GPIO_P32
  56. 49 * @arg GPIO_P33
  57. 50 * @arg GPIO_P34
  58. 51 * @arg GPIO_P35
  59. 52 * @arg GPIO_P36
  60. 53 * @arg GPIO_P37
  61. C51 COMPILER V9.60.7.0 GPIO 11/21/2025 17:21:11 PAGE 2
  62. 54 * @param Mux
  63. 55 * @ref eGpioP1xMUX_t,where x can be 0 to 6
  64. 56 * @ref eGpioP3yMUX_t,where y can be 0 to 7
  65. 57 * @param Mode:
  66. 58 * @arg GPIO_MODE_INPUT
  67. 59 * @arg GPIO_MODE_OUTPUT_PP
  68. 60 * @arg GPIO_MODE_OUTPUT_OD
  69. 61 * @arg GPIO_MODE_ANALOG
  70. 62 * @param per : Pull:
  71. 63 * @arg GPIO_NOPULL
  72. 64 * @arg GPIO_PULLUP
  73. 65 * @arg GPIO_PULLDOWN
  74. 66 * @retval None
  75. 67 */
  76. 68 void GPIO_Init(u8 Port, u8 Mux, u8 Mode, u8 Pull)
  77. 69 {
  78. 70 1 P3Offset_t Offset;
  79. 71 1 u8 BitId = Port & 0x0F;
  80. 72 1
  81. 73 1 if ((Port & 0xF0) == GPIO_PORT1)
  82. 74 1 {
  83. 75 2 *(u8 *)(&Offset) = 0x00; /* P1x offset */
  84. 76 2 }
  85. 77 1 else if ((Port & 0xF0) == GPIO_PORT3)
  86. 78 1 {
  87. 79 2 *(u8 *)(&Offset) = 0xFB; /* P3x offset */
  88. 80 2 }
  89. 81 1 else
  90. 82 1 {
  91. 83 2 return;
  92. 84 2 }
  93. 85 1
  94. 86 1 /* set gpio multi function */
  95. 87 1 SET_WREG_BIT(SYS, SYS_P1_MFP0 + Offset.Mfp, BitId, Mux & GPIO_MUX_00X);
  96. 88 1 SET_WREG_BIT(SYS, SYS_P1_MFP1 + Offset.Mfp, BitId, Mux & GPIO_MUX_0X0);
  97. 89 1 SET_WREG_BIT(SYS, SYS_P1_MFP2 + Offset.Mfp, BitId, Mux & GPIO_MUX_X00);
  98. 90 1
  99. 91 1 /* set gpio Mode:digital input,push Pull,open drain,analog input */
  100. 92 1 if (Mode == GPIO_MODE_ANALOG)
  101. 93 1 {
  102. 94 2 SET_WREG_BIT(SYS, SYS_P1_MODE0 + Offset.Mode, BitId, 0);
  103. 95 2 SET_WREG_BIT(SYS, SYS_P1_MODE1 + Offset.Mode, BitId, 0);
  104. 96 2 }
  105. 97 1 else
  106. 98 1 {
  107. 99 2 SET_WREG_BIT(SYS, SYS_P1_MODE0 + Offset.Mode, BitId, Mode & GPIO_MODE_00X);
  108. 100 2 SET_WREG_BIT(SYS, SYS_P1_MODE1 + Offset.Mode, BitId, Mode & GPIO_MODE_0X0);
  109. 101 2 }
  110. 102 1
  111. 103 1 /* set gpio Px_x output&input enable or disable */
  112. 104 1 SET_WREG_BIT(SYS, SYS_P1_OE + Offset.Doen, BitId, GpioInOutCfg[Mode].Doen);
  113. 105 1 SET_WREG_BIT(SYS, SYS_P1_DIEN + Offset.Dien, BitId, GpioInOutCfg[Mode].Dien);
  114. 106 1
  115. 107 1 /* set gpio Px_x Pull up or down resistor */
  116. 108 1 SET_WREG_BIT(SYS, SYS_P1_PUEN + Offset.Puen, BitId, Pull & GPIO_PULLUP);
  117. 109 1 SET_WREG_BIT(SYS, SYS_P1_PDEN + Offset.Pden, BitId, Pull & GPIO_PULLDOWN);
  118. 110 1 }
  119. 111
  120. 112 /**
  121. 113 * @brief Config GPIO INT0/1 interrupt
  122. 114 * @param GPIO_INTx:where x can be 0 and 1
  123. 115 * @param Trigger: specifies gpio int0/1 trigger mode.
  124. C51 COMPILER V9.60.7.0 GPIO 11/21/2025 17:21:11 PAGE 3
  125. 116 * This parameter can be a value of @ref PWM_ModeTypeDef
  126. 117 * @retval None
  127. 118 */
  128. 119 void GPIO_ExtIntConfig(u8 GPIO_INTx, GPIO_TriggerTypeDef Trigger)
  129. 120 {
  130. 121 1 if (GPIO_INTx == GPIO_INT0)
  131. 122 1 {
  132. 123 2 IT0 = Trigger;
  133. 124 2 EX0 = TRUE;
  134. 125 2 }
  135. 126 1 else
  136. 127 1 {
  137. 128 2 IT1 = Trigger;
  138. 129 2 EX1 = TRUE;
  139. 130 2 }
  140. 131 1 }
  141. 132
  142. 133 /**
  143. 134 * @brief This function enable gpio Debounce function
  144. 135 * @param GPIO_INTx: where x can be 0 and 1
  145. 136 * @param DbcTicks: debounce time=DbcTicks*128us
  146. 137 * @retval None
  147. 138 */
  148. 139 void GPIO_EnableDbc(u8 GPIO_INTx, u8 DbcTicks)
  149. 140 {
  150. 141 1 if (GPIO_INTx == GPIO_INT0)
  151. 142 1 {
  152. 143 2 MODIFY_WREG(SYS, EINT0_DBC, 0xFF, DbcTicks | 0x80);
  153. 144 2 }
  154. 145 1 else
  155. 146 1 {
  156. 147 2 MODIFY_WREG(SYS, EINT1_DBC, 0xFF, DbcTicks | 0x80);
  157. 148 2 }
  158. 149 1 }
  159. 150
  160. 151 /**
  161. 152 * @brief This function disable gpio Debounce function
  162. 153 * @param GPIO_INTx:where x can be 0 and 1
  163. 154 * @retval None
  164. 155 */
  165. 156 void GPIO_DisableDbc(u8 GPIO_INTx)
  166. 157 {
  167. 158 1 if (GPIO_INTx == GPIO_INT0)
  168. 159 1 {
  169. 160 2 MODIFY_WREG(SYS, EINT0_DBC, 0xFF, 0x00);
  170. 161 2 }
  171. 162 1 else
  172. 163 1 {
  173. 164 2 MODIFY_WREG(SYS, EINT1_DBC, 0xFF, 0x00);
  174. 165 2 }
  175. 166 1 }
  176. 167
  177. 168 /**
  178. 169 * @brief This function enable P36 reset function
  179. 170 * @param uDat
  180. 171 * @retval None
  181. 172 */
  182. 173 void GPIO_EnableRst(void)
  183. 174 {
  184. 175 1 ANA_SEL = GPIO_RCH_SYNC_TRG;
  185. 176 1 ANA_DAT |= P36_NRST_EN;
  186. 177 1 }
  187. C51 COMPILER V9.60.7.0 GPIO 11/21/2025 17:21:11 PAGE 4
  188. 178
  189. 179 /**
  190. 180 * @brief This function disable P36 reset function
  191. 181 * @param uDat
  192. 182 * @retval None
  193. 183 */
  194. 184 void GPIO_DisableRst(void)
  195. 185 {
  196. 186 1 ANA_SEL = GPIO_RCH_SYNC_TRG;
  197. 187 1 ANA_DAT &= ~P36_NRST_EN;
  198. 188 1 }
  199. 189 /**
  200. 190 * @}
  201. 191 */
  202. 192
  203. 193 /**
  204. 194 * @}
  205. 195 */
  206. 196
  207. 197 /**
  208. 198 * @}
  209. 199 */
  210. MODULE INFORMATION: STATIC OVERLAYABLE
  211. CODE SIZE = 670 ----
  212. CONSTANT SIZE = 8 ----
  213. XDATA SIZE = ---- ----
  214. PDATA SIZE = ---- ----
  215. DATA SIZE = ---- 5
  216. IDATA SIZE = ---- ----
  217. BIT SIZE = ---- ----
  218. EDATA SIZE = ---- ----
  219. HDATA SIZE = ---- ----
  220. XDATA CONST SIZE = ---- ----
  221. FAR CONST SIZE = ---- ----
  222. END OF MODULE INFORMATION.
  223. C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)