IgH EtherCAT Master  1.5.3
device.h File Reference

EtherCAT device structure. More...

Go to the source code of this file.

Data Structures

struct  ec_device
 EtherCAT device. More...
 

Macros

#define EC_TX_RING_SIZE   2
 Size of the transmit ring. More...
 

Functions

int ec_device_init (ec_device_t *, ec_master_t *)
 Constructor. More...
 
void ec_device_clear (ec_device_t *)
 Destructor.
 
void ec_device_attach (ec_device_t *, struct net_device *, ec_pollfunc_t, struct module *)
 Associate with net_device.
 
void ec_device_detach (ec_device_t *)
 Disconnect from net_device.
 
int ec_device_open (ec_device_t *)
 Opens the EtherCAT device. More...
 
int ec_device_close (ec_device_t *)
 Stops the EtherCAT device. More...
 
void ec_device_poll (ec_device_t *)
 Calls the poll function of the assigned net_device. More...
 
uint8_t * ec_device_tx_data (ec_device_t *)
 Returns a pointer to the device's transmit memory. More...
 
void ec_device_send (ec_device_t *, size_t)
 Sends the content of the transmit socket buffer. More...
 
void ec_device_clear_stats (ec_device_t *)
 Clears the frame statistics.
 
void ec_device_update_stats (ec_device_t *)
 Update device statistics.
 

Detailed Description

EtherCAT device structure.

Definition in file device.h.

Macro Definition Documentation

◆ EC_TX_RING_SIZE

#define EC_TX_RING_SIZE   2

Size of the transmit ring.

This memory ring is used to transmit frames. It is necessary to use different memory regions, because otherwise the network device DMA could send the same data twice, if it is called twice.

Definition at line 51 of file device.h.

Function Documentation

◆ ec_device_init()

int ec_device_init ( ec_device_t device,
ec_master_t master 
)

Constructor.

Returns
0 in case of success, else < 0
Parameters
deviceEtherCAT device
mastermaster owning the device

Definition at line 68 of file device.c.

◆ ec_device_open()

int ec_device_open ( ec_device_t device)

Opens the EtherCAT device.

Returns
0 in case of success, else < 0
Parameters
deviceEtherCAT device

Definition at line 247 of file device.c.

◆ ec_device_close()

int ec_device_close ( ec_device_t device)

Stops the EtherCAT device.

Returns
0 in case of success, else < 0
Parameters
deviceEtherCAT device

Definition at line 284 of file device.c.

◆ ec_device_poll()

void ec_device_poll ( ec_device_t device)

Calls the poll function of the assigned net_device.

The master itself works without using interrupts. Therefore the processing of received data and status changes of the network device has to be done by the master calling the ISR "manually".

Parameters
deviceEtherCAT device

Definition at line 483 of file device.c.

◆ ec_device_tx_data()

uint8_t* ec_device_tx_data ( ec_device_t device)

Returns a pointer to the device's transmit memory.

Returns
pointer to the TX socket buffer
Parameters
deviceEtherCAT device

Definition at line 317 of file device.c.

◆ ec_device_send()

void ec_device_send ( ec_device_t device,
size_t  size 
)

Sends the content of the transmit socket buffer.

Cuts the socket buffer content to the (now known) size, and calls the start_xmit() function of the assigned net_device.

Parameters
deviceEtherCAT device
sizenumber of bytes to send

Definition at line 336 of file device.c.