Motion Master
Loading...
Searching...
No Matches
co_dictionary.h
Go to the documentation of this file.
5#include <stdint.h>
6#include <stdlib.h>
8#ifndef OD_OBJECT_H
9#define OD_OBJECT_H
10
11/*
12 * Definitions of bit fields for object access
13 */
14
15#define ACCESS_PO_RD 0x0001
16#define ACCESS_SO_RD 0x0002
17#define ACCESS_OP_RD 0x0004
18#define ACCESS_ALL_RD (ACCESS_PO_RD | ACCESS_SO_RD | ACCESS_OP_RD)
19
20#define ACCESS_PO_WR 0x0008
21#define ACCESS_SO_WR 0x0010
22#define ACCESS_OP_WR 0x0020
23#define ACCESS_ALL_WR (ACCESS_PO_WR | ACCESS_SO_WR | ACCESS_OP_WR)
24
25#define ACCESS_PO_RDWR (ACCESS_PO_RD | ACCESS_PO_WR)
26#define ACCESS_SO_RDWR (ACCESS_SO_RD | ACCESS_SO_WR)
27#define ACCESS_OP_RDWR (ACCESS_OP_RD | ACCESS_OP_WR)
28#define ACCESS_ALL_RDWR (ACCESS_PO_RDWR | ACCESS_SO_RDWR | ACCESS_OP_RDWR)
29
30#define ACCESS_RXPDO_MAP 0x0040
31#define ACCESS_TXPDO_MAP 0x0080
32#define ACCESS_RXTXPDO_MAP 0x00C0
33
34#define ACCESS_BACKUP 0x0100
35#define ACCESS_STARTUP 0x0200
36
37#define ACCESS_ALL_LIST_FLAGS \
38 (ACCESS_RXPDO_MAP | ACCESS_TXPDO_MAP | ACCESS_BACKUP | ACCESS_STARTUP)
39
40#define ACCESS_SET_FLAGS(b, s, p, a) (b | s | p | a)
41
42/*
43 * Value info
44 */
45
46#define VALUEINFO_UNIT_TYPE 0x08
47#define VALUEINFO_DEFAULT_VALUE 0x10
48#define VALUEINFO_MIN_VALUE 0x20
49#define VALUEINFO_MAX_VALUE 0x40
50
51/*
52 * list of dictionary lists identifiers
53 */
54
55#define LIST_ALL_LIST_LENGTH 0x00
56#define LIST_ALL_OBJECTS 0x01
57#define LIST_RXPDO_MAPABLE 0x02
58#define LIST_TXPDO_MAPABLE 0x03
59#define LIST_DEVICE_REPLACEMENT 0x04
60#define LIST_STARTUP_PARAMETER 0x05
61
62/*
63 * possible object types of dictionary objects
64 *
65 * FIXME according to ETG1000.6 v1.0.3 only VAR, RECORD and ARRAY are expected
66 * in SDO Info reply.
67 */
68
69#define OBJECT_TYPE_DOMAIN 0x0
70#define OBJECT_TYPE_DEFTYPE 0x5
71#define OBJECT_TYPE_DEFSTRUCT 0x6
72#define OBJECT_TYPE_VAR 0x7
73#define OBJECT_TYPE_ARRAY 0x8
74#define OBJECT_TYPE_RECORD 0x9
75
76/*
77 * Index of Basic Data Types
78 */
79
80#define DEFTYPE_BOOLEAN 0x0001
81#define DEFTYPE_INTEGER8 0x0002
82#define DEFTYPE_INTEGER16 0x0003
83#define DEFTYPE_INTEGER32 0x0004
84#define DEFTYPE_UNSIGNED8 0x0005
85#define DEFTYPE_UNSIGNED16 0x0006
86#define DEFTYPE_UNSIGNED32 0x0007
87#define DEFTYPE_REAL32 0x0008
88#define DEFTYPE_VISIBLE_STRING 0x0009
89#define DEFTYPE_OCTET_STRING 0x000A
90#define DEFTYPE_UNICODE_STRING 0x000B
91#define DEFTYPE_TIME_OF_DAY 0x000C
92#define DEFTYPE_TIME_DIFFERENCE 0x000D
93
94#define DEFTYPE_DOMAIN 0x000F
95
96#define DEFSTRUCT_PDO_PARAMETER 0x0020
97#define DEFSTRUCT_PDO_MAPPING 0x0021
98#define DEFSTRUCT_IDENTITY 0x0023
99#define DEFSTRUCT_VENDOR_MOTOR 0x0040
100
101#define CODE_GET_INDEX(a) ((a >> 16) & 0xffff)
102#define CODE_GET_SUBINDEX(a) ((a >> 8) & 0xff)
103#define CODE_GET_FLAGS(a) (a & 0xff)
104#define CODE_SET_ENTRY_INDEX(i, s, f) \
105 (((i & 0xffff) << 16) | ((s & 0xff) << 8) | (f & 0xff))
106
107// set the "is modified" flag of COD_Subitem::index
108#define CODE_SET_MODIFIED_FLAG(i) (i | 1)
109// unset the "is modified" flag of COD_Subitem::index
110#define CODE_CLEAR_MODIFIED_FLAG(i) (i & ~1)
111
112#define OD_COMMUNICATION_AREA 0x1000
113#define OD_MANUFACTURER_AREA 0x2000
114#define OD_PROFILE_AREA 0x6000
115
116#ifdef __XC__
117#warning co_dictionary is not intended to be accessed directly from XC!
118extern "C" {
119#endif
120
121typedef struct _cod_object COD_Object;
123
124#ifdef WINDOWS_BUILD
125__pragma(pack(push, 1)) struct _cod_object {
126 uint16_t index;
127 uint8_t type; /* object code: VAR, RECORD, ARRAY */
128 uint16_t data_type; /* index of data type, e.g. for VAR it is the basic data
129 type, some complex objects have special types like
130 DEVSTRUCT_IDENTITY */
131 uint16_t access; /* Read/Write access flags */
132 uint8_t max_subindex; /* number of the largest subindex */
133 const char **name; /* pointer to element in \c *entry_name ??? */
134 COD_Subitem *entry; /* pointer to entry */
135};
136__pragma(pack(pop))
137
138 __pragma(pack(push, 1)) struct _cod_subitem {
139 // | obj_index:16 | sub_index:8 | flags:8 (bit 0: "is modified" flag, bit
140 // 1-7: unused
141 uint32_t index;
142 uint16_t data_type; /* index of data type */
143 size_t bitsize;
144 uint16_t access; /* object access flags, see also R/W flags and PDO Mapping
145 above */
146 uint32_t unit;
147 const char **name; /* pointer to element in \see *entry_name */
148 uint8_t *value; /* pointer to start in \see *od_values - type is determined
149 by `data_type` */
150};
151__pragma(pack(pop))
152#else
154 uint16_t index;
155 uint8_t type; /* object code: VAR, RECORD, ARRAY */
156 uint16_t data_type; /* index of data type, e.g. for VAR it is the basic data
157 type, some complex objects have special types like
158 DEVSTRUCT_IDENTITY */
159 uint16_t access; /* Read/Write access flags */
160 uint8_t max_subindex; /* number of the largest subindex */
161 const char **name; /* pointer to element in \c *entry_name ??? */
162 COD_Subitem *entry; /* pointer to entry */
163} __attribute__((packed));
164
166 // | obj_index:16 | sub_index:8 | flags:8 (bit 0: "is modified" flag, bit
167 // 1-7: unused
168 uint32_t index;
169 uint16_t data_type; /* index of data type */
170 size_t bitsize;
171 uint16_t access; /* object access flags, see also R/W flags and PDO Mapping
172 above */
173 uint32_t unit;
174 const char **name; /* pointer to element in \see *entry_name */
175 uint8_t *value; /* pointer to start in \see *od_values - type is determined
176 by `data_type` */
177} __attribute__((packed));
178#endif
179
180 /*
181 * Define variable to be accessible from the application
182 */
183
184 extern COD_Subitem od_subitems[];
185extern COD_Object od_objects[];
186
187/* sizes */
188extern const size_t OD_SUBITEMS_LENGTH;
189extern const size_t OD_OBJECTS_LENGTH;
190
191/*
192 * lib internal functions
193 */
194
202COD_Subitem *sdo_get_entry(uint16_t object_index, uint8_t subindex);
203
204#ifdef __XC__
205}
206#endif
207
208#endif /* OD_OBJECT_H */
struct _cod_object __attribute__((packed))
uint8_t type
Definition: co_dictionary.h:1
size_t bitsize
Definition: co_dictionary.h:4
const size_t OD_SUBITEMS_LENGTH
Definition: co_dictionary.cc:23
uint8_t max_subindex
Definition: co_dictionary.h:6
COD_Object od_objects[]
Definition: co_dictionary.cc:2546
const char ** name
Definition: co_dictionary.h:7
uint8_t * value
Definition: co_dictionary.h:9
COD_Subitem * sdo_get_entry(uint16_t object_index, uint8_t subindex)
Get pointer to the element with given addrees.
uint16_t access
Definition: co_dictionary.h:5
uint16_t index
Definition: co_dictionary.h:0
const size_t OD_OBJECTS_LENGTH
Definition: co_dictionary.cc:24
uint32_t unit
Definition: co_dictionary.h:7
COD_Subitem * entry
Definition: co_dictionary.h:8
uint16_t data_type
Definition: co_dictionary.h:2
COD_Subitem od_subitems[]
Definition: co_dictionary.cc:933
Definition: co_dictionary.h:153
uint16_t index
Definition: co_dictionary.h:154
uint16_t data_type
Definition: co_dictionary.h:156
const char ** name
Definition: co_dictionary.h:161
uint16_t access
Definition: co_dictionary.h:159
COD_Subitem * entry
Definition: co_dictionary.h:162
uint8_t max_subindex
Definition: co_dictionary.h:160
uint8_t type
Definition: co_dictionary.h:155
Definition: co_dictionary.h:165
const char ** name
Definition: co_dictionary.h:174
size_t bitsize
Definition: co_dictionary.h:170
uint16_t access
Definition: co_dictionary.h:171
uint16_t data_type
Definition: co_dictionary.h:169
uint32_t unit
Definition: co_dictionary.h:173
uint8_t * value
Definition: co_dictionary.h:175
uint32_t index
Definition: co_dictionary.h:168