OpcUaCanOpen
CANopen OPC-UA server
CANopen.h
Go to the documentation of this file.
1
/* -------------------------------------------------------------------------
2
File : CANopen.h
3
4
Descr : Definitions for CANopen.
5
6
History: 20.11.12; Henk B; Created (copy from existing project).
7
---------------------------------------------------------------------------- */
8
9
#ifndef CANOPEN_H
10
#define CANOPEN_H
11
12
// ----------------------------------------------------------------------------
13
// Communication Objects for the CANopen Predefined Connection Set
14
15
#define CANOPEN_COBID_MASK 0x7FF
16
#define CANOPEN_OBJECT_MASK 0x780
17
#define CANOPEN_NODEID_MASK 0x07F
18
19
#define CANOPEN_NMT_COBID 0x000
20
#define CANOPEN_SYNC_COBID 0x080
21
#define CANOPEN_EMERGENCY_COBID CANOPEN_SYNC_COBID
22
#define CANOPEN_TIMESTAMP_COBID 0x100
23
#define CANOPEN_TPDO1_COBID 0x180
24
#define CANOPEN_RPDO1_COBID 0x200
25
#define CANOPEN_TPDO2_COBID 0x280
26
#define CANOPEN_RPDO2_COBID 0x300
27
#define CANOPEN_TPDO3_COBID 0x380
28
#define CANOPEN_RPDO3_COBID 0x400
29
#define CANOPEN_TPDO4_COBID 0x480
30
#define CANOPEN_RPDO4_COBID 0x500
31
#define CANOPEN_SDOSERVER_COBID 0x580
32
#define CANOPEN_SDOCLIENT_COBID 0x600
33
#define CANOPEN_NODEGUARD_COBID 0x700
34
#define CANOPEN_BOOTUP_COBID CANOPEN_NODEGUARD_COBID
35
#define CANOPEN_LSSREQ_COBID 0x7E5
36
#define CANOPEN_LSSREPLY_COBID 0x7E4
37
38
// ----------------------------------------------------------------------------
39
// NMT Start/Stop Service command specifiers
40
41
#define NMT_START_REMOTE_NODE 1
42
#define NMT_STOP_REMOTE_NODE 2
43
#define NMT_ENTER_PREOPERATIONAL_STATE 0x80
44
#define NMT_RESET_NODE 0x81
45
#define NMT_RESET_COMMUNICATION 0x82
46
47
enum
NMTcommand
48
{
49
nop
= 0,
50
start
=
NMT_START_REMOTE_NODE
,
51
stop
=
NMT_STOP_REMOTE_NODE
,
52
preOperational
=
NMT_ENTER_PREOPERATIONAL_STATE
,
53
reset
=
NMT_RESET_NODE
54
};
55
56
// ----------------------------------------------------------------------------
57
// NMT Slave state
58
59
#define NMT_INITIALISING 0
60
#define NMT_DISCONNECTED 1
61
#define NMT_CONNECTING 2
62
#define NMT_PREPARING 3
63
#define NMT_STOPPED 4
64
#define NMT_OPERATIONAL 5
65
#define NMT_PREOPERATIONAL 127
66
67
#define NMT_STATE_MASK 0x7F
68
#define NMT_TOGGLE_MASK 0x80
69
70
// ----------------------------------------------------------------------------
71
// SDO command specifiers and other bits
72
73
#define SDO_COMMAND_SPECIFIER_MASK (7<<5)
74
75
// Client command specifiers (0x20, 0x00, 0x40, 0x60)
76
#define SDO_INITIATE_DOWNLOAD_REQ (1<<5)
77
#define SDO_DOWNLOAD_SEGMENT_REQ (0<<5)
78
#define SDO_INITIATE_UPLOAD_REQ (2<<5)
79
#define SDO_UPLOAD_SEGMENT_REQ (3<<5)
80
81
// Server command specifiers (0x60, 0x20, 0x40, 0x00)
82
#define SDO_INITIATE_DOWNLOAD_RESP (3<<5)
83
#define SDO_DOWNLOAD_SEGMENT_RESP (1<<5)
84
#define SDO_INITIATE_UPLOAD_RESP (2<<5)
85
#define SDO_UPLOAD_SEGMENT_RESP (0<<5)
86
87
// Client or Server command specifiers (0x80)
88
#define SDO_ABORT_TRANSFER (4<<5)
89
90
// Expedited- and Segmented-SDO related bits (0x02, 0x10, 0x01(3x), 0x0E, 0x0C)
91
#define SDO_EXPEDITED (1<<1)
92
#define SDO_TOGGLE_BIT (1<<4)
93
#define SDO_LAST_SEGMENT (1<<0)
94
#define SDO_SEGMENT_SIZE_INDICATED (1<<0)
95
#define SDO_DATA_SIZE_INDICATED (1<<0)
96
#define SDO_SEGMENT_SIZE_MASK (0x7<<1)
97
#define SDO_DATA_SIZE_MASK (0x3<<2)
98
#define SDO_SEGMENT_SIZE_SHIFT 1
99
#define SDO_DATA_SIZE_SHIFT 2
100
101
// ----------------------------------------------------------------------------
102
// SDO Abort Domain Transfer protocol: abort codes
103
104
// Error classes (MSB)
105
#define SDO_ECLASS_SERVICE 5
106
#define SDO_ECLASS_ACCESS 6
107
#define SDO_ECLASS_OTHER 8
108
109
// Error codes (MSB-1)
110
#define SDO_ECODE_PAR_INCONSISTENT 3
111
#define SDO_ECODE_PAR_ILLEGAL 4
112
#define SDO_ECODE_ACCESS 1
113
#define SDO_ECODE_NONEXISTENT 2
114
#define SDO_ECODE_HARDWARE 6
115
#define SDO_ECODE_TYPE_CONFLICT 7
116
#define SDO_ECODE_ATTRIBUTE 9
117
#define SDO_ECODE_OKAY 0
118
119
// ----------------------------------------------------------------------------
120
// CANopen Object Dictionary indices's and sub-indices's
121
122
#define OD_DEVICE_TYPE 0x1000
123
#define OD_ERROR_REG 0x1001
124
#define OD_STATUS_REG 0x1002
125
#define OD_DEVICE_NAME 0x1008
126
#define OD_HW_VERSION 0x1009
127
#define OD_SW_VERSION 0x100A
128
#define OD_GUARDTIME 0x100C
129
#define OD_LIFETIME_FACTOR 0x100D
130
#define OD_STORE_PARAMETERS 0x1010
131
#define OD_DFLT_PARAMETERS 0x1011
132
#define OD_HEARTBEAT_TIME 0x1017
133
#define OD_IDENTITY 0x1018
134
#define OD_STORE_ALL 1
135
#define OD_STORE_COMM_PARS 2
136
#define OD_STORE_APP_PARS 3
137
// Often subindex 0 provides access to the number of entries in the object
138
#define OD_OBJECT_ENTRIES 0
139
140
// Receive PDOs
141
#define OD_RPDO1_PAR 0x1400
142
#define OD_RPDO1_MAP 0x1600
143
144
// Transmit PDOs
145
#define OD_TPDO1_PAR 0x1800
146
#define OD_TPDO2_PAR 0x1801
147
#define OD_TPDO3_PAR 0x1802
148
#define OD_TPDO4_PAR 0x1803
149
#define OD_PDO_COBID 1
150
#define OD_PDO_TRANSMTYPE 2
151
#define OD_PDO_INHIBITTIME 3
152
#define OD_PDO_DUMMY_ENTRY 4
153
#define OD_PDO_EVENT_TIMER 5
154
155
// PDO mapping
156
#define OD_TPDO1_MAP 0x1A00
157
#define OD_TPDO2_MAP 0x1A01
158
#define OD_TPDO3_MAP 0x1A02
159
#define OD_TPDO4_MAP 0x1A03
160
161
// Manufacturer-specific objects: ELMB
162
163
// Serial Number
164
#define OD_SERIAL_NO 0x3100
165
#define OD_SN_WRITE_ENA 0x3101
166
// CAN-controller configuration
167
#define OD_CAN_CONFIG 0x3200
168
// CANopen Node-ID configuration
169
#define OD_NODEID_CONFIG 0x3300
170
#define OD_NODEID_WRITE_ENA 0x3301
171
// Other
172
#define OD_SWITCH_TO_LOADER 0x5E00
173
174
// Some standardized Device Profile objects
175
176
// Digital inputs
177
#define OD_DIGITAL_IN_8 0x6000
178
#define OD_DIGIN_INTRPT_ENA 0x6005
179
#define OD_DIGIN_INTRPT_MSK 0x6006
180
181
// Digital outputs
182
#define OD_DIGITAL_OUT_8 0x6200
183
#define OD_DIGITAL_OUT_8_MSK 0x6208
184
#define OD_DIGITAL_OUT_1 0x6220
185
186
// Analog inputs
187
#define OD_ANALOG_IN 0x6404
188
189
// ----------------------------------------------------------------------------
190
#endif // CANOPEN_H
CanOpen
include
CANopen.h
Generated on Fri Sep 11 2020 14:29:43 for OpcUaCanOpen by
1.8.14