📄 sle4428.lst
字号:
260 //返回:
261 // TRUE
262
263 bit read_wpbit_sle4428(uint iOffset,uchar iReadLen,uchar* sBuffer)
264 {
265 1 uchar data i,iTemp;
266 1 uchar cTemp[2];
267 1 if((iOffset<0)||(iOffset>1023))
268 1 return FALSE;
269 1 if((1024-iOffset)<iReadLen)
270 1 return FALSE;
271 1 answer_reset_4428();
272 1 memcpy(cTemp,&iOffset,2);
273 1 cTemp[0]=(cTemp[0]*64)|0x0c;
274 1 byte_write_4428(cTemp[0]);
275 1 byte_write_4428(cTemp[1]);
276 1 byte_write_4428(0xff);
277 1 for(i=0;i<iReadLen;i++)
278 1 {
279 2 iTemp=byte_read_wpbit_4428();
280 2 memcpy(sBuffer,&iTemp,2);
281 2 sBuffer+=2;
282 2 }
283 1 return TRUE;
284 1 }
285
286
287 //功能:向SLE4428中写入数据(带保护位)
288 //参数:
289 // iOffset:写入数据起始地址
290 // iWriteLen:写入数据长度
291 // sBuffer:写入数据指针
292 //返回:
293 // TRUE
294
295 bit write_wpbit_sle4428(uint iOffset,uchar iWriteLen,uchar* sBuffer)
296 {
297 1 uchar data i,ipOffset,iTemp;
298 1 uchar cTemp[2];
299 1 uchar* swBuffer;
300 1 if((iOffset<0)||(iOffset>1020))
301 1 return FALSE;
302 1 if((1021-iOffset)<iWriteLen)
303 1 return FALSE;
C51 COMPILER V6.12 SLE4428 08/15/2002 18:03:17 PAGE 6
304 1 ipOffset=iOffset;
305 1 swBuffer=sBuffer;
306 1 answer_reset_4428();
307 1 for(i=0;i<iWriteLen;i++)
308 1 {
309 2 memcpy(cTemp,&ipOffset,2);
310 2 cTemp[0]=(cTemp[0]*64)|0x31;
311 2 byte_write_4428(cTemp[0]);
312 2 byte_write_4428(cTemp[1]);
313 2 byte_write_4428(*swBuffer++);
314 2 if(process_4428()!=TRUE)
315 2 return FALSE;
316 2 ipOffset++;
317 2 }
318 1 answer_reset_4428();
319 1 memcpy(cTemp,&iOffset,2);
320 1 cTemp[0]=(cTemp[0]*64)|0x0c;
321 1 byte_write_4428(cTemp[0]);
322 1 byte_write_4428(cTemp[1]);
323 1 byte_write_4428(0xff);
324 1 for(i=0;i<iWriteLen;i++)
325 1 {
326 2 iTemp=byte_read_wpbit_4428();
327 2 memcpy(cTemp,&iTemp,2);
328 2 if(cTemp[1]!=0x00)
329 2 return FALSE;
330 2 if(cTemp[0]!=*sBuffer++)
331 2 return FALSE;
332 2 }
333 1 return TRUE;
334 1 }
335
336
337 //功能:写SLE4428卡保护位
338 //参数:
339 // iOffset:写入数据起始地址
340 // sBuffer:写入数据指针
341 // iBufferLen:写入长度
342 //返回:
343 // TRUE
344
345 bit write_pbit_sle4428(uint iOffset,uchar iBufferLen,uchar* sBuffer)
346 {
347 1 uchar data i,ipOffset,iTemp;
348 1 uchar cTemp[2];
349 1 uchar* swBuffer;
350 1 if((iOffset<0)||(iOffset>1020))
351 1 return FALSE;
352 1 if((1021-iOffset)<iBufferLen)
353 1 return FALSE;
354 1 swBuffer=sBuffer;
355 1 ipOffset=iOffset;
356 1 answer_reset_4428();
357 1 for(i=0;i<iBufferLen;i++)
358 1 {
359 2 memcpy(cTemp,&ipOffset,2);
360 2 cTemp[0]=(cTemp[0]*64)|0x30;
361 2 byte_write_4428(cTemp[0]);
362 2 byte_write_4428(cTemp[1]);
363 2 byte_write_4428(*swBuffer++);
364 2 if(process_4428()!=TRUE)
365 2 return FALSE;
C51 COMPILER V6.12 SLE4428 08/15/2002 18:03:17 PAGE 7
366 2 ipOffset++;
367 2 }
368 1 answer_reset_4428();
369 1 memcpy(cTemp,&iOffset,2);
370 1 cTemp[0]=(cTemp[0]*64)|0x0c;
371 1 byte_write_4428(cTemp[0]);
372 1 byte_write_4428(cTemp[1]);
373 1 byte_write_4428(0xff);
374 1 for(i=0;i<iBufferLen;i++)
375 1 {
376 2 iTemp=byte_read_wpbit_4428();
377 2 memcpy(cTemp,&iTemp,2);
378 2 if(cTemp[1]!=0x00)
379 2 return FALSE;
380 2 if(cTemp[0]!=*sBuffer++)
381 2 return FALSE;
382 2 }
383 1 return TRUE;
384 1 }
385
386
387 //功能:比较SLE4428密码
388 //参数:
389 // sPassword:密码存放指针
390 // iPassLen:密码长度
391 //返回:
392 // TRUE
393
394 bit compare_password_sle4428(uchar* sPassword,uchar iPassLen)
395 {
396 1 uchar cTemp;
397 1 if(iPassLen!=2)
398 1 return FALSE;
399 1 cTemp=error_counter_4428();
400 1 if(cTemp!=0x00)
401 1 {
402 2 switch(cTemp)
403 2 {
404 3 case 0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff:
405 3 {
406 4 cTemp=cTemp&0xfe;
407 4 break;
408 4 }
409 3 case 0x02,0x06,0x0e,0x1e,0x3e,0x7e,0xfe:
410 3 {
411 4 cTemp=cTemp&0xfc;
412 4 break;
413 4 }
414 3 case 0x04,0x0c,0x1c,0x3c,0x7c,0xfc:
415 3 {
416 4 cTemp=cTemp&0xf8;
417 4 break;
418 4 }
419 3 case 0x08,0x18,0x38,0x78,0xf8:
420 3 {
421 4 cTemp=cTemp&0xf0;
422 4 break;
423 4 }
424 3 case 0x10,0x30,0x70,0xf0:
425 3 {
426 4 cTemp=cTemp&0xe0;
427 4 break;
C51 COMPILER V6.12 SLE4428 08/15/2002 18:03:17 PAGE 8
428 4 }
429 3 case 0x20,0x60,0xe0:
430 3 {
431 4 cTemp=cTemp&0xc0;
432 4 break;
433 4 }
434 3 case 0x40,0xc0:
435 3 {
436 4 cTemp=cTemp&0x80;
437 4 break;
438 4 }
439 3 case 0x80:
440 3 {
441 4 cTemp=cTemp&0x00;
442 4 break;
443 4 }
444 3 default:
445 3 {
446 4 return FALSE;
447 4 }
448 3 }
449 2 }
450 1 byte_write_4428(0xf2);
451 1 byte_write_4428(0xfd);
452 1 byte_write_4428(cTemp);
453 1 if(process_4428()!=TRUE)
454 1 return FALSE;
455 1 byte_write_4428(0xcd);
456 1 byte_write_4428(0xfe);
457 1 byte_write_4428(*sPassword++);
458 1 if(process_4428()!=TRUE)
459 1 return FALSE;
460 1 byte_write_4428(0xcd);
461 1 byte_write_4428(0xff);
462 1 byte_write_4428(*sPassword);
463 1 if(process_4428()!=TRUE)
464 1 return FALSE;
465 1 byte_write_4428(0xf3);
466 1 byte_write_4428(0xfd);
467 1 byte_write_4428(0xff);
468 1 if(process_4428()!=TRUE)
469 1 return FALSE;
470 1 cTemp=error_counter_4428();
471 1 if(cTemp==0xff)
472 1 return TRUE;
473 1 return FALSE;
474 1 }
475
476
477 //功能:读取SLE4428密码
478 //参数:
479 // sPassword:密码存放指针
480 // iPassLen:密码长度
481 //返回:
482 // TRUE
483
484 bit read_password_sle4428(uchar* sPassword,uchar iPassLen)
485 {
486 1 bit st;
487 1 if(iPassLen!=2)
488 1 return FALSE;
489 1 st=read_sle4428(1022,2,sPassword);
C51 COMPILER V6.12 SLE4428 08/15/2002 18:03:17 PAGE 9
490 1 if(st!=1)
491 1 return FALSE;
492 1 return TRUE;
493 1 }
494
495
496 //功能:更改SLE4428密码
497 //参数:
498 // iPassLen:密码数量
499 // sPassword:密码指针
500 //返回:
501 // TRUE
502
503 bit change_password_sle4428(uchar* sPassword,uchar iPassLen)
504 {
505 1 bit st;
506 1 if(iPassLen!=2)
507 1 return FALSE;
508 1 st=write_sle4428(1022,2,sPassword);
509 1 if(st!=1)
510 1 return FALSE;
511 1 return TRUE;
512 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1542 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 64
IDATA SIZE = ---- 4
BIT SIZE = ---- 2
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -