48 * ecrt_slave_config_state(). |
48 * ecrt_slave_config_state(). |
49 * - Process data memory for a domain can now be allocated externally. This |
49 * - Process data memory for a domain can now be allocated externally. This |
50 * offers the possibility to use a shared-memory region. Therefore, |
50 * offers the possibility to use a shared-memory region. Therefore, |
51 * added the domain methods ecrt_domain_size() and |
51 * added the domain methods ecrt_domain_size() and |
52 * ecrt_domain_external_memory(). |
52 * ecrt_domain_external_memory(). |
53 * - Pdo entry registration functions do not return a process data pointer, |
53 * - PDO entry registration functions do not return a process data pointer, |
54 * but an offset in the domain's process data. In addition, an optional bit |
54 * but an offset in the domain's process data. In addition, an optional bit |
55 * position can be requested. This was necessary for the external domain |
55 * position can be requested. This was necessary for the external domain |
56 * memory. An additional advantage is, that the returned offset is |
56 * memory. An additional advantage is, that the returned offset is |
57 * immediately valid. If the domain's process data is allocated internally, |
57 * immediately valid. If the domain's process data is allocated internally, |
58 * the start address can be retrieved with ecrt_domain_data(). |
58 * the start address can be retrieved with ecrt_domain_data(). |
59 * - Replaced ecrt_slave_pdo_mapping/add/clear() with |
59 * - Replaced ecrt_slave_pdo_mapping/add/clear() with |
60 * ecrt_slave_config_pdo_assign_add() to add a Pdo to a sync manager's Pdo |
60 * ecrt_slave_config_pdo_assign_add() to add a PDO to a sync manager's PDO |
61 * assignment and ecrt_slave_config_pdo_mapping_add() to add a Pdo entry to a |
61 * assignment and ecrt_slave_config_pdo_mapping_add() to add a PDO entry to a |
62 * Pdo's mapping. ecrt_slave_config_pdos() is a convenience function |
62 * PDO's mapping. ecrt_slave_config_pdos() is a convenience function |
63 * for both, that uses the new data types ec_pdo_info_t and |
63 * for both, that uses the new data types ec_pdo_info_t and |
64 * ec_pdo_entry_info_t. Pdo entries, that are mapped with these functions |
64 * ec_pdo_entry_info_t. PDO entries, that are mapped with these functions |
65 * can now immediately be registered, even if the bus is offline. |
65 * can now immediately be registered, even if the bus is offline. |
66 * - Renamed ec_bus_status_t, ec_master_status_t to ec_bus_state_t and |
66 * - Renamed ec_bus_status_t, ec_master_status_t to ec_bus_state_t and |
67 * ec_master_state_t, respectively. Renamed ecrt_master_get_status() to |
67 * ec_master_state_t, respectively. Renamed ecrt_master_get_status() to |
68 * ecrt_master_state(), for consistency reasons. |
68 * ecrt_master_state(), for consistency reasons. |
69 * - Added ec_domain_state_t and #ec_wc_state_t for a new output parameter |
69 * - Added ec_domain_state_t and #ec_wc_state_t for a new output parameter |
70 * of ecrt_domain_state(). The domain state object does now contain |
70 * of ecrt_domain_state(). The domain state object does now contain |
71 * information, if the process data was exchanged completely. |
71 * information, if the process data was exchanged completely. |
72 * - Former "Pdo registration" meant Pdo entry registration in fact, therefore |
72 * - Former "PDO registration" meant PDO entry registration in fact, therefore |
73 * renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo() |
73 * renamed ec_pdo_reg_t to ec_pdo_entry_reg_t and ecrt_domain_register_pdo() |
74 * to ecrt_slave_config_reg_pdo_entry(). |
74 * to ecrt_slave_config_reg_pdo_entry(). |
75 * - Removed ecrt_domain_register_pdo_range(), because it's functionality can |
75 * - Removed ecrt_domain_register_pdo_range(), because it's functionality can |
76 * be reached by specifying an explicit Pdo assignment/mapping and |
76 * be reached by specifying an explicit PDO assignment/mapping and |
77 * registering the mapped Pdo entries. |
77 * registering the mapped PDO entries. |
78 * - Added an Sdo access interface, working with Sdo requests. These can be |
78 * - Added an SDO access interface, working with SDO requests. These can be |
79 * scheduled for reading and writing during realtime operation. |
79 * scheduled for reading and writing during realtime operation. |
80 * - Exported ecrt_slave_config_sdo(), the generic Sdo configuration function. |
80 * - Exported ecrt_slave_config_sdo(), the generic SDO configuration function. |
81 * - Removed the bus_state and bus_tainted flags from ec_master_state_t. |
81 * - Removed the bus_state and bus_tainted flags from ec_master_state_t. |
82 * |
82 * |
83 * @{ |
83 * @{ |
84 */ |
84 */ |
85 |
85 |
212 ec_wc_state_t wc_state; /**< Working counter interpretation. */ |
212 ec_wc_state_t wc_state; /**< Working counter interpretation. */ |
213 } ec_domain_state_t; |
213 } ec_domain_state_t; |
214 |
214 |
215 /*****************************************************************************/ |
215 /*****************************************************************************/ |
216 |
216 |
217 /** Direction type for Pdo assignment functions. |
217 /** Direction type for PDO assignment functions. |
218 */ |
218 */ |
219 typedef enum { |
219 typedef enum { |
220 EC_DIR_INVALID, /**< Invalid direction. Do not use this value. */ |
220 EC_DIR_INVALID, /**< Invalid direction. Do not use this value. */ |
221 EC_DIR_OUTPUT, /**< Values written by the master. */ |
221 EC_DIR_OUTPUT, /**< Values written by the master. */ |
222 EC_DIR_INPUT, /**< Values read by the master. */ |
222 EC_DIR_INPUT, /**< Values read by the master. */ |
223 EC_DIR_COUNT /**< Number of directions. For internal use only. */ |
223 EC_DIR_COUNT /**< Number of directions. For internal use only. */ |
224 } ec_direction_t; |
224 } ec_direction_t; |
225 |
225 |
226 /*****************************************************************************/ |
226 /*****************************************************************************/ |
227 |
227 |
228 /** Pdo entry configuration information. |
228 /** PDO entry configuration information. |
229 * |
229 * |
230 * This is the data type of the \a entries field in ec_pdo_info_t. |
230 * This is the data type of the \a entries field in ec_pdo_info_t. |
231 * |
231 * |
232 * \see ecrt_slave_config_pdos(). |
232 * \see ecrt_slave_config_pdos(). |
233 */ |
233 */ |
234 typedef struct { |
234 typedef struct { |
235 uint16_t index; /**< Pdo entry index. */ |
235 uint16_t index; /**< PDO entry index. */ |
236 uint8_t subindex; /**< Pdo entry subindex. */ |
236 uint8_t subindex; /**< PDO entry subindex. */ |
237 uint8_t bit_length; /**< Size of the Pdo entry in bit. */ |
237 uint8_t bit_length; /**< Size of the PDO entry in bit. */ |
238 } ec_pdo_entry_info_t; |
238 } ec_pdo_entry_info_t; |
239 |
239 |
240 /*****************************************************************************/ |
240 /*****************************************************************************/ |
241 |
241 |
242 /** Pdo configuration information. |
242 /** PDO configuration information. |
243 * |
243 * |
244 * This is the data type of the \a pdos field in ec_sync_info_t. |
244 * This is the data type of the \a pdos field in ec_sync_info_t. |
245 * |
245 * |
246 * \see ecrt_slave_config_pdos(). |
246 * \see ecrt_slave_config_pdos(). |
247 */ |
247 */ |
248 typedef struct { |
248 typedef struct { |
249 uint16_t index; /**< Pdo index. */ |
249 uint16_t index; /**< PDO index. */ |
250 unsigned int n_entries; /**< Number of Pdo entries in \a entries to map. |
250 unsigned int n_entries; /**< Number of PDO entries in \a entries to map. |
251 Zero means, that the default mapping shall be |
251 Zero means, that the default mapping shall be |
252 used (this can only be done if the slave is |
252 used (this can only be done if the slave is |
253 present at bus configuration time). */ |
253 present at bus configuration time). */ |
254 ec_pdo_entry_info_t *entries; /**< Array of Pdo entries to map. Can either |
254 ec_pdo_entry_info_t *entries; /**< Array of PDO entries to map. Can either |
255 be \a NULL, or must contain at |
255 be \a NULL, or must contain at |
256 least \a n_entries values. */ |
256 least \a n_entries values. */ |
257 } ec_pdo_info_t; |
257 } ec_pdo_info_t; |
258 |
258 |
259 /*****************************************************************************/ |
259 /*****************************************************************************/ |
260 |
260 |
261 /** Sync manager configuration information. |
261 /** Sync manager configuration information. |
262 * |
262 * |
263 * This can be use to configure multiple sync managers including the Pdo |
263 * This can be use to configure multiple sync managers including the PDO |
264 * assignment and Pdo mapping. It is used as an input parameter type in |
264 * assignment and PDO mapping. It is used as an input parameter type in |
265 * ecrt_slave_config_pdos(). |
265 * ecrt_slave_config_pdos(). |
266 */ |
266 */ |
267 typedef struct { |
267 typedef struct { |
268 uint8_t index; /**< Sync manager index. Must be less |
268 uint8_t index; /**< Sync manager index. Must be less |
269 than #EC_MAX_SYNC_MANAGERS for a valid sync manager, |
269 than #EC_MAX_SYNC_MANAGERS for a valid sync manager, |
270 but can also be \a 0xff to mark the end of the list. */ |
270 but can also be \a 0xff to mark the end of the list. */ |
271 ec_direction_t dir; /**< Sync manager direction. */ |
271 ec_direction_t dir; /**< Sync manager direction. */ |
272 unsigned int n_pdos; /**< Number of Pdos in \a pdos. */ |
272 unsigned int n_pdos; /**< Number of PDOs in \a pdos. */ |
273 ec_pdo_info_t *pdos; /**< Array with Pdos to assign. This must contain |
273 ec_pdo_info_t *pdos; /**< Array with PDOs to assign. This must contain |
274 at least \a n_pdos Pdos. */ |
274 at least \a n_pdos PDOs. */ |
275 } ec_sync_info_t; |
275 } ec_sync_info_t; |
276 |
276 |
277 /*****************************************************************************/ |
277 /*****************************************************************************/ |
278 |
278 |
279 /** List record type for Pdo entry mass-registration. |
279 /** List record type for PDO entry mass-registration. |
280 * |
280 * |
281 * This type is used for the array parameter of the |
281 * This type is used for the array parameter of the |
282 * ecrt_domain_reg_pdo_entry_list() |
282 * ecrt_domain_reg_pdo_entry_list() |
283 */ |
283 */ |
284 typedef struct { |
284 typedef struct { |
285 uint16_t alias; /**< Slave alias address. */ |
285 uint16_t alias; /**< Slave alias address. */ |
286 uint16_t position; /**< Slave position. */ |
286 uint16_t position; /**< Slave position. */ |
287 uint32_t vendor_id; /**< Slave vendor ID. */ |
287 uint32_t vendor_id; /**< Slave vendor ID. */ |
288 uint32_t product_code; /**< Slave product code. */ |
288 uint32_t product_code; /**< Slave product code. */ |
289 uint16_t index; /**< Pdo entry index. */ |
289 uint16_t index; /**< PDO entry index. */ |
290 uint8_t subindex; /**< Pdo entry subindex. */ |
290 uint8_t subindex; /**< PDO entry subindex. */ |
291 unsigned int *offset; /**< Pointer to a variable to store the Pdo entry's |
291 unsigned int *offset; /**< Pointer to a variable to store the PDO entry's |
292 (byte-)offset in the process data. */ |
292 (byte-)offset in the process data. */ |
293 unsigned int *bit_position; /**< Pointer to a variable to store a bit |
293 unsigned int *bit_position; /**< Pointer to a variable to store a bit |
294 position (0-7) within the \a offset. Can be |
294 position (0-7) within the \a offset. Can be |
295 NULL, in which case an error is raised if the |
295 NULL, in which case an error is raised if the |
296 Pdo entry does not byte-align. */ |
296 PDO entry does not byte-align. */ |
297 } ec_pdo_entry_reg_t; |
297 } ec_pdo_entry_reg_t; |
298 |
298 |
299 /*****************************************************************************/ |
299 /*****************************************************************************/ |
300 |
300 |
301 /** Sdo request state. |
301 /** SDO request state. |
302 * |
302 * |
303 * This is used as return type of ecrt_sdo_request_state(). |
303 * This is used as return type of ecrt_sdo_request_state(). |
304 */ |
304 */ |
305 typedef enum { |
305 typedef enum { |
306 EC_SDO_REQUEST_UNUSED, /**< Not requested. */ |
306 EC_SDO_REQUEST_UNUSED, /**< Not requested. */ |
486 uint8_t sync_index, /**< Sync manager index. Must be less |
486 uint8_t sync_index, /**< Sync manager index. Must be less |
487 than #EC_MAX_SYNC_MANAGERS. */ |
487 than #EC_MAX_SYNC_MANAGERS. */ |
488 ec_direction_t dir /**< Input/Output. */ |
488 ec_direction_t dir /**< Input/Output. */ |
489 ); |
489 ); |
490 |
490 |
491 /** Add a Pdo to a sync manager's Pdo assignment. |
491 /** Add a PDO to a sync manager's PDO assignment. |
492 * |
492 * |
493 * \see ecrt_slave_config_pdos() |
493 * \see ecrt_slave_config_pdos() |
494 * \return zero on success, else non-zero |
494 * \return zero on success, else non-zero |
495 */ |
495 */ |
496 int ecrt_slave_config_pdo_assign_add( |
496 int ecrt_slave_config_pdo_assign_add( |
497 ec_slave_config_t *sc, /**< Slave configuration. */ |
497 ec_slave_config_t *sc, /**< Slave configuration. */ |
498 uint8_t sync_index, /**< Sync manager index. Must be less |
498 uint8_t sync_index, /**< Sync manager index. Must be less |
499 than #EC_MAX_SYNC_MANAGERS. */ |
499 than #EC_MAX_SYNC_MANAGERS. */ |
500 uint16_t index /**< Index of the Pdo to assign. */ |
500 uint16_t index /**< Index of the PDO to assign. */ |
501 ); |
501 ); |
502 |
502 |
503 /** Clear a sync manager's Pdo assignment. |
503 /** Clear a sync manager's PDO assignment. |
504 * |
504 * |
505 * This can be called before assigning Pdos via |
505 * This can be called before assigning PDOs via |
506 * ecrt_slave_config_pdo_assign_add(), to clear the default assignment of a |
506 * ecrt_slave_config_pdo_assign_add(), to clear the default assignment of a |
507 * sync manager. |
507 * sync manager. |
508 * |
508 * |
509 * \see ecrt_slave_config_pdos() |
509 * \see ecrt_slave_config_pdos() |
510 */ |
510 */ |
512 ec_slave_config_t *sc, /**< Slave configuration. */ |
512 ec_slave_config_t *sc, /**< Slave configuration. */ |
513 uint8_t sync_index /**< Sync manager index. Must be less |
513 uint8_t sync_index /**< Sync manager index. Must be less |
514 than #EC_MAX_SYNC_MANAGERS. */ |
514 than #EC_MAX_SYNC_MANAGERS. */ |
515 ); |
515 ); |
516 |
516 |
517 /** Add a Pdo entry to the given Pdo's mapping. |
517 /** Add a PDO entry to the given PDO's mapping. |
518 * |
518 * |
519 * \see ecrt_slave_config_pdos() |
519 * \see ecrt_slave_config_pdos() |
520 * \return zero on success, else non-zero |
520 * \return zero on success, else non-zero |
521 */ |
521 */ |
522 int ecrt_slave_config_pdo_mapping_add( |
522 int ecrt_slave_config_pdo_mapping_add( |
523 ec_slave_config_t *sc, /**< Slave configuration. */ |
523 ec_slave_config_t *sc, /**< Slave configuration. */ |
524 uint16_t pdo_index, /**< Index of the Pdo. */ |
524 uint16_t pdo_index, /**< Index of the PDO. */ |
525 uint16_t entry_index, /**< Index of the Pdo entry to add to the Pdo's |
525 uint16_t entry_index, /**< Index of the PDO entry to add to the PDO's |
526 mapping. */ |
526 mapping. */ |
527 uint8_t entry_subindex, /**< Subindex of the Pdo entry to add to the |
527 uint8_t entry_subindex, /**< Subindex of the PDO entry to add to the |
528 Pdo's mapping. */ |
528 PDO's mapping. */ |
529 uint8_t entry_bit_length /**< Size of the Pdo entry in bit. */ |
529 uint8_t entry_bit_length /**< Size of the PDO entry in bit. */ |
530 ); |
530 ); |
531 |
531 |
532 /** Clear the mapping of a given Pdo. |
532 /** Clear the mapping of a given PDO. |
533 * |
533 * |
534 * This can be called before mapping Pdo entries via |
534 * This can be called before mapping PDO entries via |
535 * ecrt_slave_config_pdo_mapping_add(), to clear the default mapping. |
535 * ecrt_slave_config_pdo_mapping_add(), to clear the default mapping. |
536 * |
536 * |
537 * \see ecrt_slave_config_pdos() |
537 * \see ecrt_slave_config_pdos() |
538 */ |
538 */ |
539 void ecrt_slave_config_pdo_mapping_clear( |
539 void ecrt_slave_config_pdo_mapping_clear( |
540 ec_slave_config_t *sc, /**< Slave configuration. */ |
540 ec_slave_config_t *sc, /**< Slave configuration. */ |
541 uint16_t pdo_index /**< Index of the Pdo. */ |
541 uint16_t pdo_index /**< Index of the PDO. */ |
542 ); |
542 ); |
543 |
543 |
544 /** Specify a complete Pdo configuration. |
544 /** Specify a complete PDO configuration. |
545 * |
545 * |
546 * This function is a convenience wrapper for the functions |
546 * This function is a convenience wrapper for the functions |
547 * ecrt_slave_config_sync_manager(), ecrt_slave_config_pdo_assign_clear(), |
547 * ecrt_slave_config_sync_manager(), ecrt_slave_config_pdo_assign_clear(), |
548 * ecrt_slave_config_pdo_assign_add(), ecrt_slave_config_pdo_mapping_clear() |
548 * ecrt_slave_config_pdo_assign_add(), ecrt_slave_config_pdo_mapping_clear() |
549 * and ecrt_slave_config_pdo_mapping_add(), that are better suitable for |
549 * and ecrt_slave_config_pdo_mapping_add(), that are better suitable for |
550 * automatic code generation. |
550 * automatic code generation. |
551 * |
551 * |
552 * The following example shows, how to specify a complete configuration, |
552 * The following example shows, how to specify a complete configuration, |
553 * including the Pdo mappings. With this information, the master is able to |
553 * including the PDO mappings. With this information, the master is able to |
554 * reserve the complete process data, even if the slave is not present at |
554 * reserve the complete process data, even if the slave is not present at |
555 * configuration time: |
555 * configuration time: |
556 * |
556 * |
557 * \code |
557 * \code |
558 * ec_pdo_entry_info_t el3162_channel1[] = { |
558 * ec_pdo_entry_info_t el3162_channel1[] = { |
615 \a syncs. */ |
615 \a syncs. */ |
616 const ec_sync_info_t syncs[] /**< Array of sync manager |
616 const ec_sync_info_t syncs[] /**< Array of sync manager |
617 configurations. */ |
617 configurations. */ |
618 ); |
618 ); |
619 |
619 |
620 /** Registers a Pdo entry for process data exchange in a domain. |
620 /** Registers a PDO entry for process data exchange in a domain. |
621 * |
621 * |
622 * Searches the assigned Pdos for the given Pdo entry. An error is raised, if |
622 * Searches the assigned PDOs for the given PDO entry. An error is raised, if |
623 * the given entry is not mapped. Otherwise, the corresponding sync manager |
623 * the given entry is not mapped. Otherwise, the corresponding sync manager |
624 * and FMMU configurations are provided for slave configuration and the |
624 * and FMMU configurations are provided for slave configuration and the |
625 * respective sync manager's assigned Pdos are appended to the given domain, |
625 * respective sync manager's assigned PDOs are appended to the given domain, |
626 * if not already done. The offset of the requested Pdo entry's data inside |
626 * if not already done. The offset of the requested PDO entry's data inside |
627 * the domain's process data is returned. Optionally, the Pdo entry bit |
627 * the domain's process data is returned. Optionally, the PDO entry bit |
628 * position (0-7) can be retrieved via the \a bit_position output parameter. |
628 * position (0-7) can be retrieved via the \a bit_position output parameter. |
629 * This pointer may be \a NULL, in this case an error is raised if the Pdo |
629 * This pointer may be \a NULL, in this case an error is raised if the PDO |
630 * entry does not byte-align. |
630 * entry does not byte-align. |
631 * |
631 * |
632 * \retval >=0 Success: Offset of the Pdo entry's process data. |
632 * \retval >=0 Success: Offset of the PDO entry's process data. |
633 * \retval -1 Error: Pdo entry not found. |
633 * \retval -1 Error: PDO entry not found. |
634 * \retval -2 Error: Failed to register Pdo entry. |
634 * \retval -2 Error: Failed to register PDO entry. |
635 * \retval -3 Error: Pdo entry is not byte-aligned. |
635 * \retval -3 Error: PDO entry is not byte-aligned. |
636 */ |
636 */ |
637 int ecrt_slave_config_reg_pdo_entry( |
637 int ecrt_slave_config_reg_pdo_entry( |
638 ec_slave_config_t *sc, /**< Slave configuration. */ |
638 ec_slave_config_t *sc, /**< Slave configuration. */ |
639 uint16_t entry_index, /**< Index of the Pdo entry to register. */ |
639 uint16_t entry_index, /**< Index of the PDO entry to register. */ |
640 uint8_t entry_subindex, /**< Subindex of the Pdo entry to register. */ |
640 uint8_t entry_subindex, /**< Subindex of the PDO entry to register. */ |
641 ec_domain_t *domain, /**< Domain. */ |
641 ec_domain_t *domain, /**< Domain. */ |
642 unsigned int *bit_position /**< Optional address if bit addressing |
642 unsigned int *bit_position /**< Optional address if bit addressing |
643 is desired */ |
643 is desired */ |
644 ); |
644 ); |
645 |
645 |
646 /** Add an Sdo configuration. |
646 /** Add an SDO configuration. |
647 * |
647 * |
648 * An Sdo configuration is stored in the slave configuration object and is |
648 * An SDO configuration is stored in the slave configuration object and is |
649 * downloaded to the slave whenever the slave is being configured by the |
649 * downloaded to the slave whenever the slave is being configured by the |
650 * master. This usually happens once on master activation, but can be repeated |
650 * master. This usually happens once on master activation, but can be repeated |
651 * subsequently, for example after the slave's power supply failed. |
651 * subsequently, for example after the slave's power supply failed. |
652 * |
652 * |
653 * \attention The Sdos for Pdo assignment (\p 0x1C10 - \p 0x1C2F) and Pdo |
653 * \attention The SDOs for PDO assignment (\p 0x1C10 - \p 0x1C2F) and PDO |
654 * mapping (\p 0x1600 - \p 0x17FF and \p 0x1A00 - \p 0x1BFF) should not be |
654 * mapping (\p 0x1600 - \p 0x17FF and \p 0x1A00 - \p 0x1BFF) should not be |
655 * configured with this function, because they are part of the slave |
655 * configured with this function, because they are part of the slave |
656 * configuration done by the master. Please use ecrt_slave_config_pdos() and |
656 * configuration done by the master. Please use ecrt_slave_config_pdos() and |
657 * friends instead. |
657 * friends instead. |
658 * |
658 * |
659 * This is the generic function for adding an Sdo configuration. Please note |
659 * This is the generic function for adding an SDO configuration. Please note |
660 * that the this function does not do any endianess correction. If |
660 * that the this function does not do any endianess correction. If |
661 * datatype-specific functions are needed (that automatically correct the |
661 * datatype-specific functions are needed (that automatically correct the |
662 * endianess), have a look at ecrt_slave_config_sdo8(), |
662 * endianess), have a look at ecrt_slave_config_sdo8(), |
663 * ecrt_slave_config_sdo16() and ecrt_slave_config_sdo32(). |
663 * ecrt_slave_config_sdo16() and ecrt_slave_config_sdo32(). |
664 * |
664 * |
665 * \return 0 in case of success, else < 0 |
665 * \return 0 in case of success, else < 0 |
666 */ |
666 */ |
667 int ecrt_slave_config_sdo( |
667 int ecrt_slave_config_sdo( |
668 ec_slave_config_t *sc, /**< Slave configuration. */ |
668 ec_slave_config_t *sc, /**< Slave configuration. */ |
669 uint16_t index, /**< Index of the Sdo to configure. */ |
669 uint16_t index, /**< Index of the SDO to configure. */ |
670 uint8_t subindex, /**< Subindex of the Sdo to configure. */ |
670 uint8_t subindex, /**< Subindex of the SDO to configure. */ |
671 const uint8_t *data, /**< Pointer to the data. */ |
671 const uint8_t *data, /**< Pointer to the data. */ |
672 size_t size /**< Size of the \a data. */ |
672 size_t size /**< Size of the \a data. */ |
673 ); |
673 ); |
674 |
674 |
675 /** Add a configuration value for an 8-bit SDO. |
675 /** Add a configuration value for an 8-bit SDO. |
706 uint16_t sdo_index, /**< Index of the SDO to configure. */ |
706 uint16_t sdo_index, /**< Index of the SDO to configure. */ |
707 uint8_t sdo_subindex, /**< Subindex of the SDO to configure. */ |
707 uint8_t sdo_subindex, /**< Subindex of the SDO to configure. */ |
708 uint32_t value /**< Value to set. */ |
708 uint32_t value /**< Value to set. */ |
709 ); |
709 ); |
710 |
710 |
711 /** Create an Sdo request to exchange Sdos during realtime operation. |
711 /** Create an SDO request to exchange SDOs during realtime operation. |
712 * |
712 * |
713 * The created Sdo request object is freed automatically when the master is |
713 * The created SDO request object is freed automatically when the master is |
714 * released. |
714 * released. |
715 */ |
715 */ |
716 ec_sdo_request_t *ecrt_slave_config_create_sdo_request( |
716 ec_sdo_request_t *ecrt_slave_config_create_sdo_request( |
717 ec_slave_config_t *sc, /**< Slave configuration. */ |
717 ec_slave_config_t *sc, /**< Slave configuration. */ |
718 uint16_t index, /**< Sdo index. */ |
718 uint16_t index, /**< SDO index. */ |
719 uint8_t subindex, /**< Sdo subindex. */ |
719 uint8_t subindex, /**< SDO subindex. */ |
720 size_t size /**< Data size to reserve. */ |
720 size_t size /**< Data size to reserve. */ |
721 ); |
721 ); |
722 |
722 |
723 /** Outputs the state of the slave configuration. |
723 /** Outputs the state of the slave configuration. |
724 * |
724 * |
809 ec_domain_state_t *state /**< Pointer to a state object to store the |
809 ec_domain_state_t *state /**< Pointer to a state object to store the |
810 information. */ |
810 information. */ |
811 ); |
811 ); |
812 |
812 |
813 /***************************************************************************** |
813 /***************************************************************************** |
814 * Sdo request methods. |
814 * SDO request methods. |
815 ****************************************************************************/ |
815 ****************************************************************************/ |
816 |
816 |
817 /** Set the timeout for an Sdo request. |
817 /** Set the timeout for an SDO request. |
818 * |
818 * |
819 * If the request cannot be processed in the specified time, if will be marked |
819 * If the request cannot be processed in the specified time, if will be marked |
820 * as failed. |
820 * as failed. |
821 * |
821 * |
822 * The timeout is permanently stored in the request object and is valid until |
822 * The timeout is permanently stored in the request object and is valid until |
823 * the next call of this method. |
823 * the next call of this method. |
824 */ |
824 */ |
825 void ecrt_sdo_request_timeout( |
825 void ecrt_sdo_request_timeout( |
826 ec_sdo_request_t *req, /**< Sdo request. */ |
826 ec_sdo_request_t *req, /**< SDO request. */ |
827 uint32_t timeout /**< Timeout in milliseconds. Zero means no |
827 uint32_t timeout /**< Timeout in milliseconds. Zero means no |
828 timeout. */ |
828 timeout. */ |
829 ); |
829 ); |
830 |
830 |
831 /** Access to the Sdo request's data. |
831 /** Access to the SDO request's data. |
832 * |
832 * |
833 * This function returns a pointer to the request's internal Sdo data memory. |
833 * This function returns a pointer to the request's internal SDO data memory. |
834 * |
834 * |
835 * - After a read operation was successful, integer data can be evaluated using |
835 * - After a read operation was successful, integer data can be evaluated using |
836 * the EC_READ_*() macros as usual. Example: |
836 * the EC_READ_*() macros as usual. Example: |
837 * \code |
837 * \code |
838 * uint16_t value = EC_READ_U16(ecrt_sdo_request_data(sdo))); |
838 * uint16_t value = EC_READ_U16(ecrt_sdo_request_data(sdo))); |
844 * \code |
844 * \code |
845 * EC_WRITE_U16(ecrt_sdo_request_data(sdo), 0xFFFF); |
845 * EC_WRITE_U16(ecrt_sdo_request_data(sdo), 0xFFFF); |
846 * \endcode |
846 * \endcode |
847 * |
847 * |
848 * \attention The return value can be invalid during a read operation, because |
848 * \attention The return value can be invalid during a read operation, because |
849 * the internal Sdo data memory could be re-allocated if the read Sdo data do |
849 * the internal SDO data memory could be re-allocated if the read SDO data do |
850 * not fit inside. |
850 * not fit inside. |
851 * |
851 * |
852 * \return Pointer to the internal Sdo data memory. |
852 * \return Pointer to the internal SDO data memory. |
853 */ |
853 */ |
854 uint8_t *ecrt_sdo_request_data( |
854 uint8_t *ecrt_sdo_request_data( |
855 ec_sdo_request_t *req /**< Sdo request. */ |
855 ec_sdo_request_t *req /**< SDO request. */ |
856 ); |
856 ); |
857 |
857 |
858 /** Returns the current Sdo data size. |
858 /** Returns the current SDO data size. |
859 * |
859 * |
860 * When the Sdo request is created, the data size is set to the size of the |
860 * When the SDO request is created, the data size is set to the size of the |
861 * reserved memory. After a read operation the size is set to the size of the |
861 * reserved memory. After a read operation the size is set to the size of the |
862 * read data. The size is not modified in any other situation. |
862 * read data. The size is not modified in any other situation. |
863 * |
863 * |
864 * \return Sdo data size in bytes. |
864 * \return SDO data size in bytes. |
865 */ |
865 */ |
866 size_t ecrt_sdo_request_data_size( |
866 size_t ecrt_sdo_request_data_size( |
867 const ec_sdo_request_t *req /**< Sdo request. */ |
867 const ec_sdo_request_t *req /**< SDO request. */ |
868 ); |
868 ); |
869 |
869 |
870 /** Get the current state of the Sdo request. |
870 /** Get the current state of the SDO request. |
871 * |
871 * |
872 * \return Request state. |
872 * \return Request state. |
873 */ |
873 */ |
874 ec_sdo_request_state_t ecrt_sdo_request_state( |
874 ec_sdo_request_state_t ecrt_sdo_request_state( |
875 const ec_sdo_request_t *req /**< Sdo request. */ |
875 const ec_sdo_request_t *req /**< SDO request. */ |
876 ); |
876 ); |
877 |
877 |
878 /** Schedule an Sdo write operation. |
878 /** Schedule an SDO write operation. |
879 * |
879 * |
880 * \attention This method may not be called while ecrt_sdo_request_state() |
880 * \attention This method may not be called while ecrt_sdo_request_state() |
881 * returns EC_SDO_REQUEST_BUSY. |
881 * returns EC_SDO_REQUEST_BUSY. |
882 */ |
882 */ |
883 void ecrt_sdo_request_write( |
883 void ecrt_sdo_request_write( |
884 ec_sdo_request_t *req /**< Sdo request. */ |
884 ec_sdo_request_t *req /**< SDO request. */ |
885 ); |
885 ); |
886 |
886 |
887 /** Schedule an Sdo read operation. |
887 /** Schedule an SDO read operation. |
888 * |
888 * |
889 * \attention This method may not be called while ecrt_sdo_request_state() |
889 * \attention This method may not be called while ecrt_sdo_request_state() |
890 * returns EC_SDO_REQUEST_BUSY. |
890 * returns EC_SDO_REQUEST_BUSY. |
891 * |
891 * |
892 * \attention After calling this function, the return value of |
892 * \attention After calling this function, the return value of |
893 * ecrt_sdo_request_data() must be considered as invalid while |
893 * ecrt_sdo_request_data() must be considered as invalid while |
894 * ecrt_sdo_request_state() returns EC_SDO_REQUEST_BUSY. |
894 * ecrt_sdo_request_state() returns EC_SDO_REQUEST_BUSY. |
895 */ |
895 */ |
896 void ecrt_sdo_request_read( |
896 void ecrt_sdo_request_read( |
897 ec_sdo_request_t *req /**< Sdo request. */ |
897 ec_sdo_request_t *req /**< SDO request. */ |
898 ); |
898 ); |
899 |
899 |
900 /****************************************************************************** |
900 /****************************************************************************** |
901 * Bitwise read/write macros |
901 * Bitwise read/write macros |
902 *****************************************************************************/ |
902 *****************************************************************************/ |