190 bit! */ |
190 bit! */ |
191 } ec_slave_config_state_t; |
191 } ec_slave_config_state_t; |
192 |
192 |
193 /*****************************************************************************/ |
193 /*****************************************************************************/ |
194 |
194 |
195 #ifndef __KERNEL__ |
|
196 |
|
197 /** Master information. |
|
198 * |
|
199 * This is used as an output parameter of ecrt_master(). |
|
200 * |
|
201 * \see ecrt_master(). |
|
202 */ |
|
203 typedef struct { |
|
204 unsigned int slave_count; /**< Number of slaves in the bus. */ |
|
205 unsigned int link_up : 1; /**< \a true, if the network link is up. */ |
|
206 uint64_t app_time; /**< Application time. */ |
|
207 } ec_master_info_t; |
|
208 |
|
209 /*****************************************************************************/ |
|
210 |
|
211 /** Slave information. |
195 /** Slave information. |
212 * |
196 * |
213 * This is used as an output parameter of ecrt_master_slave(). |
197 * This is used as an output parameter of ecrt_master_slave(). |
214 * |
198 * |
215 * \see ecrt_master_slave(). |
199 * \see ecrt_master_slave(). |
227 uint8_t sync_count; /**< Number of sync managers. */ |
211 uint8_t sync_count; /**< Number of sync managers. */ |
228 uint16_t sdo_count; /**< Number of SDO's. */ |
212 uint16_t sdo_count; /**< Number of SDO's. */ |
229 char name[EC_MAX_STRING_LENGTH]; /**< Name of the slave. */ |
213 char name[EC_MAX_STRING_LENGTH]; /**< Name of the slave. */ |
230 } ec_slave_info_t; |
214 } ec_slave_info_t; |
231 |
215 |
232 #endif // #ifndef __KERNEL__ |
|
233 |
|
234 /*****************************************************************************/ |
216 /*****************************************************************************/ |
235 |
217 |
236 /** Domain working counter interpretation. |
218 /** Domain working counter interpretation. |
237 * |
219 * |
238 * This is used in ec_domain_state_t. |
220 * This is used in ec_domain_state_t. |
390 */ |
372 */ |
391 void ecrt_release_master( |
373 void ecrt_release_master( |
392 ec_master_t *master /**< EtherCAT master */ |
374 ec_master_t *master /**< EtherCAT master */ |
393 ); |
375 ); |
394 |
376 |
395 |
|
396 #ifndef __KERNEL__ |
|
397 |
|
398 /** Opens an EtherCAT master for userspace access. |
|
399 * |
|
400 * This function has to be the first function an application has to call to |
|
401 * use EtherCAT. The function takes the index of the master as its argument. |
|
402 * The first master has index 0, the n-th master has index n - 1. The number |
|
403 * of masters has to be specified when loading the master module. |
|
404 * |
|
405 * \return Pointer to the opened master, otherwise \a NULL. |
|
406 */ |
|
407 ec_master_t *ecrt_open_master( |
|
408 unsigned int master_index /**< Index of the master to request. */ |
|
409 ); |
|
410 |
|
411 /** Reserves an EtherCAT master for realtime operation. |
|
412 * |
|
413 * Before an application can use PDO/domain registration functions or SDO |
|
414 * request functions on the master, it has to reserve one for exclusive use. |
|
415 * |
|
416 * \return 0 in case of success, else < 0 |
|
417 * |
|
418 */ |
|
419 |
|
420 int ecrt_reserve_master( |
|
421 ec_master_t *master /**< EtherCAT master */ |
|
422 ); |
|
423 |
|
424 /** Obtains master information. |
|
425 * |
|
426 * No memory is allocated on the heap in |
|
427 * this function. |
|
428 * |
|
429 * \attention The pointer to this structure must point to a valid variable. |
|
430 * |
|
431 * \return 0 in case of success, else < 0 |
|
432 */ |
|
433 int ecrt_master( |
|
434 ec_master_t *master, /**< EtherCAT master */ |
|
435 ec_master_info_t *master_info /**< Structure that will output the |
|
436 information */ |
|
437 ); |
|
438 |
|
439 #endif // #ifndef __KERNEL__ |
|
440 |
|
441 /****************************************************************************** |
377 /****************************************************************************** |
442 * Master methods |
378 * Master methods |
443 *****************************************************************************/ |
379 *****************************************************************************/ |
444 |
380 |
445 #ifdef __KERNEL__ |
381 #ifdef __KERNEL__ |
530 uint16_t position, /**< Slave position. */ |
466 uint16_t position, /**< Slave position. */ |
531 ec_slave_info_t *slave_info /**< Structure that will output the |
467 ec_slave_info_t *slave_info /**< Structure that will output the |
532 information */ |
468 information */ |
533 ); |
469 ); |
534 |
470 |
535 #endif /* #ifndef __KERNEL__ */ |
471 #endif /* ifndef __KERNEL__ */ |
536 |
472 |
537 /** Finishes the configuration phase and prepares for cyclic operation. |
473 /** Finishes the configuration phase and prepares for cyclic operation. |
538 * |
474 * |
539 * This function tells the master that the configuration phase is finished and |
475 * This function tells the master that the configuration phase is finished and |
540 * the realtime operation will begin. The function allocates internal memory |
476 * the realtime operation will begin. The function allocates internal memory |
665 size_t target_size, /**< Size of the target buffer. */ |
601 size_t target_size, /**< Size of the target buffer. */ |
666 size_t *result_size, /**< Uploaded data size. */ |
602 size_t *result_size, /**< Uploaded data size. */ |
667 uint32_t *abort_code /**< Abort code of the SDO upload. */ |
603 uint32_t *abort_code /**< Abort code of the SDO upload. */ |
668 ); |
604 ); |
669 |
605 |
670 #endif /* #ifndef __KERNEL__ */ |
606 #endif /* ifndef __KERNEL__ */ |
671 |
607 |
672 /****************************************************************************** |
608 /****************************************************************************** |
673 * Slave configuration methods |
609 * Slave configuration methods |
674 *****************************************************************************/ |
610 *****************************************************************************/ |
675 |
611 |