master/device.c
author Florian Pose <fp@igh-essen.com>
Thu, 13 Jul 2006 13:10:57 +0000
branchstable-1.1
changeset 1714 f149465f4c63
parent 246 0bf7c769de06
child 331 17f58fe99511
permissions -rw-r--r--
Created stable-1.1 branch for new interfaces.
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
     1
/******************************************************************************
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
     3
 *  $Id$
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     6
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     8
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    10
 *  and/or modify it under the terms of the GNU General Public License
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    11
 *  as published by the Free Software Foundation; either version 2 of the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    12
 *  License, or (at your option) any later version.
197
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    13
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    17
 *  GNU General Public License for more details.
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    18
 *
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
b9a6e2c22745 GPLv2 License and enhanced Doxygen output.
Florian Pose <fp@igh-essen.com>
parents: 195
diff changeset
    22
 *
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    23
 *  The right to use EtherCAT Technology is granted and comes free of
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    24
 *  charge under condition of compatibility of product made by
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    25
 *  Licensee. People intending to distribute/sell products based on the
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    26
 *  code, have to sign an agreement to guarantee that products using
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    27
 *  software based on IgH EtherCAT master stay compatible with the actual
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    28
 *  EtherCAT specification (which are released themselves as an open
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    29
 *  standard) as the (only) precondition to have the right to use EtherCAT
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    30
 *  Technology, IP and trade marks.
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 231
diff changeset
    31
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    32
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    34
/**
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    35
   \file
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    36
   EtherCAT device methods.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    37
*/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    38
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    39
/*****************************************************************************/
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
    40
24
d417dd9bdc2f Wilhelms ?nderungen ?bernommen.
Florian Pose <fp@igh-essen.com>
parents: 23
diff changeset
    41
#include <linux/module.h>
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
#include <linux/skbuff.h>
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
#include <linux/if_ether.h>
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#include <linux/netdevice.h>
2
b0a7a4745bf9 ?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents: 0
diff changeset
    45
#include <linux/delay.h>
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
    47
#include "device.h"
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    48
#include "master.h"
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    50
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    53
   Device constructor.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    54
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    55
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    56
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    57
int ec_device_init(ec_device_t *device, /**< EtherCAT device */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    58
                   ec_master_t *master, /**< master owning the device */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    59
                   struct net_device *net_dev, /**< net_device structure */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    60
                   ec_isr_t isr, /**< pointer to device's ISR */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    61
                   struct module *module /**< pointer to the owning module */
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    62
                   )
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    63
{
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    64
    struct ethhdr *eth;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    65
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    66
    device->master = master;
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    67
    device->dev = net_dev;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    68
    device->isr = isr;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    69
    device->module = module;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    70
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    71
    device->open = 0;
96
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
    72
    device->link_state = 0; // down
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
    73
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    74
    if (ec_debug_init(&device->dbg)) {
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    75
        EC_ERR("Failed to init debug device!\n");
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    76
        goto out_return;
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    77
    }
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    78
211
c684b6b7adaf Using kernel Ethernet constants.
Florian Pose <fp@igh-essen.com>
parents: 199
diff changeset
    79
    if (!(device->tx_skb = dev_alloc_skb(ETH_FRAME_LEN))) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
    80
        EC_ERR("Error allocating device socket buffer!\n");
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    81
        goto out_debug;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
    82
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
    83
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    84
    device->tx_skb->dev = net_dev;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    85
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    86
    // add Ethernet-II-header
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    87
    skb_reserve(device->tx_skb, ETH_HLEN);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    88
    eth = (struct ethhdr *) skb_push(device->tx_skb, ETH_HLEN);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    89
    eth->h_proto = htons(0x88A4);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    90
    memcpy(eth->h_source, net_dev->dev_addr, net_dev->addr_len);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    91
    memset(eth->h_dest, 0xFF, net_dev->addr_len);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
    92
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
    93
    return 0;
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    94
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    95
 out_debug:
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    96
    ec_debug_clear(&device->dbg);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    97
 out_return:
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
    98
    return -1;
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    99
}
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   100
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   101
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   102
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   103
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   104
   EtherCAT device destuctor.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   105
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   106
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   107
void ec_device_clear(ec_device_t *device /**< EtherCAT device */)
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   108
{
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   109
    if (device->open) ec_device_close(device);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   110
    if (device->tx_skb) dev_kfree_skb(device->tx_skb);
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   111
    ec_debug_clear(&device->dbg);
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   112
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   113
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   114
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   115
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   117
   Opens the EtherCAT device.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   118
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   119
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   120
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   121
int ec_device_open(ec_device_t *device /**< EtherCAT device */)
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   122
{
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   123
    unsigned int i;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   124
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   125
    if (!device->dev) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
   126
        EC_ERR("No net_device to open!\n");
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   127
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   128
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   129
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   130
    if (device->open) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
   131
        EC_WARN("Device already opened!\n");
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   132
        return 0;
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   133
    }
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   134
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   135
    // device could have received frames before
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   136
    for (i = 0; i < 4; i++) ec_device_call_isr(device);
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   137
96
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   138
    device->link_state = 0;
91
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   139
0120d6214948 Code-Dokumentation angepasst.
Florian Pose <fp@igh-essen.com>
parents: 84
diff changeset
   140
    if (device->dev->open(device->dev) == 0) device->open = 1;
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   141
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   142
    return device->open ? 0 : -1;
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   143
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   145
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   148
   Stops the EtherCAT device.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   149
   \return 0 in case of success, else < 0
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   150
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   151
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   152
int ec_device_close(ec_device_t *device /**< EtherCAT device */)
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   153
{
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   154
    if (!device->dev) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
   155
        EC_ERR("No device to close!\n");
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   156
        return -1;
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   157
    }
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   158
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   159
    if (!device->open) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
   160
        EC_WARN("Device already closed!\n");
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   161
        return 0;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   162
    }
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   163
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   164
    if (device->dev->stop(device->dev) == 0) device->open = 0;
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   165
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   166
    return !device->open ? 0 : -1;
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   167
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   168
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   169
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   170
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   171
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   172
   Returns a pointer to the device's transmit memory.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   173
   \return pointer to the TX socket buffer
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   174
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   175
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   176
uint8_t *ec_device_tx_data(ec_device_t *device /**< EtherCAT device */)
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   177
{
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   178
    return device->tx_skb->data + ETH_HLEN;
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   179
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   181
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   184
   Sends the content of the transmit socket buffer.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   185
   Cuts the socket buffer content to the (now known) size, and calls the
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   186
   start_xmit() function of the assigned net_device.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   187
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   188
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   189
void ec_device_send(ec_device_t *device, /**< EtherCAT device */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   190
                    size_t size /**< number of bytes to send */
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   191
                    )
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   192
{
97
e6264685dd7b Link-Down-Verhalten verbessert.
Florian Pose <fp@igh-essen.com>
parents: 96
diff changeset
   193
    if (unlikely(!device->link_state)) // Link down
96
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   194
        return;
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   195
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   196
    // set the right length for the data
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   197
    device->tx_skb->len = ETH_HLEN + size;
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   198
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   199
    if (unlikely(device->master->debug_level > 1)) {
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 97
diff changeset
   200
        EC_DBG("sending frame:\n");
152
9654f3cf588d Plugfest: Globale Debug-Funktionen f?r Frame-Daten.
Florian Pose <fp@igh-essen.com>
parents: 104
diff changeset
   201
        ec_print_data(device->tx_skb->data + ETH_HLEN, size);
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   202
    }
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   203
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   204
    ec_debug_send(&device->dbg, device->tx_skb->data, ETH_HLEN + size);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   205
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   206
    // start sending
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   207
    device->dev->hard_start_xmit(device->tx_skb, device->dev);
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   208
}
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   209
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   210
/*****************************************************************************/
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   211
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   212
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   213
   Calls the interrupt service routine of the assigned net_device.
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   214
   The master itself works without using interrupts. Therefore the processing
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   215
   of received data and status changes of the network device has to be
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   216
   done by the master calling the ISR "manually".
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   217
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   218
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   219
void ec_device_call_isr(ec_device_t *device /**< EtherCAT device */)
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   220
{
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   221
    if (likely(device->isr)) device->isr(0, device->dev, NULL);
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   222
}
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   223
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   224
/******************************************************************************
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   225
 *  Device interface
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   226
 *****************************************************************************/
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   227
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   228
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   229
   Accepts a received frame.
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   230
   Forwards the received data to the master. The master will analyze the frame
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   231
   and dispatch the received commands to the sending instances.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   232
   \ingroup DeviceInterface
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   233
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   234
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   235
void ecdev_receive(ec_device_t *device, /**< EtherCAT device */
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   236
                   const void *data, /**< pointer to received data */
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   237
                   size_t size /**< number of bytes received */
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   238
                   )
73
9f4ea66d89a3 Dynamische FMMU-Konfiguration, zwei Kopieroperationen eingespart, Einr?ckungen angepasst.
Florian Pose <fp@igh-essen.com>
parents: 70
diff changeset
   239
{
78
3d74183d6c6b Frame-Debugging ins Device ausgelagert und verbessert.
Florian Pose <fp@igh-essen.com>
parents: 73
diff changeset
   240
    if (unlikely(device->master->debug_level > 1)) {
84
b4ae98855cea printk durch Makros ersetzt.
Florian Pose <fp@igh-essen.com>
parents: 78
diff changeset
   241
        EC_DBG("Received frame:\n");
231
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   242
        ec_print_data_diff(device->tx_skb->data + ETH_HLEN,
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   243
                           data + ETH_HLEN, size - ETH_HLEN);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   244
    }
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   245
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   246
    ec_debug_send(&device->dbg, data, size);
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   247
767548c75bf3 Added debug interface for network monitors.
Florian Pose <fp@igh-essen.com>
parents: 211
diff changeset
   248
    ec_master_receive(device->master, data + ETH_HLEN, size - ETH_HLEN);
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   249
}
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   250
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   251
/*****************************************************************************/
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   252
96
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   253
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   254
   Sets a new link state.
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   255
   If the device notifies the master about the link being down, the master
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   256
   will not try to send frames using this device.
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   257
   \ingroup DeviceInterface
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   258
*/
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   259
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   260
void ecdev_link_state(ec_device_t *device, /**< EtherCAT device */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   261
                      uint8_t state /**< new link state */
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   262
                      )
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   263
{
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   264
    if (unlikely(!device)) {
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   265
        EC_WARN("ecdev_link_state: no device!\n");
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   266
        return;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   267
    }
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 152
diff changeset
   268
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   269
    if (likely(state != device->link_state)) {
96
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   270
        device->link_state = state;
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   271
        EC_INFO("Link state changed to %s.\n", (state ? "UP" : "DOWN"));
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   272
    }
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   273
}
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   274
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   275
/*****************************************************************************/
080b46eb6e2d Link-State im Device.
Florian Pose <fp@igh-essen.com>
parents: 91
diff changeset
   276
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   277
/** \cond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   278
104
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   279
EXPORT_SYMBOL(ecdev_receive);
052bc82d5442 MERGE branches/async -> trunk (alle Unterschiede ?bernommen)
Florian Pose <fp@igh-essen.com>
parents: 101
diff changeset
   280
EXPORT_SYMBOL(ecdev_link_state);
27
d75ef6b46e33 EtherCAT-Master in eigenes Modul ausgelagert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   281
199
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   282
/** \endcond */
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   283
04ecf40fc2e9 Doxygen added interface modules and file documentation.
Florian Pose <fp@igh-essen.com>
parents: 197
diff changeset
   284
/*****************************************************************************/