author | Florian Pose <fp@igh.de> |
Wed, 13 Dec 2017 15:39:13 +0100 | |
branch | stable-1.5 |
changeset 2693 | 8051d05cb935 |
parent 2658 | 7690a5df7539 |
permissions | -rw-r--r-- |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
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:
1318
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
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:
1318
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:
1318
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:
1318
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:
1318
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:
1318
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:
1318
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:
1318
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:
1318
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:
1318
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:
1318
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:
1318
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1347
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1347
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1347
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:
1347
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:
1347
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
30 |
/** \file |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
31 |
* |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
32 |
* EtherCAT slave configuration state machine. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
33 |
*/ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
|
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
37 |
#include <asm/div64.h> |
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
38 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
#include "globals.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
#include "master.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include "mailbox.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include "slave_config.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "fsm_slave_config.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
|
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
47 |
/** Maximum clock difference (in ns) before going to SAFEOP. |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
48 |
* |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
49 |
* Wait for DC time difference to drop under this absolute value before |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
50 |
* requesting SAFEOP. |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
51 |
*/ |
2448
41dc9a4a0f76
Adjusted DC clock discipline parameters.
Florian Pose <fp@igh-essen.com>
parents:
2374
diff
changeset
|
52 |
#define EC_DC_MAX_SYNC_DIFF_NS 10000 |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
53 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
54 |
/** Maximum time (in ms) to wait for clock discipline. |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
55 |
*/ |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
56 |
#define EC_DC_SYNC_WAIT_MS 5000 |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
57 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
58 |
/** Time offset (in ns), that is added to cyclic start time. |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
59 |
*/ |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
60 |
#define EC_DC_START_OFFSET 100000000ULL |
1889
131f655c03d3
Improved DC tome offset calculation:
Florian Pose <fp@igh-essen.com>
parents:
1873
diff
changeset
|
61 |
|
131f655c03d3
Improved DC tome offset calculation:
Florian Pose <fp@igh-essen.com>
parents:
1873
diff
changeset
|
62 |
/*****************************************************************************/ |
131f655c03d3
Improved DC tome offset calculation:
Florian Pose <fp@igh-essen.com>
parents:
1873
diff
changeset
|
63 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
void ec_fsm_slave_config_state_start(ec_fsm_slave_config_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
void ec_fsm_slave_config_state_init(ec_fsm_slave_config_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
void ec_fsm_slave_config_state_clear_fmmus(ec_fsm_slave_config_t *); |
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
67 |
void ec_fsm_slave_config_state_clear_sync(ec_fsm_slave_config_t *); |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
68 |
void ec_fsm_slave_config_state_dc_clear_assign(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
69 |
void ec_fsm_slave_config_state_mbox_sync(ec_fsm_slave_config_t *); |
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
70 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
71 |
void ec_fsm_slave_config_state_assign_pdi(ec_fsm_slave_config_t *); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
72 |
#endif |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
73 |
void ec_fsm_slave_config_state_boot_preop(ec_fsm_slave_config_t *); |
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
74 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
75 |
void ec_fsm_slave_config_state_assign_ethercat(ec_fsm_slave_config_t *); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
76 |
#endif |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
77 |
void ec_fsm_slave_config_state_sdo_conf(ec_fsm_slave_config_t *); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
78 |
void ec_fsm_slave_config_state_soe_conf_preop(ec_fsm_slave_config_t *); |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
79 |
void ec_fsm_slave_config_state_watchdog_divider(ec_fsm_slave_config_t *); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
80 |
void ec_fsm_slave_config_state_watchdog(ec_fsm_slave_config_t *); |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
81 |
void ec_fsm_slave_config_state_pdo_sync(ec_fsm_slave_config_t *); |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
82 |
void ec_fsm_slave_config_state_pdo_conf(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
void ec_fsm_slave_config_state_fmmu(ec_fsm_slave_config_t *); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
84 |
void ec_fsm_slave_config_state_dc_cycle(ec_fsm_slave_config_t *); |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
85 |
void ec_fsm_slave_config_state_dc_sync_check(ec_fsm_slave_config_t *); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
86 |
void ec_fsm_slave_config_state_dc_start(ec_fsm_slave_config_t *); |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
87 |
void ec_fsm_slave_config_state_dc_assign(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
void ec_fsm_slave_config_state_safeop(ec_fsm_slave_config_t *); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
89 |
void ec_fsm_slave_config_state_soe_conf_safeop(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
void ec_fsm_slave_config_state_op(ec_fsm_slave_config_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
92 |
void ec_fsm_slave_config_enter_init(ec_fsm_slave_config_t *); |
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
93 |
void ec_fsm_slave_config_enter_clear_sync(ec_fsm_slave_config_t *); |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
94 |
void ec_fsm_slave_config_enter_dc_clear_assign(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
void ec_fsm_slave_config_enter_mbox_sync(ec_fsm_slave_config_t *); |
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
96 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
97 |
void ec_fsm_slave_config_enter_assign_pdi(ec_fsm_slave_config_t *); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
98 |
#endif |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
99 |
void ec_fsm_slave_config_enter_boot_preop(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
void ec_fsm_slave_config_enter_sdo_conf(ec_fsm_slave_config_t *); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
101 |
void ec_fsm_slave_config_enter_soe_conf_preop(ec_fsm_slave_config_t *); |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
102 |
void ec_fsm_slave_config_enter_pdo_conf(ec_fsm_slave_config_t *); |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
103 |
void ec_fsm_slave_config_enter_watchdog_divider(ec_fsm_slave_config_t *); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
104 |
void ec_fsm_slave_config_enter_watchdog(ec_fsm_slave_config_t *); |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
105 |
void ec_fsm_slave_config_enter_pdo_sync(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
void ec_fsm_slave_config_enter_fmmu(ec_fsm_slave_config_t *); |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
107 |
void ec_fsm_slave_config_enter_dc_cycle(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
void ec_fsm_slave_config_enter_safeop(ec_fsm_slave_config_t *); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
109 |
void ec_fsm_slave_config_enter_soe_conf_safeop(ec_fsm_slave_config_t *); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
110 |
void ec_fsm_slave_config_enter_op(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
void ec_fsm_slave_config_state_end(ec_fsm_slave_config_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
void ec_fsm_slave_config_state_error(ec_fsm_slave_config_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
115 |
void ec_fsm_slave_config_reconfigure(ec_fsm_slave_config_t *); |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
116 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
/** Constructor. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
*/ |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
121 |
void ec_fsm_slave_config_init( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
122 |
ec_fsm_slave_config_t *fsm, /**< slave state machine */ |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
123 |
ec_datagram_t *datagram, /**< datagram structure to use */ |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
124 |
ec_fsm_change_t *fsm_change, /**< State change state machine to use. */ |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
125 |
ec_fsm_coe_t *fsm_coe, /**< CoE state machine to use. */ |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
126 |
ec_fsm_soe_t *fsm_soe, /**< SoE state machine to use. */ |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
127 |
ec_fsm_pdo_t *fsm_pdo /**< PDO configuration state machine to use. */ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
{ |
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
130 |
ec_sdo_request_init(&fsm->request_copy); |
1849
0a660edc7180
Fixed segfault - Initialize SoE request properly.
Florian Pose <fp@igh-essen.com>
parents:
1844
diff
changeset
|
131 |
ec_soe_request_init(&fsm->soe_request_copy); |
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
132 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
fsm->datagram = datagram; |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
134 |
fsm->fsm_change = fsm_change; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
135 |
fsm->fsm_coe = fsm_coe; |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
136 |
fsm->fsm_soe = fsm_soe; |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
137 |
fsm->fsm_pdo = fsm_pdo; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
/** Destructor. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
*/ |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
144 |
void ec_fsm_slave_config_clear( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
145 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
146 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
{ |
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
148 |
ec_sdo_request_clear(&fsm->request_copy); |
1844
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
149 |
ec_soe_request_clear(&fsm->soe_request_copy); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
154 |
/** Start slave configuration state machine. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
155 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
156 |
void ec_fsm_slave_config_start( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
157 |
ec_fsm_slave_config_t *fsm, /**< slave state machine */ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
ec_slave_t *slave /**< slave to configure */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
fsm->slave = slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
fsm->state = ec_fsm_slave_config_state_start; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
/** |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
168 |
* \return false, if state machine has terminated |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
169 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
170 |
int ec_fsm_slave_config_running( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
171 |
const ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
172 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
return fsm->state != ec_fsm_slave_config_state_end |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
&& fsm->state != ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
180 |
/** Executes the current state of the state machine. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
181 |
* |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
182 |
* If the state machine's datagram is not sent or received yet, the execution |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
183 |
* of the state machine is delayed to the next cycle. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
184 |
* |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
185 |
* \return false, if state machine has terminated |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
186 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
187 |
int ec_fsm_slave_config_exec( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
188 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
189 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
if (fsm->datagram->state == EC_DATAGRAM_SENT |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
|| fsm->datagram->state == EC_DATAGRAM_QUEUED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
// datagram was not sent or received yet. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
return ec_fsm_slave_config_running(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
fsm->state(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
return ec_fsm_slave_config_running(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
/** |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
204 |
* \return true, if the state machine terminated gracefully |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
205 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
206 |
int ec_fsm_slave_config_success( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
207 |
const ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
208 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
return fsm->state == ec_fsm_slave_config_state_end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
/****************************************************************************** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
* Slave configuration state machine |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
217 |
/** Slave configuration state: START. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
218 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
219 |
void ec_fsm_slave_config_state_start( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
220 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
221 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
{ |
1921 | 223 |
EC_SLAVE_DBG(fsm->slave, 1, "Configuring...\n"); |
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
224 |
ec_fsm_slave_config_enter_init(fsm); |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
225 |
} |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
226 |
|
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
227 |
/*****************************************************************************/ |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
228 |
|
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
229 |
/** Start state change to INIT. |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
230 |
*/ |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
231 |
void ec_fsm_slave_config_enter_init( |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
232 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
233 |
) |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
234 |
{ |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
235 |
ec_fsm_change_start(fsm->fsm_change, fsm->slave, EC_SLAVE_STATE_INIT); |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
236 |
ec_fsm_change_exec(fsm->fsm_change); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
fsm->state = ec_fsm_slave_config_state_init; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
242 |
/** Slave configuration state: INIT. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
243 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
244 |
void ec_fsm_slave_config_state_init( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
245 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
246 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
251 |
if (ec_fsm_change_exec(fsm->fsm_change)) return; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
252 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
253 |
if (!ec_fsm_change_success(fsm->fsm_change)) { |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
254 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
257 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
|
1921 | 260 |
EC_SLAVE_DBG(slave, 1, "Now in INIT.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
if (!slave->base_fmmu_count) { // skip FMMU configuration |
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
263 |
ec_fsm_slave_config_enter_clear_sync(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
265 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
266 |
|
1921 | 267 |
EC_SLAVE_DBG(slave, 1, "Clearing FMMU configurations...\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
// clear FMMU configurations |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
ec_datagram_fpwr(datagram, slave->station_address, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
0x0600, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1180
diff
changeset
|
272 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
273 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
274 |
fsm->state = ec_fsm_slave_config_state_clear_fmmus; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
275 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
276 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
278 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
279 |
/** Slave configuration state: CLEAR FMMU. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
280 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
281 |
void ec_fsm_slave_config_state_clear_fmmus( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
282 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
283 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
284 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
285 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
286 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
289 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
290 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 292 |
EC_SLAVE_ERR(fsm->slave, "Failed receive FMMU clearing datagram.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
293 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
295 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
296 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
297 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 299 |
EC_SLAVE_ERR(fsm->slave, "Failed to clear FMMUs: "); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
301 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
302 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
303 |
|
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
304 |
ec_fsm_slave_config_enter_clear_sync(fsm); |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
305 |
} |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
306 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
307 |
/*****************************************************************************/ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
308 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
309 |
/** Clear the sync manager configurations. |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
310 |
*/ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
311 |
void ec_fsm_slave_config_enter_clear_sync( |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
312 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
313 |
) |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
314 |
{ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
315 |
ec_slave_t *slave = fsm->slave; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
316 |
ec_datagram_t *datagram = fsm->datagram; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
317 |
size_t sync_size; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
318 |
|
1471
2ec173081b7f
Fixed mailbox usage for slaves that do not provide sync manager
Florian Pose <fp@igh-essen.com>
parents:
1458
diff
changeset
|
319 |
if (!slave->base_sync_count) { |
1404 | 320 |
// no sync managers |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
321 |
ec_fsm_slave_config_enter_dc_clear_assign(fsm); |
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
322 |
return; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
323 |
} |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
324 |
|
1921 | 325 |
EC_SLAVE_DBG(slave, 1, "Clearing sync manager configurations...\n"); |
1344 | 326 |
|
1471
2ec173081b7f
Fixed mailbox usage for slaves that do not provide sync manager
Florian Pose <fp@igh-essen.com>
parents:
1458
diff
changeset
|
327 |
sync_size = EC_SYNC_PAGE_SIZE * slave->base_sync_count; |
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
328 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
329 |
// clear sync manager configurations |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
330 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0800, sync_size); |
1896
1d4bca6ba543
Use ec_datagram_zero() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1889
diff
changeset
|
331 |
ec_datagram_zero(datagram); |
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
332 |
fsm->retries = EC_FSM_RETRIES; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
333 |
fsm->state = ec_fsm_slave_config_state_clear_sync; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
334 |
} |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
335 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
336 |
/*****************************************************************************/ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
337 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
338 |
/** Slave configuration state: CLEAR SYNC. |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
339 |
*/ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
340 |
void ec_fsm_slave_config_state_clear_sync( |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
341 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
342 |
) |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
343 |
{ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
344 |
ec_datagram_t *datagram = fsm->datagram; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
345 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
346 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
347 |
return; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
348 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
349 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
350 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 351 |
EC_SLAVE_ERR(fsm->slave, "Failed receive sync manager" |
352 |
" clearing datagram.\n"); |
|
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
353 |
return; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
354 |
} |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
355 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
356 |
if (datagram->working_counter != 1) { |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
357 |
fsm->slave->error_flag = 1; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
358 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 359 |
EC_SLAVE_ERR(fsm->slave, |
360 |
"Failed to clear sync manager configurations: "); |
|
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
361 |
ec_datagram_print_wc_error(datagram); |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
362 |
return; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
363 |
} |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
364 |
|
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
365 |
ec_fsm_slave_config_enter_dc_clear_assign(fsm); |
1406
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
366 |
} |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
367 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
368 |
/*****************************************************************************/ |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
369 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
370 |
/** Clear the DC assignment. |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
371 |
*/ |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
372 |
void ec_fsm_slave_config_enter_dc_clear_assign( |
1406
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
373 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
374 |
) |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
375 |
{ |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
376 |
ec_slave_t *slave = fsm->slave; |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
377 |
ec_datagram_t *datagram = fsm->datagram; |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
378 |
|
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1412
diff
changeset
|
379 |
if (!slave->base_dc_supported || !slave->has_dc_system_time) { |
1406
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
380 |
ec_fsm_slave_config_enter_mbox_sync(fsm); |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
381 |
return; |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
382 |
} |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
383 |
|
1921 | 384 |
EC_SLAVE_DBG(slave, 1, "Clearing DC assignment...\n"); |
1406
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
385 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
386 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0980, 2); |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
387 |
ec_datagram_zero(datagram); |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
388 |
fsm->retries = EC_FSM_RETRIES; |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
389 |
fsm->state = ec_fsm_slave_config_state_dc_clear_assign; |
1406
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
390 |
} |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
391 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
392 |
/*****************************************************************************/ |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
393 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
394 |
/** Slave configuration state: CLEAR DC ASSIGN. |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
395 |
*/ |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
396 |
void ec_fsm_slave_config_state_dc_clear_assign( |
1406
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
397 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
398 |
) |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
399 |
{ |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
400 |
ec_datagram_t *datagram = fsm->datagram; |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
401 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
402 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
403 |
return; |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
404 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
405 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
406 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 407 |
EC_SLAVE_ERR(fsm->slave, "Failed receive DC assignment" |
408 |
" clearing datagram.\n"); |
|
409 |
return; |
|
410 |
} |
|
411 |
||
412 |
if (datagram->working_counter != 1) { |
|
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
413 |
// clearing the DC assignment does not succeed on simple slaves |
1921 | 414 |
EC_SLAVE_DBG(fsm->slave, 1, "Failed to clear DC assignment: "); |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
415 |
ec_datagram_print_wc_error(datagram); |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
416 |
} |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
417 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
418 |
ec_fsm_slave_config_enter_mbox_sync(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
419 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
420 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
421 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
422 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
423 |
/** Check for mailbox sync managers to be configured. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
424 |
*/ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
425 |
void ec_fsm_slave_config_enter_mbox_sync( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
426 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
427 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
428 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
429 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
430 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
431 |
unsigned int i; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
432 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
433 |
// slave is now in INIT |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
434 |
if (slave->current_state == slave->requested_state) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
435 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
1921 | 436 |
EC_SLAVE_DBG(slave, 1, "Finished configuration.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
437 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
438 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
439 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
440 |
if (!slave->sii.mailbox_protocols) { |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
441 |
// no mailbox protocols supported |
1921 | 442 |
EC_SLAVE_DBG(slave, 1, "Slave does not support" |
443 |
" mailbox communication.\n"); |
|
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
444 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
445 |
ec_fsm_slave_config_enter_assign_pdi(fsm); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
446 |
#else |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
447 |
ec_fsm_slave_config_enter_boot_preop(fsm); |
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
448 |
#endif |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
449 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
450 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
451 |
|
1921 | 452 |
EC_SLAVE_DBG(slave, 1, "Configuring mailbox sync managers...\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
453 |
|
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
454 |
if (slave->requested_state == EC_SLAVE_STATE_BOOT) { |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
455 |
ec_sync_t sync; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
456 |
|
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
457 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0800, |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
458 |
EC_SYNC_PAGE_SIZE * 2); |
1896
1d4bca6ba543
Use ec_datagram_zero() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1889
diff
changeset
|
459 |
ec_datagram_zero(datagram); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
460 |
|
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
461 |
ec_sync_init(&sync, slave); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
462 |
sync.physical_start_address = slave->sii.boot_rx_mailbox_offset; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
463 |
sync.control_register = 0x26; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
464 |
sync.enable = 1; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
465 |
ec_sync_page(&sync, 0, slave->sii.boot_rx_mailbox_size, |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
466 |
EC_DIR_INVALID, // use default direction |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
467 |
0, // no PDO xfer |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
468 |
datagram->data); |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
469 |
slave->configured_rx_mailbox_offset = |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
470 |
slave->sii.boot_rx_mailbox_offset; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
471 |
slave->configured_rx_mailbox_size = |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
472 |
slave->sii.boot_rx_mailbox_size; |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
473 |
|
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
474 |
ec_sync_init(&sync, slave); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
475 |
sync.physical_start_address = slave->sii.boot_tx_mailbox_offset; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
476 |
sync.control_register = 0x22; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
477 |
sync.enable = 1; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
478 |
ec_sync_page(&sync, 1, slave->sii.boot_tx_mailbox_size, |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
479 |
EC_DIR_INVALID, // use default direction |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
480 |
0, // no PDO xfer |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
481 |
datagram->data + EC_SYNC_PAGE_SIZE); |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
482 |
slave->configured_tx_mailbox_offset = |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
483 |
slave->sii.boot_tx_mailbox_offset; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
484 |
slave->configured_tx_mailbox_size = |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
485 |
slave->sii.boot_tx_mailbox_size; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
486 |
|
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
487 |
} else if (slave->sii.sync_count >= 2) { // mailbox configuration provided |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
488 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0800, |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
489 |
EC_SYNC_PAGE_SIZE * slave->sii.sync_count); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1180
diff
changeset
|
490 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
491 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
492 |
for (i = 0; i < 2; i++) { |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
493 |
ec_sync_page(&slave->sii.syncs[i], i, |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
494 |
slave->sii.syncs[i].default_length, |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
495 |
NULL, // use default sync manager configuration |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
496 |
0, // no PDO xfer |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
497 |
datagram->data + EC_SYNC_PAGE_SIZE * i); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
498 |
} |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
499 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
500 |
slave->configured_rx_mailbox_offset = |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
501 |
slave->sii.syncs[0].physical_start_address; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
502 |
slave->configured_rx_mailbox_size = |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
503 |
slave->sii.syncs[0].default_length; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
504 |
slave->configured_tx_mailbox_offset = |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
505 |
slave->sii.syncs[1].physical_start_address; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
506 |
slave->configured_tx_mailbox_size = |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
507 |
slave->sii.syncs[1].default_length; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
508 |
} else { // no mailbox sync manager configurations provided |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
509 |
ec_sync_t sync; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
510 |
|
1921 | 511 |
EC_SLAVE_DBG(slave, 1, "Slave does not provide" |
512 |
" mailbox sync manager configurations.\n"); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
513 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
514 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0800, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
515 |
EC_SYNC_PAGE_SIZE * 2); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1180
diff
changeset
|
516 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
517 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
518 |
ec_sync_init(&sync, slave); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
519 |
sync.physical_start_address = slave->sii.std_rx_mailbox_offset; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
520 |
sync.control_register = 0x26; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
521 |
sync.enable = 1; |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
522 |
ec_sync_page(&sync, 0, slave->sii.std_rx_mailbox_size, |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
523 |
NULL, // use default sync manager configuration |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
524 |
0, // no PDO xfer |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
525 |
datagram->data); |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
526 |
slave->configured_rx_mailbox_offset = |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
527 |
slave->sii.std_rx_mailbox_offset; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
528 |
slave->configured_rx_mailbox_size = |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
529 |
slave->sii.std_rx_mailbox_size; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
530 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
531 |
ec_sync_init(&sync, slave); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
532 |
sync.physical_start_address = slave->sii.std_tx_mailbox_offset; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
533 |
sync.control_register = 0x22; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
534 |
sync.enable = 1; |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
535 |
ec_sync_page(&sync, 1, slave->sii.std_tx_mailbox_size, |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
536 |
NULL, // use default sync manager configuration |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
537 |
0, // no PDO xfer |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
538 |
datagram->data + EC_SYNC_PAGE_SIZE); |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
539 |
slave->configured_tx_mailbox_offset = |
1471
2ec173081b7f
Fixed mailbox usage for slaves that do not provide sync manager
Florian Pose <fp@igh-essen.com>
parents:
1458
diff
changeset
|
540 |
slave->sii.std_tx_mailbox_offset; |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
541 |
slave->configured_tx_mailbox_size = |
1471
2ec173081b7f
Fixed mailbox usage for slaves that do not provide sync manager
Florian Pose <fp@igh-essen.com>
parents:
1458
diff
changeset
|
542 |
slave->sii.std_tx_mailbox_size; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
543 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
544 |
|
1347
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
545 |
fsm->take_time = 1; |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
546 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
547 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
548 |
fsm->state = ec_fsm_slave_config_state_mbox_sync; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
549 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
550 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
551 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
552 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
553 |
/** Slave configuration state: SYNC. |
1345 | 554 |
* |
555 |
* \todo Timeout for response. |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
556 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
557 |
void ec_fsm_slave_config_state_mbox_sync( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
558 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
559 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
560 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
561 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
562 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
563 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
564 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
565 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
566 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
567 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
568 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 569 |
EC_SLAVE_ERR(slave, "Failed to receive sync manager" |
570 |
" configuration datagram: "); |
|
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1520
diff
changeset
|
571 |
ec_datagram_print_state(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
572 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
573 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
574 |
|
1347
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
575 |
if (fsm->take_time) { |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
576 |
fsm->take_time = 0; |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
577 |
fsm->jiffies_start = datagram->jiffies_sent; |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
578 |
} |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
579 |
|
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
580 |
/* Because the sync manager configurations are cleared during the last |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
581 |
* cycle, some slaves do not immediately respond to the mailbox sync |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
582 |
* manager configuration datagram. Therefore, resend the datagram for |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
583 |
* a certain time, if the slave does not respond. |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
584 |
*/ |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
585 |
if (datagram->working_counter == 0) { |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
586 |
unsigned long diff = datagram->jiffies_received - fsm->jiffies_start; |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
587 |
|
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
588 |
if (diff >= HZ) { |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
589 |
slave->error_flag = 1; |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
590 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 591 |
EC_SLAVE_ERR(slave, "Timeout while configuring" |
592 |
" mailbox sync managers.\n"); |
|
1347
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
593 |
return; |
1921 | 594 |
} else { |
595 |
EC_SLAVE_DBG(slave, 1, "Resending after %u ms...\n", |
|
1347
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
596 |
(unsigned int) diff * 1000 / HZ); |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
597 |
} |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
598 |
|
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
599 |
// send configuration datagram again |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
600 |
fsm->retries = EC_FSM_RETRIES; |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
601 |
return; |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
602 |
} |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
603 |
else if (datagram->working_counter != 1) { |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
604 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
605 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 606 |
EC_SLAVE_ERR(slave, "Failed to set sync managers: "); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
607 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
608 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
609 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
610 |
|
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
611 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
612 |
ec_fsm_slave_config_enter_assign_pdi(fsm); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
613 |
#else |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
614 |
ec_fsm_slave_config_enter_boot_preop(fsm); |
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
615 |
#endif |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
616 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
617 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
618 |
/*****************************************************************************/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
619 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
620 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
621 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
622 |
/** Assign SII to PDI. |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
623 |
*/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
624 |
void ec_fsm_slave_config_enter_assign_pdi( |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
625 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
626 |
) |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
627 |
{ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
628 |
ec_datagram_t *datagram = fsm->datagram; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
629 |
ec_slave_t *slave = fsm->slave; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
630 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
631 |
if (fsm->slave->requested_state != EC_SLAVE_STATE_BOOT) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
632 |
EC_SLAVE_DBG(slave, 1, "Assigning SII access to PDI.\n"); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
633 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
634 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0500, 0x01); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
635 |
EC_WRITE_U8(datagram->data, 0x01); // PDI |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
636 |
fsm->retries = EC_FSM_RETRIES; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
637 |
fsm->state = ec_fsm_slave_config_state_assign_pdi; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
638 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
639 |
else { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
640 |
ec_fsm_slave_config_enter_boot_preop(fsm); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
641 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
642 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
643 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
644 |
/*****************************************************************************/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
645 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
646 |
/** Slave configuration state: ASSIGN_PDI. |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
647 |
*/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
648 |
void ec_fsm_slave_config_state_assign_pdi( |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
649 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
650 |
) |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
651 |
{ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
652 |
ec_datagram_t *datagram = fsm->datagram; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
653 |
ec_slave_t *slave = fsm->slave; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
654 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
655 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
656 |
return; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
657 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
658 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
659 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
660 |
EC_SLAVE_WARN(slave, "Failed receive SII assignment datagram: "); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
661 |
ec_datagram_print_state(datagram); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
662 |
goto cont_preop; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
663 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
664 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
665 |
if (datagram->working_counter != 1) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
666 |
EC_SLAVE_WARN(slave, "Failed to assign SII to PDI: "); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
667 |
ec_datagram_print_wc_error(datagram); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
668 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
669 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
670 |
cont_preop: |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
671 |
ec_fsm_slave_config_enter_boot_preop(fsm); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
672 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
673 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
674 |
#endif |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
675 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
676 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
677 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
678 |
/** Request PREOP state. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
679 |
*/ |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
680 |
void ec_fsm_slave_config_enter_boot_preop( |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
681 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
682 |
) |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
683 |
{ |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
684 |
fsm->state = ec_fsm_slave_config_state_boot_preop; |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
685 |
|
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
686 |
if (fsm->slave->requested_state != EC_SLAVE_STATE_BOOT) { |
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
687 |
ec_fsm_change_start(fsm->fsm_change, |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
688 |
fsm->slave, EC_SLAVE_STATE_PREOP); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
689 |
} else { // BOOT |
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
690 |
ec_fsm_change_start(fsm->fsm_change, |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
691 |
fsm->slave, EC_SLAVE_STATE_BOOT); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
692 |
} |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
693 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
694 |
ec_fsm_change_exec(fsm->fsm_change); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
695 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
696 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
697 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
698 |
|
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
699 |
/** Slave configuration state: BOOT/PREOP. |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
700 |
*/ |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
701 |
void ec_fsm_slave_config_state_boot_preop( |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
702 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
703 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
704 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
705 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
706 |
|
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
707 |
if (ec_fsm_change_exec(fsm->fsm_change)) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
708 |
return; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
709 |
} |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
710 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
711 |
if (!ec_fsm_change_success(fsm->fsm_change)) { |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
712 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
713 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
714 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
715 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
716 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
717 |
|
1404 | 718 |
// slave is now in BOOT or PREOP |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
719 |
slave->jiffies_preop = fsm->datagram->jiffies_received; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
720 |
|
1921 | 721 |
EC_SLAVE_DBG(slave, 1, "Now in %s.\n", |
722 |
slave->requested_state != EC_SLAVE_STATE_BOOT ? "PREOP" : "BOOT"); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
723 |
|
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
724 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
725 |
EC_SLAVE_DBG(slave, 1, "Assigning SII access back to EtherCAT.\n"); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
726 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
727 |
ec_datagram_fpwr(fsm->datagram, slave->station_address, 0x0500, 0x01); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
728 |
EC_WRITE_U8(fsm->datagram->data, 0x00); // EtherCAT |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
729 |
fsm->retries = EC_FSM_RETRIES; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
730 |
fsm->state = ec_fsm_slave_config_state_assign_ethercat; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
731 |
#else |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
732 |
if (slave->current_state == slave->requested_state) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
733 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
1921 | 734 |
EC_SLAVE_DBG(slave, 1, "Finished configuration.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
735 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
736 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
737 |
|
1491
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
738 |
ec_fsm_slave_config_enter_sdo_conf(fsm); |
2508
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
739 |
#endif |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
740 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
741 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
742 |
/*****************************************************************************/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
743 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
744 |
#ifdef EC_SII_ASSIGN |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
745 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
746 |
/** Slave configuration state: ASSIGN_ETHERCAT. |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
747 |
*/ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
748 |
void ec_fsm_slave_config_state_assign_ethercat( |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
749 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
750 |
) |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
751 |
{ |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
752 |
ec_datagram_t *datagram = fsm->datagram; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
753 |
ec_slave_t *slave = fsm->slave; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
754 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
755 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
756 |
return; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
757 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
758 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
759 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
760 |
EC_SLAVE_WARN(slave, "Failed receive SII assignment datagram: "); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
761 |
ec_datagram_print_state(datagram); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
762 |
goto cont_sdo_conf; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
763 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
764 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
765 |
if (datagram->working_counter != 1) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
766 |
EC_SLAVE_WARN(slave, "Failed to assign SII back to EtherCAT: "); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
767 |
ec_datagram_print_wc_error(datagram); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
768 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
769 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
770 |
cont_sdo_conf: |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
771 |
if (slave->current_state == slave->requested_state) { |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
772 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
773 |
EC_SLAVE_DBG(slave, 1, "Finished configuration.\n"); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
774 |
return; |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
775 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
776 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
777 |
ec_fsm_slave_config_enter_sdo_conf(fsm); |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
778 |
} |
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
779 |
|
6b21b3f88a9a
Introduced --enable-sii-assign.
Florian Pose <fp@igh-essen.com>
parents:
2498
diff
changeset
|
780 |
#endif |
1491
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
781 |
|
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
782 |
/*****************************************************************************/ |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
783 |
|
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
784 |
/** Check for SDO configurations to be applied. |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
785 |
*/ |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
786 |
void ec_fsm_slave_config_enter_sdo_conf( |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
787 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
788 |
) |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
789 |
{ |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
790 |
ec_slave_t *slave = fsm->slave; |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
791 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
792 |
if (!slave->config) { |
1491
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
793 |
ec_fsm_slave_config_enter_pdo_sync(fsm); |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
794 |
return; |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
795 |
} |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
796 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
797 |
// No CoE configuration to be applied? |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
798 |
if (list_empty(&slave->config->sdo_configs)) { // skip SDO configuration |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
799 |
ec_fsm_slave_config_enter_soe_conf_preop(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
800 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
801 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
802 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
803 |
// start SDO configuration |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
804 |
fsm->state = ec_fsm_slave_config_state_sdo_conf; |
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
805 |
fsm->request = list_entry(fsm->slave->config->sdo_configs.next, |
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
806 |
ec_sdo_request_t, list); |
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
807 |
ec_sdo_request_copy(&fsm->request_copy, fsm->request); |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
808 |
ecrt_sdo_request_write(&fsm->request_copy); |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
809 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request_copy); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
810 |
ec_fsm_coe_exec(fsm->fsm_coe, fsm->datagram); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
811 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
812 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
813 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
814 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
815 |
/** Slave configuration state: SDO_CONF. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
816 |
*/ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
817 |
void ec_fsm_slave_config_state_sdo_conf( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
818 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
819 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
820 |
{ |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
821 |
if (ec_fsm_coe_exec(fsm->fsm_coe, fsm->datagram)) { |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
822 |
return; |
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
823 |
} |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
824 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
825 |
if (!ec_fsm_coe_success(fsm->fsm_coe)) { |
1921 | 826 |
EC_SLAVE_ERR(fsm->slave, "SDO configuration failed.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
827 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
828 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
829 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
830 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
831 |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
832 |
if (!fsm->slave->config) { // config removed in the meantime |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
833 |
ec_fsm_slave_config_reconfigure(fsm); |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
834 |
return; |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
835 |
} |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
836 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
837 |
// Another SDO to configure? |
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
834
diff
changeset
|
838 |
if (fsm->request->list.next != &fsm->slave->config->sdo_configs) { |
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
839 |
fsm->request = list_entry(fsm->request->list.next, |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
840 |
ec_sdo_request_t, list); |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
841 |
ec_sdo_request_copy(&fsm->request_copy, fsm->request); |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
842 |
ecrt_sdo_request_write(&fsm->request_copy); |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
843 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request_copy); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
844 |
ec_fsm_coe_exec(fsm->fsm_coe, fsm->datagram); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
845 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
846 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
847 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
848 |
// All SDOs are now configured. |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
849 |
ec_fsm_slave_config_enter_soe_conf_preop(fsm); |
1844
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
850 |
} |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
851 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
852 |
/*****************************************************************************/ |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
853 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
854 |
/** Check for SoE configurations to be applied. |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
855 |
*/ |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
856 |
void ec_fsm_slave_config_enter_soe_conf_preop( |
1844
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
857 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
858 |
) |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
859 |
{ |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
860 |
ec_slave_t *slave = fsm->slave; |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
861 |
ec_soe_request_t *req; |
1844
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
862 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
863 |
if (!slave->config) { |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
864 |
ec_fsm_slave_config_enter_pdo_sync(fsm); |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
865 |
return; |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
866 |
} |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
867 |
|
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
868 |
list_for_each_entry(req, &slave->config->soe_configs, list) { |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
869 |
if (req->al_state == EC_AL_STATE_PREOP) { |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
870 |
// start SoE configuration |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
871 |
fsm->state = ec_fsm_slave_config_state_soe_conf_preop; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
872 |
fsm->soe_request = req; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
873 |
ec_soe_request_copy(&fsm->soe_request_copy, fsm->soe_request); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
874 |
ec_soe_request_write(&fsm->soe_request_copy); |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
875 |
ec_fsm_soe_transfer(fsm->fsm_soe, fsm->slave, |
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
876 |
&fsm->soe_request_copy); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
877 |
ec_fsm_soe_exec(fsm->fsm_soe, fsm->datagram); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
878 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
879 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
880 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
881 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
882 |
// No SoE configuration to be applied in PREOP |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
883 |
ec_fsm_slave_config_enter_pdo_conf(fsm); |
1844
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
884 |
} |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
885 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
886 |
/*****************************************************************************/ |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
887 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
888 |
/** Slave configuration state: SOE_CONF. |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
889 |
*/ |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
890 |
void ec_fsm_slave_config_state_soe_conf_preop( |
1844
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
891 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
892 |
) |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
893 |
{ |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
894 |
ec_slave_t *slave = fsm->slave; |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
895 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
896 |
if (ec_fsm_soe_exec(fsm->fsm_soe, fsm->datagram)) { |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
897 |
return; |
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
898 |
} |
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
899 |
|
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
900 |
if (!ec_fsm_soe_success(fsm->fsm_soe)) { |
1921 | 901 |
EC_SLAVE_ERR(slave, "SoE configuration failed.\n"); |
1844
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
902 |
fsm->slave->error_flag = 1; |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
903 |
fsm->state = ec_fsm_slave_config_state_error; |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
904 |
return; |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
905 |
} |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
906 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
907 |
if (!fsm->slave->config) { // config removed in the meantime |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
908 |
ec_fsm_slave_config_reconfigure(fsm); |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
909 |
return; |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
910 |
} |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
911 |
|
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
912 |
// Another IDN to configure in PREOP? |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
913 |
while (fsm->soe_request->list.next != &fsm->slave->config->soe_configs) { |
1844
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
914 |
fsm->soe_request = list_entry(fsm->soe_request->list.next, |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
915 |
ec_soe_request_t, list); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
916 |
if (fsm->soe_request->al_state == EC_AL_STATE_PREOP) { |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
917 |
ec_soe_request_copy(&fsm->soe_request_copy, fsm->soe_request); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
918 |
ec_soe_request_write(&fsm->soe_request_copy); |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
919 |
ec_fsm_soe_transfer(fsm->fsm_soe, fsm->slave, |
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
920 |
&fsm->soe_request_copy); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
921 |
ec_fsm_soe_exec(fsm->fsm_soe, fsm->datagram); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
922 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
923 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
924 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
925 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
926 |
// All PREOP IDNs are now configured. |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
927 |
ec_fsm_slave_config_enter_pdo_conf(fsm); |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
928 |
} |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
929 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
930 |
/*****************************************************************************/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
931 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
932 |
/** PDO_CONF entry function. |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
933 |
*/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
934 |
void ec_fsm_slave_config_enter_pdo_conf( |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
935 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
936 |
) |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
937 |
{ |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
938 |
// Start configuring PDOs |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
939 |
ec_fsm_pdo_start_configuration(fsm->fsm_pdo, fsm->slave); |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
940 |
fsm->state = ec_fsm_slave_config_state_pdo_conf; |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
941 |
fsm->state(fsm); // execute immediately |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
942 |
} |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
943 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
944 |
/*****************************************************************************/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
945 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
946 |
/** Slave configuration state: PDO_CONF. |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
947 |
*/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
948 |
void ec_fsm_slave_config_state_pdo_conf( |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
949 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
950 |
) |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
951 |
{ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1491
diff
changeset
|
952 |
// TODO check for config here |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
953 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
954 |
if (ec_fsm_pdo_exec(fsm->fsm_pdo, fsm->datagram)) { |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
955 |
return; |
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
956 |
} |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
957 |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
958 |
if (!fsm->slave->config) { // config removed in the meantime |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
959 |
ec_fsm_slave_config_reconfigure(fsm); |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
960 |
return; |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
961 |
} |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
962 |
|
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
963 |
if (!ec_fsm_pdo_success(fsm->fsm_pdo)) { |
1921 | 964 |
EC_SLAVE_WARN(fsm->slave, "PDO configuration failed.\n"); |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
965 |
} |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
966 |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
967 |
ec_fsm_slave_config_enter_watchdog_divider(fsm); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
968 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
969 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
970 |
/*****************************************************************************/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
971 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
972 |
/** WATCHDOG_DIVIDER entry function. |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
973 |
*/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
974 |
void ec_fsm_slave_config_enter_watchdog_divider( |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
975 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
976 |
) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
977 |
{ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
978 |
ec_slave_t *slave = fsm->slave; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
979 |
ec_datagram_t *datagram = fsm->datagram; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
980 |
ec_slave_config_t *config = slave->config; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
981 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
982 |
if (config && config->watchdog_divider) { |
1921 | 983 |
EC_SLAVE_DBG(slave, 1, "Setting watchdog divider to %u.\n", |
984 |
config->watchdog_divider); |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
985 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
986 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0400, 2); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
987 |
EC_WRITE_U16(datagram->data, config->watchdog_divider); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
988 |
fsm->retries = EC_FSM_RETRIES; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
989 |
fsm->state = ec_fsm_slave_config_state_watchdog_divider; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
990 |
} else { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
991 |
ec_fsm_slave_config_enter_watchdog(fsm); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
992 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
993 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
994 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
995 |
/*****************************************************************************/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
996 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
997 |
/** Slave configuration state: WATCHDOG_DIVIDER. |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
998 |
*/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
999 |
void ec_fsm_slave_config_state_watchdog_divider( |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1000 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1001 |
) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1002 |
{ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1003 |
ec_datagram_t *datagram = fsm->datagram; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1004 |
ec_slave_t *slave = fsm->slave; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1005 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1006 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1007 |
return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1008 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1009 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1010 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1011 |
EC_SLAVE_ERR(slave, "Failed to receive watchdog divider" |
1012 |
" configuration datagram: "); |
|
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1520
diff
changeset
|
1013 |
ec_datagram_print_state(datagram); |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1014 |
return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1015 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1016 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1017 |
if (datagram->working_counter != 1) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1018 |
slave->error_flag = 1; |
1921 | 1019 |
EC_SLAVE_WARN(slave, "Failed to set watchdog divider: "); |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1020 |
ec_datagram_print_wc_error(datagram); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1021 |
return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1022 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1023 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1024 |
ec_fsm_slave_config_enter_watchdog(fsm); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1025 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1026 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1027 |
/*****************************************************************************/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1028 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1029 |
/** WATCHDOG entry function |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1030 |
*/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1031 |
void ec_fsm_slave_config_enter_watchdog( |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1032 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1033 |
) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1034 |
{ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1035 |
ec_datagram_t *datagram = fsm->datagram; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1036 |
ec_slave_t *slave = fsm->slave; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1037 |
ec_slave_config_t *config = slave->config; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1038 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1039 |
if (config && config->watchdog_intervals) { |
1921 | 1040 |
EC_SLAVE_DBG(slave, 1, "Setting process data" |
1041 |
" watchdog intervals to %u.\n", config->watchdog_intervals); |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1042 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1043 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0420, 2); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1044 |
EC_WRITE_U16(datagram->data, config->watchdog_intervals); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1045 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1046 |
fsm->retries = EC_FSM_RETRIES; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1047 |
fsm->state = ec_fsm_slave_config_state_watchdog; |
1520
09cf61d61af0
Fixed setting watchdog intervals.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
1048 |
} else { |
09cf61d61af0
Fixed setting watchdog intervals.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
1049 |
ec_fsm_slave_config_enter_pdo_sync(fsm); |
09cf61d61af0
Fixed setting watchdog intervals.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
1050 |
} |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1051 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1052 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1053 |
/*****************************************************************************/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1054 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1055 |
/** Slave configuration state: WATCHDOG. |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1056 |
*/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1057 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1058 |
void ec_fsm_slave_config_state_watchdog( |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1059 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1060 |
) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1061 |
{ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1062 |
ec_datagram_t *datagram = fsm->datagram; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1063 |
ec_slave_t *slave = fsm->slave; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1064 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1065 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1066 |
return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1067 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1068 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1069 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1070 |
EC_SLAVE_ERR(slave, "Failed to receive sync manager" |
1071 |
" watchdog configuration datagram: "); |
|
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1520
diff
changeset
|
1072 |
ec_datagram_print_state(datagram); |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1073 |
return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1074 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1075 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1076 |
if (datagram->working_counter != 1) { |
1921 | 1077 |
EC_SLAVE_WARN(slave, "Failed to set process data" |
1078 |
" watchdog intervals: "); |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1079 |
ec_datagram_print_wc_error(datagram); |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1080 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1081 |
|
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1082 |
ec_fsm_slave_config_enter_pdo_sync(fsm); |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1083 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1084 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1085 |
/*****************************************************************************/ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1086 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1087 |
/** Check for PDO sync managers to be configured. |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1088 |
*/ |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1089 |
void ec_fsm_slave_config_enter_pdo_sync( |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1090 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1091 |
) |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1092 |
{ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1093 |
ec_slave_t *slave = fsm->slave; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1094 |
ec_datagram_t *datagram = fsm->datagram; |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1095 |
unsigned int i, j, offset, num_pdo_syncs; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
1096 |
uint8_t sync_index; |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1097 |
const ec_sync_t *sync; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1098 |
uint16_t size; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1099 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1100 |
if (slave->sii.mailbox_protocols) { |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1101 |
offset = 2; // slave has mailboxes |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1102 |
} else { |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1103 |
offset = 0; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1104 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1105 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1106 |
if (slave->sii.sync_count <= offset) { |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1107 |
// no PDO sync managers to configure |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
1108 |
ec_fsm_slave_config_enter_fmmu(fsm); |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1109 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1110 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1111 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1112 |
num_pdo_syncs = slave->sii.sync_count - offset; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1113 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1114 |
// configure sync managers for process data |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1115 |
ec_datagram_fpwr(datagram, slave->station_address, |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1116 |
0x0800 + EC_SYNC_PAGE_SIZE * offset, |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1117 |
EC_SYNC_PAGE_SIZE * num_pdo_syncs); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1180
diff
changeset
|
1118 |
ec_datagram_zero(datagram); |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1119 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1120 |
for (i = 0; i < num_pdo_syncs; i++) { |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1121 |
const ec_sync_config_t *sync_config; |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1122 |
uint8_t pdo_xfer = 0; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
1123 |
sync_index = i + offset; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
1124 |
sync = &slave->sii.syncs[sync_index]; |
1491
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
1125 |
|
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
1126 |
if (slave->config) { |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1127 |
const ec_slave_config_t *sc = slave->config; |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1128 |
sync_config = &sc->sync_configs[sync_index]; |
1491
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
1129 |
size = ec_pdo_list_total_size(&sync_config->pdos); |
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1130 |
|
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1131 |
// determine, if PDOs shall be transferred via this SM |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1132 |
// inthat case, enable sync manager in every case |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1133 |
for (j = 0; j < sc->used_fmmus; j++) { |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1134 |
if (sc->fmmu_configs[j].sync_index == sync_index) { |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1135 |
pdo_xfer = 1; |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1136 |
break; |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1137 |
} |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1138 |
} |
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1139 |
|
1491
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
1140 |
} else { |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1141 |
sync_config = NULL; |
1491
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
1142 |
size = sync->default_length; |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
1143 |
} |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
1144 |
|
2123
4c335a1d4db0
Always enable a sync manager, if there are registered PDOs conatined (and it
Florian Pose <fp@igh-essen.com>
parents:
2104
diff
changeset
|
1145 |
ec_sync_page(sync, sync_index, size, sync_config, pdo_xfer, |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
1146 |
datagram->data + EC_SYNC_PAGE_SIZE * i); |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1147 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1148 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1149 |
fsm->retries = EC_FSM_RETRIES; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1150 |
fsm->state = ec_fsm_slave_config_state_pdo_sync; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1151 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1152 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1153 |
/*****************************************************************************/ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1154 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1155 |
/** Configure PDO sync managers. |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1156 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1157 |
void ec_fsm_slave_config_state_pdo_sync( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1158 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1159 |
) |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1160 |
{ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1161 |
ec_datagram_t *datagram = fsm->datagram; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1162 |
ec_slave_t *slave = fsm->slave; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1163 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1164 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1165 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1166 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1167 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1168 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1169 |
EC_SLAVE_ERR(slave, "Failed to receive process data sync" |
1170 |
" manager configuration datagram: "); |
|
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1520
diff
changeset
|
1171 |
ec_datagram_print_state(datagram); |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1172 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1173 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1174 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1175 |
if (datagram->working_counter != 1) { |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1176 |
slave->error_flag = 1; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1177 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1178 |
EC_SLAVE_ERR(slave, "Failed to set process data sync managers: "); |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1179 |
ec_datagram_print_wc_error(datagram); |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1180 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1181 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1182 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1183 |
ec_fsm_slave_config_enter_fmmu(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1184 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1185 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1186 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1187 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1188 |
/** Check for FMMUs to be configured. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1189 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1190 |
void ec_fsm_slave_config_enter_fmmu( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1191 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1192 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1193 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1194 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1195 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1196 |
unsigned int i; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1197 |
const ec_fmmu_config_t *fmmu; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1198 |
const ec_sync_t *sync; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1199 |
|
1491
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
1200 |
if (!slave->config) { |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
1201 |
ec_fsm_slave_config_enter_safeop(fsm); |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1202 |
return; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1203 |
} |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1204 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1205 |
if (slave->base_fmmu_count < slave->config->used_fmmus) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1206 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1207 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1208 |
EC_SLAVE_ERR(slave, "Slave has less FMMUs (%u)" |
1209 |
" than requested (%u).\n", slave->base_fmmu_count, |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1210 |
slave->config->used_fmmus); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1211 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1212 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1213 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1214 |
if (!slave->base_fmmu_count) { // skip FMMU configuration |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1215 |
ec_fsm_slave_config_enter_dc_cycle(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1216 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1217 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1218 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1219 |
// configure FMMUs |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1220 |
ec_datagram_fpwr(datagram, slave->station_address, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1221 |
0x0600, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1180
diff
changeset
|
1222 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1223 |
for (i = 0; i < slave->config->used_fmmus; i++) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1224 |
fmmu = &slave->config->fmmu_configs[i]; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
1225 |
if (!(sync = ec_slave_get_sync(slave, fmmu->sync_index))) { |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1226 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1227 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1228 |
EC_SLAVE_ERR(slave, "Failed to determine PDO sync manager" |
1229 |
" for FMMU!\n"); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1230 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1231 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1232 |
ec_fmmu_config_page(fmmu, sync, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1233 |
datagram->data + EC_FMMU_PAGE_SIZE * i); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1234 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1235 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1236 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1237 |
fsm->state = ec_fsm_slave_config_state_fmmu; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1238 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1239 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1240 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1241 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1242 |
/** Slave configuration state: FMMU. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1243 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1244 |
void ec_fsm_slave_config_state_fmmu( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1245 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1246 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1247 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1248 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1249 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1250 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1251 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1252 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1253 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1254 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1255 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1256 |
EC_SLAVE_ERR(slave, "Failed to receive FMMUs datagram: "); |
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1520
diff
changeset
|
1257 |
ec_datagram_print_state(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1258 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1259 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1260 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1261 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1262 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1263 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1264 |
EC_SLAVE_ERR(slave, "Failed to set FMMUs: "); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1265 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1266 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1267 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1268 |
|
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1269 |
ec_fsm_slave_config_enter_dc_cycle(fsm); |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1270 |
} |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1271 |
|
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1272 |
/*****************************************************************************/ |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1273 |
|
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1274 |
/** Check for DC to be configured. |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1275 |
*/ |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1276 |
void ec_fsm_slave_config_enter_dc_cycle( |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1277 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1278 |
) |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1279 |
{ |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1280 |
ec_datagram_t *datagram = fsm->datagram; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1281 |
ec_slave_t *slave = fsm->slave; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1282 |
ec_slave_config_t *config = slave->config; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1283 |
|
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1284 |
if (!config) { // config removed in the meantime |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1285 |
ec_fsm_slave_config_reconfigure(fsm); |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1392
diff
changeset
|
1286 |
return; |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1392
diff
changeset
|
1287 |
} |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1288 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1289 |
if (config->dc_assign_activate) { |
1419
8fc38c37d86e
Determine type of DC implementation (full or delay meas. only); update scan FSM graph.
Florian Pose <fp@igh-essen.com>
parents:
1412
diff
changeset
|
1290 |
if (!slave->base_dc_supported || !slave->has_dc_system_time) { |
1921 | 1291 |
EC_SLAVE_WARN(slave, "Slave seems not to support" |
1292 |
" distributed clocks!\n"); |
|
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1293 |
} |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1294 |
|
1921 | 1295 |
EC_SLAVE_DBG(slave, 1, "Setting DC cycle times to %u / %u.\n", |
1296 |
config->dc_sync[0].cycle_time, config->dc_sync[1].cycle_time); |
|
1458 | 1297 |
|
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1298 |
// set DC cycle times |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1299 |
ec_datagram_fpwr(datagram, slave->station_address, 0x09A0, 8); |
1438
1d30b96bb04f
Replaced ecrt_slave_config_dc_cycle_times() and ecrt_slave_config_dc_shift_times() by ecrt_slave_config_dc_sync_signals().
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1300 |
EC_WRITE_U32(datagram->data, config->dc_sync[0].cycle_time); |
1d30b96bb04f
Replaced ecrt_slave_config_dc_cycle_times() and ecrt_slave_config_dc_shift_times() by ecrt_slave_config_dc_sync_signals().
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1301 |
EC_WRITE_U32(datagram->data + 4, config->dc_sync[1].cycle_time); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1302 |
fsm->retries = EC_FSM_RETRIES; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1303 |
fsm->state = ec_fsm_slave_config_state_dc_cycle; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1304 |
} else { |
1404 | 1305 |
// DC are unused |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1392
diff
changeset
|
1306 |
ec_fsm_slave_config_enter_safeop(fsm); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1307 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1308 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1309 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1310 |
/*****************************************************************************/ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1311 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1312 |
/** Slave configuration state: DC CYCLE. |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1313 |
*/ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1314 |
void ec_fsm_slave_config_state_dc_cycle( |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1315 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1316 |
) |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1317 |
{ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1318 |
ec_datagram_t *datagram = fsm->datagram; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1319 |
ec_slave_t *slave = fsm->slave; |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1320 |
ec_slave_config_t *config = slave->config; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1321 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1322 |
if (!config) { // config removed in the meantime |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1323 |
ec_fsm_slave_config_reconfigure(fsm); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1324 |
return; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1325 |
} |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1326 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1327 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1328 |
return; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1329 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1330 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1331 |
fsm->state = ec_fsm_slave_config_state_error; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1332 |
EC_SLAVE_ERR(slave, "Failed to receive DC cycle times datagram: "); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1333 |
ec_datagram_print_state(datagram); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1334 |
return; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1335 |
} |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1336 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1337 |
if (datagram->working_counter != 1) { |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1338 |
slave->error_flag = 1; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1339 |
fsm->state = ec_fsm_slave_config_state_error; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1340 |
EC_SLAVE_ERR(slave, "Failed to set DC cycle times: "); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1341 |
ec_datagram_print_wc_error(datagram); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1342 |
return; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1343 |
} |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1344 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1345 |
EC_SLAVE_DBG(slave, 1, "Checking for synchrony.\n"); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1346 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1347 |
fsm->jiffies_start = jiffies; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1348 |
ec_datagram_fprd(datagram, slave->station_address, 0x092c, 4); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1349 |
fsm->retries = EC_FSM_RETRIES; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1350 |
fsm->state = ec_fsm_slave_config_state_dc_sync_check; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1351 |
} |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1352 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1353 |
/*****************************************************************************/ |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1354 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1355 |
/** Slave configuration state: DC SYNC CHECK. |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1356 |
*/ |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1357 |
void ec_fsm_slave_config_state_dc_sync_check( |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1358 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1359 |
) |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1360 |
{ |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1361 |
ec_datagram_t *datagram = fsm->datagram; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1362 |
ec_slave_t *slave = fsm->slave; |
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1363 |
ec_master_t *master = slave->master; |
1412 | 1364 |
ec_slave_config_t *config = slave->config; |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1365 |
uint32_t abs_sync_diff; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1366 |
unsigned long diff_ms; |
1438
1d30b96bb04f
Replaced ecrt_slave_config_dc_cycle_times() and ecrt_slave_config_dc_shift_times() by ecrt_slave_config_dc_sync_signals().
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1367 |
ec_sync_signal_t *sync0 = &config->dc_sync[0]; |
2658
7690a5df7539
Use SYNC0 + SYNC1 cycle times for cyclic start time generation.
Florian Pose <fp@igh-essen.com>
parents:
2508
diff
changeset
|
1368 |
ec_sync_signal_t *sync1 = &config->dc_sync[1]; |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1392
diff
changeset
|
1369 |
u64 start_time; |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1370 |
|
1412 | 1371 |
if (!config) { // config removed in the meantime |
1372 |
ec_fsm_slave_config_reconfigure(fsm); |
|
1373 |
return; |
|
1374 |
} |
|
1375 |
||
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1376 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1377 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1378 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1379 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1380 |
fsm->state = ec_fsm_slave_config_state_error; |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1381 |
EC_SLAVE_ERR(slave, "Failed to receive DC sync check datagram: "); |
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1520
diff
changeset
|
1382 |
ec_datagram_print_state(datagram); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1383 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1384 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1385 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1386 |
if (datagram->working_counter != 1) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1387 |
slave->error_flag = 1; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1388 |
fsm->state = ec_fsm_slave_config_state_error; |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1389 |
EC_SLAVE_ERR(slave, "Failed to check DC synchrony: "); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1390 |
ec_datagram_print_wc_error(datagram); |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1391 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1392 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1393 |
|
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1394 |
abs_sync_diff = EC_READ_U32(datagram->data) & 0x7fffffff; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1395 |
diff_ms = (datagram->jiffies_received - fsm->jiffies_start) * 1000 / HZ; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1396 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1397 |
if (abs_sync_diff > EC_DC_MAX_SYNC_DIFF_NS) { |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1398 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1399 |
if (diff_ms >= EC_DC_SYNC_WAIT_MS) { |
1931 | 1400 |
EC_SLAVE_WARN(slave, "Slave did not sync after %lu ms.\n", |
1401 |
diff_ms); |
|
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1402 |
} else { |
1931 | 1403 |
EC_SLAVE_DBG(slave, 1, "Sync after %4lu ms: %10u ns\n", |
1404 |
diff_ms, abs_sync_diff); |
|
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1405 |
|
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1406 |
// check synchrony again |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1407 |
ec_datagram_fprd(datagram, slave->station_address, 0x092c, 4); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1408 |
fsm->retries = EC_FSM_RETRIES; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1409 |
return; |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1410 |
} |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1411 |
} else { |
1931 | 1412 |
EC_SLAVE_DBG(slave, 1, "%u ns difference after %lu ms.\n", |
1413 |
abs_sync_diff, diff_ms); |
|
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1414 |
} |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1415 |
|
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1416 |
// set DC start time |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1417 |
start_time = master->app_time + EC_DC_START_OFFSET; // now + X ns |
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1418 |
// FIXME use slave's local system time here? |
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1419 |
|
1438
1d30b96bb04f
Replaced ecrt_slave_config_dc_cycle_times() and ecrt_slave_config_dc_shift_times() by ecrt_slave_config_dc_sync_signals().
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1420 |
if (sync0->cycle_time) { |
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1421 |
// find correct phase |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1422 |
if (master->has_app_time) { |
1438
1d30b96bb04f
Replaced ecrt_slave_config_dc_cycle_times() and ecrt_slave_config_dc_shift_times() by ecrt_slave_config_dc_sync_signals().
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1423 |
u64 diff, start; |
2658
7690a5df7539
Use SYNC0 + SYNC1 cycle times for cyclic start time generation.
Florian Pose <fp@igh-essen.com>
parents:
2508
diff
changeset
|
1424 |
u32 remainder, cycle; |
1438
1d30b96bb04f
Replaced ecrt_slave_config_dc_cycle_times() and ecrt_slave_config_dc_shift_times() by ecrt_slave_config_dc_sync_signals().
Florian Pose <fp@igh-essen.com>
parents:
1436
diff
changeset
|
1425 |
|
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1426 |
diff = start_time - master->app_start_time; |
2658
7690a5df7539
Use SYNC0 + SYNC1 cycle times for cyclic start time generation.
Florian Pose <fp@igh-essen.com>
parents:
2508
diff
changeset
|
1427 |
cycle = sync0->cycle_time + sync1->cycle_time; |
7690a5df7539
Use SYNC0 + SYNC1 cycle times for cyclic start time generation.
Florian Pose <fp@igh-essen.com>
parents:
2508
diff
changeset
|
1428 |
remainder = do_div(diff, cycle); |
7690a5df7539
Use SYNC0 + SYNC1 cycle times for cyclic start time generation.
Florian Pose <fp@igh-essen.com>
parents:
2508
diff
changeset
|
1429 |
|
7690a5df7539
Use SYNC0 + SYNC1 cycle times for cyclic start time generation.
Florian Pose <fp@igh-essen.com>
parents:
2508
diff
changeset
|
1430 |
start = start_time + cycle - remainder + sync0->shift_time; |
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1431 |
|
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1432 |
EC_SLAVE_DBG(slave, 1, "app_start_time=%llu\n", |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1433 |
master->app_start_time); |
2104
330e2d43d3b4
Output app_time in DC debugging.
Florian Pose <fp@igh-essen.com>
parents:
1944
diff
changeset
|
1434 |
EC_SLAVE_DBG(slave, 1, " app_time=%llu\n", master->app_time); |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1435 |
EC_SLAVE_DBG(slave, 1, " start_time=%llu\n", start_time); |
2658
7690a5df7539
Use SYNC0 + SYNC1 cycle times for cyclic start time generation.
Florian Pose <fp@igh-essen.com>
parents:
2508
diff
changeset
|
1436 |
EC_SLAVE_DBG(slave, 1, " cycle=%u\n", cycle); |
2449
5db725cc40f9
Changed the datatypes of the shift times in ecrt_slave_config_dc()
Florian Pose <fp@igh-essen.com>
parents:
2448
diff
changeset
|
1437 |
EC_SLAVE_DBG(slave, 1, " shift_time=%i\n", sync0->shift_time); |
1925
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1438 |
EC_SLAVE_DBG(slave, 1, " remainder=%u\n", remainder); |
29161abef052
Write DC system time offsets right after slave scan / config change. Wait for DC clock discipline.
Florian Pose <fp@igh-essen.com>
parents:
1921
diff
changeset
|
1439 |
EC_SLAVE_DBG(slave, 1, " start=%llu\n", start); |
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1440 |
start_time = start; |
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1441 |
} else { |
1921 | 1442 |
EC_SLAVE_WARN(slave, "No application time supplied." |
1443 |
" Cyclic start time will not be in phase.\n"); |
|
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1444 |
} |
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1445 |
} |
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1446 |
|
1921 | 1447 |
EC_SLAVE_DBG(slave, 1, "Setting DC cyclic operation" |
1448 |
" start time to %llu.\n", start_time); |
|
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1392
diff
changeset
|
1449 |
|
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1450 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0990, 8); |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1392
diff
changeset
|
1451 |
EC_WRITE_U64(datagram->data, start_time); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1452 |
fsm->retries = EC_FSM_RETRIES; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1453 |
fsm->state = ec_fsm_slave_config_state_dc_start; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1454 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1455 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1456 |
/*****************************************************************************/ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1457 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1458 |
/** Slave configuration state: DC START. |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1459 |
*/ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1460 |
void ec_fsm_slave_config_state_dc_start( |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1461 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1462 |
) |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1463 |
{ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1464 |
ec_datagram_t *datagram = fsm->datagram; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1465 |
ec_slave_t *slave = fsm->slave; |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1466 |
ec_slave_config_t *config = slave->config; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1467 |
|
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1468 |
if (!config) { // config removed in the meantime |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1469 |
ec_fsm_slave_config_reconfigure(fsm); |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1470 |
return; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1471 |
} |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1472 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1473 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1474 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1475 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1476 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1477 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1478 |
EC_SLAVE_ERR(slave, "Failed to receive DC start time datagram: "); |
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1520
diff
changeset
|
1479 |
ec_datagram_print_state(datagram); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1480 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1481 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1482 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1483 |
if (datagram->working_counter != 1) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1484 |
slave->error_flag = 1; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1485 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1486 |
EC_SLAVE_ERR(slave, "Failed to set DC start time: "); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1487 |
ec_datagram_print_wc_error(datagram); |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1488 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1489 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1490 |
|
1921 | 1491 |
EC_SLAVE_DBG(slave, 1, "Setting DC AssignActivate to 0x%04x.\n", |
1492 |
config->dc_assign_activate); |
|
1458 | 1493 |
|
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1494 |
// assign sync unit to EtherCAT or PDI |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1495 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0980, 2); |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1496 |
EC_WRITE_U16(datagram->data, config->dc_assign_activate); |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1497 |
fsm->retries = EC_FSM_RETRIES; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1498 |
fsm->state = ec_fsm_slave_config_state_dc_assign; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1499 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1500 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1501 |
/*****************************************************************************/ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1502 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1503 |
/** Slave configuration state: DC ASSIGN. |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1504 |
*/ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1505 |
void ec_fsm_slave_config_state_dc_assign( |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1506 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1507 |
) |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1508 |
{ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1509 |
ec_datagram_t *datagram = fsm->datagram; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1510 |
ec_slave_t *slave = fsm->slave; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1511 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1512 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1513 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1514 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1515 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1516 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1517 |
EC_SLAVE_ERR(slave, "Failed to receive DC activation datagram: "); |
1822
74e6ac2369f4
Introduced ec_datagram_print_state() method and used it at all places where
Florian Pose <fp@igh-essen.com>
parents:
1520
diff
changeset
|
1518 |
ec_datagram_print_state(datagram); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1519 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1520 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1521 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1522 |
if (datagram->working_counter != 1) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1523 |
slave->error_flag = 1; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1524 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1525 |
EC_SLAVE_ERR(slave, "Failed to activate DC: "); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1526 |
ec_datagram_print_wc_error(datagram); |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1527 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1528 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1529 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1530 |
ec_fsm_slave_config_enter_safeop(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1531 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1532 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1533 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1534 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1535 |
/** Request SAFEOP state. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1536 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1537 |
void ec_fsm_slave_config_enter_safeop( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1538 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1539 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1540 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1541 |
fsm->state = ec_fsm_slave_config_state_safeop; |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1542 |
ec_fsm_change_start(fsm->fsm_change, fsm->slave, EC_SLAVE_STATE_SAFEOP); |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1543 |
ec_fsm_change_exec(fsm->fsm_change); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1544 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1545 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1546 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1547 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1548 |
/** Slave configuration state: SAFEOP. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1549 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1550 |
void ec_fsm_slave_config_state_safeop( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1551 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1552 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1553 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1554 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1555 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1556 |
if (ec_fsm_change_exec(fsm->fsm_change)) return; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1557 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1558 |
if (!ec_fsm_change_success(fsm->fsm_change)) { |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1559 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1560 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1561 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1562 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1563 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1564 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1565 |
// slave is now in SAFEOP |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1566 |
|
1921 | 1567 |
EC_SLAVE_DBG(slave, 1, "Now in SAFEOP.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1568 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1569 |
if (fsm->slave->current_state == fsm->slave->requested_state) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1570 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
1921 | 1571 |
EC_SLAVE_DBG(slave, 1, "Finished configuration.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1572 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1573 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1574 |
|
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1575 |
ec_fsm_slave_config_enter_soe_conf_safeop(fsm); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1576 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1577 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1578 |
/*****************************************************************************/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1579 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1580 |
/** Check for SoE configurations to be applied in SAFEOP. |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1581 |
*/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1582 |
void ec_fsm_slave_config_enter_soe_conf_safeop( |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1583 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1584 |
) |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1585 |
{ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1586 |
ec_slave_t *slave = fsm->slave; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1587 |
ec_soe_request_t *req; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1588 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1589 |
if (!slave->config) { |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1590 |
ec_fsm_slave_config_enter_op(fsm); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1591 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1592 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1593 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1594 |
list_for_each_entry(req, &slave->config->soe_configs, list) { |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1595 |
if (req->al_state == EC_AL_STATE_SAFEOP) { |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1596 |
// start SoE configuration |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1597 |
fsm->state = ec_fsm_slave_config_state_soe_conf_safeop; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1598 |
fsm->soe_request = req; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1599 |
ec_soe_request_copy(&fsm->soe_request_copy, fsm->soe_request); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1600 |
ec_soe_request_write(&fsm->soe_request_copy); |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
1601 |
ec_fsm_soe_transfer(fsm->fsm_soe, fsm->slave, |
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
1602 |
&fsm->soe_request_copy); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
1603 |
ec_fsm_soe_exec(fsm->fsm_soe, fsm->datagram); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1604 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1605 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1606 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1607 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1608 |
// No SoE configuration to be applied in SAFEOP |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1609 |
ec_fsm_slave_config_enter_op(fsm); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1610 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1611 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1612 |
/*****************************************************************************/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1613 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1614 |
/** Slave configuration state: SOE_CONF. |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1615 |
*/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1616 |
void ec_fsm_slave_config_state_soe_conf_safeop( |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1617 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1618 |
) |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1619 |
{ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1620 |
ec_slave_t *slave = fsm->slave; |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
1621 |
|
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
1622 |
if (ec_fsm_soe_exec(fsm->fsm_soe, fsm->datagram)) { |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
1623 |
return; |
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
1624 |
} |
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
1625 |
|
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
1626 |
if (!ec_fsm_soe_success(fsm->fsm_soe)) { |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1627 |
EC_SLAVE_ERR(slave, "SoE configuration failed.\n"); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1628 |
fsm->slave->error_flag = 1; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1629 |
fsm->state = ec_fsm_slave_config_state_error; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1630 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1631 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1632 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1633 |
if (!fsm->slave->config) { // config removed in the meantime |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1634 |
ec_fsm_slave_config_reconfigure(fsm); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1635 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1636 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1637 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1638 |
// Another IDN to configure in SAFEOP? |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1639 |
while (fsm->soe_request->list.next != &fsm->slave->config->soe_configs) { |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1640 |
fsm->soe_request = list_entry(fsm->soe_request->list.next, |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1641 |
ec_soe_request_t, list); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1642 |
if (fsm->soe_request->al_state == EC_AL_STATE_SAFEOP) { |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1643 |
ec_soe_request_copy(&fsm->soe_request_copy, fsm->soe_request); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1644 |
ec_soe_request_write(&fsm->soe_request_copy); |
2482
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
1645 |
ec_fsm_soe_transfer(fsm->fsm_soe, fsm->slave, |
06b53ebfa0c3
Do not use slaves's SoE state machine for configuration.
Florian Pose <fp@igh-essen.com>
parents:
2449
diff
changeset
|
1646 |
&fsm->soe_request_copy); |
2498
9cdd7669dc0b
Avoided io_sem locking from userspace/rtdm library.
Florian Pose <fp@igh-essen.com>
parents:
2482
diff
changeset
|
1647 |
ec_fsm_soe_exec(fsm->fsm_soe, fsm->datagram); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1648 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1649 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1650 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1651 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1652 |
// All SAFEOP IDNs are now configured. |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1653 |
ec_fsm_slave_config_enter_op(fsm); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1654 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1655 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1656 |
/*****************************************************************************/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1657 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1658 |
/** Bring slave to OP. |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1659 |
*/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1660 |
void ec_fsm_slave_config_enter_op( |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1661 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1662 |
) |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1663 |
{ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1664 |
// set state to OP |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1665 |
fsm->state = ec_fsm_slave_config_state_op; |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1666 |
ec_fsm_change_start(fsm->fsm_change, fsm->slave, EC_SLAVE_STATE_OP); |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1667 |
ec_fsm_change_exec(fsm->fsm_change); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1668 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1669 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1670 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1671 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1672 |
/** Slave configuration state: OP |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1673 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1674 |
void ec_fsm_slave_config_state_op( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1675 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1676 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1677 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1678 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1679 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1680 |
if (ec_fsm_change_exec(fsm->fsm_change)) return; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1681 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1682 |
if (!ec_fsm_change_success(fsm->fsm_change)) { |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1683 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1684 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1685 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1686 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1687 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1688 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1689 |
// slave is now in OP |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1690 |
|
1921 | 1691 |
EC_SLAVE_DBG(slave, 1, "Now in OP. Finished configuration.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1692 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1693 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1694 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1695 |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1696 |
/*****************************************************************************/ |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1697 |
|
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1698 |
/** Reconfigure the slave starting at INIT. |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1699 |
*/ |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1700 |
void ec_fsm_slave_config_reconfigure( |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1701 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1702 |
) |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1703 |
{ |
1921 | 1704 |
EC_SLAVE_DBG(fsm->slave, 1, "Slave configuration detached during " |
1705 |
"configuration. Reconfiguring."); |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1706 |
|
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1707 |
ec_fsm_slave_config_enter_init(fsm); // reconfigure |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1708 |
} |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1709 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1710 |
/****************************************************************************** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1711 |
* Common state functions |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1712 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1713 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1714 |
/** State: ERROR. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1715 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1716 |
void ec_fsm_slave_config_state_error( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1717 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1718 |
) |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1719 |
{ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1720 |
} |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1721 |
|
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1722 |
/*****************************************************************************/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1723 |
|
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1724 |
/** State: END. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1725 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1726 |
void ec_fsm_slave_config_state_end( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1727 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1728 |
) |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1729 |
{ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1730 |
} |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1731 |
|
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1732 |
/*****************************************************************************/ |