📄 rs232.lst
字号:
C51 COMPILER V7.50 RS232 08/11/2008 14:05:26 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE RS232
OBJECT MODULE PLACED IN .\Output\RS232.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE RS232.C BROWSE DEBUG OBJECTEXTEND PRINT(.\Output\RS232.lst) OBJECT(.\Output
-\RS232.obj)
line level source
1 /*--------------------------------------------------------------------------
2 RS232.C
3 C file for RS232
4
5 History:
6 07/20/2006 : First Version V0.1 ---HsinChu Office
7 09/15/2006 : Version 0.2 ---HsinChu Office
8 1. Modify Debug_Command_Process function
9
10
11 Copyright (c) 1998-2006 AverLogic Inc
12 All rights reserved.
13 --------------------------------------------------------------------------*/
14 #include <REG52.h>
15 #include <stdio.h>
16 #include <ctype.h>
17 #include "DATATYPE.H"
18 #include "RS232.H"
19 #include "I2C.H"
20 #include "DEFINE.H"
21
22 Byte gucChipAddress;
23 // ********************************************************************************
24 // Function: MCU_RS232Init
25 // Description: Initial setting for MCU RS232
26 // Input parameters: None.
27 // Return values: None.
28 // ********************************************************************************
29 void MCU_RS232Init(void){
30 1
31 1 SCON = 0x52; /* SCON */
32 1 PCON |= 0x80; /* BAUD x2 = 4800 BPS */
33 1 RCAP2L = 0xf7; // 38400 @11.0592MHz
34 1 RCAP2H = 0xff;
35 1 T2CON = 0x34;
36 1 }
37
38 // ********************************************************************************
39 // Function: PrintDebugSetup
40 // Description: Operation instructions of Hyper Terminal
41 // Input parameters: None.
42 // Return values: None.
43 // ********************************************************************************
44
45 void PrintDebugSetup(void)
46 {
47 1 printf(" AverLogic Technology \n\n\n");
48 1 printf("Program is runing! \n\n");
49 1 printf("Press Left & Right Key at one time to enter Debug Mode \n\n\n");
50 1
51 1 }
52
53 // ********************************************************************************
54 // Function: PrintHelp
C51 COMPILER V7.50 RS232 08/11/2008 14:05:26 PAGE 2
55 // Description: Operation instructions of Hyper Terminal
56 // Input parameters: None.
57 // Return values: None.
58 // ********************************************************************************
59
60 void PrintHelp(void)
61 {
62 1 printf("Help: \n");
63 1 printf(" W addr data -- I2C Write Register Address Data\n");
64 1 printf(" R addr -- I2C Read Register Address\n");
65 1 printf(" L addr data -- Set I2C slave Address Data\n");
66 1 printf(" M addr1 addr2 -- I2C multiple Read Register \n");
67 1 printf(" P addr data -- I2C Write Panel Register Address Data\n");
68 1 printf(" H or ? -- Print Help\n");
69 1 }
70
71
72 // ********************************************************************************
73 // Function: Debug_Command_Process
74 // Description: Function of Debug Mode
75 // Input parameters: None.
76 // Return values: None.
77 // ********************************************************************************
78
79 void Debug_Command_Process(void)
80 {
81 1
82 1 Byte idata ucBuf[32];
83 1 Byte idata ucCmd[8];
84 1 Word uiAddress;
85 1 Word uiData, uiData1, uiTemp;
86 1
87 1 gets (ucBuf, sizeof (ucBuf)); // get input line
88 1 sscanf(ucBuf, "%s %x %x %x", ucCmd, &uiAddress, &uiData, &uiData1); // sscanf only support Max 15bytes
89 1
90 1
91 1 if(toupper(ucCmd[0]) == 'H' || ucCmd[0] == '?')
92 1 {
93 2 PrintHelp();
94 2 }
95 1 else if (toupper(ucCmd[0]) == 'L')
96 1 {
97 2 gucChipAddress = uiAddress;
98 2 printf("Set Chip I2C slave address %02x\n", uiAddress);
99 2
100 2 }
101 1 else if (toupper(ucCmd[0]) == 'W')
102 1 {
103 2 I2CWrite(gucChipAddress, uiAddress, uiData);
104 2 printf("I2C bus #1 Write Reg:%x %x\n", uiAddress, uiData);
105 2 }
106 1 else if (toupper(ucCmd[0]) == 'R')
107 1 {
108 2 uiData = I2CRead(gucChipAddress, uiAddress);
109 2 printf("I2C bus #1 Read Reg:%x = %x\n", uiAddress, uiData & 0xff);
110 2 }
111 1 else if (toupper(ucCmd[0]) == 'P')
112 1 {
113 2 srgb_write(uiAddress,uiData);
114 2 printf("I2C bus #1 Read Reg:%x = %x\n", uiAddress, uiData & 0xff);
115 2 }
116 1 else if (toupper(ucCmd[0]) == 'B')
C51 COMPILER V7.50 RS232 08/11/2008 14:05:26 PAGE 3
117 1 {
118 2 BL_EN=~BL_EN;
119 2 }
120 1
121 1 else if (toupper(ucCmd[0]) == 'M')
122 1 {
123 2 printf("I2C bus #1 Read multiple Reg:");
124 2 for (uiTemp = 0; uiTemp < (uiData ? (uiData - uiAddress) : 16); uiTemp++)
125 2 {
126 3 if(uiTemp % 16 == 0)
127 3 printf("\naddr:%02x --", uiAddress + uiTemp);
128 3 uiData1 = I2CRead(gucChipAddress, uiAddress + uiTemp);
129 3 printf(" %02x,", uiData1 & 0xff);
130 3 }
131 2 printf("\n");
132 2 }
133 1 else
134 1 {
135 2 printf("Unknown command !! type h or ? for help \n");
136 2 }
137 1 printf(">");
138 1
139 1 }
140
*** WARNING C316 IN LINE 140 OF RS232.C: unterminated conditionals
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 512 ----
CONSTANT SIZE = 648 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 1 8
IDATA SIZE = ---- 40
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -