📄 serial.lst
字号:
C51 COMPILER V7.06 SERIAL 06/06/2005 16:32:37 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE SERIAL
OBJECT MODULE PLACED IN .\output\SERIAL.obj
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE SERIAL.C OPTIMIZE(6,SPEED) BROWSE ORDER DEBUG OBJECTEXTEND PRINT(.\output\S
-ERIAL.lst) OBJECT(.\output\SERIAL.obj)
stmt level source
1 /*********************************************************************************************************
2 **--------------文件信息--------------------------------------------------------------------------------
3 **文 件 名: serial.c
4 **创 建 人: 刘宝贵
5 **最后修改日期: 2004年4月20日
6 **描 述: 串行口驱动
7 **
8 **--------------历史版本信息----------------------------------------------------------------------------
9 ** 创建人: 刘宝贵
10 ** 版 本: V1.00
11 ** 日 期: 2004年4月20日
12 ** 描 述: 原始版本
13 **
14 **------------------------------------------------------------------------------------------------------
15 ** 修改人:
16 ** 版 本:
17 ** 日 期:
18 ** 描 述:
19 **
20 **------------------------------------------------------------------------------------------------------
21 **--------------当前版本修订------------------------------------------------------------------------------
22 ** 修改人: 刘宝贵
23 ** 日 期: 2004年4月20日
24 ** 描 述:
25 **
26 **------------------------------------------------------------------------------------------------------
27 ********************************************************************************************************/
28
29 #include "config.h"
30
31 uint8 OS_Q_MEM_SEL NotUse _at_ 0x0000; //指针的NULL为0,这个变量占用0地质避免出现有效的NULL指针
32 uint8 OS_Q_MEM_SEL SerialInData[130]; //给读串口消息队列分配的队列空间
33 uint8 OS_Q_MEM_SEL SerialOutData[200]; //给写串口消息队列分配的队列空间
34 void PutChar(uint8 Data); //发送一个字节
35 void Send(uint8 Data); //发送一个数据包
36 uint8 GetCharWithCheck(void); //从读串口消息队列取一字节,并且对该字节校验
37
38 bit SerialCanSend = 1;
39 bit CommSending = 0;
40 //uint8 data test;
41 uint8 data inchk; //校验和
42 uint8 data outchk; //校验和
43 uint8 data cid; //命令码
44 uint8 data rtn; //返回码 RTN值 表示意义
45 uint8 xdata buf[130]; // 缓冲串口数据
46 #define RIGHT 1 // 01H 正常
47 #define CHKSUM_ERROR 2 // 02H CHKSUM 错
48 #define LENGTH_ERROR 3 // 03H LENGTH 错
49 #define CID_ERROR 4 // 04H CID 无效
50 #define TYPE_ERROR 5 // 05H 命令格式错
51 #define DATA_ERROR 6 // 06H 无效数据
52 #define LOGIC_ERROR 7 // 07H 逻辑错
53
54 #define OTHER_ERROR 0XE0 // E0H~EFH 其他错误
C51 COMPILER V7.06 SERIAL 06/06/2005 16:32:37 PAGE 2
55 /*********************************************************************************************************
56 ** 函数名称: PutChar
57 ** 功能描述: 发送一个字节
58 ** 输 入: Data:发送的数据
59 ** 输 出: 无
60 ** 全局变量: 无
61 ** 调用模块: 无
62 **
63 ** 作 者: 陈明计
64 ** 日 期: 2002年12月4日
65 **-------------------------------------------------------------------------------------------------------
66 ** 修改人:
67 ** 日 期:
68 **------------------------------------------------------------------------------------------------------
69 ********************************************************************************************************/
70 void PutChar(uint8 Data)
71 {
72 1 OS_ENTER_CRITICAL();
73 1 if (SerialCanSend == 1)
74 1 {
75 2 SerialCanSend = 0;
76 2 SBUF0 = Data;
77 2 }
78 1 else
79 1 {
80 2 OSQIntPost(SerialOutData,Data);
81 2 }
82 1 OS_EXIT_CRITICAL();
83 1 }
84
85 /*********************************************************************************************************
86 ** 函数名称: PutCharWithcheck
87 ** 功能描述: 发送一个字节同时校验
88 ** 输 入: Data:发送的数据
89 ** 输 出: 无
90 ** 全局变量: chk
91 ** 调用模块: PutChar
92 **
93 ** 作 者: 刘宝贵
94 ** 日 期: 2004年4月21日
95 **-------------------------------------------------------------------------------------------------------
96 ** 修改人:
97 ** 日 期:
98 **------------------------------------------------------------------------------------------------------
99 ********************************************************************************************************/
100 void PutCharWithCheck(uint8 Data)
101 {
102 1 outchk ^= Data ;
103 1 PutChar (Data);
104 1 }
105
106 /*********************************************************************************************************
107 ** 函数名称: CommSendInfo
108 ** 功能描述: 发送一个报文
109 ** 输 入: 无
110 ** 输 出: 无
111 ** 全局变量: address cid rtn chk
112 ** 调用模块: OSQCreate PutCharWithCheck PutChar
113 **
114 ** 作 者: 刘宝贵
115 ** 日 期: 2004年4月25日
116 **-------------------------------------------------------------------------------------------------------
C51 COMPILER V7.06 SERIAL 06/06/2005 16:32:37 PAGE 3
117 ** 修改人:
118 ** 日 期:
119 **------------------------------------------------------------------------------------------------------
120 ********************************************************************************************************/
121 void CommSendInfo(void)
122 {
123 1 OSQCreate(SerialOutData,200);
124 1 outchk = 0;
125 1 PutCharWithCheck(0xeb);
126 1 PutCharWithCheck(0x90);
127 1 PutCharWithCheck(0xeb);
128 1 PutCharWithCheck(0x90);
129 1 PutCharWithCheck(Address);
130 1 PutCharWithCheck(cid);
131 1 PutCharWithCheck(1);
132 1 PutCharWithCheck(rtn);
133 1 PutChar(outchk);
134 1 PutChar(0x0d);
135 1 }
136 /*********************************************************************************************************
137 ** 函数名称: CommSendParaInfo
138 ** 功能描述: 发送参数报文
139 ** 输 入: 无
140 ** 输 出: 无
141 ** 全局变量: address cid rtn outchk
142 ** 调用模块: OSQCreate PutCharWithCheck PutChar
143 **
144 ** 作 者: 刘宝贵
145 ** 日 期: 2004年4月25日
146 **-------------------------------------------------------------------------------------------------------
147 ** 修改人:
148 ** 日 期:
149 **------------------------------------------------------------------------------------------------------
150 ********************************************************************************************************/
151 void CommSendParaInfo(void)
152 {
153 1 OSQCreate(SerialOutData,200);
154 1 outchk = 0;
155 1 PutCharWithCheck(0xeb);
156 1 PutCharWithCheck(0x90);
157 1 PutCharWithCheck(0xeb);
158 1 PutCharWithCheck(0x90);
159 1 PutCharWithCheck(Address);
160 1 PutCharWithCheck(cid);
161 1 PutCharWithCheck(4);
162 1 PutCharWithCheck(rtn);
163 1 PutCharWithCheck(buf[0]);
164 1 if(OSSemPend(IICSem,10)==OS_SEM_OK)
165 1 {
166 2 PutCharWithCheck( EepromReadByteA(CellParaIICBase+buf[0]*2) );
167 2 PutCharWithCheck( EepromReadByteA(CellParaIICBase+buf[0]*2+1));
168 2 OSSemPost(IICSem);
169 2 }
170 1 PutChar(outchk);
171 1 PutChar(0x0d);
172 1 }
173 /*********************************************************************************************************
174 ** 函数名称: CommSendCellDataInfo
175 ** 功能描述: 发送电池数据报文
176 ** 输 入: 无
177 ** 输 出: 无
178 ** 全局变量: address cid rtn outchk cell.u cell.i cell.c cell.s
C51 COMPILER V7.06 SERIAL 06/06/2005 16:32:37 PAGE 4
179 ** 调用模块: OSQCreate PutCharWithCheck PutChar
180 **
181 ** 作 者: 刘宝贵
182 ** 日 期: 2004年4月27日
183 **-------------------------------------------------------------------------------------------------------
184 ** 修改人: 刘宝贵
185 ** 日 期: 2004年4月29日22:17
186 **-------------------------------------------------------------------------------------------------------
187 ** 修改人:
188 ** 日 期:
189 **------------------------------------------------------------------------------------------------------
190 ********************************************************************************************************/
191
192 void CommSendCellDataInfo (void)
193 {
194 1 uint8 data i;
195 1 OSQCreate(SerialOutData,200);
196 1 outchk = 0;
197 1 OS_ENTER_CRITICAL();
198 1 PutCharWithCheck(0xeb);
199 1 PutCharWithCheck(0x90);
200 1 PutCharWithCheck(0xeb);
201 1 PutCharWithCheck(0x90);
202 1 PutCharWithCheck(Address);
203 1 PutCharWithCheck(cid);
204 1 PutCharWithCheck(24*7+1);
205 1 PutCharWithCheck(rtn);
206 1 for (i=0;i<24;i++)
207 1 {
208 2 uint16 data temp;
209 2 OS_ENTER_CRITICAL();
210 2 temp=Cell[i].u;
211 2 OS_EXIT_CRITICAL();
212 2 PutCharWithCheck((uint8)(temp>>8));
213 2 PutCharWithCheck((uint8)(temp));
214 2 }
215 1 for (i=0;i<24;i++)
216 1 {
217 2 uint16 data temp;
218 2 OS_ENTER_CRITICAL();
219 2 temp=Cell[i].i;
220 2 OS_EXIT_CRITICAL();
221 2 PutCharWithCheck((uint8)(temp>>8));
222 2 PutCharWithCheck((uint8)(temp));
223 2 }
224 1 for (i=0;i<24;i++)
225 1 {
226 2 uint32 data temp;
227 2 OS_ENTER_CRITICAL();
228 2 temp = Cell[i].c;
229 2 OS_ENTER_CRITICAL();
230 2 temp/= 36000; //0.1mAsecond--->mAhour
231 2 PutCharWithCheck((uint8)(temp>>8));
232 2 PutCharWithCheck((uint8)(temp));
233 2 }
234 1 if(CurrentWorkStepMax < CurrentWorkStep)
235 1 {
236 2 CurrentWorkStepMax = CurrentWorkStep;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -