定义晶振频率为8000KHZ.docx

上传人:b****6 文档编号:4605508 上传时间:2022-12-07 格式:DOCX 页数:13 大小:17.61KB
下载 相关 举报
定义晶振频率为8000KHZ.docx_第1页
第1页 / 共13页
定义晶振频率为8000KHZ.docx_第2页
第2页 / 共13页
定义晶振频率为8000KHZ.docx_第3页
第3页 / 共13页
定义晶振频率为8000KHZ.docx_第4页
第4页 / 共13页
定义晶振频率为8000KHZ.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

定义晶振频率为8000KHZ.docx

《定义晶振频率为8000KHZ.docx》由会员分享,可在线阅读,更多相关《定义晶振频率为8000KHZ.docx(13页珍藏版)》请在冰豆网上搜索。

定义晶振频率为8000KHZ.docx

定义晶振频率为8000KHZ

一、宏定义

//定义晶振频率为8000KHZ

#defineXTAL8000

//定义定时器1的分时复用标志

#defineT1_Interval1

#defineT1_Period2

#defineT1_NonPeriod3

//定义网络中包的长度的上下限

#defineMax_Size200

#defineMin_Size60

//定义域下载数据的最大可能长度(2+70)*2

#defineDomainDownload_Max_Size144

//定义设备本身的信息,用户组态程序对这些参数只能读,不能写

#defineMy_DeviceID_Len24

#defineDevice_Type_ID'T'

#defineDevice_Version_ID114

//定义组态信息,通过域下载服务发给仪表节点

#defineResponse_Time30

#defineMacro_Cycle200

#defineNonPeriodic_Offset100

#defineSendtime_Offset50

//定义消息类型

#defineMessage_REQ(0<<6)

#defineMessage_REP(1<<6)

#defineMessage_ERR(2<<6)

//定义服务标识

#defineEM_FindTagQuery_ID1

#defineEM_FindTagReply_ID2

#defineEM_GetDeviceAttribute_ID3

#defineEM_DeviceAnnunciation_ID4

#defineEM_SetDeviceAttribute_ID5

#defineEM_ClearDeviceAttribute_ID6

#defineDomainDownload_ID10

#defineDomainUpload_ID11

#defineRead_ID12

#defineWrite_ID13

#defineDistribute_ID14

#defineEventNotification_ID15

#defineAcknowledgeEventNotification_ID16

#defineAlterEventCondition_ID17

#defineConfiguration_ID18

//定义相关的AppID和ObjectID

#defineMIB_AppID0

#defineDomain_Application_Information_ObjectID4000

#defineAAE_AppID1

#defineDistribute_ObjectID8

//定义时间同步对象中的时间同步精度

#defineTime_None0

#defineTime_1s1

#defineTime_100ms2

#defineTime_10ms3

#defineTime_1ms4

#defineTime_100us5

#defineTime_10us6

#defineTime_1us7

//定义链接对象中本地设备的通信角色

#defineRole_Transmitter0

#defineRole_Receiver1

#defineRole_None0xff

//定义设备声明时的三种状态

#defineWithout_My_IP0

#defineStandby1

#defineReady2

//relevanttoEtherheader

#defineEther_Type_ARP0x0806

#defineEther_Type_IP0x0800

//relevanttoARPmessage

#defineARP_REQ0x0001

#defineARP_ACK0x0002

//relevanttoIPmessage

#defineIP_Version4

#defineIP_Header_MinLen20

#defineIP_Header_Len((R_Pip->IP_VerLen&0x0f)<<2)

#defineIP_Tos_Value0

#defineIP_TTL_Value255

#defineIP_ICMP1

#defineIP_TCP6

#defineIP_UDP17

//revelanttoICMPmessage

#defineICMP_Num32

#defineICMP_Type_REQ8

#defineICMP_Type_ACK0

//revelanttoUDPmessage

#defineUDP_Header_Len8

#defineEPA_Port0x88bc

//定义节点相关信息

#defineNode_Number2

#defineNULL0

//定义声明报文标识

#defineNonPeriodDataAnnunciation_ID0x20

#defineEndofNonPeriodDataSending_ID0x21

二、报文结构体

//组态信息报文格式

structConfiguration

{

ucharServiceID;

ulongMrt_Response_Time;

ulongCsm_Macro_Cycle;

ulongCsm_NonPeriodic_Offset;

ulongLo_Sendtime_Offset;

};

//应用层服务报文头

structService_Header

{

ucharServiceID;

ucharReserved[3];

uintLength;

uintMessageID;

};

//EPA设备描述对象

structEPA_Device_Descriptor

{

uintObjectID;

ucharReserved[2];

ucharDeviceID[32];

ucharPD_Tag[32];

ucharActive_IP_Address[4];

ucharDevice_Type;

ucharStatus;

uintDevice_Version;

uintAnnunciation_Interval;

uintAnnunciation_Version_Number;

ucharDevice_Redundancy_State;

ucharDevice_Redundancy_Number;

uintLAN_Redundancy_Port;

ucharMax_Redundancy_Number;

ucharDuplicate_Tag_Detected;

};

//证实服务最大响应时间

structMax_Response_Time

{

uintObjectID;

ucharReserved[2];

ulongMax_Response_Time;

};

//通信调度管理对象

structCommunication_Schedule_Management

{

uintObjectID;

ucharReserved[2];

ulongCommunication_Macro_Cycle;

ulongNonPeriodic_Data_Transfer_Offset;

uintCommunicationCycle_Version_Number;

};

//链接对象

structLink_Object

{

uintObjectID;

uintLocal_AppID;

uintLocal_ObjectID;

uintRemote_AppID;

uintRemote_ObjectID;

ucharService_Operation;

ucharService_Role;

ucharRemote_IP_Address[4];

ulongSend_Time_Offset;

};

//设备声明请求报文

structEM_DeviceAnnunciation

{

ucharDeviceID[32];

ucharPD_Tag[32];

ucharStatus;

ucharDevice_Type;

uintAnnunciation_Version_Number;

ucharDevice_Redundancy_Number;

ucharDevice_Redundancy_State;

uintLAN_Redundancy_Port;

ucharDuplicate_Tag_Detected;

ucharReserved[2];

ucharMax_Redundancy_Number;

ucharActive_IP_Address[4];

};

//清除设备属性请求报文

structEM_ClearDeviceAttribute

{

ucharDestination_IP_Address[4];

ucharDeviceID[32];

ucharPD_Tag[32];

};

//清除设备属性报文正响应

structEM_ClearDeviceAttribute_Result_Positive

{

ucharDestination_IP_Address[4];

};

//设置设备属性请求报文

structEM_SetDeviceAttribute

{

ucharDestination_IP_Address[4];

ucharDeviceID[32];

ucharPD_Tag[32];

uintAnnunciation_Interval;

ucharDuplicate_Tag_Detected;

ucharDevice_Redundancy_Number;

uintLAN_Redundancy_Port;

ucharDevice_Redundancy_State;

ucharMax_Redundancy_Number;

ucharActive_IP_Address[4];

};

//设置设备属性报文正响应

structEM_SetDeviceAttribute_Result_Positive

{

ucharDestination_IP_Address[4];

ucharMax_Redundancy_Number;

};

//域下载请求

structDomainDownload

{

uintSource_AppID;

uintDestination_AppID;

uintDestination_ObjectID;

uintData_Number;

ucharMore_Follows;

ucharReserved;

uintData_Length;

ucharLoad_Data[70];

};

//域下载服务正响应

structDomainDownload_Result_Positive

{

uintDestination_AppID;

};

//信息分发服务

structDistribute

{

uintSource_AppID;

uintSource_ObjectID;

ucharData[70];

};

//Etherheader

structEther_Header

{

ucharEther_Dest_MAC[6];

ucharEther_Sour_MAC[6];

uintEther_Type;

};

//ARPmessage

structARP

{

uintARP_Net_Type;

uintARP_Protocol;

ucharARP_MAC_Len;

ucharARP_IP_Len;

uintARP_Operator;

ucharARP_Sour_MAC[6];

ucharARP_Sour_IP[4];

ucharARP_Dest_MAC[6];

ucharARP_Dest_IP[4];

};

//IPmessage

structIP

{

ucharIP_VerLen;

ucharIP_Tos;

uintIP_Len;

uintIP_ID;

uintIP_FlagOffset;

ucharIP_TTL;

ucharIP_Protocol;

uintIP_Check;

ucharIP_Sour_IP[4];

ucharIP_Dest_IP[4];

ucharIP_Data[1];

};

//ICMPmessage

structICMP

{

ucharICMP_Type;

ucharICMP_Code;

uintICMP_Check;

uintICMP_ID;

uintICMP_Sequence;

ucharICMP_Data[ICMP_Num];

};

//UDPmessage

structUDP

{

uintUDP_Sour_Port;

uintUDP_Dest_Port;

uintUDP_Len;

uintUDP_Check;

ucharUDP_Data[1];

};

//周期队列节点

structEpaPeriodicDataNode

{

uchar*pkt;

uintlenth;

structEpaPeriodicDataNode*pNext;

};

//非周期队列节点

structEpaNonPeriodicDataNode

{

uchar*pkt;

uintlenth;

ucharpri;

structEpaNonPeriodicDataNode*pNext;

};

//声明队列节点

structEpaAnnNode

{

ucharpri;

ucharu_mac[6];

ucharu_ip[4];

structEpaAnnNode*pNext;

};

//非周期声明

structNonPeriodDataAnnunciation

{

ucharNPMA_TAG;

ucharPRI;

ucharPAD[44];

ulongCRC;

};

//非周期结束声明

structEndofNonPeriodDataSending

{

ucharENPMTA_TAG;

ucharPRI;

ucharPAD[44];

ulongCRC;

};

三、全局变量

1、Main.c

//静态设定的地址标识

externucharDest_IP[4];

externucharDest_MAC[6];

externucharMy_IP[4];

externucharMask[4];

externucharGate[4];

externucharMy_MAC[6];

externucharBro_IP[4];

externucharBro_MAC[6];

externucharMy_DeviceID[24];

//发送与接收缓冲区

externucharSend_Buf[Max_Size];

externucharRece_Buf[Max_Size];

//域下载数据的接收缓冲区

externucharDomainDownload_Buf[DomainDownload_Max_Size];

//信息分发数据的接收缓冲区

externucharDis_Data[70];

//本地设备是否已组态的标志

externucharReady_Ed;

//本地是否已经启动通信宏周期的标志

externucharMacro_Cycle_Ed;

2、Application.c

//为EPA管理信息库开辟内存

externucharMIB_Buf2[sizeof(structEPA_Device_Descriptor)];

externucharMIB_Buf4[sizeof(structMax_Response_Time)];

externucharMIB_Buf5[sizeof(structCommunication_Schedule_

Management)];

externucharMIB_Buf12[sizeof(structLink_Object)];

3、IP_UDP.c

//是否接收到ARP应答的标志

externucharARP_Ed;

//是否接收到Ping应答的标志

externucharPing_Ed;

4、Timer.c

//定时器T1的分时复用标志

externucharT1_Flag;

5、Pointer.c

//pointtoEtherheader

externstructEther_Header*S_Ehe,*R_Ehe;

//pointtoARPmessage

externstructARP*S_Arp,*R_Arp;

//pointtoIPmessage

externstructIP*S_Pip,*R_Pip;

//pointtoICMPmessage

externstructICMP*S_Pic,*R_Pic;

//pointtoUDPmessage

externstructUDP*S_Pdp,*R_Pdp;

//pointtoNonPeriodDataAnnunciation

externstructNonPeriodDataAnnunciation*S_Nda,*R_Nda;

//pointtoEndofNonPeriodDataSending

externstructEndofNonPeriodDataSending*S_End,*R_End;

//pointtoServiceheader

externstructService_Header*S_She,*R_She;

//pointtoDeviceAnnunciationmessage

externstructEM_DeviceAnnunciation*S_SME_Eda,*R_SME_Eda;

//pointtoClearDeviceAttributmessage

externstructEM_ClearDeviceAttribute*S_SME_Cda,*R_SME_Cda;

//pointtoClearDeviceAttributPositiveResultmessage

externstructEM_ClearDeviceAttribute_Result_Positive*S_SME_Cdp,*R_SME_Cdp;

//pointtoSetDeviceAttributemessage

externstructEM_SetDeviceAttribute*S_SME_Sda,*R_SME_Sda;

//pointtoSetDeviceAttributePositiveResultmessage

externstructEM_SetDeviceAttribute_Result_Positive*S_SME_Sdp,*R_SME_Sdp;

//pointtoDomainDownloadmessage

externstructDomainDownload*S_AAE_Ddl,*R_AAE_Ddl;

//pointtoDomainDownloadPositiveResultmessage

externstructDomainDownload_Result_Positive*S_AAE_Ddp,*R_AAE_Ddp;

//pointtoDistributemessage

externstructDistribute*S_AAE_Dis,*R_AAE_Dis;

//pointtoEPADeviceDescriptorObject

externstructEPA_Device_Descriptor*MIB_Edd;

//pointtoMaxResponseTimeObject

externstructMax_Response_Time*MIB_Mrt;

//pointtoCommunicationScheduleManagementObject

externstructCommunication_Schedule_Management*MIB_Csm;

//pointtoLinkObject

externstructLink_Object*MIB_Lo;

//pointtoConfiguration

externstructConfiguration*R_Con;

四、外部函数

1、Application.c

externvoidMIB_Init(void);

externvoidSend_EM_DeviceAnnunciation(void);

externvoidSend_Distribute(uchar*,uchar);

externvoidError_Man(void);

externvoidReceive_Application_Data(void);

2、IP_UDP.c

externvoidSend_ARP_REQ(uchar*);

externvoidReceive_ARP(uint);

externvoidReceive_IP(uint);

externvoidSend_ICMP_REQ(uchar*);

externvoidReceive_ICMP(uint);

externvoidReceive_UDP(void);

externvoidSend_UDP(uchar*,uchar*,uint,uint,uint)

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 法律文书 > 辩护词

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1