📄 copy.lst
字号:
285 1 jubuSend_byte (suba % 256); // the low byte address
286 1 if (ack == 0 ) return (0);
287 1 jubuStartI2c();
288 1 jubuSend_byte(sla + 1);
289 1 if ( ack == 0) return ( 0 );
290 1 for(i =0;i< no -1; i++)
291 1 {
292 2 *s = jubuRcv_byte();
293 2 jubuAckI2c(0);
294 2 s++;
295 2 }
296 1 *s = jubuRcv_byte();
297 1 jubuAckI2c(1);
298 1 jubuStopI2c();
299 1 return(1);
300 1 }
301 ////////////////////////////////
302 bit jubuSendStr16K( uchar sla, uchar suba, uchar *s, uchar no )
C51 COMPILER V7.06 COPY 03/04/2005 11:38:34 PAGE 6
303 {
304 1 uchar i;
305 1 jubuStartI2c();
306 1 jubuSend_byte(sla);
307 1 if(ack == 0)return (0);
308 1 jubuSend_byte(suba);
309 1 if(ack == 0)return (0);
310 1 for( i = 0; i < no ;i ++)
311 1 {
312 2 jubuSend_byte(*s);
313 2 if(ack == 0)return (0);
314 2 s++;
315 2 }
316 1 jubuStopI2c();
317 1 return (1);
318 1 }
319 bit jubuSendStr32K( uchar sla, uint suba, uchar *s, uchar no )
320 {
321 1 uchar i;
322 1 jubuStartI2c();
323 1 jubuSend_byte(sla);
324 1 if(ack == 0)return (0);
325 1 jubuSend_byte(suba / 256); // the high byte address
326 1 if(ack == 0)return (0);
327 1 jubuSend_byte(suba % 256); // the low byte address
328 1 if(ack == 0)return (0);
329 1 for( i = 0; i < no-1 ;i ++)
330 1 {
331 2 jubuSend_byte(*s);
332 2 if(ack == 0)return (0);
333 2 s++;
334 2 }
335 1 jubuSend_byte(*s);
336 1 jubuStopI2c();
337 1
338 1 return (1);
339 1 }
340 //////////////////////////////////////////////
341 void feedStartI2c( )
342 {
343 1
344 1 SDA9 = 1;
345 1 _Nop();
346 1 _Nop();
347 1 _Nop();
348 1 SCL = 1;
349 1 _Nop(); // after stop must wait > 4.7 can to new start
350 1 _Nop();
351 1 _Nop();
352 1 _Nop();
353 1 _Nop();
354 1 _Nop();
355 1 _Nop();
356 1 SDA9 = 0;
357 1 _Nop(); // the start signal keep up to > 4.0
358 1 _Nop();
359 1 _Nop();
360 1 _Nop();
361 1 _Nop();
362 1 _Nop();
363 1 _Nop();
364 1 SCL = 0;
C51 COMPILER V7.06 COPY 03/04/2005 11:38:34 PAGE 7
365 1 _Nop(); // T_low > 4.7
366 1 _Nop();
367 1 _Nop();
368 1 _Nop();
369 1 _Nop();
370 1 _Nop();
371 1 _Nop();
372 1
373 1 }
374
375 void feedStopI2c()
376 {
377 1 SDA9 = 0;
378 1 _Nop();
379 1 _Nop();
380 1 SCL = 1;
381 1 _Nop();
382 1 _Nop();
383 1 _Nop();
384 1 _Nop();
385 1 _Nop();
386 1 _Nop();
387 1 _Nop();
388 1 SDA9 = 1;
389 1 _Nop();
390 1 _Nop();
391 1 _Nop();
392 1 _Nop();
393 1 _Nop();
394 1 }
395
396 void feedSend_byte( uchar c )
397 {
398 1 uchar BitCnt;
399 1 for( BitCnt = 0; BitCnt < 8; BitCnt ++ )
400 1 {
401 2 if((c << BitCnt) & 0x80) SDA9 = 1;
402 2 else SDA9 = 0;
403 2 _Nop();
404 2 _Nop();
405 2 _Nop();
406 2 SCL = 1;
407 2 _Nop();
408 2 _Nop();
409 2 _Nop();
410 2 _Nop();
411 2 _Nop();
412 2 _Nop();
413 2 _Nop();
414 2 SCL = 0;
415 2 _Nop();
416 2 _Nop();
417 2 _Nop();
418 2 }
419 1 _Nop();
420 1 _Nop();
421 1 _Nop();
422 1 SDA9 = 1;
423 1 _Nop();
424 1 _Nop();
425 1 _Nop();
426 1 SCL = 1;
C51 COMPILER V7.06 COPY 03/04/2005 11:38:34 PAGE 8
427 1 _Nop();
428 1 _Nop();
429 1 _Nop();
430 1 _Nop();
431 1 _Nop();
432 1 _Nop();
433 1 if (SDA9 == 1) ack =0;
434 1 else ack = 1;
435 1 SCL = 0;
436 1 _Nop();
437 1 _Nop();
438 1 _Nop();
439 1 _Nop();
440 1 }
441
442 uchar feedRcv_byte()
443 {
444 1 uchar retc;
445 1 uchar BitCnt;
446 1
447 1 retc = 0;
448 1 SDA9 = 1;
449 1 for( BitCnt = 0 ; BitCnt < 8; BitCnt ++)
450 1 {
451 2 _Nop();
452 2 _Nop();
453 2 _Nop();
454 2 SCL = 0;
455 2 _Nop();
456 2 _Nop();
457 2 _Nop();
458 2 _Nop();
459 2 _Nop();
460 2 _Nop();
461 2 _Nop();
462 2 SCL = 1;
463 2 _Nop();
464 2 _Nop();
465 2 _Nop();
466 2 _Nop();
467 2 _Nop();
468 2 _Nop();
469 2 _Nop();
470 2 retc = retc << 1;
471 2 if (SDA9 == 1) retc= retc +1;
472 2 _Nop();
473 2 _Nop();
474 2 _Nop();
475 2 _Nop();
476 2 }
477 1 SCL = 0;
478 1 _Nop();
479 1 _Nop();
480 1 _Nop();
481 1 _Nop();
482 1 return(retc);
483 1 }
484
485 void feedAckI2c( bit a )
486 {
487 1 if ( a == 0) SDA9 = 0;
488 1 else SDA9 = 1;
C51 COMPILER V7.06 COPY 03/04/2005 11:38:34 PAGE 9
489 1 _Nop();
490 1 _Nop();
491 1 _Nop();
492 1 _Nop();
493 1 _Nop();
494 1 SCL = 1;
495 1 _Nop();
496 1 _Nop();
497 1 _Nop();
498 1 _Nop();
499 1 _Nop();
500 1 _Nop();
501 1 SCL = 0;
502 1 _Nop();
503 1 _Nop();
504 1 _Nop();
505 1 }
506
507 bit fed_RS16K ( uchar sla, uchar suba, uchar *s, uchar no )
508 {
509 1 uchar i;
510 1 feedStartI2c ();
511 1 feedSend_byte (sla);
512 1 if( ack == 0 ) return (0);
513 1 feedSend_byte (suba);
514 1 if (ack == 0 ) return (0);
515 1 feedStartI2c();
516 1 feedSend_byte(sla + 1);
517 1 if ( ack == 0) return ( 0 );
518 1 for(i =0;i< no -1; i++)
519 1 {
520 2 *s = feedRcv_byte();
521 2 feedAckI2c(0);
522 2 s++;
523 2 }
524 1 *s = feedRcv_byte();
525 1 feedAckI2c(1);
526 1 feedStopI2c();
527 1 return(1);
528 1 }
529
530
531
532 bit fed_RS32K ( uchar sla, uint suba, uchar *s, uchar no )
533 {
534 1 uchar i;
535 1 feedStartI2c ();
536 1 feedSend_byte (sla);
537 1 if( ack == 0 ) return (0);
538 1 feedSend_byte (suba / 256); // the high byte address
539 1 if (ack == 0 ) return (0);
540 1 feedSend_byte (suba % 256); // the low byte address
541 1 if (ack == 0 ) return (0);
542 1 feedStartI2c();
543 1 feedSend_byte(sla + 1);
544 1 if ( ack == 0) return ( 0 );
545 1 for(i =0;i< no -1; i++)
546 1 {
547 2 *s = feedRcv_byte();
548 2 feedAckI2c(0);
549 2 s++;
550 2 }
C51 COMPILER V7.06 COPY 03/04/2005 11:38:34 PAGE 10
551 1 *s = feedRcv_byte();
552 1 feedAckI2c(1);
553 1 feedStopI2c();
554 1 return(1);
555 1 }
556 ////////////////////////////////////////////
557 bit feedSendStr16K( uchar sla, uchar suba, uchar *s, uchar no )
558 {
559 1 uchar i;
560 1 feedStartI2c();
561 1 feedSend_byte(sla);
562 1 if(ack == 0)return (0);
563 1 feedSend_byte(suba);
564 1 if(ack == 0)return (0);
565 1 for( i = 0; i < no ;i ++)
566 1 {
567 2 feedSend_byte(*s);
568 2 if(ack == 0)return (0);
569 2 s++;
570 2 }
571 1 feedStopI2c();
572 1 return (1);
573 1 }
574 bit feedSendStr32K( uchar sla, uint suba, uchar *s, uchar no )
575 {
576 1 uchar i;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -