-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataFrameSheet.h
67 lines (55 loc) · 1.25 KB
/
DataFrameSheet.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef ETHERNETFRAMESHEET_H
#define ETHERNETFRAMESHEET_H
#define uint8_t unsigned char
#define uint16_t unsigned short
#define int16_t short
#define uint32_t unsigned int
//电机连接状态
extern bool statusflag1;
extern bool statusflag2;
#define CAN1_ID 384
#define CAN2_ID 896
//extern uint32_t Node_CAN_ID_1;
//extern uint32_t Node_CAN_ID_2;
//Standard CANID
typedef union
{
struct //从高到低
{
uint32_t MasterSlaveID : 1;
uint32_t ProtocolID : 1;
uint32_t CTRCode : 5;
uint32_t NodeGroupID : 4;
uint32_t Reserve : 21;
}STDCANID;
uint32_t Value;
}CANID_STD;
//CANFrame
typedef struct
{
CANID_STD CANID;
uint8_t CANData[8];
}CANFrame_STD;
//CANNet控制帧头
typedef union
{
struct
{
uint8_t DataLen : 4;
uint8_t RSVD : 1;
uint8_t UDP : 1;
uint8_t RTR : 1;
uint8_t FF : 1;
}Header;
uint8_t Value;
}FrameControlHeader;
#pragma pack(1)
//以太网帧
typedef struct EthernetFrame
{
FrameControlHeader EtherHeader; //帧控制头
CANFrame_STD CANFrame;
}EtherFrame;
#pragma pack()
uint16_t WordCombine(uint8_t byte1, uint8_t byte2);
#endif // ETHERNETFRAMESHEET_H