author | Edouard Tisserant <edouard.tisserant@gmail.com> |
Fri, 14 Sep 2018 17:59:33 +0200 | |
branch | stable-1.5 |
changeset 2710 | 05359dee3578 |
parent 2696 | 2b072c95b34c |
permissions | -rw-r--r-- |
220 | 1 |
/****************************************************************************** |
2 |
* |
|
3 |
* $Id$ |
|
4 |
* |
|
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
220 | 6 |
* |
7 |
* This file is part of the IgH EtherCAT Master. |
|
8 |
* |
|
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
11 |
* published by the Free Software Foundation. |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
12 |
* |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
16 |
* Public License for more details. |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
17 |
* |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1239
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
220 | 20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
21 |
* |
|
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
226
diff
changeset
|
27 |
* |
220 | 28 |
*****************************************************************************/ |
29 |
||
1501
59990318c95b
Added semaphore header distinction in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
30 |
#include <linux/version.h> |
220 | 31 |
#include <linux/module.h> |
32 |
#include <linux/timer.h> |
|
33 |
#include <linux/interrupt.h> |
|
1239
b50b93faaf3e
Used ERR_PTR() macro for return value of ecrt_request_master().
Florian Pose <fp@igh-essen.com>
parents:
1212
diff
changeset
|
34 |
#include <linux/err.h> |
220 | 35 |
|
1975
8e173dddd183
Improved compiling on 2.6.34 (thanks to Malcolm Lewis).
Florian Pose <fp@igh-essen.com>
parents:
1580
diff
changeset
|
36 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34) |
8e173dddd183
Improved compiling on 2.6.34 (thanks to Malcolm Lewis).
Florian Pose <fp@igh-essen.com>
parents:
1580
diff
changeset
|
37 |
#include <linux/slab.h> |
8e173dddd183
Improved compiling on 2.6.34 (thanks to Malcolm Lewis).
Florian Pose <fp@igh-essen.com>
parents:
1580
diff
changeset
|
38 |
#endif |
8e173dddd183
Improved compiling on 2.6.34 (thanks to Malcolm Lewis).
Florian Pose <fp@igh-essen.com>
parents:
1580
diff
changeset
|
39 |
|
1501
59990318c95b
Added semaphore header distinction in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
40 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) |
59990318c95b
Added semaphore header distinction in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
41 |
#include <linux/semaphore.h> |
59990318c95b
Added semaphore header distinction in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
42 |
#else |
59990318c95b
Added semaphore header distinction in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
43 |
#include <asm/semaphore.h> |
59990318c95b
Added semaphore header distinction in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
44 |
#endif |
59990318c95b
Added semaphore header distinction in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1500
diff
changeset
|
45 |
|
223
daa5e5656b35
Applied new path information to example modules.
Florian Pose <fp@igh-essen.com>
parents:
220
diff
changeset
|
46 |
#include "../../include/ecrt.h" // EtherCAT realtime interface |
220 | 47 |
|
820 | 48 |
/*****************************************************************************/ |
49 |
||
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
50 |
// Module parameters |
220 | 51 |
#define FREQUENCY 100 |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
52 |
|
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
53 |
// Optional features |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
54 |
#define CONFIGURE_PDOS 1 |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
55 |
#define EL3152_ALT_PDOS 0 |
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
56 |
#define EXTERNAL_MEMORY 1 |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
57 |
#define SDO_ACCESS 0 |
1209 | 58 |
#define VOE_ACCESS 0 |
457
2b4ba84b6058
Minor changes to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
454
diff
changeset
|
59 |
|
820 | 60 |
#define PFX "ec_mini: " |
61 |
||
62 |
/*****************************************************************************/ |
|
220 | 63 |
|
64 |
// EtherCAT |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
65 |
static ec_master_t *master = NULL; |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
66 |
static ec_master_state_t master_state = {}; |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
67 |
struct semaphore master_sem; |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
68 |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
69 |
static ec_domain_t *domain1 = NULL; |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
70 |
static ec_domain_state_t domain1_state = {}; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
71 |
|
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
72 |
static ec_slave_config_t *sc_ana_in = NULL; |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
73 |
static ec_slave_config_state_t sc_ana_in_state = {}; |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
74 |
|
1080
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
75 |
// Timer |
820 | 76 |
static struct timer_list timer; |
77 |
||
78 |
/*****************************************************************************/ |
|
79 |
||
80 |
// process data |
|
81 |
static uint8_t *domain1_pd; // process data memory |
|
82 |
||
1212 | 83 |
#define AnaInSlavePos 0, 2 |
84 |
#define AnaOutSlavePos 0, 1 |
|
1080
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
85 |
#define DigOutSlavePos 0, 3 |
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
86 |
|
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
87 |
#define Beckhoff_EL2004 0x00000002, 0x07D43052 |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
88 |
#define Beckhoff_EL3152 0x00000002, 0x0c503052 |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
89 |
#define Beckhoff_EL4102 0x00000002, 0x10063052 |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
90 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
91 |
// offsets for PDO entries |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
92 |
static unsigned int off_ana_in; |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
93 |
static unsigned int off_ana_out; |
820 | 94 |
static unsigned int off_dig_out; |
95 |
||
1080
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
96 |
const static ec_pdo_entry_reg_t domain1_regs[] = { |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
97 |
#if EL3152_ALT_PDOS |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
98 |
{AnaInSlavePos, Beckhoff_EL3152, 0x6401, 1, &off_ana_in}, |
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
99 |
#else |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
100 |
{AnaInSlavePos, Beckhoff_EL3152, 0x3101, 2, &off_ana_in}, |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
101 |
#endif |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
102 |
{AnaOutSlavePos, Beckhoff_EL4102, 0x3001, 1, &off_ana_out}, |
1080
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
103 |
{DigOutSlavePos, Beckhoff_EL2004, 0x3001, 1, &off_dig_out}, |
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
104 |
{} |
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
105 |
}; |
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
106 |
|
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
107 |
static unsigned int counter = 0; |
820 | 108 |
static unsigned int blink = 0; |
109 |
||
110 |
/*****************************************************************************/ |
|
111 |
||
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
112 |
#if CONFIGURE_PDOS |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
113 |
|
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
114 |
// Analog in -------------------------- |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
115 |
|
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
116 |
static ec_pdo_entry_info_t el3152_pdo_entries[] = { |
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
117 |
{0x3101, 1, 8}, // channel 1 status |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
118 |
{0x3101, 2, 16}, // channel 1 value |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
119 |
{0x3102, 1, 8}, // channel 2 status |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
120 |
{0x3102, 2, 16}, // channel 2 value |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
121 |
{0x6401, 1, 16}, // channel 1 value (alt.) |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
122 |
{0x6401, 2, 16} // channel 2 value (alt.) |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
123 |
}; |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
124 |
|
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
125 |
#if EL3152_ALT_PDOS |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
126 |
static ec_pdo_info_t el3152_pdos[] = { |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
127 |
{0x1A10, 2, el3152_pdo_entries + 4}, |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
128 |
}; |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
129 |
|
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
130 |
static ec_sync_info_t el3152_syncs[] = { |
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
131 |
{2, EC_DIR_OUTPUT}, |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
132 |
{3, EC_DIR_INPUT, 1, el3152_pdos}, |
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
133 |
{0xff} |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
134 |
}; |
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
135 |
#else |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
136 |
static ec_pdo_info_t el3152_pdos[] = { |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
137 |
{0x1A00, 2, el3152_pdo_entries}, |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
138 |
{0x1A01, 2, el3152_pdo_entries + 2} |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
139 |
}; |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
140 |
|
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
141 |
static ec_sync_info_t el3152_syncs[] = { |
1061
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
142 |
{2, EC_DIR_OUTPUT}, |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
143 |
{3, EC_DIR_INPUT, 1, el3152_pdos}, |
1061
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
144 |
{0xff} |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
654
diff
changeset
|
145 |
}; |
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
146 |
#endif |
809 | 147 |
|
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
148 |
// Analog out ------------------------- |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
149 |
|
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
150 |
static ec_pdo_entry_info_t el4102_pdo_entries[] = { |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
151 |
{0x3001, 1, 16}, // channel 1 value |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
152 |
{0x3002, 1, 16}, // channel 2 value |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
153 |
}; |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
154 |
|
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
155 |
static ec_pdo_info_t el4102_pdos[] = { |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
156 |
{0x1600, 1, el4102_pdo_entries}, |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
157 |
{0x1601, 1, el4102_pdo_entries + 1} |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
158 |
}; |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
159 |
|
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
160 |
static ec_sync_info_t el4102_syncs[] = { |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
161 |
{2, EC_DIR_OUTPUT, 2, el4102_pdos}, |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
162 |
{3, EC_DIR_INPUT}, |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
163 |
{0xff} |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
164 |
}; |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
165 |
|
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
166 |
// Digital out ------------------------ |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
167 |
|
851
2bb18adcd204
Removed 'const' from Pdo configuration entries.
Florian Pose <fp@igh-essen.com>
parents:
846
diff
changeset
|
168 |
static ec_pdo_entry_info_t el2004_channels[] = { |
809 | 169 |
{0x3001, 1, 1}, // Value 1 |
170 |
{0x3001, 2, 1}, // Value 2 |
|
171 |
{0x3001, 3, 1}, // Value 3 |
|
172 |
{0x3001, 4, 1} // Value 4 |
|
173 |
}; |
|
174 |
||
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
878
diff
changeset
|
175 |
static ec_pdo_info_t el2004_pdos[] = { |
1061
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
176 |
{0x1600, 1, &el2004_channels[0]}, |
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
177 |
{0x1601, 1, &el2004_channels[1]}, |
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
178 |
{0x1602, 1, &el2004_channels[2]}, |
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
179 |
{0x1603, 1, &el2004_channels[3]} |
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
180 |
}; |
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
181 |
|
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
182 |
static ec_sync_info_t el2004_syncs[] = { |
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
183 |
{0, EC_DIR_OUTPUT, 4, el2004_pdos}, |
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
184 |
{1, EC_DIR_INPUT}, |
90c3d75057e4
Adapted minimal example to sync manager configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
1027
diff
changeset
|
185 |
{0xff} |
809 | 186 |
}; |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
654
diff
changeset
|
187 |
#endif |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
654
diff
changeset
|
188 |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
189 |
/*****************************************************************************/ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
190 |
|
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
191 |
#if SDO_ACCESS |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
192 |
static ec_sdo_request_t *sdo; |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
193 |
#endif |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
194 |
|
1209 | 195 |
#if VOE_ACCESS |
196 |
static ec_voe_handler_t *voe; |
|
197 |
#endif |
|
198 |
||
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
199 |
/*****************************************************************************/ |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
200 |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
201 |
void check_domain1_state(void) |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
202 |
{ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
203 |
ec_domain_state_t ds; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
204 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
205 |
down(&master_sem); |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
206 |
ecrt_domain_state(domain1, &ds); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
207 |
up(&master_sem); |
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
208 |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
209 |
if (ds.working_counter != domain1_state.working_counter) |
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
210 |
printk(KERN_INFO PFX "Domain1: WC %u.\n", ds.working_counter); |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
211 |
if (ds.wc_state != domain1_state.wc_state) |
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
212 |
printk(KERN_INFO PFX "Domain1: State %u.\n", ds.wc_state); |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
213 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
214 |
domain1_state = ds; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
215 |
} |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
216 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
217 |
/*****************************************************************************/ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
218 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
219 |
void check_master_state(void) |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
220 |
{ |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
221 |
ec_master_state_t ms; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
222 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
223 |
down(&master_sem); |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
224 |
ecrt_master_state(master, &ms); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
225 |
up(&master_sem); |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
226 |
|
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
227 |
if (ms.slaves_responding != master_state.slaves_responding) |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
228 |
printk(KERN_INFO PFX "%u slave(s).\n", ms.slaves_responding); |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
229 |
if (ms.al_states != master_state.al_states) |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
230 |
printk(KERN_INFO PFX "AL states: 0x%02X.\n", ms.al_states); |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
231 |
if (ms.link_up != master_state.link_up) |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
232 |
printk(KERN_INFO PFX "Link is %s.\n", ms.link_up ? "up" : "down"); |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
233 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
234 |
master_state = ms; |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
235 |
} |
220 | 236 |
|
237 |
/*****************************************************************************/ |
|
238 |
||
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
239 |
void check_slave_config_states(void) |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
240 |
{ |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
241 |
ec_slave_config_state_t s; |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
242 |
|
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
243 |
down(&master_sem); |
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
244 |
ecrt_slave_config_state(sc_ana_in, &s); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
245 |
up(&master_sem); |
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
246 |
|
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
247 |
if (s.al_state != sc_ana_in_state.al_state) |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
248 |
printk(KERN_INFO PFX "AnaIn: State 0x%02X.\n", s.al_state); |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
249 |
if (s.online != sc_ana_in_state.online) |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
250 |
printk(KERN_INFO PFX "AnaIn: %s.\n", s.online ? "online" : "offline"); |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
251 |
if (s.operational != sc_ana_in_state.operational) |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
252 |
printk(KERN_INFO PFX "AnaIn: %soperational.\n", |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
253 |
s.operational ? "" : "Not "); |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
254 |
|
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
255 |
sc_ana_in_state = s; |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
256 |
} |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
257 |
|
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
258 |
/*****************************************************************************/ |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
259 |
|
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
260 |
#if SDO_ACCESS |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
261 |
void read_sdo(void) |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
262 |
{ |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
263 |
switch (ecrt_sdo_request_state(sdo)) { |
1209 | 264 |
case EC_REQUEST_UNUSED: // request was not used yet |
867 | 265 |
ecrt_sdo_request_read(sdo); // trigger first read |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
266 |
break; |
1209 | 267 |
case EC_REQUEST_BUSY: |
861
6e3de145421a
Introduced ec_sdo_request_state_t, making ec_request_t private again;
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
268 |
printk(KERN_INFO PFX "Still busy...\n"); |
6e3de145421a
Introduced ec_sdo_request_state_t, making ec_request_t private again;
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
269 |
break; |
1209 | 270 |
case EC_REQUEST_SUCCESS: |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
271 |
printk(KERN_INFO PFX "SDO value: 0x%04X\n", |
861
6e3de145421a
Introduced ec_sdo_request_state_t, making ec_request_t private again;
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
272 |
EC_READ_U16(ecrt_sdo_request_data(sdo))); |
867 | 273 |
ecrt_sdo_request_read(sdo); // trigger next read |
861
6e3de145421a
Introduced ec_sdo_request_state_t, making ec_request_t private again;
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
274 |
break; |
1209 | 275 |
case EC_REQUEST_ERROR: |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
276 |
printk(KERN_INFO PFX "Failed to read SDO!\n"); |
867 | 277 |
ecrt_sdo_request_read(sdo); // retry reading |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
278 |
break; |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
279 |
} |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
280 |
} |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
281 |
#endif |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
282 |
|
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
283 |
/*****************************************************************************/ |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
284 |
|
1209 | 285 |
#if VOE_ACCESS |
286 |
void read_voe(void) |
|
287 |
{ |
|
288 |
switch (ecrt_voe_handler_execute(voe)) { |
|
289 |
case EC_REQUEST_UNUSED: |
|
290 |
ecrt_voe_handler_read(voe); // trigger first read |
|
291 |
break; |
|
292 |
case EC_REQUEST_BUSY: |
|
293 |
printk(KERN_INFO PFX "VoE read still busy...\n"); |
|
294 |
break; |
|
295 |
case EC_REQUEST_SUCCESS: |
|
296 |
printk(KERN_INFO PFX "VoE received.\n"); |
|
297 |
// get data via ecrt_voe_handler_data(voe) |
|
298 |
ecrt_voe_handler_read(voe); // trigger next read |
|
299 |
break; |
|
300 |
case EC_REQUEST_ERROR: |
|
301 |
printk(KERN_INFO PFX "Failed to read VoE data!\n"); |
|
302 |
ecrt_voe_handler_read(voe); // retry reading |
|
303 |
break; |
|
304 |
} |
|
305 |
} |
|
306 |
#endif |
|
307 |
||
308 |
/*****************************************************************************/ |
|
309 |
||
2696
2b072c95b34c
Applied 0002-use-setup_timer-for-v4.15.patch from Beckhoff.
Florian Pose
parents:
2421
diff
changeset
|
310 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) |
2b072c95b34c
Applied 0002-use-setup_timer-for-v4.15.patch from Beckhoff.
Florian Pose
parents:
2421
diff
changeset
|
311 |
void cyclic_task(struct timer_list *t) |
2b072c95b34c
Applied 0002-use-setup_timer-for-v4.15.patch from Beckhoff.
Florian Pose
parents:
2421
diff
changeset
|
312 |
#else |
820 | 313 |
void cyclic_task(unsigned long data) |
2696
2b072c95b34c
Applied 0002-use-setup_timer-for-v4.15.patch from Beckhoff.
Florian Pose
parents:
2421
diff
changeset
|
314 |
#endif |
820 | 315 |
{ |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
316 |
// receive process data |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
317 |
down(&master_sem); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
280
diff
changeset
|
318 |
ecrt_master_receive(master); |
220 | 319 |
ecrt_domain_process(domain1); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
320 |
up(&master_sem); |
220 | 321 |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
322 |
// check process data state (optional) |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
323 |
check_domain1_state(); |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
324 |
|
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
325 |
if (counter) { |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
326 |
counter--; |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
327 |
} else { // do this at 1 Hz |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
328 |
counter = FREQUENCY; |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
329 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
330 |
// calculate new process data |
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
331 |
blink = !blink; |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
332 |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
333 |
// check for master state (optional) |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
334 |
check_master_state(); |
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
335 |
|
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
336 |
// check for islave configuration state(s) (optional) |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
337 |
check_slave_config_states(); |
2421 | 338 |
|
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
339 |
#if SDO_ACCESS |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
340 |
// read process data SDO |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
341 |
read_sdo(); |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
342 |
#endif |
1209 | 343 |
|
344 |
#if VOE_ACCESS |
|
345 |
read_voe(); |
|
346 |
#endif |
|
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
347 |
} |
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
348 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
349 |
// write process data |
846 | 350 |
EC_WRITE_U8(domain1_pd + off_dig_out, blink ? 0x06 : 0x09); |
818
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
351 |
|
b6c87ae254c9
Calculate expected working counter for domains.
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
352 |
// send process data |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
353 |
down(&master_sem); |
509
87baea61d0c7
Adjusted examples to 1.2.0 interface changes.
Florian Pose <fp@igh-essen.com>
parents:
472
diff
changeset
|
354 |
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
|
355 |
ecrt_master_send(master); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
356 |
up(&master_sem); |
220 | 357 |
|
358 |
// restart timer |
|
359 |
timer.expires += HZ / FREQUENCY; |
|
360 |
add_timer(&timer); |
|
361 |
} |
|
362 |
||
363 |
/*****************************************************************************/ |
|
364 |
||
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
365 |
void send_callback(void *cb_data) |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
366 |
{ |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
367 |
ec_master_t *m = (ec_master_t *) cb_data; |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
368 |
down(&master_sem); |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
369 |
ecrt_master_send_ext(m); |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
370 |
up(&master_sem); |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
371 |
} |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
372 |
|
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
373 |
/*****************************************************************************/ |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
374 |
|
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
375 |
void receive_callback(void *cb_data) |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
376 |
{ |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
377 |
ec_master_t *m = (ec_master_t *) cb_data; |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
378 |
down(&master_sem); |
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
379 |
ecrt_master_receive(m); |
1500
ed1a733efbc5
Improved the callback mechanism.
Florian Pose <fp@igh-essen.com>
parents:
1378
diff
changeset
|
380 |
up(&master_sem); |
220 | 381 |
} |
382 |
||
383 |
/*****************************************************************************/ |
|
384 |
||
385 |
int __init init_mini_module(void) |
|
386 |
{ |
|
1239
b50b93faaf3e
Used ERR_PTR() macro for return value of ecrt_request_master().
Florian Pose <fp@igh-essen.com>
parents:
1212
diff
changeset
|
387 |
int ret = -1; |
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
388 |
#if CONFIGURE_PDOS |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
654
diff
changeset
|
389 |
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
|
390 |
#endif |
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
391 |
#if EXTERNAL_MEMORY |
809 | 392 |
unsigned int size; |
393 |
#endif |
|
2421 | 394 |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
395 |
printk(KERN_INFO PFX "Starting...\n"); |
220 | 396 |
|
1239
b50b93faaf3e
Used ERR_PTR() macro for return value of ecrt_request_master().
Florian Pose <fp@igh-essen.com>
parents:
1212
diff
changeset
|
397 |
master = ecrt_request_master(0); |
1378
1853f6c0b9b2
Removed IS_ERR() from minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
398 |
if (!master) { |
2421 | 399 |
ret = -EBUSY; |
1239
b50b93faaf3e
Used ERR_PTR() macro for return value of ecrt_request_master().
Florian Pose <fp@igh-essen.com>
parents:
1212
diff
changeset
|
400 |
printk(KERN_ERR PFX "Requesting master 0 failed.\n"); |
220 | 401 |
goto out_return; |
402 |
} |
|
403 |
||
1579
326d47aa986c
applied komax patch to version r1822
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1501
diff
changeset
|
404 |
sema_init(&master_sem, 1); |
1513
60ca68d853b8
Re-added callback data pointer, because it is necessary for some applications.
Florian Pose <fp@igh-essen.com>
parents:
1501
diff
changeset
|
405 |
ecrt_master_callbacks(master, send_callback, receive_callback, master); |
220 | 406 |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
407 |
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
|
408 |
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
|
409 |
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
|
410 |
goto out_release_master; |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
411 |
} |
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
412 |
|
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
413 |
if (!(sc_ana_in = ecrt_master_slave_config( |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
414 |
master, AnaInSlavePos, Beckhoff_EL3152))) { |
1022
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
415 |
printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
416 |
goto out_release_master; |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
417 |
} |
8e49b519e6ba
Implemented ecrt_slave_config_state(); minor changes in
Florian Pose <fp@igh-essen.com>
parents:
909
diff
changeset
|
418 |
|
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
419 |
#if CONFIGURE_PDOS |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
420 |
printk(KERN_INFO PFX "Configuring PDOs...\n"); |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
421 |
if (ecrt_slave_config_pdos(sc_ana_in, EC_END, el3152_syncs)) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
422 |
printk(KERN_ERR PFX "Failed to configure PDOs.\n"); |
1179
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
423 |
goto out_release_master; |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
424 |
} |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
425 |
|
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
426 |
if (!(sc = ecrt_master_slave_config( |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
427 |
master, AnaOutSlavePos, Beckhoff_EL4102))) { |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
428 |
printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
429 |
goto out_release_master; |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
430 |
} |
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
431 |
|
c0e6adec1aee
Added analog output to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1171
diff
changeset
|
432 |
if (ecrt_slave_config_pdos(sc, EC_END, el4102_syncs)) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
433 |
printk(KERN_ERR PFX "Failed to configure PDOs.\n"); |
809 | 434 |
goto out_release_master; |
435 |
} |
|
436 |
||
1080
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
437 |
if (!(sc = ecrt_master_slave_config( |
088a61306930
Removed MSR example; adapted RTAI example; README files for examples.
Florian Pose <fp@igh-essen.com>
parents:
1061
diff
changeset
|
438 |
master, DigOutSlavePos, Beckhoff_EL2004))) { |
809 | 439 |
printk(KERN_ERR PFX "Failed to get slave configuration.\n"); |
440 |
goto out_release_master; |
|
441 |
} |
|
442 |
||
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1080
diff
changeset
|
443 |
if (ecrt_slave_config_pdos(sc, EC_END, el2004_syncs)) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
444 |
printk(KERN_ERR PFX "Failed to configure PDOs.\n"); |
792
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
654
diff
changeset
|
445 |
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
|
446 |
} |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
654
diff
changeset
|
447 |
#endif |
3778920f61e4
Implemented most realtime interface changes for version 1.4, improved
Florian Pose <fp@igh-essen.com>
parents:
654
diff
changeset
|
448 |
|
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
449 |
#if SDO_ACCESS |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
450 |
printk(KERN_INFO PFX "Creating SDO requests...\n"); |
1026
021b8cdeb384
Minor changes to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
451 |
if (!(sdo = ecrt_slave_config_create_sdo_request(sc_ana_in, 0x3102, 2, 2))) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
452 |
printk(KERN_ERR PFX "Failed to create SDO request.\n"); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
453 |
goto out_release_master; |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
454 |
} |
1026
021b8cdeb384
Minor changes to minimal example.
Florian Pose <fp@igh-essen.com>
parents:
1022
diff
changeset
|
455 |
ecrt_sdo_request_timeout(sdo, 500); // ms |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
456 |
#endif |
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
851
diff
changeset
|
457 |
|
1209 | 458 |
#if VOE_ACCESS |
459 |
printk(KERN_INFO PFX "Creating VoE handlers...\n"); |
|
460 |
if (!(voe = ecrt_slave_config_create_voe_handler(sc_ana_in, 1000))) { |
|
461 |
printk(KERN_ERR PFX "Failed to create VoE handler.\n"); |
|
462 |
goto out_release_master; |
|
463 |
} |
|
464 |
#endif |
|
465 |
||
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
466 |
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
|
467 |
if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
468 |
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
|
469 |
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
|
470 |
} |
635
d304ef4af542
Implemented alternative PDO mapping configuration interface.
Florian Pose <fp@igh-essen.com>
parents:
612
diff
changeset
|
471 |
|
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
472 |
#if EXTERNAL_MEMORY |
809 | 473 |
if ((size = ecrt_domain_size(domain1))) { |
820 | 474 |
if (!(domain1_pd = (uint8_t *) kmalloc(size, GFP_KERNEL))) { |
809 | 475 |
printk(KERN_ERR PFX "Failed to allocate %u bytes of process data" |
476 |
" memory!\n", size); |
|
477 |
goto out_release_master; |
|
478 |
} |
|
820 | 479 |
ecrt_domain_external_memory(domain1, domain1_pd); |
809 | 480 |
} |
481 |
#endif |
|
482 |
||
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
483 |
printk(KERN_INFO PFX "Activating master...\n"); |
220 | 484 |
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
|
485 |
printk(KERN_ERR PFX "Failed to activate master!\n"); |
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
486 |
#if EXTERNAL_MEMORY |
809 | 487 |
goto out_free_process_data; |
488 |
#else |
|
489 |
goto out_release_master; |
|
490 |
#endif |
|
491 |
} |
|
492 |
||
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
493 |
#if !EXTERNAL_MEMORY |
809 | 494 |
// Get internal process data for domain |
820 | 495 |
domain1_pd = ecrt_domain_data(domain1); |
809 | 496 |
#endif |
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
497 |
|
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
498 |
printk(KERN_INFO PFX "Starting cyclic sample thread.\n"); |
2696
2b072c95b34c
Applied 0002-use-setup_timer-for-v4.15.patch from Beckhoff.
Florian Pose
parents:
2421
diff
changeset
|
499 |
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) |
2b072c95b34c
Applied 0002-use-setup_timer-for-v4.15.patch from Beckhoff.
Florian Pose
parents:
2421
diff
changeset
|
500 |
timer_setup(&timer, cyclic_task, 0); |
2b072c95b34c
Applied 0002-use-setup_timer-for-v4.15.patch from Beckhoff.
Florian Pose
parents:
2421
diff
changeset
|
501 |
#else |
220 | 502 |
init_timer(&timer); |
820 | 503 |
timer.function = cyclic_task; |
2696
2b072c95b34c
Applied 0002-use-setup_timer-for-v4.15.patch from Beckhoff.
Florian Pose
parents:
2421
diff
changeset
|
504 |
#endif |
220 | 505 |
timer.expires = jiffies + 10; |
506 |
add_timer(&timer); |
|
507 |
||
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
508 |
printk(KERN_INFO PFX "Started.\n"); |
220 | 509 |
return 0; |
510 |
||
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
511 |
#if EXTERNAL_MEMORY |
809 | 512 |
out_free_process_data: |
820 | 513 |
kfree(domain1_pd); |
809 | 514 |
#endif |
515 |
out_release_master: |
|
654
8278e1e27010
Minor changes in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
643
diff
changeset
|
516 |
printk(KERN_ERR PFX "Releasing master...\n"); |
220 | 517 |
ecrt_release_master(master); |
809 | 518 |
out_return: |
654
8278e1e27010
Minor changes in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
643
diff
changeset
|
519 |
printk(KERN_ERR PFX "Failed to load. Aborting.\n"); |
1239
b50b93faaf3e
Used ERR_PTR() macro for return value of ecrt_request_master().
Florian Pose <fp@igh-essen.com>
parents:
1212
diff
changeset
|
520 |
return ret; |
220 | 521 |
} |
522 |
||
523 |
/*****************************************************************************/ |
|
524 |
||
525 |
void __exit cleanup_mini_module(void) |
|
526 |
{ |
|
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
527 |
printk(KERN_INFO PFX "Stopping...\n"); |
220 | 528 |
|
449
3caf8ff4d8a2
Moved functionality of ecrt_master_deactivate() (now deprecated) to ecrt_master_release().
Florian Pose <fp@igh-essen.com>
parents:
446
diff
changeset
|
529 |
del_timer_sync(&timer); |
809 | 530 |
|
1171
de880622f253
Alternative Pdo assignment for el3162.
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
531 |
#if EXTERNAL_MEMORY |
820 | 532 |
kfree(domain1_pd); |
809 | 533 |
#endif |
534 |
||
612
aede068f9a74
Introduced master status, ecrt_master_get_status(), tainted flag,
Florian Pose <fp@igh-essen.com>
parents:
551
diff
changeset
|
535 |
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
|
536 |
ecrt_release_master(master); |
220 | 537 |
|
654
8278e1e27010
Minor changes in minimal example.
Florian Pose <fp@igh-essen.com>
parents:
643
diff
changeset
|
538 |
printk(KERN_INFO PFX "Unloading.\n"); |
220 | 539 |
} |
540 |
||
541 |
/*****************************************************************************/ |
|
542 |
||
543 |
MODULE_LICENSE("GPL"); |
|
512
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
544 |
MODULE_AUTHOR("Florian Pose <fp@igh-essen.com>"); |
24292123d174
Shorter critical sections in examples.
Florian Pose <fp@igh-essen.com>
parents:
509
diff
changeset
|
545 |
MODULE_DESCRIPTION("EtherCAT minimal test environment"); |
220 | 546 |
|
547 |
module_init(init_mini_module); |
|
548 |
module_exit(cleanup_mini_module); |
|
549 |
||
550 |
/*****************************************************************************/ |