第1页共9页I2CArbitration3A软件设计第一部分原理图1.1SoundGenerator.SchDocHZ_5555556SoundHZ_22046HZ_793651PulseStartPulseEndHZ_5555556HZ_22046ClockPulseWidth[7..0]PulseQ[7..0]PulseEndPulseStartPM1PWM.SCHDOCMHZ_50DIN[7..0]HZ_793651HZ_11023HZ_11023CDQU20FDCDQU21FDCDQU26FDU15INVU16INVU25INV/9U17CDIV9/9U18CDIV9/7U19CDIV7/7U34CDIV7第2页共9页1.2SoundGenerator./*****************************************************************************VERSIONCONTROL:@(#)tcpip_global.h1.604/03/17****INPACKAGE:EmbeddedTCPIP****COPYRIGHT:Copyright(c)2002Altium****DESCRIPTION:globaldefinitionsforTCP****************************************************************************/#ifndef_TCPIP_GLOBAL_H_#define_TCPIP_GLOBAL_H_#includetcpipset.htypedefstructTCP_SESSIONTCP_SESSION;typedefstructTCPIP_SETTINGSTCPIP_SETTINGS;#ifdefOPTION_FTP_SERVER#includecommon/servers/ftp_server.h#endif#ifdefOPTION_HTTP_SERVER#includecommon/servers/http_server.h#endif#ifdefOPTION_SMTP_CLIENT#includecommon/servers/smtp_client.h#endif#ifdefOPTION_TELNET_SERVER第3页共9页#includecommon/servers/telnet_server.h#endif#ifdefUSER_CLIENTSERVER1_H#includeUSER_CLIENTSERVER1_H#endif#ifdefUSER_CLIENTSERVER2_H#includeUSER_CLIENTSERVER2_H#endif#ifdefUSER_CLIENTSERVER3_H#includeUSER_CLIENTSERVER3_H#endif//**************************************************************************//TCPportnumbersforsupportedservices#defineTCP_PORT_FTPDATA20#defineTCP_PORT_FTP21#defineTCP_PORT_TELNET23#defineTCP_PORT_SMTP25#defineTCP_PORT_HTTP80//TCPsessionstate#defineTCP_STATE_CLOSED0x01#defineTCP_STATE_SYN0x02#defineTCP_STATE_SYNACK0x03#defineTCP_STATE_CONNECTED0x04#defineTCP_STATE_FIN0x05#defineTCP_STATE_FINACK0x06#defineTCP_STATE_LASTACK0x07#defineTCP_STATE_RESET0x08第4页共9页//TCPbitmapflags#defineTCP_FLAG_FIN0x01#defineTCP_FLAG_SYN0x02#defineTCP_FLAG_RESET0x04#defineTCP_FLAG_PUSH0x08#defineTCP_FLAG_ACK0x10#defineTCP_FLAG_URGENT0x20//**************************************************************************//usedtokeeptrackofaconnectionstructTCP_SESSION{Uint16localport;Uint16remoteport;Uint32remoteip;Uint32sendnext;Uint32acknext;Uint32recvnext;Uint16maxdatalength;Uint16CALLBACKMEMSPEC(*application)(Sint8resend,TCP_SESSION*session,Uint16datalength,Uint8*tcp_flags);Uint8state;Sint8retries;Uint8timer;Uint16wdtimer;unionCARGO{Uint8dummybyte;#ifdefOPTION_FTP_SERVERFTP_SERVER_CARGOftp_server;第5页共9页#endif#ifdefOPTION_HTTP_SERVERHTTP_SERVER_CARGOhttp_server;#endif#ifdefOPTION_SMTP_CLIENTSMTP_CLIENT_CARGOsmtp_client;#endif#ifdefOPTION_TELNET_SERVERTELNET_SERVER_CARGOtelnet_server;#endif#ifdefUSER_CLIENTSERVER1_CARGOUSER_CLIENTSERVER1_CARGOTYPEUSER_CLIENTSERVER1_CARGO;#endif#ifdefUSER_CLIENTSERVER2_CARGOUSER_CLIENTSERVER2_CARGOTYPEUSER_CLIENTSERVER2_CARGO;#endif#ifdefUSER_CLIENTSERVER3_CARGOUSER_CLIENTSERVER3_CARGOTYPEUSER_CLIENTSERVER3_CARGO;#endif}cargo;};//TCPserverfunctiontypedefUint16CALLBACKMEMSPEC(*TCP_SERVERFUNCTION)(Sint8resend,TCP_SESSION*session,Uint16datalength,Uint8*tcp_flags);//TCPclientfunction(identicaltoserverfunction,buthandshakingdiffersslightly)typedefTCP_SERVERFUNCTIONTCP_CLIENTFUNCTION;第6页共9页//usedforthearraywithimplementedserversandclients,typedefstruct{//TCPporttheapplicationislisteningonUint16port;//callbackfunctoserverforgiventcpportTCP_SERVERFUNCTIONserverfunction;}TCP_SERVER;//UDPserverfunctiontypedefUint16CALLBACKMEMSPEC(*UDP_SERVERFUNCTION)(Uint16port,Uint16datalength);//usedforthearraywithimplementedserversandclients,typedefstruct{//UDPporttheapplicationislisteningonUint16port;//callbackfunctoclientorserverforgivenudpportUDP_SERVERFUNCTIONclientserverfunction;}UDP_CLIENTSERVER;//allglobaldefinitions,usedforinitializingandcross-modulehousekeeping//justoneglobalinstancetcpip_settings(intcpip.c)typedefstructTCPIP_SETTINGS{//ourownIP-address,canbeoverruledbyPPPnegotiation第7页共9页//TODO:infactwejustreacttoalltrafficcomingoutway,changethat?Uint8self_ip[4];//arraywithTCP-port/TCP-serverapplications//(lastelementshouldhaveserverfunctionNULL)TCP_SERVER*tcpservers;#ifdefOPTION_UDP//arraywithUDP-port/UDP-server/clientapplications//(lastelementshouldhaveserverfunctionNULL)UDP_CLIENTSERVER*udpclientservers;#endif#ifdefOPTION_DNS_SERVERchar*dns_self_name;//ourownname#endif#ifdefOPTION_DNS_CLIENTUint8dns_world_ip[4];//theIPaddressoftheDNSserverintheworldweknowaboutvoidCALLBACKMEMSPEC(*dns_portip)(Uint16port,Sint8*ip);//callbackfunctionforincomingDNSipanswers#endif#ifdefOPTION_DHCPUint8dhcp_server_ip[4];//IPaddressofDHCPserverUint8dhcp_state;//stateforDHCP#ifdefDHCP_TIMERTICK_MANUALvolatile#endifUint16dhcp_timer;//timer#endif#ifdefOPTION_SERIAL//pointertofunctionwhichwillbecalledwheneveramajor第8页共9页//statuschangeoccursinthestatusoftheconnectionvoidCALLBACKMEMSPEC(*serial_statuschange)(Uint16state);#ifdefSERIAL_MODEMchar*modem_init;//initstringformodem#ifdefSERIAL_CALLOUTchar*modem_dialoutnr;//telephonenumberweusefordial-out#endif#endif#ifdefSERIAL_PPP//functocallforuser/pwdcheckUint8CALLBACKMEMSPEC(*ppp_usercheck)(char*user,char*password);//theIPaddresswesuggestfortheothersideofaPPPconnectionUint8ppp_client_ip[4];#i