ct_test/Keil_C/List/sc92f_gpio.lst

604 lines
22 KiB
Plaintext
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

C51 COMPILER V9.59.0.0 SC92F_GPIO 01/18/2024 10:03:13 PAGE 1
C51 COMPILER V9.59.0.0, COMPILATION OF MODULE SC92F_GPIO
OBJECT MODULE PLACED IN ..\Output\sc92f_gpio.obj
COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE ..\FWLib\SC92F_Lib\src\sc92f_gpio.c LARGE OBJECTADVANCED OPTIMIZE(8,SIZE
-) BROWSE INCDIR(..\FWLib\SC92F_Lib\inc;..\User;..\Apps;..\Apps;..\User) DEFINE(SC92F836xB) DEBUG PRINT(..\List\sc92f_gpi
-o.lst) OBJECT(..\Output\sc92f_gpio.obj)
line level source
1 //************************************************************
2 // Copyright (c) 深圳市赛元微电子有限公司
3 // 文件名称 : sc92f_gpio.c
4 // 作者 :
5 // 模块功能 : GPIO固件库函数C文件
6 // 局部函数列表 :
7 // 最后更正日期 : 2022/01/11
8 // 版本 : V1.10004
9 // 说明 : 本文件仅适用于赛元92F/93F/92L系列单片机
10 //*************************************************************
11
12
13 #include "sc92f_gpio.h"
14
15 /**************************************************
16 *函数名称:void GPIO_DeInit(void)
17 *函数功能:GPIO相关寄存器复位至缺省值
18 *入口参数:void
19 *出口参数:void
20 **************************************************/
21 void GPIO_DeInit(void)
22 {
23 1 P0CON = 0x00;
24 1 P0PH = 0x00;
25 1 P0 = 0;
26 1 P1CON = 0x00;
27 1 P1PH = 0x00;
28 1 P1 = 0;
29 1 P2CON = 0x00;
30 1 P2PH = 0x00;
31 1 P2 = 0;
32 1 #if defined(SC92F854x) || defined(SC92F754x) || defined(SC92F844xB) || defined(SC92F744xB) || defined(SC92
-F84Ax_2) || defined(SC92F74Ax_2)\
33 1 || defined(SC92FWxx) || defined(SC92F859x) || defined(SC92F759x)
P3CON = 0x00;
P3PH = 0x00;
P3 = 0;
P4CON = 0x00;
P4PH = 0x00;
P4 = 0;
#endif
41 1 #if !defined(SC92F730x) && !defined(SC92F725X) && !defined(SC92F735X) && !defined(SC92F7003) && !defined(S
-C92F8003) && !defined(SC92F740x) && !defined(SC92F827X) && !defined(SC92F837X)
42 1 P5CON = 0x00;
43 1 P5PH = 0x00;
44 1 P5 = 0;
45 1 #endif
46 1 }
47
48 /**************************************************
49 *函数名称:void GPIO_Init(GPIO_TypeDef GPIOx, uint8_t PortPins, GPIO_Mode_TypeDef GPIO_Mode)
50 *函数功能:GPIO口模式配置初始化
51 *入口参数:
C51 COMPILER V9.59.0.0 SC92F_GPIO 01/18/2024 10:03:13 PAGE 2
52 GPIO_TypeDef:GPIOx:选择操作的GPIO口
53 GPIO_Pin_TypeDef:PortPins:选择GPIO管脚Pxy
54 GPIO_Mode_TypeDef:GPIO_Mode:选择GPIO口模式高阻输入、上拉输入、推挽输出
55 *出口参数:void
56 **************************************************/
57 void GPIO_Init(GPIO_TypeDef GPIOx,
58 uint8_t PortPins, GPIO_Mode_TypeDef GPIO_Mode)
59 {
60 1 if (GPIOx == GPIO0)
61 1 {
62 2 if (GPIO_Mode == GPIO_MODE_IN_HI)
63 2 {
64 3 P0CON &= ~PortPins;
65 3 P0PH &= ~PortPins;
66 3 }
67 2
68 2 if (GPIO_Mode == GPIO_MODE_IN_PU)
69 2 {
70 3 P0CON &= ~PortPins;
71 3 P0PH |= PortPins;
72 3 }
73 2
74 2 if (GPIO_Mode == GPIO_MODE_OUT_PP)
75 2 {
76 3 P0CON |= PortPins;
77 3 }
78 2 }
79 1 else if (GPIOx == GPIO1)
80 1 {
81 2 if (GPIO_Mode == GPIO_MODE_IN_HI)
82 2 {
83 3 P1CON &= ~PortPins;
84 3 P1PH &= ~PortPins;
85 3 }
86 2
87 2 if (GPIO_Mode == GPIO_MODE_IN_PU)
88 2 {
89 3 P1CON &= ~PortPins;
90 3 P1PH |= PortPins;
91 3 }
92 2
93 2 if (GPIO_Mode == GPIO_MODE_OUT_PP)
94 2 {
95 3 P1CON |= PortPins;
96 3 }
97 2 }
98 1 else if (GPIOx == GPIO2)
99 1 {
100 2 if (GPIO_Mode == GPIO_MODE_IN_HI)
101 2 {
102 3 P2CON &= ~PortPins;
103 3 P2PH &= ~PortPins;
104 3 }
105 2
106 2 if (GPIO_Mode == GPIO_MODE_IN_PU)
107 2 {
108 3 P2CON &= ~PortPins;
109 3 P2PH |= PortPins;
110 3 }
111 2
112 2 if (GPIO_Mode == GPIO_MODE_OUT_PP)
113 2 {
C51 COMPILER V9.59.0.0 SC92F_GPIO 01/18/2024 10:03:13 PAGE 3
114 3 P2CON |= PortPins;
115 3 }
116 2 }
117 1
118 1 #if defined(SC92F854x) || defined(SC92F754x) || defined(SC92F844xB) || defined(SC92F744xB) || defined(SC92
-F84Ax_2) || defined(SC92F74Ax_2)\
119 1 || defined(SC92FWxx) || defined(SC92F859x) || defined(SC92F759x)
else if (GPIOx == GPIO3)
{
if (GPIO_Mode == GPIO_MODE_IN_HI)
{
P3CON &= ~PortPins;
P3PH &= ~PortPins;
}
if (GPIO_Mode == GPIO_MODE_IN_PU)
{
P3CON &= ~PortPins;
P3PH |= PortPins;
}
if (GPIO_Mode == GPIO_MODE_OUT_PP)
{
P3CON |= PortPins;
}
}
else if (GPIOx == GPIO4)
{
if (GPIO_Mode == GPIO_MODE_IN_HI)
{
P4CON &= ~PortPins;
P4PH &= ~PortPins;
}
if (GPIO_Mode == GPIO_MODE_IN_PU)
{
P4CON &= ~PortPins;
P4PH |= PortPins;
}
if (GPIO_Mode == GPIO_MODE_OUT_PP)
{
P4CON |= PortPins;
}
}
#endif
160 1 #if !defined(SC92F730x) && !defined(SC92F725X) && !defined(SC92F735X) && !defined(SC92F7003) && !defined(S
-C92F8003) && !defined(SC92F740x) && !defined(SC92F827X) && !defined(SC92F837X)
161 1 else if (GPIOx == GPIO5)
162 1 {
163 2 if (GPIO_Mode == GPIO_MODE_IN_HI)
164 2 {
165 3 P5CON &= ~PortPins;
166 3 P5PH &= ~PortPins;
167 3 }
168 2
169 2 if (GPIO_Mode == GPIO_MODE_IN_PU)
170 2 {
171 3 P5CON &= ~PortPins;
172 3 P5PH |= PortPins;
173 3 }
C51 COMPILER V9.59.0.0 SC92F_GPIO 01/18/2024 10:03:13 PAGE 4
174 2
175 2 if (GPIO_Mode == GPIO_MODE_OUT_PP)
176 2 {
177 3 P5CON |= PortPins;
178 3 }
179 2 }
180 1
181 1 #endif
182 1 }
183
184 /**************************************************
185 *函数名称:void GPIO_Write(GPIO_TypeDef GPIOx, uint8_t PortVal)
186 *函数功能:GPIO口赋值
187 *入口参数:
188 GPIO_TypeDef:GPIOx:选择操作的GPIO口
189 uint8_t:PortVal:GPIO口的值
190 *出口参数:void
191 **************************************************/
192 void GPIO_Write(GPIO_TypeDef GPIOx,
193 uint8_t PortVal)
194 {
195 1 if (GPIOx == GPIO0)
196 1 {
197 2 P0 = PortVal;
198 2 }
199 1
200 1 if (GPIOx == GPIO1)
201 1 {
202 2 P1 = PortVal;
203 2 }
204 1
205 1 if (GPIOx == GPIO2)
206 1 {
207 2 P2 = PortVal;
208 2 }
209 1
210 1 #if defined(SC92F854x) || defined(SC92F754x) || defined(SC92F844xB) || defined(SC92F744xB) || defined(SC92
-F84Ax_2) || defined(SC92F74Ax_2)\
211 1 || defined(SC92FWxx) || defined(SC92F859x) || defined(SC92F759x)
if (GPIOx == GPIO3)
{
P3 = PortVal;
}
if (GPIOx == GPIO4)
{
P4 = PortVal;
}
#endif
224 1 #if !defined(SC92F730x) && !defined(SC92F725X) && !defined(SC92F735X) && !defined(SC92F8003) && !defined(S
-C92F740x) && !defined(SC92F827X) && !defined(SC92F837X) && !defined(SC92F7003)
225 1
226 1 if (GPIOx == GPIO5)
227 1 {
228 2 P5 = PortVal;
229 2 }
230 1
231 1 #endif
232 1 }
233
C51 COMPILER V9.59.0.0 SC92F_GPIO 01/18/2024 10:03:13 PAGE 5
234 /**************************************************
235 *函数名称:void GPIO_WriteHigh(GPIO_TypeDef GPIOx, uint8_t PortPins)
236 *函数功能:GPIO口管脚Pxy置位
237 *入口参数:
238 GPIO_TypeDef:GPIOx:选择操作的GPIO口
239 GPIO_Pin_TypeDef:PortPins:选择GPIO口管脚Pxy
240 *出口参数:void
241 **************************************************/
242 void GPIO_WriteHigh(GPIO_TypeDef GPIOx,
243 uint8_t PortPins)
244 {
245 1 if (GPIOx == GPIO0)
246 1 {
247 2 P0 |= PortPins;
248 2 }
249 1
250 1 if (GPIOx == GPIO1)
251 1 {
252 2 P1 |= PortPins;
253 2 }
254 1
255 1 if (GPIOx == GPIO2)
256 1 {
257 2 P2 |= PortPins;
258 2 }
259 1
260 1 #if defined(SC92F854x) || defined(SC92F754x) || defined(SC92F844xB) || defined(SC92F744xB) || defined(SC92
-F84Ax_2) || defined(SC92F74Ax_2)\
261 1 || defined(SC92FWxx) || defined(SC92F859x) || defined(SC92F759x)
-
if (GPIOx == GPIO3)
{
P3 |= PortPins;
}
if (GPIOx == GPIO4)
{
P4 |= PortPins;
}
#endif
274 1 #if !defined(SC92F730x) && !defined(SC92F725X) && !defined(SC92F735X) && !defined(SC92F8003) && !defined(S
-C92F740x) && !defined(SC92F827X) && !defined(SC92F837X) && !defined(SC92F7003)
275 1
276 1 if (GPIOx == GPIO5)
277 1 {
278 2 P5 |= PortPins;
279 2 }
280 1
281 1 #endif
282 1 }
283
284 /**************************************************
285 *函数名称:void GPIO_WriteLow(GPIO_TypeDef GPIOx, uint8_t PortPins)
286 *函数功能:GPIO口管脚Pxy复位
287 *入口参数:
288 GPIO_TypeDef:GPIOx:选择操作的GPIO口
289 GPIO_Pin_TypeDef:PortPins:选择GPIO口管脚Pxy
290 *出口参数:void
291 **************************************************/
292 void GPIO_WriteLow(GPIO_TypeDef GPIOx,
C51 COMPILER V9.59.0.0 SC92F_GPIO 01/18/2024 10:03:13 PAGE 6
293 uint8_t PortPins)
294 {
295 1 if (GPIOx == GPIO0)
296 1 {
297 2 P0 &= ~PortPins;
298 2 }
299 1
300 1 if (GPIOx == GPIO1)
301 1 {
302 2 P1 &= ~PortPins;
303 2 }
304 1
305 1 if (GPIOx == GPIO2)
306 1 {
307 2 P2 &= ~PortPins;
308 2 }
309 1
310 1 #if defined(SC92F854x) || defined(SC92F754x) || defined(SC92F844xB) || defined(SC92F744xB) || defined(SC92
-F84Ax_2) || defined(SC92F74Ax_2)\
311 1 || defined(SC92FWxx) || defined(SC92F859x) || defined(SC92F759x)
if (GPIOx == GPIO3)
{
P3 &= ~PortPins;
}
if (GPIOx == GPIO4)
{
P4 &= ~PortPins;
}
#endif
324 1 #if !defined(SC92F730x) && !defined(SC92F725X) && !defined(SC92F735X) && !defined(SC92F8003) && !defined(S
-C92F740x) && !defined(SC92F827X) && !defined(SC92F837X) && !defined(SC92F7003)
325 1
326 1 if (GPIOx == GPIO5)
327 1 {
328 2 P5 &= ~PortPins;
329 2 }
330 1
331 1 #endif
332 1 }
333
334 /**************************************************
335 *函数名称:uint8_t GPIO_ReadPort(GPIO_TypeDef GPIOx)
336 *函数功能:读GPIO口Px的值
337 *入口参数:
338 GPIO_TypeDef:GPIOx:选择操作的GPIO口
339 *出口参数:uint8_t 返回Px的值
340 **************************************************/
341 uint8_t GPIO_ReadPort(GPIO_TypeDef GPIOx)
342 {
343 1 if (GPIOx == GPIO0)
344 1 {
345 2 return P0;
346 2 }
347 1 else if (GPIOx == GPIO1)
348 1 {
349 2 return P1;
350 2 }
351 1 else if (GPIOx == GPIO2)
352 1 {
C51 COMPILER V9.59.0.0 SC92F_GPIO 01/18/2024 10:03:13 PAGE 7
353 2 return P2;
354 2 }
355 1
356 1 #if defined(SC92F854x) || defined(SC92F754x) || defined(SC92F844xB) || defined(SC92F744xB) || defined(SC92
-F84Ax_2) || defined(SC92F74Ax_2)\
357 1 || defined(SC92FWxx) || defined(SC92F859x) || defined(SC92F759x)
else if (GPIOx == GPIO3)
{
return P3;
}
else if (GPIOx == GPIO4)
{
return P4;
}
#endif
368 1 #if !defined(SC92F730x) && !defined(SC92F725X) && !defined(SC92F735X) && !defined(SC92F8003) && !defined(S
-C92F740x) && !defined(SC92F827X) && !defined(SC92F837X) && !defined(SC92F7003)
369 1 else if (GPIOx == GPIO5)
370 1 {
371 2 return P5;
372 2 }
373 1
374 1 #endif
375 1 else
376 1 {
377 2 return 0;
378 2 }
379 1 }
380
381 /**************************************************
382 *函数名称:BitStatus GPIO_ReadPin(GPIO_TypeDef GPIOx, uint8_t PortPins)
383 *函数功能:读GPIO口管脚Pxy的值
384 *入口参数:
385 GPIO_TypeDef:GPIOx:选择操作的GPIO口
386 GPIO_Pin_TypeDef:PortPins:选择GPIO口管脚Pxy
387 *出口参数:BitStatus 返回Pxy的值
388 **************************************************/
389 BitStatus GPIO_ReadPin(GPIO_TypeDef GPIOx,
390 uint8_t PortPins)
391 {
392 1 if (GPIOx == GPIO0)
393 1 {
394 2 return ((bit)(P0 & PortPins));
395 2 }
396 1 else if (GPIOx == GPIO1)
397 1 {
398 2 return ((bit)(P1 & PortPins));
399 2 }
400 1 else if (GPIOx == GPIO2)
401 1 {
402 2 return ((bit)(P2 & PortPins));
403 2 }
404 1
405 1 #if defined(SC92F854x) || defined(SC92F754x) || defined(SC92F844xB) || defined(SC92F744xB) || defined(SC92
-F84Ax_2) || defined(SC92F74Ax_2)\
406 1 || defined(SC92FWxx) || defined(SC92F859x) || defined(SC92F759x)
else if (GPIOx == GPIO3)
{
return ((bit)(P3 & PortPins));
}
else if (GPIOx == GPIO4)
C51 COMPILER V9.59.0.0 SC92F_GPIO 01/18/2024 10:03:13 PAGE 8
{
return ((bit)(P4 & PortPins));
}
#endif
417 1 #if !defined(SC92F730x) && !defined(SC92F725X) && !defined(SC92F735X) && !defined(SC92F8003) && !defined(S
-C92F740x) && !defined(SC92F827X) && !defined(SC92F837X) && !defined(SC92F7003)
418 1 else if (GPIOx == GPIO5)
419 1 {
420 2 return ((bit)(P5 & PortPins));
421 2 }
422 1
423 1 #endif
424 1 return 0;
425 1 }
426
427
428 /**************************************************
429 *函数名称:void GPIO_IOH_Config(GPIO_TypeDef GPIOx, uint8_t PortPins,GPIO_IOH_Grade_TypeDef GPIO_IOH_Grade)
430 *函数功能:设置GPIO口管脚IOH输出能力
431 *入口参数:
432 GPIO_TypeDef:GPIOx:选择操作的GPIO口
433 GPIO_Pin_TypeDef:PortPins:选择GPIO口管脚Pxy
434 GPIO_IOH_Grade_TypeDef:GPIO_IOH_Grade:IO输出等级
435 *出口参数:BitStatus 返回Pxy的值
436 **************************************************/
437 #if !defined(SC92F7003) && !defined(SC92F8003) && !defined(SC92F740x)
438 void GPIO_IOH_Config(GPIO_TypeDef GPIOx, GPIO_Pin_TypeDef PortPins, GPIO_IOH_Grade_TypeDef GPIO_IOH_Grade)
439 {
440 1 #if defined(SC92F854x) || defined(SC92F754x) || defined(SC92F844xB) || defined(SC92F744xB) || defined(SC92
-F84Ax_2) || defined(SC92F74Ax_2)\
441 1 || defined(SC92FWxx) || defined(SC92F859x) || defined(SC92F759x) || defined (SC92L853x) || defined (SC92
-L753x)
switch (GPIOx)
{
case GPIO0:
if (PortPins == GPIO_PIN_LNIB)
{
IOHCON0 &= 0xFC;
IOHCON0 |= GPIO_IOH_Grade;
}
else if (PortPins == GPIO_PIN_HNIB)
{
IOHCON0 &= 0xF3;
IOHCON0 |= GPIO_IOH_Grade << 2;
}
break;
case GPIO1:
if (PortPins == GPIO_PIN_LNIB)
{
IOHCON0 &= 0xCF;
IOHCON0 |= GPIO_IOH_Grade << 4;
}
else if (PortPins == GPIO_PIN_HNIB)
{
IOHCON0 &= 0x3F;
IOHCON0 |= GPIO_IOH_Grade << 6;
}
break;
case GPIO2:
if (PortPins == GPIO_PIN_LNIB)
{
C51 COMPILER V9.59.0.0 SC92F_GPIO 01/18/2024 10:03:13 PAGE 9
IOHCON1 &= 0xFC;
IOHCON1 |= GPIO_IOH_Grade;
}
else if (PortPins == GPIO_PIN_HNIB)
{
IOHCON1 &= 0xF3;
IOHCON1 |= GPIO_IOH_Grade << 2;
}
break;
#if defined (SC92L853x) || defined (SC92L753x)
case GPIO5:
if (PortPins == GPIO_PIN_LNIB)
{
IOHCON1 &= 0xCF;
IOHCON1 |= GPIO_IOH_Grade << 4;
}
else if (PortPins == GPIO_PIN_HNIB)
{
IOHCON1 &= 0x3f;
IOHCON1 |= GPIO_IOH_Grade << 6;
}
break;
#else
case GPIO3:
if (PortPins == GPIO_PIN_LNIB)
{
IOHCON1 &= 0xCF;
IOHCON1 |= GPIO_IOH_Grade << 4;
}
break;
#endif
default:
break;
}
#else
506 1 switch (GPIOx)
507 1 {
508 2 case GPIO0:
509 2 if (PortPins == GPIO_PIN_LNIB)
510 2 {
511 3 IOHCON &= 0xFC;
512 3 IOHCON |= GPIO_IOH_Grade;
513 3 }
514 2 else if (PortPins == GPIO_PIN_HNIB)
515 2 {
516 3 IOHCON &= 0xF3;
517 3 IOHCON |= GPIO_IOH_Grade << 2;
518 3 }
519 2 break;
520 2 case GPIO2:
521 2 if (PortPins == GPIO_PIN_LNIB)
522 2 {
523 3 IOHCON &= 0xFC;
524 3 IOHCON |= GPIO_IOH_Grade;
525 3 }
526 2 else if (PortPins == GPIO_PIN_HNIB)
527 2 {
528 3 IOHCON &= 0xF3;
529 3 IOHCON |= GPIO_IOH_Grade << 2;
530 3 }
531 2 break;
532 2 default:
C51 COMPILER V9.59.0.0 SC92F_GPIO 01/18/2024 10:03:13 PAGE 10
533 2 break;
534 2 }
535 1 #endif
536 1 }
537 #endif
538
539 /******************* (C) COPYRIGHT 2021 SinOne Microelectronics *****END OF FILE****/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 541 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
EDATA SIZE = ---- ----
HDATA SIZE = ---- ----
XDATA CONST SIZE = ---- ----
FAR CONST SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)