54 * ecrt_slave_config_state(). |
54 * ecrt_slave_config_state(). |
55 * - Process data memory for a domain can now be allocated externally. This |
55 * - Process data memory for a domain can now be allocated externally. This |
56 * offers the possibility to use a shared-memory region. Therefore, |
56 * offers the possibility to use a shared-memory region. Therefore, |
57 * added the domain methods ecrt_domain_size() and |
57 * added the domain methods ecrt_domain_size() and |
58 * ecrt_domain_external_memory(). |
58 * ecrt_domain_external_memory(). |
59 * - Pdo entry registration functions do not return a process data pointer, |
59 * - PDO entry registration functions do not return a process data pointer, |
60 * but an offset in the domain's process data. In addition, an optional bit |
60 * but an offset in the domain's process data. In addition, an optional bit |
61 * position can be requested. This was necessary for the external domain |
61 * position can be requested. This was necessary for the external domain |
62 * memory. An additional advantage is, that the returned offset is |
62 * memory. An additional advantage is, that the returned offset is |
63 * immediately valid. If the domain's process data is allocated internally, |
63 * immediately valid. If the domain's process data is allocated internally, |
64 * the start address can be retrieved with ecrt_domain_data(). |
64 * the start address can be retrieved with ecrt_domain_data(). |
65 * - Replaced ecrt_slave_pdo_mapping/add/clear() with |
65 * - Replaced ecrt_slave_pdo_mapping/add/clear() with |
66 * ecrt_slave_config_pdo_assign_add() to add a Pdo to a sync manager's Pdo |
66 * ecrt_slave_config_pdo_assign_add() to add a PDO to a sync manager's PDO |
67 * assignment and ecrt_slave_config_pdo_mapping_add() to add a Pdo entry to a |
67 * assignment and ecrt_slave_config_pdo_mapping_add() to add a PDO entry to a |
68 * Pdo's mapping. ecrt_slave_config_pdos() is a convenience function |
68 * PDO's mapping. ecrt_slave_config_pdos() is a convenience function |
69 * for both, that uses the new data types ec_pdo_info_t and |
69 * for both, that uses the new data types ec_pdo_info_t and |
70 * ec_pdo_entry_info_t. Pdo entries, that are mapped with these functions |
70 * ec_pdo_entry_info_t. PDO entries, that are mapped with these functions |
71 * can now immediately be registered, even if the bus is offline. |
71 * can now immediately be registered, even if the bus is offline. |
72 * - Renamed ec_bus_status_t, ec_master_status_t to ec_bus_state_t and |
72 * - Renamed ec_bus_status_t, ec_master_status_t to ec_bus_state_t and |
73 * ec_master_state_t, respectively. Renamed ecrt_master_get_status() to |
73 * ec_master_state_t, respectively. Renamed ecrt_master_get_status() to |
74 * ecrt_master_state(), for consistency reasons. |
74 * ecrt_master_state(), for consistency reasons. |
75 * - Added ec_domain_state_t and #ec_wc_state_t for a new output parameter |
75 * - Added ec_domain_state_t and #ec_wc_state_t for a new output parameter |
76 * of ecrt_domain_state(). The domain state object does now contain |
76 * of ecrt_domain_state(). The domain state object does now contain |
77 * information, if the process data was exchanged completely. |
77 * information, if the process data was exchanged completely. |
78 * - Former "Pdo registration" meant Pdo entry registration in fact, therefore |
78 * - Former "PDO registration" meant PDO entry registration in fact, therefore |
79 * renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo() |
79 * renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo() |
80 * to ecrt_slave_config_reg_pdo_entry(). |
80 * to ecrt_slave_config_reg_pdo_entry(). |
81 * - Removed ecrt_domain_register_pdo_range(), because it's functionality can |
81 * - Removed ecrt_domain_register_pdo_range(), because it's functionality can |
82 * be reached by specifying an explicit Pdo assignment/mapping and |
82 * be reached by specifying an explicit PDO assignment/mapping and |
83 * registering the mapped Pdo entries. |
83 * registering the mapped PDO entries. |
84 * - Added an Sdo access interface, working with Sdo requests. These can be |
84 * - Added an SDO access interface, working with SDO requests. These can be |
85 * scheduled for reading and writing during realtime operation. |
85 * scheduled for reading and writing during realtime operation. |
86 * - Exported ecrt_slave_config_sdo(), the generic Sdo configuration function. |
86 * - Exported ecrt_slave_config_sdo(), the generic SDO configuration function. |
87 * - Removed the bus_state and bus_tainted flags from ec_master_state_t. |
87 * - Removed the bus_state and bus_tainted flags from ec_master_state_t. |
88 * |
88 * |
89 * @{ |
89 * @{ |
90 */ |
90 */ |
91 |
91 |
221 ec_wc_state_t wc_state; /**< Working counter interpretation. */ |
221 ec_wc_state_t wc_state; /**< Working counter interpretation. */ |
222 } ec_domain_state_t; |
222 } ec_domain_state_t; |
223 |
223 |
224 /*****************************************************************************/ |
224 /*****************************************************************************/ |
225 |
225 |
226 /** Direction type for Pdo assignment functions. |
226 /** Direction type for PDO assignment functions. |
227 */ |
227 */ |
228 typedef enum { |
228 typedef enum { |
229 EC_DIR_INVALID, /**< Invalid direction. Do not use this value. */ |
229 EC_DIR_INVALID, /**< Invalid direction. Do not use this value. */ |
230 EC_DIR_OUTPUT, /**< Values written by the master. */ |
230 EC_DIR_OUTPUT, /**< Values written by the master. */ |
231 EC_DIR_INPUT, /**< Values read by the master. */ |
231 EC_DIR_INPUT, /**< Values read by the master. */ |
232 EC_DIR_COUNT /**< Number of directions. For internal use only. */ |
232 EC_DIR_COUNT /**< Number of directions. For internal use only. */ |
233 } ec_direction_t; |
233 } ec_direction_t; |
234 |
234 |
235 /*****************************************************************************/ |
235 /*****************************************************************************/ |
236 |
236 |
237 /** Pdo entry configuration information. |
237 /** PDO entry configuration information. |
238 * |
238 * |
239 * This is the data type of the \a entries field in ec_pdo_info_t. |
239 * This is the data type of the \a entries field in ec_pdo_info_t. |
240 * |
240 * |
241 * \see ecrt_slave_config_pdos(). |
241 * \see ecrt_slave_config_pdos(). |
242 */ |
242 */ |
243 typedef struct { |
243 typedef struct { |
244 uint16_t index; /**< Pdo entry index. */ |
244 uint16_t index; /**< PDO entry index. */ |
245 uint8_t subindex; /**< Pdo entry subindex. */ |
245 uint8_t subindex; /**< PDO entry subindex. */ |
246 uint8_t bit_length; /**< Size of the Pdo entry in bit. */ |
246 uint8_t bit_length; /**< Size of the PDO entry in bit. */ |
247 } ec_pdo_entry_info_t; |
247 } ec_pdo_entry_info_t; |
248 |
248 |
249 /*****************************************************************************/ |
249 /*****************************************************************************/ |
250 |
250 |
251 /** Pdo configuration information. |
251 /** PDO configuration information. |
252 * |
252 * |
253 * This is the data type of the \a pdos field in ec_sync_info_t. |
253 * This is the data type of the \a pdos field in ec_sync_info_t. |
254 * |
254 * |
255 * \see ecrt_slave_config_pdos(). |
255 * \see ecrt_slave_config_pdos(). |
256 */ |
256 */ |
257 typedef struct { |
257 typedef struct { |
258 uint16_t index; /**< Pdo index. */ |
258 uint16_t index; /**< PDO index. */ |
259 unsigned int n_entries; /**< Number of Pdo entries in \a entries to map. |
259 unsigned int n_entries; /**< Number of PDO entries in \a entries to map. |
260 Zero means, that the default mapping shall be |
260 Zero means, that the default mapping shall be |
261 used (this can only be done if the slave is |
261 used (this can only be done if the slave is |
262 present at bus configuration time). */ |
262 present at bus configuration time). */ |
263 ec_pdo_entry_info_t *entries; /**< Array of Pdo entries to map. Can either |
263 ec_pdo_entry_info_t *entries; /**< Array of PDO entries to map. Can either |
264 be \a NULL, or must contain at |
264 be \a NULL, or must contain at |
265 least \a n_entries values. */ |
265 least \a n_entries values. */ |
266 } ec_pdo_info_t; |
266 } ec_pdo_info_t; |
267 |
267 |
268 /*****************************************************************************/ |
268 /*****************************************************************************/ |
269 |
269 |
270 /** Sync manager configuration information. |
270 /** Sync manager configuration information. |
271 * |
271 * |
272 * This can be use to configure multiple sync managers including the Pdo |
272 * This can be use to configure multiple sync managers including the PDO |
273 * assignment and Pdo mapping. It is used as an input parameter type in |
273 * assignment and PDO mapping. It is used as an input parameter type in |
274 * ecrt_slave_config_pdos(). |
274 * ecrt_slave_config_pdos(). |
275 */ |
275 */ |
276 typedef struct { |
276 typedef struct { |
277 uint8_t index; /**< Sync manager index. Must be less |
277 uint8_t index; /**< Sync manager index. Must be less |
278 than #EC_MAX_SYNC_MANAGERS for a valid sync manager, |
278 than #EC_MAX_SYNC_MANAGERS for a valid sync manager, |
279 but can also be \a 0xff to mark the end of the list. */ |
279 but can also be \a 0xff to mark the end of the list. */ |
280 ec_direction_t dir; /**< Sync manager direction. */ |
280 ec_direction_t dir; /**< Sync manager direction. */ |
281 unsigned int n_pdos; /**< Number of Pdos in \a pdos. */ |
281 unsigned int n_pdos; /**< Number of PDOs in \a pdos. */ |
282 ec_pdo_info_t *pdos; /**< Array with Pdos to assign. This must contain |
282 ec_pdo_info_t *pdos; /**< Array with PDOs to assign. This must contain |
283 at least \a n_pdos Pdos. */ |
283 at least \a n_pdos PDOs. */ |
284 } ec_sync_info_t; |
284 } ec_sync_info_t; |
285 |
285 |
286 /*****************************************************************************/ |
286 /*****************************************************************************/ |
287 |
287 |
288 /** List record type for Pdo entry mass-registration. |
288 /** List record type for PDO entry mass-registration. |
289 * |
289 * |
290 * This type is used for the array parameter of the |
290 * This type is used for the array parameter of the |
291 * ecrt_domain_reg_pdo_entry_list() |
291 * ecrt_domain_reg_pdo_entry_list() |
292 */ |
292 */ |
293 typedef struct { |
293 typedef struct { |
294 uint16_t alias; /**< Slave alias address. */ |
294 uint16_t alias; /**< Slave alias address. */ |
295 uint16_t position; /**< Slave position. */ |
295 uint16_t position; /**< Slave position. */ |
296 uint32_t vendor_id; /**< Slave vendor ID. */ |
296 uint32_t vendor_id; /**< Slave vendor ID. */ |
297 uint32_t product_code; /**< Slave product code. */ |
297 uint32_t product_code; /**< Slave product code. */ |
298 uint16_t index; /**< Pdo entry index. */ |
298 uint16_t index; /**< PDO entry index. */ |
299 uint8_t subindex; /**< Pdo entry subindex. */ |
299 uint8_t subindex; /**< PDO entry subindex. */ |
300 unsigned int *offset; /**< Pointer to a variable to store the Pdo entry's |
300 unsigned int *offset; /**< Pointer to a variable to store the PDO entry's |
301 (byte-)offset in the process data. */ |
301 (byte-)offset in the process data. */ |
302 unsigned int *bit_position; /**< Pointer to a variable to store a bit |
302 unsigned int *bit_position; /**< Pointer to a variable to store a bit |
303 position (0-7) within the \a offset. Can be |
303 position (0-7) within the \a offset. Can be |
304 NULL, in which case an error is raised if the |
304 NULL, in which case an error is raised if the |
305 Pdo entry does not byte-align. */ |
305 PDO entry does not byte-align. */ |
306 } ec_pdo_entry_reg_t; |
306 } ec_pdo_entry_reg_t; |
307 |
307 |
308 /*****************************************************************************/ |
308 /*****************************************************************************/ |
309 |
309 |
310 /** Request state. |
310 /** Request state. |
504 uint8_t sync_index, /**< Sync manager index. Must be less |
504 uint8_t sync_index, /**< Sync manager index. Must be less |
505 than #EC_MAX_SYNC_MANAGERS. */ |
505 than #EC_MAX_SYNC_MANAGERS. */ |
506 ec_direction_t dir /**< Input/Output. */ |
506 ec_direction_t dir /**< Input/Output. */ |
507 ); |
507 ); |
508 |
508 |
509 /** Add a Pdo to a sync manager's Pdo assignment. |
509 /** Add a PDO to a sync manager's PDO assignment. |
510 * |
510 * |
511 * \see ecrt_slave_config_pdos() |
511 * \see ecrt_slave_config_pdos() |
512 * \return zero on success, else non-zero |
512 * \return zero on success, else non-zero |
513 */ |
513 */ |
514 int ecrt_slave_config_pdo_assign_add( |
514 int ecrt_slave_config_pdo_assign_add( |
515 ec_slave_config_t *sc, /**< Slave configuration. */ |
515 ec_slave_config_t *sc, /**< Slave configuration. */ |
516 uint8_t sync_index, /**< Sync manager index. Must be less |
516 uint8_t sync_index, /**< Sync manager index. Must be less |
517 than #EC_MAX_SYNC_MANAGERS. */ |
517 than #EC_MAX_SYNC_MANAGERS. */ |
518 uint16_t index /**< Index of the Pdo to assign. */ |
518 uint16_t index /**< Index of the PDO to assign. */ |
519 ); |
519 ); |
520 |
520 |
521 /** Clear a sync manager's Pdo assignment. |
521 /** Clear a sync manager's PDO assignment. |
522 * |
522 * |
523 * This can be called before assigning Pdos via |
523 * This can be called before assigning PDOs via |
524 * ecrt_slave_config_pdo_assign_add(), to clear the default assignment of a |
524 * ecrt_slave_config_pdo_assign_add(), to clear the default assignment of a |
525 * sync manager. |
525 * sync manager. |
526 * |
526 * |
527 * \see ecrt_slave_config_pdos() |
527 * \see ecrt_slave_config_pdos() |
528 */ |
528 */ |
530 ec_slave_config_t *sc, /**< Slave configuration. */ |
530 ec_slave_config_t *sc, /**< Slave configuration. */ |
531 uint8_t sync_index /**< Sync manager index. Must be less |
531 uint8_t sync_index /**< Sync manager index. Must be less |
532 than #EC_MAX_SYNC_MANAGERS. */ |
532 than #EC_MAX_SYNC_MANAGERS. */ |
533 ); |
533 ); |
534 |
534 |
535 /** Add a Pdo entry to the given Pdo's mapping. |
535 /** Add a PDO entry to the given PDO's mapping. |
536 * |
536 * |
537 * \see ecrt_slave_config_pdos() |
537 * \see ecrt_slave_config_pdos() |
538 * \return zero on success, else non-zero |
538 * \return zero on success, else non-zero |
539 */ |
539 */ |
540 int ecrt_slave_config_pdo_mapping_add( |
540 int ecrt_slave_config_pdo_mapping_add( |
541 ec_slave_config_t *sc, /**< Slave configuration. */ |
541 ec_slave_config_t *sc, /**< Slave configuration. */ |
542 uint16_t pdo_index, /**< Index of the Pdo. */ |
542 uint16_t pdo_index, /**< Index of the PDO. */ |
543 uint16_t entry_index, /**< Index of the Pdo entry to add to the Pdo's |
543 uint16_t entry_index, /**< Index of the PDO entry to add to the PDO's |
544 mapping. */ |
544 mapping. */ |
545 uint8_t entry_subindex, /**< Subindex of the Pdo entry to add to the |
545 uint8_t entry_subindex, /**< Subindex of the PDO entry to add to the |
546 Pdo's mapping. */ |
546 PDO's mapping. */ |
547 uint8_t entry_bit_length /**< Size of the Pdo entry in bit. */ |
547 uint8_t entry_bit_length /**< Size of the PDO entry in bit. */ |
548 ); |
548 ); |
549 |
549 |
550 /** Clear the mapping of a given Pdo. |
550 /** Clear the mapping of a given PDO. |
551 * |
551 * |
552 * This can be called before mapping Pdo entries via |
552 * This can be called before mapping PDO entries via |
553 * ecrt_slave_config_pdo_mapping_add(), to clear the default mapping. |
553 * ecrt_slave_config_pdo_mapping_add(), to clear the default mapping. |
554 * |
554 * |
555 * \see ecrt_slave_config_pdos() |
555 * \see ecrt_slave_config_pdos() |
556 */ |
556 */ |
557 void ecrt_slave_config_pdo_mapping_clear( |
557 void ecrt_slave_config_pdo_mapping_clear( |
558 ec_slave_config_t *sc, /**< Slave configuration. */ |
558 ec_slave_config_t *sc, /**< Slave configuration. */ |
559 uint16_t pdo_index /**< Index of the Pdo. */ |
559 uint16_t pdo_index /**< Index of the PDO. */ |
560 ); |
560 ); |
561 |
561 |
562 /** Specify a complete Pdo configuration. |
562 /** Specify a complete PDO configuration. |
563 * |
563 * |
564 * This function is a convenience wrapper for the functions |
564 * This function is a convenience wrapper for the functions |
565 * ecrt_slave_config_sync_manager(), ecrt_slave_config_pdo_assign_clear(), |
565 * ecrt_slave_config_sync_manager(), ecrt_slave_config_pdo_assign_clear(), |
566 * ecrt_slave_config_pdo_assign_add(), ecrt_slave_config_pdo_mapping_clear() |
566 * ecrt_slave_config_pdo_assign_add(), ecrt_slave_config_pdo_mapping_clear() |
567 * and ecrt_slave_config_pdo_mapping_add(), that are better suitable for |
567 * and ecrt_slave_config_pdo_mapping_add(), that are better suitable for |
568 * automatic code generation. |
568 * automatic code generation. |
569 * |
569 * |
570 * The following example shows, how to specify a complete configuration, |
570 * The following example shows, how to specify a complete configuration, |
571 * including the Pdo mappings. With this information, the master is able to |
571 * including the PDO mappings. With this information, the master is able to |
572 * reserve the complete process data, even if the slave is not present at |
572 * reserve the complete process data, even if the slave is not present at |
573 * configuration time: |
573 * configuration time: |
574 * |
574 * |
575 * \code |
575 * \code |
576 * ec_pdo_entry_info_t el3162_channel1[] = { |
576 * ec_pdo_entry_info_t el3162_channel1[] = { |
633 \a syncs. */ |
633 \a syncs. */ |
634 const ec_sync_info_t syncs[] /**< Array of sync manager |
634 const ec_sync_info_t syncs[] /**< Array of sync manager |
635 configurations. */ |
635 configurations. */ |
636 ); |
636 ); |
637 |
637 |
638 /** Registers a Pdo entry for process data exchange in a domain. |
638 /** Registers a PDO entry for process data exchange in a domain. |
639 * |
639 * |
640 * Searches the assigned Pdos for the given Pdo entry. An error is raised, if |
640 * Searches the assigned PDOs for the given PDO entry. An error is raised, if |
641 * the given entry is not mapped. Otherwise, the corresponding sync manager |
641 * the given entry is not mapped. Otherwise, the corresponding sync manager |
642 * and FMMU configurations are provided for slave configuration and the |
642 * and FMMU configurations are provided for slave configuration and the |
643 * respective sync manager's assigned Pdos are appended to the given domain, |
643 * respective sync manager's assigned PDOs are appended to the given domain, |
644 * if not already done. The offset of the requested Pdo entry's data inside |
644 * if not already done. The offset of the requested PDO entry's data inside |
645 * the domain's process data is returned. Optionally, the Pdo entry bit |
645 * the domain's process data is returned. Optionally, the PDO entry bit |
646 * position (0-7) can be retrieved via the \a bit_position output parameter. |
646 * position (0-7) can be retrieved via the \a bit_position output parameter. |
647 * This pointer may be \a NULL, in this case an error is raised if the Pdo |
647 * This pointer may be \a NULL, in this case an error is raised if the PDO |
648 * entry does not byte-align. |
648 * entry does not byte-align. |
649 * |
649 * |
650 * \retval >=0 Success: Offset of the Pdo entry's process data. |
650 * \retval >=0 Success: Offset of the PDO entry's process data. |
651 * \retval <0 Error code. |
651 * \retval <0 Error code. |
652 */ |
652 */ |
653 int ecrt_slave_config_reg_pdo_entry( |
653 int ecrt_slave_config_reg_pdo_entry( |
654 ec_slave_config_t *sc, /**< Slave configuration. */ |
654 ec_slave_config_t *sc, /**< Slave configuration. */ |
655 uint16_t entry_index, /**< Index of the Pdo entry to register. */ |
655 uint16_t entry_index, /**< Index of the PDO entry to register. */ |
656 uint8_t entry_subindex, /**< Subindex of the Pdo entry to register. */ |
656 uint8_t entry_subindex, /**< Subindex of the PDO entry to register. */ |
657 ec_domain_t *domain, /**< Domain. */ |
657 ec_domain_t *domain, /**< Domain. */ |
658 unsigned int *bit_position /**< Optional address if bit addressing |
658 unsigned int *bit_position /**< Optional address if bit addressing |
659 is desired */ |
659 is desired */ |
660 ); |
660 ); |
661 |
661 |
662 /** Add an Sdo configuration. |
662 /** Add an SDO configuration. |
663 * |
663 * |
664 * An Sdo configuration is stored in the slave configuration object and is |
664 * An SDO configuration is stored in the slave configuration object and is |
665 * downloaded to the slave whenever the slave is being configured by the |
665 * downloaded to the slave whenever the slave is being configured by the |
666 * master. This usually happens once on master activation, but can be repeated |
666 * master. This usually happens once on master activation, but can be repeated |
667 * subsequently, for example after the slave's power supply failed. |
667 * subsequently, for example after the slave's power supply failed. |
668 * |
668 * |
669 * \attention The Sdos for Pdo assignment (\p 0x1C10 - \p 0x1C2F) and Pdo |
669 * \attention The SDOs for PDO assignment (\p 0x1C10 - \p 0x1C2F) and PDO |
670 * mapping (\p 0x1600 - \p 0x17FF and \p 0x1A00 - \p 0x1BFF) should not be |
670 * mapping (\p 0x1600 - \p 0x17FF and \p 0x1A00 - \p 0x1BFF) should not be |
671 * configured with this function, because they are part of the slave |
671 * configured with this function, because they are part of the slave |
672 * configuration done by the master. Please use ecrt_slave_config_pdos() and |
672 * configuration done by the master. Please use ecrt_slave_config_pdos() and |
673 * friends instead. |
673 * friends instead. |
674 * |
674 * |
675 * This is the generic function for adding an Sdo configuration. Please note |
675 * This is the generic function for adding an SDO configuration. Please note |
676 * that the this function does not do any endianess correction. If |
676 * that the this function does not do any endianess correction. If |
677 * datatype-specific functions are needed (that automatically correct the |
677 * datatype-specific functions are needed (that automatically correct the |
678 * endianess), have a look at ecrt_slave_config_sdo8(), |
678 * endianess), have a look at ecrt_slave_config_sdo8(), |
679 * ecrt_slave_config_sdo16() and ecrt_slave_config_sdo32(). |
679 * ecrt_slave_config_sdo16() and ecrt_slave_config_sdo32(). |
680 * |
680 * |
681 * \retval 0 Success. |
681 * \retval 0 Success. |
682 * \retval <0 Error code. |
682 * \retval <0 Error code. |
683 */ |
683 */ |
684 int ecrt_slave_config_sdo( |
684 int ecrt_slave_config_sdo( |
685 ec_slave_config_t *sc, /**< Slave configuration. */ |
685 ec_slave_config_t *sc, /**< Slave configuration. */ |
686 uint16_t index, /**< Index of the Sdo to configure. */ |
686 uint16_t index, /**< Index of the SDO to configure. */ |
687 uint8_t subindex, /**< Subindex of the Sdo to configure. */ |
687 uint8_t subindex, /**< Subindex of the SDO to configure. */ |
688 const uint8_t *data, /**< Pointer to the data. */ |
688 const uint8_t *data, /**< Pointer to the data. */ |
689 size_t size /**< Size of the \a data. */ |
689 size_t size /**< Size of the \a data. */ |
690 ); |
690 ); |
691 |
691 |
692 /** Add a configuration value for an 8-bit SDO. |
692 /** Add a configuration value for an 8-bit SDO. |
729 uint16_t sdo_index, /**< Index of the SDO to configure. */ |
729 uint16_t sdo_index, /**< Index of the SDO to configure. */ |
730 uint8_t sdo_subindex, /**< Subindex of the SDO to configure. */ |
730 uint8_t sdo_subindex, /**< Subindex of the SDO to configure. */ |
731 uint32_t value /**< Value to set. */ |
731 uint32_t value /**< Value to set. */ |
732 ); |
732 ); |
733 |
733 |
734 /** Create an Sdo request to exchange Sdos during realtime operation. |
734 /** Create an SDO request to exchange SDOs during realtime operation. |
735 * |
735 * |
736 * The created Sdo request object is freed automatically when the master is |
736 * The created SDO request object is freed automatically when the master is |
737 * released. |
737 * released. |
738 */ |
738 */ |
739 ec_sdo_request_t *ecrt_slave_config_create_sdo_request( |
739 ec_sdo_request_t *ecrt_slave_config_create_sdo_request( |
740 ec_slave_config_t *sc, /**< Slave configuration. */ |
740 ec_slave_config_t *sc, /**< Slave configuration. */ |
741 uint16_t index, /**< Sdo index. */ |
741 uint16_t index, /**< SDO index. */ |
742 uint8_t subindex, /**< Sdo subindex. */ |
742 uint8_t subindex, /**< SDO subindex. */ |
743 size_t size /**< Data size to reserve. */ |
743 size_t size /**< Data size to reserve. */ |
744 ); |
744 ); |
745 |
745 |
746 /** Create an VoE handler to exchange vendor-specific data during realtime |
746 /** Create an VoE handler to exchange vendor-specific data during realtime |
747 * operation. |
747 * operation. |
856 ec_domain_state_t *state /**< Pointer to a state object to store the |
856 ec_domain_state_t *state /**< Pointer to a state object to store the |
857 information. */ |
857 information. */ |
858 ); |
858 ); |
859 |
859 |
860 /***************************************************************************** |
860 /***************************************************************************** |
861 * Sdo request methods. |
861 * SDO request methods. |
862 ****************************************************************************/ |
862 ****************************************************************************/ |
863 |
863 |
864 /** Set the timeout for an Sdo request. |
864 /** Set the timeout for an SDO request. |
865 * |
865 * |
866 * If the request cannot be processed in the specified time, if will be marked |
866 * If the request cannot be processed in the specified time, if will be marked |
867 * as failed. |
867 * as failed. |
868 * |
868 * |
869 * The timeout is permanently stored in the request object and is valid until |
869 * The timeout is permanently stored in the request object and is valid until |
870 * the next call of this method. |
870 * the next call of this method. |
871 */ |
871 */ |
872 void ecrt_sdo_request_timeout( |
872 void ecrt_sdo_request_timeout( |
873 ec_sdo_request_t *req, /**< Sdo request. */ |
873 ec_sdo_request_t *req, /**< SDO request. */ |
874 uint32_t timeout /**< Timeout in milliseconds. Zero means no |
874 uint32_t timeout /**< Timeout in milliseconds. Zero means no |
875 timeout. */ |
875 timeout. */ |
876 ); |
876 ); |
877 |
877 |
878 /** Access to the Sdo request's data. |
878 /** Access to the SDO request's data. |
879 * |
879 * |
880 * This function returns a pointer to the request's internal Sdo data memory. |
880 * This function returns a pointer to the request's internal SDO data memory. |
881 * |
881 * |
882 * - After a read operation was successful, integer data can be evaluated using |
882 * - After a read operation was successful, integer data can be evaluated using |
883 * the EC_READ_*() macros as usual. Example: |
883 * the EC_READ_*() macros as usual. Example: |
884 * \code |
884 * \code |
885 * uint16_t value = EC_READ_U16(ecrt_sdo_request_data(sdo))); |
885 * uint16_t value = EC_READ_U16(ecrt_sdo_request_data(sdo))); |
891 * \code |
891 * \code |
892 * EC_WRITE_U16(ecrt_sdo_request_data(sdo), 0xFFFF); |
892 * EC_WRITE_U16(ecrt_sdo_request_data(sdo), 0xFFFF); |
893 * \endcode |
893 * \endcode |
894 * |
894 * |
895 * \attention The return value can be invalid during a read operation, because |
895 * \attention The return value can be invalid during a read operation, because |
896 * the internal Sdo data memory could be re-allocated if the read Sdo data do |
896 * the internal SDO data memory could be re-allocated if the read SDO data do |
897 * not fit inside. |
897 * not fit inside. |
898 * |
898 * |
899 * \return Pointer to the internal Sdo data memory. |
899 * \return Pointer to the internal SDO data memory. |
900 */ |
900 */ |
901 uint8_t *ecrt_sdo_request_data( |
901 uint8_t *ecrt_sdo_request_data( |
902 ec_sdo_request_t *req /**< Sdo request. */ |
902 ec_sdo_request_t *req /**< SDO request. */ |
903 ); |
903 ); |
904 |
904 |
905 /** Returns the current Sdo data size. |
905 /** Returns the current SDO data size. |
906 * |
906 * |
907 * When the Sdo request is created, the data size is set to the size of the |
907 * When the SDO request is created, the data size is set to the size of the |
908 * reserved memory. After a read operation the size is set to the size of the |
908 * reserved memory. After a read operation the size is set to the size of the |
909 * read data. The size is not modified in any other situation. |
909 * read data. The size is not modified in any other situation. |
910 * |
910 * |
911 * \return Sdo data size in bytes. |
911 * \return SDO data size in bytes. |
912 */ |
912 */ |
913 size_t ecrt_sdo_request_data_size( |
913 size_t ecrt_sdo_request_data_size( |
914 const ec_sdo_request_t *req /**< Sdo request. */ |
914 const ec_sdo_request_t *req /**< SDO request. */ |
915 ); |
915 ); |
916 |
916 |
917 /** Get the current state of the Sdo request. |
917 /** Get the current state of the SDO request. |
918 * |
918 * |
919 * \return Request state. |
919 * \return Request state. |
920 */ |
920 */ |
921 ec_request_state_t ecrt_sdo_request_state( |
921 ec_request_state_t ecrt_sdo_request_state( |
922 const ec_sdo_request_t *req /**< Sdo request. */ |
922 const ec_sdo_request_t *req /**< SDO request. */ |
923 ); |
923 ); |
924 |
924 |
925 /** Schedule an Sdo write operation. |
925 /** Schedule an SDO write operation. |
926 * |
926 * |
927 * \attention This method may not be called while ecrt_sdo_request_state() |
927 * \attention This method may not be called while ecrt_sdo_request_state() |
928 * returns EC_SDO_REQUEST_BUSY. |
928 * returns EC_SDO_REQUEST_BUSY. |
929 */ |
929 */ |
930 void ecrt_sdo_request_write( |
930 void ecrt_sdo_request_write( |
931 ec_sdo_request_t *req /**< Sdo request. */ |
931 ec_sdo_request_t *req /**< SDO request. */ |
932 ); |
932 ); |
933 |
933 |
934 /** Schedule an Sdo read operation. |
934 /** Schedule an SDO read operation. |
935 * |
935 * |
936 * \attention This method may not be called while ecrt_sdo_request_state() |
936 * \attention This method may not be called while ecrt_sdo_request_state() |
937 * returns EC_SDO_REQUEST_BUSY. |
937 * returns EC_SDO_REQUEST_BUSY. |
938 * |
938 * |
939 * \attention After calling this function, the return value of |
939 * \attention After calling this function, the return value of |
940 * ecrt_sdo_request_data() must be considered as invalid while |
940 * ecrt_sdo_request_data() must be considered as invalid while |
941 * ecrt_sdo_request_state() returns EC_SDO_REQUEST_BUSY. |
941 * ecrt_sdo_request_state() returns EC_SDO_REQUEST_BUSY. |
942 */ |
942 */ |
943 void ecrt_sdo_request_read( |
943 void ecrt_sdo_request_read( |
944 ec_sdo_request_t *req /**< Sdo request. */ |
944 ec_sdo_request_t *req /**< SDO request. */ |
945 ); |
945 ); |
946 |
946 |
947 /***************************************************************************** |
947 /***************************************************************************** |
948 * VoE handler methods. |
948 * VoE handler methods. |
949 ****************************************************************************/ |
949 ****************************************************************************/ |