📄 flashmodule.lst
字号:
163 3 }
164 2 FeedDog();
165 2 }
166 1 }
167
168 //--------------------------------------------------------------------------------------------------
169 //函数名称:unsigned int CaculateCheckSum(unsigned char xdata *Source, unsigned int uiLength)
170 //功 能:根据长度将源地址的数据累加
171 //输入参数:源地址、数据长度
172 //返 回:累加和
173 //完成日期:4/13/2007
174 //-------------------------------------------------------------------------------------------------
175 unsigned int CaculateCheckSum(unsigned char xdata *Source, unsigned int uiLength)
176 {
177 1 unsigned int xdata uiL;
C51 COMPILER V7.10 FLASHMODULE 09/18/2008 14:09:29 PAGE 4
178 1 unsigned int xdata uiTempVariable = 0;
179 1
180 1 uiTempVariable = 0;
181 1 for (uiL=0; uiL<uiLength; uiL++)
182 1 {
183 2 uiTempVariable = uiTempVariable + *Source;
184 2 Source++;
185 2 }
186 1
187 1 return uiTempVariable;
188 1 }
189
190
191 //--------------------------------------------------------------------------------------------------
192 //函数名称:void WriteSystemPara(unsigned char xdata *destination,unsigned char xdata *Source,unsigned int
- uchLength)
193 //功 能:根据长度将目的地址的内容写入到28C64存储器中的各个不同地址中
194 //输入参数:目的地址、源地址、数据长度
195 //返 回:无
196 //完成日期:4/13/2007
197 //-------------------------------------------------------------------------------------------------
198 void WriteSystemPara(unsigned char xdata *destination,unsigned char xdata *Source,unsigned int uiLength)
199 {
200 1 WriteExternFlash(destination, Source, uiLength);
201 1 WriteExternFlash(destination + FLASHREMOTIONADRESS, Source, uiLength);
202 1 }
203
204 //--------------------------------------------------------------------------------------------------
205 //函数名称:void ReadSystemPara(unsigned char xdata *destination, unsigned int xdata *source,unsigned char
- uchLength)
206 //功 能:根据长度并进行校验和判断后将28C64存储器中的不同地址的内容读到目的数组中
207 //输入参数:数据目的地址,数据源地址,数据长度 (不包括校验和位的数据)
208 //返 回:无
209 //完成日期:4/13/2007
210 //-------------------------------------------------------------------------------------------------
211 void ReadSystemPara(unsigned char xdata *destination, unsigned char xdata *source,unsigned int uiLength)
212 {
213 1 unsigned char xdata uchTempArray[220]; //数组临时设定,维数要与实际情况为准
214 1 unsigned int xdata uiTempVariable;
215 1 unsigned int xdata uiFirstCheckSum;
216 1 unsigned int xdata uiSecondCheckSum;
217 1 unsigned int xdata uiL;
218 1 unsigned char xdata uchCountNumber;
219 1
220 1 uchCountNumber = 0;
221 1 ReadExternFlash(destination,source,(uiLength+2));
222 1 uiFirstCheckSum = CaculateCheckSum(destination, uiLength);
223 1 uiTempVariable = *(destination + uiLength) << 8 ;
224 1 uiTempVariable = uiTempVariable + *(destination + uiLength + 1);
225 1 FeedDog();
226 1 if (uiFirstCheckSum == uiTempVariable)
227 1 {
228 2 source = source + FLASHREMOTIONADRESS;
229 2 ReadExternFlash(uchTempArray, source, (uiLength + 2));
230 2
231 2 uiSecondCheckSum = CaculateCheckSum(uchTempArray, uiLength);
232 2 uiTempVariable = *(uchTempArray + uiLength) << 8;
233 2 uiTempVariable = uiTempVariable + *(uchTempArray + uiLength +1);
234 2 while (uiSecondCheckSum != uiTempVariable)
235 2 {
236 3 ReadExternFlash(uchTempArray, source, (uiLength + 2));
237 3
C51 COMPILER V7.10 FLASHMODULE 09/18/2008 14:09:29 PAGE 5
238 3 uiSecondCheckSum = CaculateCheckSum(uchTempArray, uiLength);
239 3 uiTempVariable = *(uchTempArray + uiLength) << 8;
240 3 uiTempVariable = uiTempVariable + *(uchTempArray + uiLength +1);
241 3 uchCountNumber++;
242 3 if (uchCountNumber == 10)
243 3 {
244 4 WriteExternFlash(FLASHREMOTIONADRESS, destination, uiLength);
245 4 break;
246 4 }
247 3 }
248 2 }
249 1 else if (uiFirstCheckSum != uiTempVariable)
250 1 {
251 2 uchCountNumber = 0;
252 2 ReadExternFlash(destination,source,(uiLength+2));
253 2 uiFirstCheckSum = CaculateCheckSum(destination, uiLength);
254 2 uiTempVariable = *(destination + uiLength) << 8 ;
255 2 uiTempVariable = uiTempVariable + *(destination + uiLength + 1);
256 2 while(uiFirstCheckSum != uiTempVariable)
257 2 {
258 3 ReadExternFlash(destination,source,(uiLength+2));
259 3 uiFirstCheckSum = CaculateCheckSum(destination, uiLength);
260 3 uiTempVariable = *(destination + uiLength) << 8 ;
261 3 uiTempVariable = uiTempVariable + *(destination + uiLength + 1);
262 3 uchCountNumber++;
263 3 if (uchCountNumber == 9)
264 3 {
265 4 break;
266 4 }
267 3 }
268 2 if (uiFirstCheckSum == uiTempVariable)
269 2 {
270 3 source = source + FLASHREMOTIONADRESS;
271 3 ReadExternFlash(uchTempArray, source, (uiLength + 2));
272 3 FeedDog();
273 3 uiSecondCheckSum = CaculateCheckSum(uchTempArray, uiLength);
274 3 uiTempVariable = *(uchTempArray + uiLength) << 8;
275 3 uiTempVariable = uiTempVariable + *(uchTempArray + uiLength +1);
276 3 while (uiSecondCheckSum != uiTempVariable)
277 3 {
278 4 ReadExternFlash(uchTempArray, source, (uiLength + 2));
279 4
280 4 uiSecondCheckSum = CaculateCheckSum(uchTempArray, uiLength);
281 4 uiTempVariable = *(uchTempArray + uiLength) << 8;
282 4 uiTempVariable = uiTempVariable + *(uchTempArray + uiLength +1);
283 4 uchCountNumber++;
284 4 if (uchCountNumber == 10)
285 4 {
286 5 WriteExternFlash(FLASHREMOTIONADRESS, destination, uiLength);
287 5 break;
288 5 }
289 4 }
290 3 return;
291 3 }
292 2 source = source + FLASHREMOTIONADRESS;
293 2 ReadExternFlash(uchTempArray, source, (uiLength + 2));
294 2 uiSecondCheckSum = CaculateCheckSum(uchTempArray, uiLength);
295 2 uiTempVariable = *(uchTempArray + uiLength) << 8;
296 2 uiTempVariable = uiTempVariable + *(uchTempArray + uiLength +1);
297 2 FeedDog();
298 2 uchCountNumber = 0;
299 2 while (uiSecondCheckSum != uiTempVariable)
C51 COMPILER V7.10 FLASHMODULE 09/18/2008 14:09:29 PAGE 6
300 2 {
301 3 ReadExternFlash(uchTempArray, source, (uiLength + 2));
302 3
303 3 uiSecondCheckSum = CaculateCheckSum(uchTempArray, uiLength);
304 3 uiTempVariable = *(uchTempArray + uiLength) << 8;
305 3 uiTempVariable = uiTempVariable + *(uchTempArray + uiLength +1);
306 3 uchCountNumber++;
307 3 if (uchCountNumber == 10)
308 3 {
309 4 break;
310 4 }
311 3 }
312 2 if (uiSecondCheckSum == uiTempVariable)
313 2 {
314 3 for (uiL=0; uiL<uiLength; uiL++)
315 3 {
316 4 *(destination + uiL) = uchTempArray[uiL];
317 4 }
318 3 WriteExternFlash(0, uchTempArray, uiLength);
319 3 }
320 2 else
321 2 {
322 3 ReadFlashDefaultPara(destination,(char code *)&Def_Para_Array, uiLength);
323 3 WriteSystemPara(0, destination, uiLength);
324 3 }
325 2 }
326 1 else
327 1 {
328 2 return;
329 2 }
330 1 return;
331 1 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -