第1页共6页I2CArbitration5A软件设计第一部分原理图1.1PortSplitters.SchDocSDA_RDSampleFlagSCL_RDOutputOn_DACOutputOn_SpeakerSPI_DINSDA_WRSCL_WRClearSampleFlagSPI_ENABLESPI_CLKSPI_MODESPI_SELSPI_DOUTPCO[7..0]PBI[7..0]UNUSED1UNUSED2KEYCOL[3..0]KEYROW[3..0]PAI[7..0]PAO[7..0]PBO[7..0]O[7..0]IA[3..0]IB[3..0]U28J4B2_8BI[7..0]OA[3..0]OB[3..0]U30J8B_4B2I1I0I2I3I4I5I6I7O[7..0]U2J8S_8BI[7..0]O0O1O2O3O4O5O6O7U1J8B_8STSK51AOCDMicroprocessorCLKRSTEASFRDATAO[7..0]SFRDATAI[7..0]SFRADDR[6..0]SFRWRSFRRDROMDATAO[7..0]ROMDATAI[7..0]ROMADDR[15..0]ROMWRROMRDINT0INT1T0T1RXDTXDRXDOP0O[7..0]P0I[7..0]P1O[7..0]P1I[7..0]P2O[7..0]P2I[7..0]P3O[7..0]P3I[7..0]MEMDATAO[7..0]MEMDATAI[7..0]MEMADDR[15..0]MEMWRMEMRDPSWRPSRDP1TSK51A_DGNDGNDGNDGNDVCCGNDGNDGNDGNDGNDGNDMEMDATAI[7..0]MEMDATAO[7..0]MEMADDR[15..0]MEMWRMEMRDPSWRPSRDDATAO[7..0]DATAI[7..0]ADDR[10..0]WRRDRAM0_DATA[7..0]RAM_CSRAM_ADDR[16..0]RAM0_WERAM0_OEV1memif.vhdGND第2页共6页1.2PortSplitters.H/*****************************************************************************VERSIONCONTROL:@(#)tcpip.h1.303/10/31****INPACKAGE:EmbeddedTCPIP****COPYRIGHT:Copyright(c)2002Altium****DESCRIPTION:TCP,UDP,ICMP,IPrelatedfunctions****************************************************************************/#ifndef_TCPIP_H_#define_TCPIP_H_#includetcpipset.h#includecommon/tcpip_global.h//transportlayerexportstheglobalbuffer#ifdefOPTION_ETHERNET#includecommon/ethernet.h#else#includecommon/serial.h#endif//**************************************************************************//supportedIPversionisonlyIP4fornow#defineIP_VERSION_IP44第3页共6页//supportedprotocolsontopofIP#defineIP_PROTOCOL_ICMP1#defineIP_PROTOCOL_UDP17#defineIP_PROTOCOL_TCP6//IPbitmaskfragmentationflags//(notsupported,onlyusedwhendebuggingtocheckwedon'tgetany...)#defineIP_FLAG_DF0x4000#defineIP_FLAG_MF0x8000//ICMPtype&codesforsupportedmesages#defineICMP_TYPE_ECHOREPLY0x00#defineICMP_TYPE_UNREACH0x03#defineICMP_TYPE_ECHO0x08#defineICMP_CODE_UNREACH_PORT0x03//TCPoptionforreceivingwindowsize(onlyoptionweneed)#defineTCP_RECVWIN_OPTION2#defineTCP_RECVWIN_OPTION_LEN4#defineTCP_DATA_MAXLEN(IP_MAXLEN-sizeof(IPHEADER)-sizeof(TCPHEADER))//**************************************************************************typedefstruct{Uint8version;Uint8service;Uint16packetlength;Uint16ident;Uint16offset;第4页共6页Uint8timetolive;Uint8protocol;Uint16checksum;Uint32sourceip;Uint32destip;}IPHEADER;#defineIPHEADER_LENsizeof(IPHEADER)#defineIP((IPHEADER*)IPBUF)#defineIPDATA((char*)IPBUF+IPHEADER_LEN)typedefstruct{Uint8type;Uint8code;Uint16checksum;Uint16ident;Uint16sequence;}ICMPHEADER;#defineICMPHEADER_LENsizeof(ICMPHEADER)#defineICMP((ICMPHEADER*)(IPBUF+IPHEADER_LEN))#defineICMPDATA((char*)(IPBUF+IPHEADER_LEN+ICMPHEADER_LEN))typedefstruct{Uint16sourceport;Uint16destport;Uint32sequence;Uint32acknowledge;Uint8headerinfo;第5页共6页Uint8flags;Uint16window;Uint16checksum;Uint16urgent;}TCPHEADER;#defineTCPHEADER_LENsizeof(TCPHEADER)#defineTCP((TCPHEADER*)(IPBUF+IPHEADER_LEN))#defineTCPDATA((char*)(IPBUF+IPHEADER_LEN+TCPHEADER_LEN))typedefstruct{Uint16sourceport;Uint16destport;Uint16length;Uint16checksum;}UDPHEADER;#defineUDPHEADER_LENsizeof(UDPHEADER)#defineUDP((UDPHEADER*)(IPBUF+IPHEADER_LEN))#defineUDPDATA((char*)(IPBUF+IPHEADER_LEN+UDPHEADER_LEN))//**************************************************************************externvoidtcpip_init(void);externvoidtcp_resetall(void);externvoidtcp_timertick(void);externUint8tcp_retries(void);externUint16ip_process(void);第6页共6页#ifdefOPTION_IP_ROUTINGexternUint16ip_routing(void);#endifexternchar*ip_create(Uint32destip);#ifdefOPTION_UDPexternUint16udp_sendprep(Uint16ip_datalength);externvoidudp_create(Uint16sourceport,Uint16destport);#endif#ifdefDEBUG_TCPexternvoidtcp_sessionstatus(void);#endif//**************************************************************************#endif