1 /****************************************************************************** |
1 /****************************************************************************** |
2 * |
2 * |
3 * d e v i c e . c |
|
4 * |
|
5 * EtherCAT device methods. |
|
6 * |
|
7 * $Id$ |
3 * $Id$ |
8 * |
4 * |
|
5 * Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
|
6 * |
|
7 * This file is part of the IgH EtherCAT Master. |
|
8 * |
|
9 * The IgH EtherCAT Master is free software; you can redistribute it |
|
10 * and/or modify it under the terms of the GNU General Public License |
|
11 * as published by the Free Software Foundation; version 2 of the License. |
|
12 * |
|
13 * The IgH EtherCAT Master is distributed in the hope that it will be |
|
14 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
16 * GNU General Public License for more details. |
|
17 * |
|
18 * You should have received a copy of the GNU General Public License |
|
19 * along with the IgH EtherCAT Master; if not, write to the Free Software |
|
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
21 * |
9 *****************************************************************************/ |
22 *****************************************************************************/ |
|
23 |
|
24 /** |
|
25 \file |
|
26 EtherCAT device methods. |
|
27 */ |
|
28 |
|
29 /*****************************************************************************/ |
10 |
30 |
11 #include <linux/module.h> |
31 #include <linux/module.h> |
12 #include <linux/skbuff.h> |
32 #include <linux/skbuff.h> |
13 #include <linux/if_ether.h> |
33 #include <linux/if_ether.h> |
14 #include <linux/netdevice.h> |
34 #include <linux/netdevice.h> |
166 |
186 |
167 /*****************************************************************************/ |
187 /*****************************************************************************/ |
168 |
188 |
169 /** |
189 /** |
170 Calls the interrupt service routine of the assigned net_device. |
190 Calls the interrupt service routine of the assigned net_device. |
|
191 The master itself works without using interrupts. Therefore the processing |
|
192 of received data and status changes of the network device has to be |
|
193 done by the master calling the ISR "manually". |
171 */ |
194 */ |
172 |
195 |
173 void ec_device_call_isr(ec_device_t *device /**< EtherCAT device */) |
196 void ec_device_call_isr(ec_device_t *device /**< EtherCAT device */) |
174 { |
197 { |
175 if (likely(device->isr)) device->isr(0, device->dev, NULL); |
198 if (likely(device->isr)) device->isr(0, device->dev, NULL); |
179 * Device interface |
202 * Device interface |
180 *****************************************************************************/ |
203 *****************************************************************************/ |
181 |
204 |
182 /** |
205 /** |
183 Accepts a received frame. |
206 Accepts a received frame. |
184 Forwards the received data to the master. |
207 Forwards the received data to the master. The master will analyze the frame |
|
208 and dispatch the received commands to the sending instances. |
|
209 \ingroup DeviceInterface |
185 */ |
210 */ |
186 |
211 |
187 void ecdev_receive(ec_device_t *device, /**< EtherCAT device */ |
212 void ecdev_receive(ec_device_t *device, /**< EtherCAT device */ |
188 const void *data, /**< pointer to receibed data */ |
213 const void *data, /**< pointer to receibed data */ |
189 size_t size /**< number of bytes received */ |
214 size_t size /**< number of bytes received */ |
199 |
224 |
200 /*****************************************************************************/ |
225 /*****************************************************************************/ |
201 |
226 |
202 /** |
227 /** |
203 Sets a new link state. |
228 Sets a new link state. |
|
229 If the device notifies the master about the link being down, the master |
|
230 will not try to send frames using this device. |
|
231 \ingroup DeviceInterface |
204 */ |
232 */ |
205 |
233 |
206 void ecdev_link_state(ec_device_t *device, /**< EtherCAT device */ |
234 void ecdev_link_state(ec_device_t *device, /**< EtherCAT device */ |
207 uint8_t state /**< new link state */ |
235 uint8_t state /**< new link state */ |
208 ) |
236 ) |