libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
Loading...
Searching...
No Matches
hw.h
Go to the documentation of this file.
1
12/*
13 * This file is part of libethercat.
14 *
15 * libethercat is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 3 of the License, or (at your option) any later version.
19 *
20 * libethercat is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with libethercat (LICENSE.LGPL-V3); if not, write
27 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
28 * Floor, Boston, MA 02110-1301, USA.
29 *
30 * Please note that the use of the EtherCAT technology, the EtherCAT
31 * brand name and the EtherCAT logo is only permitted if the property
32 * rights of Beckhoff Automation GmbH are observed. For further
33 * information please contact Beckhoff Automation GmbH & Co. KG,
34 * Hülshorstweg 20, D-33415 Verl, Germany (www.beckhoff.com) or the
35 * EtherCAT Technology Group, Ostendstraße 196, D-90482 Nuremberg,
36 * Germany (ETG, www.ethercat.org).
37 *
38 */
39
40#ifndef LIBETHERCAT_HW_H
41#define LIBETHERCAT_HW_H
42
43#include <libosal/task.h>
44#include <libosal/types.h>
45#include <libosal/mutex.h>
46
47#include <libethercat/config.h>
48#include <libethercat/pool.h>
50
51#if LIBETHERCAT_BUILD_DEVICE_PIKEOS == 1
52#include <vm_file_types.h>
53#include <drv/sbuf_hdr.h>
54#endif
55
56#define container_of(ptr, type, member) ({ \
57 __typeof__( ((type *)0)->member ) *__mptr = (void *)(ptr); \
58 (type *)( (char *)__mptr - offsetof(type,member) );})
59
67#define ETH_P_ECAT (0x88A4)
68
69// forward decl
70struct ec;
71struct hw_common;
72
74typedef enum pooltype {
75 POOL_HIGH,
76 POOL_LOW,
78 //
80
85typedef int (*hw_device_recv_t)(struct hw_common *phw);
86
88
95typedef int (*hw_device_send_t)(struct hw_common *phw, ec_frame_t *pframe, pooltype_t pool_type);
96
98
101typedef void (*hw_device_send_finished_t)(struct hw_common *phw);
102
104
110typedef int (*hw_device_get_tx_buffer_t)(struct hw_common *phw, ec_frame_t **ppframe);
111
113
118typedef int (*hw_device_close_t)(struct hw_common *phw);
119
120#define ETH_FRAME_LEN 0x1518
121
144
145#ifdef __cplusplus
146extern "C" {
147#endif
148
150
156int hw_open(struct hw_common *phw, struct ec *pec);
157
159
163int hw_close(struct hw_common *phw);
164
166
171
173
177int hw_tx(struct hw_common *phw);
178
180
185
186#ifdef __cplusplus
187}
188#endif
189
192#endif // LIBETHERCAT_HW_H
193
ethercat datagram
void hw_process_rx_frame(struct hw_common *phw, ec_frame_t *pframe)
Process a received EtherCAT frame.
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:110
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:95
pooltype
Flag to distinguish the pool types during processing.
Definition hw.h:74
int(* hw_device_close_t)(struct hw_common *phw)
Close hardware layer.
Definition hw.h:118
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:101
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:85
Data pool implementation.
Definition datagram.h:60
ethercat master structure
Definition ec.h:188
struct hw_common * phw
pointer to hardware interface
Definition ec.h:189
hardware structure
Definition hw.h:123
pool_entry_t * tx_send[256]
sent datagrams
Definition hw.h:132
pool_t tx_low
low priority datagrams
Definition hw.h:130
osal_mutex_t hw_lock
transmit lock
Definition hw.h:127
hw_device_send_t send
Function to send frames via device.
Definition hw.h:139
osal_uint32_t mtu_size
mtu size
Definition hw.h:126
osal_size_t bytes_last_sent
Bytes last sent.
Definition hw.h:135
osal_timer_t next_cylce_start
Next cycle start time.
Definition hw.h:136
hw_device_close_t close
Function to close hw layer.
Definition hw.h:142
pool_t tx_high
high priority datagrams
Definition hw.h:129
struct ec * pec
Pointer to EtherCAT master structure.
Definition hw.h:124
osal_size_t bytes_sent
Bytes currently sent.
Definition hw.h:134
hw_device_get_tx_buffer_t get_tx_buffer
Function to retreave next TX buffer.
Definition hw.h:141
hw_device_recv_t recv
\biref Function to receive frame from device.
Definition hw.h:138
hw_device_send_finished_t send_finished
Function to be called after frames were sent.
Definition hw.h:140
Pool queue entry.
Definition pool.h:67
the datagram pool itself
Definition pool.h:81