📄 cp2200.lst
字号:
470 2 }
471 1
472 1 // Step 3: Read the entire packet from the buffer
473 1 if(cplen <=318)
474 1 {
475 2 for(i = 0; i < cplen; i++)
476 2 {
477 3 inbuf[i] = RXAUTORD;
478 3 }
479 2 num_bytes = cplen-4;
480 2
481 2 }
482 1 else
483 1 {
484 2 // Set packet length to zero
485 2 cplen = 0;
486 2 // Skip packet
487 2 skip = 1;
488 2 }
489 1
C51 COMPILER V7.06 CP2200 12/04/2007 13:46:18 PAGE 9
490 1 // Step 4: Skip the packet, or clear the valid bit if the entire packet
491 1 // has been unloaded from the buffer.
492 1 tmp = RXCN;
493 1 if(skip)
494 1 {
495 2 RXCN=(tmp | 0x02); // Skip the packet
496 2 }
497 1
498 1 else
499 1 {
500 2 RXCN=(tmp |= 0x04); // Clear the valid bit only
501 2 RXCN&=0x07;
502 2 }
503 1
504 1 // If there are no more packets in the receive buffer, enable reception
505 1 tmp = TLBVALID;
506 1 if(tmp == 0x00)
507 1 {
508 2 RXCN=0x00;
509 2 }
510 1
511 1
512 1 // Return the number of bytes added to the buffer
513 1 return cplen-4;
514 1 }
515
516 unsigned char CPRcv(void) //判断接受的包是否正确
517 {
518 1 unsigned char tmp;
519 1
520 1 if(CPINFOH & RXVALID)
521 1 tmp = 1;
522 1 else
523 1 tmp = 0;
524 1 return tmp;
525 1 }
526
527 //-----------------------------------------------------------------------------
528 // CP220x Flash Routines
529 //-----------------------------------------------------------------------------
530 // Not used. Commented to save code space.
531 //-----------------------------------------------------------------------------
532 // CPFLASH_ByteRead
533 //-----------------------------------------------------------------------------
534 //
535 // Return Value :
536 // unsigned char - the value of the Flash byte.
537 //
538 // Parameters :
539 // 1) unsigned int addr - the address in CP220x Flash.
540 //
541 // Reads a Flash byte and returns its value.
542 //-----------------------------------------------------------------------------
543 /*
544 unsigned char CPFLASH_ByteRead (unsigned int addr)
545 {
546
547 // Set the Flash Address Pointer to <addr>
548 FLASHADDRH = (addr >> 8); // Copy High Byte
549 FLASHADDRL = (addr & 0xFF); // Copy Low Byte
550
551 // Read and Return the value in the Flash Data Register
C51 COMPILER V7.06 CP2200 12/04/2007 13:46:18 PAGE 10
552 return FLASHDATA;
553 }
554 //-----------------------------------------------------------------------------
555 // poll_flash_busy
556 //-----------------------------------------------------------------------------
557 //
558 // Return Value :
559 // unsigned char - Returns '0' on success or FLASH_ERROR if a problem
560 // is encountered.
561 //
562 // Parameters : None
563 //
564 // Waits for a Flash operation to start and complete
565 //
566 // Return Values:
567 //
568 //-----------------------------------------------------------------------------
569 unsigned char poll_flash_busy (void)
570 {
571
572 // Start Millisecond Timer and set timeout
573 reset_timeout(DEFAULT_TIMEOUT);
574
575 // Wait for operation to end
576 while((FLASHSTA & 0x08)){
577
578 if(!AB4_RST_State()){
579 #if(UART_ENABLED)
580 puts("Reset Pin Driven Low. Could indicate power failure.");
581 #endif
582 return FLASH_ERROR;
583 }
584
585 if(timeout_expired()){
586 #if(UART_ENABLED)
587 puts("Timeout: Flash operation has not ended.");
588 #endif
589 return FLASH_ERROR;
590 }
591
592 }
593
594 return 0;
595 }*/
596
597 //-----------------------------------------------------------------------------
598 // CPFLASH_ByteWrite
599 //-----------------------------------------------------------------------------
600 //
601 // Return Value :
602 // unsigned char - Returns '0' on success or FLASH_ERROR if a problem
603 // is encountered.
604 //
605 // Parameters :
606 // 1) unsigned int addr - the address of the Flash byte.
607 // 2) unsigned char byte - the data to write to Flash.
608 //
609 // Writes the value <byte> to the Flash address <addr>.
610 //
611 // Note: The addresses 0x1FFA through 0x1FFF cannot be written using this
612 // function because they contain the MAC address.
613 //
C51 COMPILER V7.06 CP2200 12/04/2007 13:46:18 PAGE 11
614 // Note: Software calling this function must ensure that the target Flash
615 // byte has been erased (value = 0xFF).
616 //
617 // Note: The Flash must be unlocked prior to calling this function.
618 //-----------------------------------------------------------------------------
619 /*
620 unsigned char CPFLASH_ByteWrite (unsigned int addr, char byte)
621 {
622
623
624 // Check if address is in-range
625 if(addr < 0x1FFA)
626 {
627 // Set the Flash Address Pointer to <addr>
628 FLASHADDRH = (addr >> 8); // Copy High Byte
629 FLASHADDRL = (addr & 0xFF); // Copy Low Byte
630
631 // Write the Flash unlock sequence 0xA5, 0xF1
632 FLASHKEY = 0xA5;
633 FLASHKEY = 0xF1;
634
635 // Initiate the Flash write
636 FLASHDATA = byte;
637
638
639 // Wait for the Flash operation to start and complete
640 return poll_flash_busy();
641
642 }
643
644 return FLASH_ERROR;
645 }
646
647
648 //-----------------------------------------------------------------------------
649 // CPFLASH_PageErase
650 //-----------------------------------------------------------------------------
651 //
652 // Return Value :
653 // unsigned char - Returns '0' on success or FLASH_ERROR if a problem
654 // is encountered.
655 //
656 // Parameters :
657 // 1) unsigned int addr - the address of the Flash Page.
658 //
659 // Erases the Flash page containing address <addr>.
660 //
661 // Note: The last Flash page (0x1E00 - 0x1FFF) cannot be erased using this
662 // function because it contains the MAC address.
663 //
664 // Note: All data stored on a Flash page will be lost once the page is erased.
665 //
666 // Note: The Flash must be unlocked prior to calling this function.
667 //-----------------------------------------------------------------------------
668 unsigned char CPFLASH_PageErase (unsigned int addr)
669 {
670 // Check if address is in-range
671 if(addr < 0x1E00)
672 {
673 // Set the Flash Address Pointer to <addr>
674 FLASHADDRH = (addr >> 8); // Copy High Byte
675 FLASHADDRL = (addr & 0xFF); // Copy Low Byte
C51 COMPILER V7.06 CP2200 12/04/2007 13:46:18 PAGE 12
676
677 // Write the Flash unlock sequence 0xA5, 0xF1
678 FLASHKEY = 0xA5;
679 FLASHKEY = 0xF1;
680
681 // Initiate the Flash erase
682 FLASHERASE = 0x01;
683
684 // Wait for the Flash operation to start and complete
685 return poll_flash_busy();
686
687 }
688
689 return FLASH_ERROR;
690 }*/
691
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 807 ----
CONSTANT SIZE = 14 ----
XDATA SIZE = 1 ----
PDATA SIZE = ---- ----
DATA SIZE = 2 16
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -