|
47 | 47 | #ifndef CO_SDO_H
|
48 | 48 | #define CO_SDO_H
|
49 | 49 |
|
| 50 | +#ifdef __cplusplus |
| 51 | +extern "C" { |
| 52 | +#endif |
50 | 53 |
|
51 | 54 | /**
|
52 | 55 | * @defgroup CO_SDO SDO server
|
@@ -256,17 +259,42 @@ typedef enum{
|
256 | 259 | *
|
257 | 260 | *
|
258 | 261 | * Function CO_SDO_init() initializes object CO_SDO_t, which includes SDO
|
259 |
| - * server and Object dictionary. Interface to Object dictionary is provided by |
260 |
| - * following functions: CO_OD_find() finds OD entry by index, CO_OD_getLength() |
261 |
| - * returns length of variable, CO_OD_getAttribute returns attribute and |
262 |
| - * CO_OD_getDataPointer() returns pointer to data. These functions are used by |
263 |
| - * SDO server and by PDO configuration. |
| 262 | + * server and Object dictionary. |
264 | 263 | *
|
265 | 264 | * Application doesn't need to know anything about the Object dictionary. It can
|
266 | 265 | * use variables specified in CO_OD.h file directly. If it needs more control
|
267 | 266 | * over the CANopen communication with the variables, it can configure additional
|
268 | 267 | * functionality with function CO_OD_configure(). Additional functionality
|
269 | 268 | * include: @ref CO_SDO_OD_function and #CO_SDO_OD_flags_t.
|
| 269 | + * |
| 270 | + * Interface to Object dictionary is provided by following functions: CO_OD_find() |
| 271 | + * finds OD entry by index, CO_OD_getLength() returns length of variable, |
| 272 | + * CO_OD_getAttribute returns attribute and CO_OD_getDataPointer() returns pointer |
| 273 | + * to data. These functions are used by SDO server and by PDO configuration. They |
| 274 | + * can also be used to access the OD by index like this. |
| 275 | + * |
| 276 | + * \code{.c} |
| 277 | + * index = CO_OD_find(CO->SDO[0], OD_H1001_ERR_REG); |
| 278 | + * if (index == 0xffff) { |
| 279 | + * return; |
| 280 | + * } |
| 281 | + * length = CO_OD_getLength(CO->SDO[0], index, 1); |
| 282 | + * if (length != sizeof(new_data)) { |
| 283 | + * return; |
| 284 | + * } |
| 285 | + * |
| 286 | + * p = CO_OD_getDataPointer(CO->SDO[0], index, 1); |
| 287 | + * if (p == NULL) { |
| 288 | + * return; |
| 289 | + * } |
| 290 | + * CO_LOCK_OD(); |
| 291 | + * *p = new_data; |
| 292 | + * CO_UNLOCK_OD(); |
| 293 | + * \endcode |
| 294 | + * |
| 295 | + * Be aware that accessing the OD directly using CO_OD.h files is more CPU |
| 296 | + * efficient as CO_OD_find() has to do a search everytime it is called. |
| 297 | + * |
270 | 298 | */
|
271 | 299 |
|
272 | 300 |
|
@@ -930,6 +958,9 @@ uint32_t CO_SDO_readOD(CO_SDO_t *SDO, uint16_t SDOBufferSize);
|
930 | 958 | */
|
931 | 959 | uint32_t CO_SDO_writeOD(CO_SDO_t *SDO, uint16_t length);
|
932 | 960 |
|
| 961 | +#ifdef __cplusplus |
| 962 | +} |
| 963 | +#endif /*__cplusplus*/ |
933 | 964 |
|
934 | 965 | /** @} */
|
935 | 966 | #endif
|
0 commit comments