|
IgH EtherCAT Master
1.6.0
|
Interface to interact with the EtherCAT master with real time contraints. More...
Functions | |
| EC_PUBLIC_API int | ecrt_master_send (ec_master_t *master) |
| Sends all datagrams in the queue. More... | |
| EC_PUBLIC_API int | ecrt_master_receive (ec_master_t *master) |
| Fetches received frames from the hardware and processes the datagrams. More... | |
| EC_PUBLIC_API int | ecrt_master_application_time (ec_master_t *master, uint64_t app_time) |
| Sets the application time. More... | |
| EC_PUBLIC_API int | ecrt_master_sync_reference_clock (ec_master_t *master) |
| Queues the DC reference clock drift compensation datagram for sending. More... | |
| EC_PUBLIC_API int | ecrt_master_sync_reference_clock_to (ec_master_t *master, uint64_t sync_time) |
| Queues the DC reference clock drift compensation datagram for sending. More... | |
| EC_PUBLIC_API int | ecrt_master_sync_slave_clocks (ec_master_t *master) |
| Queues the DC clock drift compensation datagram for sending. More... | |
| EC_PUBLIC_API int | ecrt_master_sync_monitor_queue (ec_master_t *master) |
| Queues the DC synchrony monitoring datagram for sending. More... | |
| EC_PUBLIC_API uint32_t | ecrt_master_sync_monitor_process (const ec_master_t *master) |
| Processes the DC synchrony monitoring datagram. More... | |
| EC_PUBLIC_API int | ecrt_master_reset (ec_master_t *master) |
| Retry configuring slaves. More... | |
| EC_PUBLIC_API int | ecrt_slave_config_emerg_pop (ec_slave_config_t *sc, uint8_t *target) |
| Read and remove one record from the CoE emergency ring buffer. More... | |
| EC_PUBLIC_API int | ecrt_slave_config_emerg_clear (ec_slave_config_t *sc) |
| Clears CoE emergency ring buffer and the overrun counter. More... | |
| EC_PUBLIC_API int | ecrt_slave_config_emerg_overruns (const ec_slave_config_t *sc) |
| Read the number of CoE emergency overruns. More... | |
| EC_PUBLIC_API int | ecrt_slave_config_state (const ec_slave_config_t *sc, ec_slave_config_state_t *state) |
| Outputs the state of the slave configuration. More... | |
| EC_PUBLIC_API int | ecrt_domain_process (ec_domain_t *domain) |
| Determines the states of the domain's datagrams. More... | |
| EC_PUBLIC_API int | ecrt_domain_queue (ec_domain_t *domain) |
| (Re-)queues all domain datagrams in the master's datagram queue. More... | |
| EC_PUBLIC_API int | ecrt_domain_state (const ec_domain_t *domain, ec_domain_state_t *state) |
| Reads the state of a domain. More... | |
| EC_PUBLIC_API int | ecrt_sdo_request_index (ec_sdo_request_t *req, uint16_t index, uint8_t subindex) |
| Set the SDO index and subindex. More... | |
| EC_PUBLIC_API uint8_t * | ecrt_sdo_request_data (const ec_sdo_request_t *req) |
| Access to the SDO request's data. More... | |
| EC_PUBLIC_API size_t | ecrt_sdo_request_data_size (const ec_sdo_request_t *req) |
| Returns the current SDO data size. More... | |
| ec_request_state_t | ecrt_sdo_request_state (const ec_sdo_request_t *req) |
| Get the current state of the SDO request. More... | |
| EC_PUBLIC_API int | ecrt_sdo_request_write (ec_sdo_request_t *req) |
| Schedule an SDO write operation. More... | |
| EC_PUBLIC_API int | ecrt_sdo_request_read (ec_sdo_request_t *req) |
| Schedule an SDO read operation. More... | |
| EC_PUBLIC_API int | ecrt_soe_request_idn (ec_soe_request_t *req, uint8_t drive_no, uint16_t idn) |
| Set the request's drive and Sercos ID numbers. More... | |
| EC_PUBLIC_API uint8_t * | ecrt_soe_request_data (const ec_soe_request_t *req) |
| Access to the SoE request's data. More... | |
| EC_PUBLIC_API ec_request_state_t | ecrt_soe_request_state (const ec_soe_request_t *req) |
| Get the current state of the SoE request. More... | |
| EC_PUBLIC_API int | ecrt_soe_request_write (ec_soe_request_t *req) |
| Schedule an SoE IDN write operation. More... | |
| EC_PUBLIC_API int | ecrt_soe_request_read (ec_soe_request_t *req) |
| Schedule an SoE IDN read operation. More... | |
| EC_PUBLIC_API int | ecrt_voe_handler_send_header (ec_voe_handler_t *voe, uint32_t vendor_id, uint16_t vendor_type) |
| Sets the VoE header for future send operations. More... | |
| EC_PUBLIC_API int | ecrt_voe_handler_received_header (const ec_voe_handler_t *voe, uint32_t *vendor_id, uint16_t *vendor_type) |
| Reads the header data of a received VoE message. More... | |
| EC_PUBLIC_API int | ecrt_voe_handler_write (ec_voe_handler_t *voe, size_t size) |
| Start a VoE write operation. More... | |
| EC_PUBLIC_API int | ecrt_voe_handler_read (ec_voe_handler_t *voe) |
| Start a VoE read operation. More... | |
| EC_PUBLIC_API int | ecrt_voe_handler_read_nosync (ec_voe_handler_t *voe) |
| Start a VoE read operation without querying the sync manager status. More... | |
| EC_PUBLIC_API ec_request_state_t | ecrt_voe_handler_execute (ec_voe_handler_t *voe) |
| Execute the handler. More... | |
| EC_PUBLIC_API uint8_t * | ecrt_reg_request_data (const ec_reg_request_t *req) |
| Access to the register request's data. More... | |
| ec_request_state_t | ecrt_reg_request_state (const ec_reg_request_t *req) |
| Get the current state of the register request. More... | |
| EC_PUBLIC_API int | ecrt_reg_request_write (ec_reg_request_t *req, uint16_t address, size_t size) |
| Schedule an register write operation. More... | |
| EC_PUBLIC_API int | ecrt_reg_request_read (ec_reg_request_t *req, uint16_t address, size_t size) |
| Schedule a register read operation. More... | |
Interface to interact with the EtherCAT master with real time contraints.
After configuring the EtherCAT master, the application switches to the operational mode by calling ecrt_master_activate(). In operational mode, do not call other methods than these listed in this group. Many of the methods in EtherCAT Configuration Interface are blocking, calling these in operational mode will result in a deadlock.
| EC_PUBLIC_API int ecrt_master_send | ( | ec_master_t * | master | ) |
Sends all datagrams in the queue.
This method takes all datagrams, that have been queued for transmission, puts them into frames, and passes them to the Ethernet device for sending.
Has to be called cyclically by the application after ecrt_master_activate() has returned.
| master | EtherCAT master. |
| EC_PUBLIC_API int ecrt_master_receive | ( | ec_master_t * | master | ) |
Fetches received frames from the hardware and processes the datagrams.
Queries the network device for received frames by calling the interrupt service routine. Extracts received datagrams and dispatches the results to the datagram objects in the queue. Received datagrams, and the ones that timed out, will be marked, and dequeued.
Has to be called cyclically by the realtime application after ecrt_master_activate() has returned.
| master | EtherCAT master. |
| EC_PUBLIC_API int ecrt_master_application_time | ( | ec_master_t * | master, |
| uint64_t | app_time | ||
| ) |
Sets the application time.
The master has to know the application's time when operating slaves with distributed clocks. The time is not incremented by the master itself, so this method has to be called cyclically.
The time is used when setting the slaves' System Time Offset and Cyclic Operation Start Time registers and when synchronizing the DC reference clock to the application time via ecrt_master_sync_reference_clock().
The time is defined as nanoseconds from 2000-01-01 00:00. Converting an epoch time can be done with the EC_TIMEVAL2NANO() macro, but is not necessary, since the absolute value is not of any interest.
| master | EtherCAT master. |
| app_time | Application time. |
| EC_PUBLIC_API int ecrt_master_sync_reference_clock | ( | ec_master_t * | master | ) |
Queues the DC reference clock drift compensation datagram for sending.
The reference clock will by synchronized to the application time provided by the last call off ecrt_master_application_time().
| 0 | Success. |
| -ENXIO | No reference clock found. |
| master | EtherCAT master. |
| EC_PUBLIC_API int ecrt_master_sync_reference_clock_to | ( | ec_master_t * | master, |
| uint64_t | sync_time | ||
| ) |
Queues the DC reference clock drift compensation datagram for sending.
The reference clock will by synchronized to the time passed in the sync_time parameter.
Has to be called by the application after ecrt_master_activate() has returned.
| 0 | Success. |
| -ENXIO | No reference clock found. |
| master | EtherCAT master. |
| sync_time | Sync reference clock to this time. |
| EC_PUBLIC_API int ecrt_master_sync_slave_clocks | ( | ec_master_t * | master | ) |
Queues the DC clock drift compensation datagram for sending.
All slave clocks synchronized to the reference clock.
Has to be called by the application after ecrt_master_activate() has returned.
| 0 | Success. |
| -ENXIO | No reference clock found. |
| master | EtherCAT master. |
| EC_PUBLIC_API int ecrt_master_sync_monitor_queue | ( | ec_master_t * | master | ) |
Queues the DC synchrony monitoring datagram for sending.
The datagram broadcast-reads all "System time difference" registers (0x092c) to get an upper estimation of the DC synchrony. The result can be checked with the ecrt_master_sync_monitor_process() method.
| master | EtherCAT master. |
| EC_PUBLIC_API uint32_t ecrt_master_sync_monitor_process | ( | const ec_master_t * | master | ) |
Processes the DC synchrony monitoring datagram.
If the sync monitoring datagram was sent before with ecrt_master_sync_monitor_queue(), the result can be queried with this method.
| master | EtherCAT master. |
| EC_PUBLIC_API int ecrt_master_reset | ( | ec_master_t * | master | ) |
Retry configuring slaves.
Via this method, the application can tell the master to bring all slaves to OP state. In general, this is not necessary, because it is automatically done by the master. But with special slaves, that can be reconfigured by the vendor during runtime, it can be useful.
Calling this method only makes sense in realtime context (after activation), because slaves will not be configured before.
| master | EtherCAT master. |
| EC_PUBLIC_API int ecrt_slave_config_emerg_pop | ( | ec_slave_config_t * | sc, |
| uint8_t * | target | ||
| ) |
Read and remove one record from the CoE emergency ring buffer.
A record consists of 8 bytes:
Byte 0-1: Error code (little endian) Byte 2: Error register Byte 3-7: Data
Calling this method makes only sense in realtime context (after master activation).
| sc | Slave configuration. |
| target | Pointer to target memory (at least EC_COE_EMERGENCY_MSG_SIZE bytes). |
Definition at line 1114 of file slave_config.c.
| EC_PUBLIC_API int ecrt_slave_config_emerg_clear | ( | ec_slave_config_t * | sc | ) |
Clears CoE emergency ring buffer and the overrun counter.
Calling this method makes only sense in realtime context (after master activation).
| sc | Slave configuration. |
Definition at line 1121 of file slave_config.c.
| EC_PUBLIC_API int ecrt_slave_config_emerg_overruns | ( | const ec_slave_config_t * | sc | ) |
Read the number of CoE emergency overruns.
The overrun counter will be incremented when a CoE emergency message could not be stored in the ring buffer and had to be dropped. Call ecrt_slave_config_emerg_clear() to reset the counter.
Calling this method makes only sense in realtime context (after master activation).
| sc | Slave configuration. |
Definition at line 1128 of file slave_config.c.
| EC_PUBLIC_API int ecrt_slave_config_state | ( | const ec_slave_config_t * | sc, |
| ec_slave_config_state_t * | state | ||
| ) |
Outputs the state of the slave configuration.
Stores the state information in the given state structure. The state information is updated by the master state machine, so it may take a few cycles, until it changes.
This method is meant to be called in realtime context (after master activation).
| sc | Slave configuration |
| state | State object to write to. |
Definition at line 1324 of file slave_config.c.
| EC_PUBLIC_API int ecrt_domain_process | ( | ec_domain_t * | domain | ) |
Determines the states of the domain's datagrams.
Evaluates the working counters of the received datagrams and outputs statistics, if necessary. This must be called after ecrt_master_receive() is expected to receive the domain datagrams in order to make ecrt_domain_state() return the result of the last process data exchange.
| domain | Domain. |
| EC_PUBLIC_API int ecrt_domain_queue | ( | ec_domain_t * | domain | ) |
(Re-)queues all domain datagrams in the master's datagram queue.
Call this function to mark the domain's datagrams for exchanging at the next call of ecrt_master_send().
| domain | Domain. |
| EC_PUBLIC_API int ecrt_domain_state | ( | const ec_domain_t * | domain, |
| ec_domain_state_t * | state | ||
| ) |
Reads the state of a domain.
Stores the domain state in the given state structure.
Using this method, the process data exchange can be monitored in realtime.
| domain | Domain. |
| state | Pointer to a state object to store the information. |
| EC_PUBLIC_API int ecrt_sdo_request_index | ( | ec_sdo_request_t * | req, |
| uint16_t | index, | ||
| uint8_t | subindex | ||
| ) |
Set the SDO index and subindex.
This method is meant to be called in realtime context (after master activation). To initialize the SDO request, the index and subindex can be set via ecrt_slave_config_create_sdo_request().
| req | SDO request. |
| index | SDO index. |
| subindex | SDO subindex. |
Definition at line 181 of file sdo_request.c.
| EC_PUBLIC_API uint8_t* ecrt_sdo_request_data | ( | const ec_sdo_request_t * | req | ) |
Access to the SDO request's data.
This function returns a pointer to the request's internal SDO data memory.
This method is meant to be called in realtime context (after master activation), but can also be used to initialize data before.
| req | SDO request. |
Definition at line 199 of file sdo_request.c.
| EC_PUBLIC_API size_t ecrt_sdo_request_data_size | ( | const ec_sdo_request_t * | req | ) |
Returns the current SDO data size.
When the SDO request is created, the data size is set to the size of the reserved memory. After a read operation the size is set to the size of the read data. The size is not modified in any other situation.
This method is meant to be called in realtime context (after master activation).
| req | SDO request. |
Definition at line 206 of file sdo_request.c.
| ec_request_state_t ecrt_sdo_request_state | ( | const ec_sdo_request_t * | req | ) |
Get the current state of the SDO request.
The user-space implementation fetches incoming data and stores the received data size in the request object, so the request is not const.
This method is meant to be called in realtime context (after master activation).
| req | SDO request. |
Definition at line 213 of file sdo_request.c.
| EC_PUBLIC_API int ecrt_sdo_request_write | ( | ec_sdo_request_t * | req | ) |
Schedule an SDO write operation.
This method is meant to be called in realtime context (after master activation).
| -EINVAL | Invalid input data, e.g. data size == 0. |
| -ENOBUFS | Reserved memory in ecrt_slave_config_create_sdo_request() too small. |
| req | SDO request. |
Definition at line 232 of file sdo_request.c.
| EC_PUBLIC_API int ecrt_sdo_request_read | ( | ec_sdo_request_t * | req | ) |
Schedule an SDO read operation.
This method is meant to be called in realtime context (after master activation).
| req | SDO request. |
Definition at line 220 of file sdo_request.c.
| EC_PUBLIC_API int ecrt_soe_request_idn | ( | ec_soe_request_t * | req, |
| uint8_t | drive_no, | ||
| uint16_t | idn | ||
| ) |
Set the request's drive and Sercos ID numbers.
This method is meant to be called in realtime context (after master activation). To initialize the SoE request, the drive_no and IDN can be set via ecrt_slave_config_create_soe_request().
| req | IDN request. |
| drive_no | SDO index. |
| idn | SoE IDN. |
Definition at line 268 of file soe_request.c.
| EC_PUBLIC_API uint8_t* ecrt_soe_request_data | ( | const ec_soe_request_t * | req | ) |
Access to the SoE request's data.
This function returns a pointer to the request's internal IDN data memory.
This method is meant to be called in realtime context (after master activation), but can also be used to initialize data before.
| req | SoE request. |
Definition at line 286 of file soe_request.c.
| EC_PUBLIC_API ec_request_state_t ecrt_soe_request_state | ( | const ec_soe_request_t * | req | ) |
Get the current state of the SoE request.
This method is meant to be called in realtime context (after master activation).
In the user-space implementation, the method fetches the size of the incoming data, so the request object is not const.
| req | SoE request. |
Definition at line 300 of file soe_request.c.
| EC_PUBLIC_API int ecrt_soe_request_write | ( | ec_soe_request_t * | req | ) |
Schedule an SoE IDN write operation.
This method is meant to be called in realtime context (after master activation).
| -EINVAL | Invalid input data, e.g. data size == 0. |
| -ENOBUFS | Reserved memory in ecrt_slave_config_create_soe_request() too small. |
| req | SoE request. |
Definition at line 314 of file soe_request.c.
| EC_PUBLIC_API int ecrt_soe_request_read | ( | ec_soe_request_t * | req | ) |
Schedule an SoE IDN read operation.
This method is meant to be called in realtime context (after master activation).
| req | SoE request. |
Definition at line 307 of file soe_request.c.
| EC_PUBLIC_API int ecrt_voe_handler_send_header | ( | ec_voe_handler_t * | voe, |
| uint32_t | vendor_id, | ||
| uint16_t | vendor_type | ||
| ) |
Sets the VoE header for future send operations.
A VoE message shall contain a 4-byte vendor ID, followed by a 2-byte vendor type at as header. These numbers can be set with this function. The values are valid and will be used for future send operations until the next call of this method.
This method is meant to be called in non-realtime context (before master activation) to initialize the header data, but it is also safe to change the header later on in realtime context.
| voe | VoE handler. |
| vendor_id | Vendor ID. |
| vendor_type | Vendor-specific type. |
Definition at line 115 of file voe_handler.c.
| EC_PUBLIC_API int ecrt_voe_handler_received_header | ( | const ec_voe_handler_t * | voe, |
| uint32_t * | vendor_id, | ||
| uint16_t * | vendor_type | ||
| ) |
Reads the header data of a received VoE message.
This method can be used to get the received VoE header information after a read operation has succeeded.
The header information is stored at the memory given by the pointer parameters.
This method is meant to be called in realtime context (after master activation).
| voe | VoE handler. |
| vendor_id | Vendor ID. |
| vendor_type | Vendor-specific type. |
Definition at line 125 of file voe_handler.c.
| EC_PUBLIC_API int ecrt_voe_handler_write | ( | ec_voe_handler_t * | voe, |
| size_t | size | ||
| ) |
Start a VoE write operation.
After this function has been called, the ecrt_voe_handler_execute() method must be called in every realtime cycle as long as it returns EC_REQUEST_BUSY. No other operation may be started while the handler is busy.
This method is meant to be called in realtime context (after master activation).
| -ENOBUFS | Reserved memory in ecrt_slave_config_create_voe_handler too small. |
| voe | VoE handler. |
| size | Number of bytes to write (without the VoE header). |
Definition at line 173 of file voe_handler.c.
| EC_PUBLIC_API int ecrt_voe_handler_read | ( | ec_voe_handler_t * | voe | ) |
Start a VoE read operation.
After this function has been called, the ecrt_voe_handler_execute() method must be called in every realtime cycle as long as it returns EC_REQUEST_BUSY. No other operation may be started while the handler is busy.
The state machine queries the slave's send mailbox for new data to be send to the master. If no data appear within the EC_VOE_RESPONSE_TIMEOUT (defined in master/voe_handler.c), the operation fails.
On success, the size of the read data can be determined via ecrt_voe_handler_data_size(), while the VoE header of the received data can be retrieved with ecrt_voe_handler_received_header().
This method is meant to be called in realtime context (after master activation).
| voe | VoE handler. |
Definition at line 153 of file voe_handler.c.
| EC_PUBLIC_API int ecrt_voe_handler_read_nosync | ( | ec_voe_handler_t * | voe | ) |
Start a VoE read operation without querying the sync manager status.
After this function has been called, the ecrt_voe_handler_execute() method must be called in every realtime cycle as long as it returns EC_REQUEST_BUSY. No other operation may be started while the handler is busy.
The state machine queries the slave by sending an empty mailbox. The slave fills its data to the master in this mailbox. If no data appear within the EC_VOE_RESPONSE_TIMEOUT (defined in master/voe_handler.c), the operation fails.
On success, the size of the read data can be determined via ecrt_voe_handler_data_size(), while the VoE header of the received data can be retrieved with ecrt_voe_handler_received_header().
This method is meant to be called in realtime context (after master activation).
| voe | VoE handler. |
Definition at line 163 of file voe_handler.c.
| EC_PUBLIC_API ec_request_state_t ecrt_voe_handler_execute | ( | ec_voe_handler_t * | voe | ) |
Execute the handler.
This method executes the VoE handler. It has to be called in every realtime cycle as long as it returns EC_REQUEST_BUSY.
This method is meant to be called in realtime context (after master activation).
| voe | VoE handler. |
Definition at line 184 of file voe_handler.c.
| EC_PUBLIC_API uint8_t* ecrt_reg_request_data | ( | const ec_reg_request_t * | req | ) |
Access to the register request's data.
This function returns a pointer to the request's internal memory.
This method is meant to be called in realtime context (after master activation), but can also be used to initialize data before.
| req | Register request. |
Definition at line 78 of file reg_request.c.
| ec_request_state_t ecrt_reg_request_state | ( | const ec_reg_request_t * | req | ) |
Get the current state of the register request.
This method is meant to be called in realtime context (after master activation).
| req | Register request. |
Definition at line 85 of file reg_request.c.
| EC_PUBLIC_API int ecrt_reg_request_write | ( | ec_reg_request_t * | req, |
| uint16_t | address, | ||
| size_t | size | ||
| ) |
Schedule an register write operation.
This method is meant to be called in realtime context (after master activation).
| -ENOBUFS | Reserved memory in ecrt_slave_config_create_reg_request too small. |
| req | Register request. |
| address | Register address. |
| size | Size to write. |
Definition at line 92 of file reg_request.c.
| EC_PUBLIC_API int ecrt_reg_request_read | ( | ec_reg_request_t * | req, |
| uint16_t | address, | ||
| size_t | size | ||
| ) |
Schedule a register read operation.
This method is meant to be called in realtime context (after master activation).
| -ENOBUFS | Reserved memory in ecrt_slave_config_create_reg_request too small. |
| req | Register request. |
| address | Register address. |
| size | Size to write. |
Definition at line 104 of file reg_request.c.