40#ifndef LIBETHERCAT_HW_H
41#define LIBETHERCAT_HW_H
43#include <libosal/task.h>
44#include <libosal/types.h>
45#include <libosal/mutex.h>
48#include <libethercat/config.h>
54#if LIBETHERCAT_BUILD_DEVICE_PIKEOS == 1
55#include <vm_file_types.h>
56#include <drv/sbuf_hdr.h>
59#define container_of(ptr, type, member) ({ \
60 __typeof__( ((type *)0)->member ) *__mptr = (void *)(ptr); \
61 (type *)( (char *)__mptr - offsetof(type,member) );})
70#define ETH_P_ECAT ((osal_uint16_t)0x88A4u)
123#define ETH_FRAME_LEN 0x1518
147 osal_uint64_t last_tx_duration_ns;
148 osal_uint64_t last_rx_duration_ns;
void hw_process_rx_frame(struct hw_common *phw, ec_frame_t *pframe)
Process a received EtherCAT frame.
int hw_tx_high(struct hw_common *phw)
start sending queued ethercat datagrams
int(* hw_device_get_tx_buffer_t)(struct hw_common *phw, ec_frame_t **ppframe)
Get a free tx buffer from underlying hw device.
Definition hw.h:113
int hw_tx(struct hw_common *phw)
start sending queued ethercat datagrams
int hw_tx_low(struct hw_common *phw)
start sending queued ethercat datagrams
int hw_close(struct hw_common *phw)
destroys a hw
int(* hw_device_send_t)(struct hw_common *phw, ec_frame_t *pframe, pooltype_t pool_type)
Send a frame from an EtherCAT hw device.
Definition hw.h:98
pooltype
Flag to distinguish the pool types during processing.
Definition hw.h:77
int(* hw_device_close_t)(struct hw_common *phw)
Close hardware layer.
Definition hw.h:121
enum pooltype pooltype_t
Flag to distinguish the pool types during processing.
void(* hw_device_send_finished_t)(struct hw_common *phw)
Doing internal stuff when finished sending frames.
Definition hw.h:104
int hw_open(struct hw_common *phw, struct ec *pec)
open a new hw
struct hw_common hw_common_t
hardware structure
int(* hw_device_recv_t)(struct hw_common *phw)
Receive a frame from an EtherCAT hw device.
Definition hw.h:88
Data pool implementation.
ethercat master structure
Definition ec.h:188
struct hw_common * phw
pointer to hardware interface
Definition ec.h:189
hardware structure
Definition hw.h:126
pool_entry_t * tx_send[256]
sent datagrams
Definition hw.h:135
pool_t tx_low
low priority datagrams
Definition hw.h:133
osal_mutex_t hw_lock
transmit lock
Definition hw.h:130
hw_device_send_t send
Function to send frames via device.
Definition hw.h:142
osal_uint32_t mtu_size
mtu size
Definition hw.h:129
osal_size_t bytes_last_sent
Bytes last sent.
Definition hw.h:138
osal_timer_t next_cylce_start
Next cycle start time.
Definition hw.h:139
hw_device_close_t close
Function to close hw layer.
Definition hw.h:145
pool_t tx_high
high priority datagrams
Definition hw.h:132
struct ec * pec
Pointer to EtherCAT master structure.
Definition hw.h:127
osal_size_t bytes_sent
Bytes currently sent.
Definition hw.h:137
hw_device_get_tx_buffer_t get_tx_buffer
Function to retreave next TX buffer.
Definition hw.h:144
hw_device_recv_t recv
\biref Function to receive frame from device.
Definition hw.h:141
hw_device_send_finished_t send_finished
Function to be called after frames were sent.
Definition hw.h:143
Pool queue entry.
Definition pool.h:67
the datagram pool itself
Definition pool.h:81