45 * ecrt_slave_config_dc() to configure a slave for cyclic |
45 * ecrt_slave_config_dc() to configure a slave for cyclic |
46 * operation, and ecrt_master_application_time(), |
46 * operation, and ecrt_master_application_time(), |
47 * ecrt_master_sync_reference_clock() and ecrt_master_sync_slave_clocks() |
47 * ecrt_master_sync_reference_clock() and ecrt_master_sync_slave_clocks() |
48 * for offset and drift compensation. The EC_TIMEVAL2NANO() macro can be |
48 * for offset and drift compensation. The EC_TIMEVAL2NANO() macro can be |
49 * used for epoch time conversion. |
49 * used for epoch time conversion. |
|
50 * - Added ecrt_open_master() and ecrt_master_reserve() separation for |
|
51 * userspace. |
|
52 * - Added ecrt_master() userspace interface, to get information about a |
|
53 * master. |
50 * - Changed the meaning of the negative return values of |
54 * - Changed the meaning of the negative return values of |
51 * ecrt_slave_config_reg_pdo_entry() and ecrt_slave_config_sdo*(). |
55 * ecrt_slave_config_reg_pdo_entry() and ecrt_slave_config_sdo*(). |
52 * - Imlemented the Vendor-specific over EtherCAT mailbox protocol. See |
56 * - Imlemented the Vendor-specific over EtherCAT mailbox protocol. See |
53 * ecrt_slave_config_create_voe_handler(). |
57 * ecrt_slave_config_create_voe_handler(). |
54 * - Renamed ec_sdo_request_state_t to ec_request_state_t, because it is also |
58 * - Renamed ec_sdo_request_state_t to ec_request_state_t, because it is also |
187 - 8: \a OP |
191 - 8: \a OP |
188 |
192 |
189 Note that each state is coded in a different |
193 Note that each state is coded in a different |
190 bit! */ |
194 bit! */ |
191 } ec_slave_config_state_t; |
195 } ec_slave_config_state_t; |
|
196 |
|
197 /*****************************************************************************/ |
|
198 |
|
199 #ifndef __KERNEL__ |
|
200 |
|
201 /** Master information. |
|
202 * |
|
203 * This is used as an output parameter of ecrt_master(). |
|
204 * |
|
205 * \see ecrt_master(). |
|
206 */ |
|
207 typedef struct { |
|
208 unsigned int slave_count; /**< Number of slaves in the bus. */ |
|
209 unsigned int link_up : 1; /**< \a true, if the network link is up. */ |
|
210 uint64_t app_time; /**< Application time. */ |
|
211 } ec_master_info_t; |
192 |
212 |
193 /*****************************************************************************/ |
213 /*****************************************************************************/ |
194 |
214 |
195 /** Slave information. |
215 /** Slave information. |
196 * |
216 * |
211 uint8_t sync_count; /**< Number of sync managers. */ |
231 uint8_t sync_count; /**< Number of sync managers. */ |
212 uint16_t sdo_count; /**< Number of SDO's. */ |
232 uint16_t sdo_count; /**< Number of SDO's. */ |
213 char name[EC_MAX_STRING_LENGTH]; /**< Name of the slave. */ |
233 char name[EC_MAX_STRING_LENGTH]; /**< Name of the slave. */ |
214 } ec_slave_info_t; |
234 } ec_slave_info_t; |
215 |
235 |
|
236 #endif // #ifndef __KERNEL__ |
|
237 |
216 /*****************************************************************************/ |
238 /*****************************************************************************/ |
217 |
239 |
218 /** Domain working counter interpretation. |
240 /** Domain working counter interpretation. |
219 * |
241 * |
220 * This is used in ec_domain_state_t. |
242 * This is used in ec_domain_state_t. |
352 /** Requests an EtherCAT master for realtime operation. |
374 /** Requests an EtherCAT master for realtime operation. |
353 * |
375 * |
354 * Before an application can access an EtherCAT master, it has to reserve one |
376 * Before an application can access an EtherCAT master, it has to reserve one |
355 * for exclusive use. |
377 * for exclusive use. |
356 * |
378 * |
|
379 * In userspace, this is a convenience function for ecrt_open_master() and |
|
380 * ecrt_master_reserve(). |
|
381 * |
357 * This function has to be the first function an application has to call to |
382 * This function has to be the first function an application has to call to |
358 * use EtherCAT. The function takes the index of the master as its argument. |
383 * use EtherCAT. The function takes the index of the master as its argument. |
359 * The first master has index 0, the n-th master has index n - 1. The number |
384 * The first master has index 0, the n-th master has index n - 1. The number |
360 * of masters has to be specified when loading the master module. |
385 * of masters has to be specified when loading the master module. |
361 * |
386 * |
363 */ |
388 */ |
364 ec_master_t *ecrt_request_master( |
389 ec_master_t *ecrt_request_master( |
365 unsigned int master_index /**< Index of the master to request. */ |
390 unsigned int master_index /**< Index of the master to request. */ |
366 ); |
391 ); |
367 |
392 |
|
393 #ifndef __KERNEL__ |
|
394 |
|
395 /** Opens an EtherCAT master for userspace access. |
|
396 * |
|
397 * This function has to be the first function an application has to call to |
|
398 * use EtherCAT. The function takes the index of the master as its argument. |
|
399 * The first master has index 0, the n-th master has index n - 1. The number |
|
400 * of masters has to be specified when loading the master module. |
|
401 * |
|
402 * For convenience, the function ecrt_request_master() can be used. |
|
403 * |
|
404 * \return Pointer to the opened master, otherwise \a NULL. |
|
405 */ |
|
406 ec_master_t *ecrt_open_master( |
|
407 unsigned int master_index /**< Index of the master to request. */ |
|
408 ); |
|
409 |
|
410 #endif // #ifndef __KERNEL__ |
|
411 |
368 /** Releases a requested EtherCAT master. |
412 /** Releases a requested EtherCAT master. |
369 * |
413 * |
370 * After use, a master it has to be released to make it available for other |
414 * After use, a master it has to be released to make it available for other |
371 * applications. |
415 * applications. |
372 */ |
416 */ |
375 ); |
419 ); |
376 |
420 |
377 /****************************************************************************** |
421 /****************************************************************************** |
378 * Master methods |
422 * Master methods |
379 *****************************************************************************/ |
423 *****************************************************************************/ |
|
424 |
|
425 #ifndef __KERNEL__ |
|
426 |
|
427 /** Reserves an EtherCAT master for realtime operation. |
|
428 * |
|
429 * Before an application can use PDO/domain registration functions or SDO |
|
430 * request functions on the master, it has to reserve one for exclusive use. |
|
431 * |
|
432 * \return 0 in case of success, else < 0 |
|
433 * |
|
434 */ |
|
435 int ecrt_master_reserve( |
|
436 ec_master_t *master /**< EtherCAT master */ |
|
437 ); |
|
438 |
|
439 #endif // #ifndef __KERNEL__ |
380 |
440 |
381 #ifdef __KERNEL__ |
441 #ifdef __KERNEL__ |
382 |
442 |
383 /** Sets the locking callbacks. |
443 /** Sets the locking callbacks. |
384 * |
444 * |
449 uint32_t product_code /**< Expected product code. */ |
509 uint32_t product_code /**< Expected product code. */ |
450 ); |
510 ); |
451 |
511 |
452 #ifndef __KERNEL__ |
512 #ifndef __KERNEL__ |
453 |
513 |
|
514 /** Obtains master information. |
|
515 * |
|
516 * No memory is allocated on the heap in |
|
517 * this function. |
|
518 * |
|
519 * \attention The pointer to this structure must point to a valid variable. |
|
520 * |
|
521 * \return 0 in case of success, else < 0 |
|
522 */ |
|
523 int ecrt_master( |
|
524 ec_master_t *master, /**< EtherCAT master */ |
|
525 ec_master_info_t *master_info /**< Structure that will output the |
|
526 information */ |
|
527 ); |
|
528 |
454 /** Obtains slave information. |
529 /** Obtains slave information. |
455 * |
530 * |
456 * Tries to find the slave with the given ring position. The obtained |
531 * Tries to find the slave with the given ring position. The obtained |
457 * information is stored in a structure. No memory is allocated on the heap in |
532 * information is stored in a structure. No memory is allocated on the heap in |
458 * this function. |
533 * this function. |
466 uint16_t position, /**< Slave position. */ |
541 uint16_t position, /**< Slave position. */ |
467 ec_slave_info_t *slave_info /**< Structure that will output the |
542 ec_slave_info_t *slave_info /**< Structure that will output the |
468 information */ |
543 information */ |
469 ); |
544 ); |
470 |
545 |
471 #endif /* ifndef __KERNEL__ */ |
546 #endif /* #ifndef __KERNEL__ */ |
472 |
547 |
473 /** Finishes the configuration phase and prepares for cyclic operation. |
548 /** Finishes the configuration phase and prepares for cyclic operation. |
474 * |
549 * |
475 * This function tells the master that the configuration phase is finished and |
550 * This function tells the master that the configuration phase is finished and |
476 * the realtime operation will begin. The function allocates internal memory |
551 * the realtime operation will begin. The function allocates internal memory |
601 size_t target_size, /**< Size of the target buffer. */ |
676 size_t target_size, /**< Size of the target buffer. */ |
602 size_t *result_size, /**< Uploaded data size. */ |
677 size_t *result_size, /**< Uploaded data size. */ |
603 uint32_t *abort_code /**< Abort code of the SDO upload. */ |
678 uint32_t *abort_code /**< Abort code of the SDO upload. */ |
604 ); |
679 ); |
605 |
680 |
606 #endif /* ifndef __KERNEL__ */ |
681 #endif /* #ifndef __KERNEL__ */ |
607 |
682 |
608 /****************************************************************************** |
683 /****************************************************************************** |
609 * Slave configuration methods |
684 * Slave configuration methods |
610 *****************************************************************************/ |
685 *****************************************************************************/ |
611 |
686 |