examples/mini/mini.c
author Florian Pose <fp@igh-essen.com>
Fri, 22 Feb 2008 17:30:50 +0000
changeset 819 76fe396bdeea
parent 818 b6c87ae254c9
child 820 f8e6f5966cce
permissions -rw-r--r--
Re-ordered TODO.
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/******************************************************************************
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  $Id$
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Copyright (C) 2006  Florian Pose, Ingenieurgemeinschaft IgH
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  This file is part of the IgH EtherCAT Master.
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *  The IgH EtherCAT Master is free software; you can redistribute it
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
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: 226
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: 226
diff changeset
    12
 *  License, or (at your option) any later version.
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
 *
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
 *  The IgH EtherCAT Master is distributed in the hope that it will be
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
 *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
 *  GNU General Public License for more details.
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
 *
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
 *  You should have received a copy of the GNU General Public License
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
 *  along with the IgH EtherCAT Master; if not, write to the Free Software
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
 *
246
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 226
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: 226
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: 226
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: 226
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: 226
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: 226
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: 226
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: 226
diff changeset
    30
 *  Technology, IP and trade marks.
0bf7c769de06 Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents: 226
diff changeset
    31
 *
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
 *****************************************************************************/
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
#include <linux/module.h>
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
#include <linux/timer.h>
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
#include <linux/spinlock.h>
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
#include <linux/interrupt.h>
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
223
daa5e5656b35 Applied new path information to example modules.
Florian Pose <fp@igh-essen.com>
parents: 220
diff changeset
    39
#include "../../include/ecrt.h" // EtherCAT realtime interface
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 280
diff changeset
    40
#include "../../include/ecdb.h" // EtherCAT slave database
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
    42
#define PFX "ec_mini: "
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
    43
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
#define FREQUENCY 100
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    46
#define CONFIGURE_MAPPING
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    47
#define EXTERNAL_MEMORY
457
2b4ba84b6058 Minor changes to minimal example.
Florian Pose <fp@igh-essen.com>
parents: 454
diff changeset
    48
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
/*****************************************************************************/
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
    51
static struct timer_list timer;
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
// EtherCAT
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
    54
static ec_master_t *master = NULL;
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    55
static ec_master_state_t master_state = {};
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    56
spinlock_t master_lock = SPIN_LOCK_UNLOCKED;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    57
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
    58
static ec_domain_t *domain1 = NULL;
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    59
static ec_domain_state_t domain1_state = {};
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    60
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
    61
#ifdef CONFIGURE_MAPPING
793
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    62
const ec_pdo_entry_info_t el3162_channel1[] = {
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    63
    {0x3101, 1,  8}, // status
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    64
    {0x3101, 2, 16}  // value
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    65
};
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    66
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    67
const ec_pdo_entry_info_t el3162_channel2[] = {
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    68
    {0x3102, 1,  8}, // status
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    69
    {0x3102, 2, 16}  // value
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    70
};
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    71
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    72
const ec_pdo_info_t el3162_mapping[] = {
793
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    73
    {EC_DIR_INPUT, 0x1A00, 2, el3162_channel1},
3b297ff8284f Fixed Pdo configuration information providing.
Florian Pose <fp@igh-essen.com>
parents: 792
diff changeset
    74
    {EC_DIR_INPUT, 0x1A01, 2, el3162_channel2},
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
    75
};
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    76
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    77
const ec_pdo_entry_info_t el2004_channels[] = {
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    78
    {0x3001, 1, 1}, // Value 1
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    79
    {0x3001, 2, 1}, // Value 2
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    80
    {0x3001, 3, 1}, // Value 3
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    81
    {0x3001, 4, 1}  // Value 4
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    82
};
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    83
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    84
const ec_pdo_info_t el2004_mapping[] = {
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    85
    {EC_DIR_OUTPUT, 0x1600, 1, &el2004_channels[0]},
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    86
    {EC_DIR_OUTPUT, 0x1601, 1, &el2004_channels[1]},
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    87
    {EC_DIR_OUTPUT, 0x1602, 1, &el2004_channels[2]},
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    88
    {EC_DIR_OUTPUT, 0x1603, 1, &el2004_channels[3]},
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    89
};
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
    90
#endif
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
    91
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    92
static uint8_t *pd; /**< Process data. */
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    93
static unsigned int off_ana_in;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    94
static unsigned int off_dig_out;
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
    95
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
    96
const static ec_pdo_entry_reg_t domain1_regs[] = {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
    97
    {0, 1, Beckhoff_EL3162, 0x3101, 2, &off_ana_in},
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
    98
    {0, 3, Beckhoff_EL2004, 0x3001, 1, &off_dig_out},
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    99
    {}
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   100
};
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   101
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   102
/*****************************************************************************/
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   103
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   104
void check_domain1_state(void)
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   105
{
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   106
    ec_domain_state_t ds;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   107
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   108
    ecrt_domain_state(domain1, &ds);
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   109
    if (ds.working_counter != domain1_state.working_counter)
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   110
        printk(KERN_INFO PFX "domain1 working_counter changed to %u.\n",
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   111
                ds.working_counter);
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   112
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   113
    if (ds.wc_state != domain1_state.wc_state)
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   114
        printk(KERN_INFO PFX "domain1 wc_state changed to %u.\n",
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   115
                ds.wc_state);
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   116
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   117
    domain1_state = ds;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   118
}
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   119
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   120
/*****************************************************************************/
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   121
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   122
void check_master_state(void)
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   123
{
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   124
    ec_master_state_t ms;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   125
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   126
    spin_lock(&master_lock);
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   127
    ecrt_master_state(master, &ms);
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   128
    spin_unlock(&master_lock);
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   129
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   130
    if (ms.bus_state != master_state.bus_state) {
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   131
        printk(KERN_INFO PFX "bus state changed to %i.\n", ms.bus_state);
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   132
    }
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   133
    if (ms.bus_tainted != master_state.bus_tainted) {
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   134
        printk(KERN_INFO PFX "tainted flag changed to %u.\n",
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   135
                ms.bus_tainted);
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   136
    }
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   137
    if (ms.slaves_responding != master_state.slaves_responding) {
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   138
        printk(KERN_INFO PFX "slaves_responding changed to %u.\n",
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   139
                ms.slaves_responding);
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   140
    }
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   141
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   142
    master_state = ms;
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   143
}
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   144
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   145
/*****************************************************************************/
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   146
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   147
void run(unsigned long data)
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   148
{
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   149
    static unsigned int counter = 0;
512
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   150
    static unsigned int blink = 0;
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   151
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   152
    // receive process data
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   153
    spin_lock(&master_lock);
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 280
diff changeset
   154
    ecrt_master_receive(master);
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   155
    ecrt_domain_process(domain1);
512
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   156
    spin_unlock(&master_lock);
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   157
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   158
    // check process data state (optional)
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   159
    check_domain1_state();
512
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   160
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   161
    if (counter) {
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   162
        counter--;
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   163
    } else { // do this at FREQUENCY
512
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   164
        counter = FREQUENCY;
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   165
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   166
        // calculate new process data
512
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   167
        blink = !blink;
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   168
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   169
        // check for master state (optional)
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   170
        check_master_state();
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   171
    }
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   172
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   173
    // write process data
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   174
    EC_WRITE_U8(pd + off_dig_out, blink ? 0x0F : 0x00);
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   175
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   176
    // send process data
512
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   177
    spin_lock(&master_lock);
509
87baea61d0c7 Adjusted examples to 1.2.0 interface changes.
Florian Pose <fp@igh-essen.com>
parents: 472
diff changeset
   178
    ecrt_domain_queue(domain1);
325
7833cf70c4f2 VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents: 280
diff changeset
   179
    ecrt_master_send(master);
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   180
    spin_unlock(&master_lock);
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   181
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   182
    // restart timer
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   183
    timer.expires += HZ / FREQUENCY;
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   184
    add_timer(&timer);
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   185
}
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   186
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   187
/*****************************************************************************/
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   188
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   189
int request_lock(void *data)
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   190
{
516
f703e33ee395 Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents: 513
diff changeset
   191
    spin_lock(&master_lock);
226
07247920a7ba EoE with workqueue; bugfix in ec_master_init()
Florian Pose <fp@igh-essen.com>
parents: 223
diff changeset
   192
    return 0; // access allowed
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   193
}
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   194
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   195
/*****************************************************************************/
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   196
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   197
void release_lock(void *data)
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   198
{
516
f703e33ee395 Adjusted examples to EtherLab starter kit hardware.
Florian Pose <fp@igh-essen.com>
parents: 513
diff changeset
   199
    spin_unlock(&master_lock);
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   200
}
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   201
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   202
/*****************************************************************************/
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   203
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   204
int __init init_mini_module(void)
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   205
{
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   206
#ifdef CONFIGURE_MAPPING
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   207
    ec_slave_config_t *sc;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   208
#endif
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   209
#ifdef EXTERNAL_MEMORY
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   210
    unsigned int size;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   211
#endif
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   212
    
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   213
    printk(KERN_INFO PFX "Starting...\n");
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   214
509
87baea61d0c7 Adjusted examples to 1.2.0 interface changes.
Florian Pose <fp@igh-essen.com>
parents: 472
diff changeset
   215
    if (!(master = ecrt_request_master(0))) {
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   216
        printk(KERN_ERR PFX "Requesting master 0 failed!\n");
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   217
        goto out_return;
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   218
    }
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   219
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   220
    ecrt_master_callbacks(master, request_lock, release_lock, NULL);
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   221
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   222
    printk(KERN_INFO PFX "Registering domain...\n");
509
87baea61d0c7 Adjusted examples to 1.2.0 interface changes.
Florian Pose <fp@igh-essen.com>
parents: 472
diff changeset
   223
    if (!(domain1 = ecrt_master_create_domain(master))) {
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   224
        printk(KERN_ERR PFX "Domain creation failed!\n");
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   225
        goto out_release_master;
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   226
    }
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   227
818
b6c87ae254c9 Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents: 814
diff changeset
   228
#ifdef CONFIGURE_MAPPING
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   229
    printk(KERN_INFO PFX "Configuring Pdo mapping...\n");
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   230
    if (!(sc = ecrt_master_slave_config(master, 0, 1, Beckhoff_EL3162))) {
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   231
        printk(KERN_ERR PFX "Failed to get slave configuration.\n");
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   232
        goto out_release_master;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   233
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   234
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   235
    if (ecrt_slave_config_mapping(sc, 2, el3162_mapping)) {
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   236
        printk(KERN_ERR PFX "Failed to configure Pdo mapping.\n");
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   237
        goto out_release_master;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   238
    }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   239
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   240
    if (!(sc = ecrt_master_slave_config(master, 0, 3, Beckhoff_EL2004))) {
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   241
        printk(KERN_ERR PFX "Failed to get slave configuration.\n");
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   242
        goto out_release_master;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   243
    }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   244
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   245
    if (ecrt_slave_config_mapping(sc, 4, el2004_mapping)) {
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   246
        printk(KERN_ERR PFX "Failed to configure Pdo mapping.\n");
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   247
        goto out_release_master;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   248
    }
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   249
#endif
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   250
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   251
    printk(KERN_INFO PFX "Registering Pdo entries...\n");
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   252
    if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
814
a51f857b1b2d Renamed [PS]DO to [PS]do.
Florian Pose <fp@igh-essen.com>
parents: 809
diff changeset
   253
        printk(KERN_ERR PFX "Pdo entry registration failed!\n");
792
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   254
        goto out_release_master;
3778920f61e4 Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents: 654
diff changeset
   255
    }
635
d304ef4af542 Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents: 612
diff changeset
   256
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   257
#ifdef EXTERNAL_MEMORY
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   258
    if ((size = ecrt_domain_size(domain1))) {
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   259
        if (!(pd = (uint8_t *) kmalloc(size, GFP_KERNEL))) {
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   260
            printk(KERN_ERR PFX "Failed to allocate %u bytes of process data"
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   261
                    " memory!\n", size);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   262
            goto out_release_master;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   263
        }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   264
        ecrt_domain_external_memory(domain1, pd);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   265
    }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   266
#endif
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   267
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   268
    printk(KERN_INFO PFX "Activating master...\n");
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   269
    if (ecrt_master_activate(master)) {
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   270
        printk(KERN_ERR PFX "Failed to activate master!\n");
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   271
#ifdef EXTERNAL_MEMORY
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   272
        goto out_free_process_data;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   273
#else
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   274
        goto out_release_master;
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   275
#endif
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   276
    }
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   277
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   278
#ifndef EXTERNAL_MEMORY
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   279
    // Get internal process data for domain
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   280
    pd = ecrt_domain_data(domain1);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   281
#endif
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   282
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   283
    printk(KERN_INFO PFX "Starting cyclic sample thread.\n");
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   284
    init_timer(&timer);
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   285
    timer.function = run;
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   286
    timer.expires = jiffies + 10;
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   287
    add_timer(&timer);
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   288
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   289
    printk(KERN_INFO PFX "Started.\n");
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   290
    return 0;
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   291
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   292
#ifdef EXTERNAL_MEMORY
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   293
out_free_process_data:
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   294
    kfree(pd);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   295
#endif
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   296
out_release_master:
654
8278e1e27010 Minor changes in minimal example.
Florian Pose <fp@igh-essen.com>
parents: 643
diff changeset
   297
    printk(KERN_ERR PFX "Releasing master...\n");
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   298
    ecrt_release_master(master);
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   299
out_return:
654
8278e1e27010 Minor changes in minimal example.
Florian Pose <fp@igh-essen.com>
parents: 643
diff changeset
   300
    printk(KERN_ERR PFX "Failed to load. Aborting.\n");
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   301
    return -1;
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   302
}
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   303
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   304
/*****************************************************************************/
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   305
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   306
void __exit cleanup_mini_module(void)
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   307
{
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   308
    printk(KERN_INFO PFX "Stopping...\n");
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   309
449
3caf8ff4d8a2 Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
   310
    del_timer_sync(&timer);
809
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   311
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   312
#ifdef EXTERNAL_MEMORY
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   313
    kfree(pd);
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   314
#endif
ec4ef8911824 External domain memory.
Florian Pose <fp@igh-essen.com>
parents: 799
diff changeset
   315
612
aede068f9a74 Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents: 551
diff changeset
   316
    printk(KERN_INFO PFX "Releasing master...\n");
449
3caf8ff4d8a2 Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents: 446
diff changeset
   317
    ecrt_release_master(master);
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   318
654
8278e1e27010 Minor changes in minimal example.
Florian Pose <fp@igh-essen.com>
parents: 643
diff changeset
   319
    printk(KERN_INFO PFX "Unloading.\n");
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   320
}
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   321
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   322
/*****************************************************************************/
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   323
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   324
MODULE_LICENSE("GPL");
512
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   325
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>");
24292123d174 Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents: 509
diff changeset
   326
MODULE_DESCRIPTION("EtherCAT minimal test environment");
220
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   327
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   328
module_init(init_mini_module);
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   329
module_exit(cleanup_mini_module);
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   330
342ad851ec78 Added examples directory.
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   331
/*****************************************************************************/