IgH EtherCAT Master  1.5.3
device.c File Reference

EtherCAT device methods. More...

Go to the source code of this file.

Enumerations

enum  { EXTRA_HEADROOM = 64 }
 

Functions

int ec_device_init (ec_device_t *device, ec_master_t *master)
 Constructor. More...
 
void ec_device_clear (ec_device_t *device)
 Destructor. More...
 
void ec_device_attach (ec_device_t *device, struct net_device *net_dev, ec_pollfunc_t poll, struct module *module)
 Associate with net_device. More...
 
void ec_device_detach (ec_device_t *device)
 Disconnect from net_device. More...
 
int ec_device_open (ec_device_t *device)
 Opens the EtherCAT device. More...
 
int ec_device_close (ec_device_t *device)
 Stops the EtherCAT device. More...
 
uint8_t * ec_device_tx_data (ec_device_t *device)
 Returns a pointer to the device's transmit memory. More...
 
void ec_device_send (ec_device_t *device, size_t size)
 Sends the content of the transmit socket buffer. More...
 
void ec_device_clear_stats (ec_device_t *device)
 Clears the frame statistics. More...
 
void ec_device_poll (ec_device_t *device)
 Calls the poll function of the assigned net_device. More...
 
void ec_device_update_stats (ec_device_t *device)
 Update device statistics. More...
 
void ecdev_withdraw (ec_device_t *device)
 Withdraws an EtherCAT device from the master. More...
 
int ecdev_open (ec_device_t *device)
 Opens the network device and makes the master enter IDLE phase. More...
 
void ecdev_close (ec_device_t *device)
 Makes the master leave IDLE phase and closes the network device. More...
 
void ecdev_receive (ec_device_t *device, const void *data, size_t size)
 Accepts a received frame. More...
 
void ecdev_set_link (ec_device_t *device, uint8_t state)
 Sets a new link state. More...
 
uint8_t ecdev_get_link (const ec_device_t *device)
 Reads the link state. More...
 

Detailed Description

EtherCAT device methods.

Definition in file device.c.

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_clear()

void ec_device_clear ( ec_device_t device)

Destructor.

Parameters
deviceEtherCAT device

Definition at line 167 of file device.c.

◆ ec_device_attach()

void ec_device_attach ( ec_device_t device,
struct net_device *  net_dev,
ec_pollfunc_t  poll,
struct module *  module 
)

Associate with net_device.

Parameters
deviceEtherCAT device
net_devnet_device structure
pollpointer to device's poll function
modulethe device's module

Definition at line 187 of file device.c.

◆ ec_device_detach()

void ec_device_detach ( ec_device_t device)

Disconnect from net_device.

Parameters
deviceEtherCAT device

Definition at line 218 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_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.

◆ ec_device_clear_stats()

void ec_device_clear_stats ( ec_device_t device)

Clears the frame statistics.

Parameters
deviceEtherCAT device

Definition at line 379 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_update_stats()

void ec_device_update_stats ( ec_device_t device)

Update device statistics.

Parameters
deviceEtherCAT device

Definition at line 501 of file device.c.