author | Florian Pose <fp@igh-essen.com> |
Fri, 28 Oct 2011 11:31:54 +0200 | |
changeset 2126 | 0383b71b88e4 |
parent 2045 | ff2a13a4603c |
child 2149 | 98e1e773bed0 |
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 |
*/ |
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
|
52 |
#define EC_DC_MAX_SYNC_DIFF_NS 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
|
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 *); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
70 |
void ec_fsm_slave_config_state_boot_preop(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
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
|
83 |
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
|
84 |
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
|
85 |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
86 |
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
|
87 |
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
|
88 |
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
|
89 |
void ec_fsm_slave_config_enter_mbox_sync(ec_fsm_slave_config_t *); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
90 |
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
|
91 |
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
|
92 |
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
|
93 |
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
|
94 |
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
|
95 |
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
|
96 |
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
|
97 |
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
|
98 |
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
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
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
|
104 |
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
|
105 |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
106 |
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
|
107 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
108 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
109 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
110 |
/** Constructor. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
*/ |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
112 |
void ec_fsm_slave_config_init( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
ec_fsm_coe_t *fsm_coe, /**< CoE 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
|
117 |
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
|
118 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
{ |
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
120 |
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
|
121 |
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
|
122 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
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
|
124 |
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
|
125 |
fsm->fsm_coe = fsm_coe; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
126 |
fsm->fsm_pdo = fsm_pdo; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
} |
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 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
/** Destructor. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
*/ |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
133 |
void ec_fsm_slave_config_clear( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
134 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
135 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
{ |
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
137 |
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
|
138 |
ec_soe_request_clear(&fsm->soe_request_copy); |
830
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 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
143 |
/** Start slave configuration state machine. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
144 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
145 |
void ec_fsm_slave_config_start( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
146 |
ec_fsm_slave_config_t *fsm, /**< slave state machine */ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
ec_slave_t *slave /**< slave to configure */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
fsm->slave = slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
fsm->state = ec_fsm_slave_config_state_start; |
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 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
/** |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
157 |
* \return false, if state machine has terminated |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
158 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
159 |
int ec_fsm_slave_config_running( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
160 |
const ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
161 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
return fsm->state != ec_fsm_slave_config_state_end |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
&& fsm->state != ec_fsm_slave_config_state_error; |
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 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
169 |
/** Executes the current state of the state machine. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
170 |
* |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
171 |
* 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
|
172 |
* of the state machine is delayed to the next cycle. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
173 |
* |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
174 |
* \return false, if state machine has terminated |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
175 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
176 |
int ec_fsm_slave_config_exec( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
177 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
178 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
{ |
2044
1ae0491b2f6b
fixed race condition when comparing datagram state
Martin Troxler <ch1010277@ch10pc446>
parents:
2018
diff
changeset
|
180 |
if (fsm->datagram->state == EC_DATAGRAM_QUEUED |
1ae0491b2f6b
fixed race condition when comparing datagram state
Martin Troxler <ch1010277@ch10pc446>
parents:
2018
diff
changeset
|
181 |
|| fsm->datagram->state == EC_DATAGRAM_SENT) { |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
// datagram was not sent or received yet. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
return ec_fsm_slave_config_running(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
fsm->state(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
return ec_fsm_slave_config_running(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
|
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 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
/** |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
193 |
* \return true, if the state machine terminated gracefully |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
194 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
195 |
int ec_fsm_slave_config_success( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
196 |
const ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
197 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
return fsm->state == ec_fsm_slave_config_state_end; |
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 |
* Slave configuration state machine |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
206 |
/** Slave configuration state: START. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
207 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
208 |
void ec_fsm_slave_config_state_start( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
209 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
210 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
{ |
1921 | 212 |
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
|
213 |
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
|
214 |
} |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
215 |
|
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
216 |
/*****************************************************************************/ |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
217 |
|
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
218 |
/** 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
|
219 |
*/ |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
220 |
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
|
221 |
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
|
222 |
) |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
223 |
{ |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
224 |
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
|
225 |
ec_fsm_change_exec(fsm->fsm_change); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
fsm->state = ec_fsm_slave_config_state_init; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
231 |
/** Slave configuration state: INIT. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
232 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
233 |
void ec_fsm_slave_config_state_init( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
234 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
235 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
240 |
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
|
241 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
242 |
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
|
243 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
return; |
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 |
|
1921 | 249 |
EC_SLAVE_DBG(slave, 1, "Now in INIT.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
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
|
252 |
ec_fsm_slave_config_enter_clear_sync(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
|
1921 | 256 |
EC_SLAVE_DBG(slave, 1, "Clearing FMMU configurations...\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
257 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
// clear FMMU configurations |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
ec_datagram_fpwr(datagram, slave->station_address, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
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
|
261 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
fsm->state = ec_fsm_slave_config_state_clear_fmmus; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
} |
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 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
268 |
/** Slave configuration state: CLEAR FMMU. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
269 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
270 |
void ec_fsm_slave_config_state_clear_fmmus( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
271 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
272 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
273 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
274 |
ec_datagram_t *datagram = fsm->datagram; |
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 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
278 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 281 |
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
|
282 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
283 |
} |
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 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
286 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 288 |
EC_SLAVE_ERR(fsm->slave, "Failed to clear FMMUs: "); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
289 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
290 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
292 |
|
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
293 |
ec_fsm_slave_config_enter_clear_sync(fsm); |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
294 |
} |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
295 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
296 |
/*****************************************************************************/ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
297 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
298 |
/** Clear the sync manager configurations. |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
299 |
*/ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
300 |
void ec_fsm_slave_config_enter_clear_sync( |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
301 |
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
|
302 |
) |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
303 |
{ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
304 |
ec_slave_t *slave = fsm->slave; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
305 |
ec_datagram_t *datagram = fsm->datagram; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
306 |
size_t sync_size; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
307 |
|
1471
2ec173081b7f
Fixed mailbox usage for slaves that do not provide sync manager
Florian Pose <fp@igh-essen.com>
parents:
1458
diff
changeset
|
308 |
if (!slave->base_sync_count) { |
1404 | 309 |
// no sync managers |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
310 |
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
|
311 |
return; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
312 |
} |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
313 |
|
1921 | 314 |
EC_SLAVE_DBG(slave, 1, "Clearing sync manager configurations...\n"); |
1344 | 315 |
|
1471
2ec173081b7f
Fixed mailbox usage for slaves that do not provide sync manager
Florian Pose <fp@igh-essen.com>
parents:
1458
diff
changeset
|
316 |
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
|
317 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
318 |
// clear sync manager configurations |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
319 |
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
|
320 |
ec_datagram_zero(datagram); |
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
321 |
fsm->retries = EC_FSM_RETRIES; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
322 |
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
|
323 |
} |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
324 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
325 |
/*****************************************************************************/ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
326 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
327 |
/** Slave configuration state: CLEAR SYNC. |
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 |
void ec_fsm_slave_config_state_clear_sync( |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
330 |
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
|
331 |
) |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
332 |
{ |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
333 |
ec_datagram_t *datagram = fsm->datagram; |
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 |
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
|
336 |
return; |
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 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
339 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 340 |
EC_SLAVE_ERR(fsm->slave, "Failed receive sync manager" |
341 |
" clearing datagram.\n"); |
|
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
342 |
return; |
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 |
|
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
345 |
if (datagram->working_counter != 1) { |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
346 |
fsm->slave->error_flag = 1; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
347 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 348 |
EC_SLAVE_ERR(fsm->slave, |
349 |
"Failed to clear sync manager configurations: "); |
|
1342
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
350 |
ec_datagram_print_wc_error(datagram); |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
351 |
return; |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
352 |
} |
a72b9b370277
Clear sync managers before configuration.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
353 |
|
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
354 |
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
|
355 |
} |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
356 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
357 |
/*****************************************************************************/ |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
358 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
359 |
/** Clear the DC assignment. |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
360 |
*/ |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
361 |
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
|
362 |
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
|
363 |
) |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
364 |
{ |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
365 |
ec_slave_t *slave = fsm->slave; |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
366 |
ec_datagram_t *datagram = fsm->datagram; |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
367 |
|
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
|
368 |
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
|
369 |
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
|
370 |
return; |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
371 |
} |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
372 |
|
1921 | 373 |
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
|
374 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
375 |
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
|
376 |
ec_datagram_zero(datagram); |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
377 |
fsm->retries = EC_FSM_RETRIES; |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
378 |
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
|
379 |
} |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
380 |
|
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
381 |
/*****************************************************************************/ |
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 |
/** Slave configuration state: CLEAR DC ASSIGN. |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
384 |
*/ |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
385 |
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
|
386 |
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
|
387 |
) |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
388 |
{ |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
389 |
ec_datagram_t *datagram = fsm->datagram; |
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 |
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
|
392 |
return; |
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 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
8686c5b3d14b
Clear DC assignment after going to INIT.
Florian Pose <fp@igh-essen.com>
parents:
1404
diff
changeset
|
395 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 396 |
EC_SLAVE_ERR(fsm->slave, "Failed receive DC assignment" |
397 |
" clearing datagram.\n"); |
|
398 |
return; |
|
399 |
} |
|
400 |
||
401 |
if (datagram->working_counter != 1) { |
|
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
402 |
// clearing the DC assignment does not succeed on simple slaves |
1921 | 403 |
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
|
404 |
ec_datagram_print_wc_error(datagram); |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
405 |
} |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
406 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
407 |
ec_fsm_slave_config_enter_mbox_sync(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
408 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
409 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
410 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
411 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
412 |
/** Check for mailbox sync managers to be configured. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
413 |
*/ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
414 |
void ec_fsm_slave_config_enter_mbox_sync( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
415 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
416 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
417 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
418 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
419 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
420 |
unsigned int i; |
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 |
// slave is now in INIT |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
423 |
if (slave->current_state == slave->requested_state) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
424 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
1921 | 425 |
EC_SLAVE_DBG(slave, 1, "Finished configuration.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
426 |
return; |
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 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
429 |
if (!slave->sii.mailbox_protocols) { |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
430 |
// no mailbox protocols supported |
1921 | 431 |
EC_SLAVE_DBG(slave, 1, "Slave does not support" |
432 |
" mailbox communication.\n"); |
|
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
433 |
ec_fsm_slave_config_enter_boot_preop(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
434 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
435 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
436 |
|
1921 | 437 |
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
|
438 |
|
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
439 |
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
|
440 |
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
|
441 |
|
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
442 |
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
|
443 |
EC_SYNC_PAGE_SIZE * 2); |
1896
1d4bca6ba543
Use ec_datagram_zero() wherever possible.
Florian Pose <fp@igh-essen.com>
parents:
1889
diff
changeset
|
444 |
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
|
445 |
|
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
446 |
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
|
447 |
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
|
448 |
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
|
449 |
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
|
450 |
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
|
451 |
EC_DIR_INVALID, // use default direction |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
452 |
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
|
453 |
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
|
454 |
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
|
455 |
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
|
456 |
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
|
457 |
|
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_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
|
459 |
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
|
460 |
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
|
461 |
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
|
462 |
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
|
463 |
EC_DIR_INVALID, // use default direction |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
464 |
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
|
465 |
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
|
466 |
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
|
467 |
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
|
468 |
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
|
469 |
|
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
470 |
} 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
|
471 |
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
|
472 |
EC_SYNC_PAGE_SIZE * slave->sii.sync_count); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1180
diff
changeset
|
473 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
474 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
475 |
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
|
476 |
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
|
477 |
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
|
478 |
NULL, // use default sync manager configuration |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
479 |
datagram->data + EC_SYNC_PAGE_SIZE * i); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
480 |
} |
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
|
481 |
|
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_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
|
483 |
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
|
484 |
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
|
485 |
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
|
486 |
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
|
487 |
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
|
488 |
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
|
489 |
slave->sii.syncs[1].default_length; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
490 |
} else { // no mailbox sync manager configurations provided |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
491 |
ec_sync_t sync; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
492 |
|
1921 | 493 |
EC_SLAVE_DBG(slave, 1, "Slave does not provide" |
494 |
" mailbox sync manager configurations.\n"); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
495 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
496 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0800, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
497 |
EC_SYNC_PAGE_SIZE * 2); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1180
diff
changeset
|
498 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
499 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
500 |
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
|
501 |
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
|
502 |
sync.control_register = 0x26; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
503 |
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
|
504 |
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
|
505 |
NULL, // use default sync manager configuration |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
506 |
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
|
507 |
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
|
508 |
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
|
509 |
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
|
510 |
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
|
511 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
512 |
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
|
513 |
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
|
514 |
sync.control_register = 0x22; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
515 |
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
|
516 |
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
|
517 |
NULL, // use default sync manager configuration |
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 |
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
|
519 |
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
|
520 |
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
|
521 |
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
|
522 |
slave->sii.std_tx_mailbox_size; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
523 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
524 |
|
1347
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
525 |
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
|
526 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
527 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
528 |
fsm->state = ec_fsm_slave_config_state_mbox_sync; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
529 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
530 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
531 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
532 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
533 |
/** Slave configuration state: SYNC. |
1345 | 534 |
* |
535 |
* \todo Timeout for response. |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
536 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
537 |
void ec_fsm_slave_config_state_mbox_sync( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
538 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
539 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
540 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
541 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
542 |
ec_slave_t *slave = fsm->slave; |
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 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
545 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
546 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
547 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
548 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 549 |
EC_SLAVE_ERR(slave, "Failed to receive sync manager" |
550 |
" 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
|
551 |
ec_datagram_print_state(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
552 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
553 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
554 |
|
1347
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
555 |
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
|
556 |
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
|
557 |
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
|
558 |
} |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
559 |
|
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
560 |
/* 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
|
561 |
* 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
|
562 |
* 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
|
563 |
* 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
|
564 |
*/ |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
565 |
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
|
566 |
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
|
567 |
|
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
568 |
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
|
569 |
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
|
570 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 571 |
EC_SLAVE_ERR(slave, "Timeout while configuring" |
572 |
" 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
|
573 |
return; |
1921 | 574 |
} else { |
575 |
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
|
576 |
(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
|
577 |
} |
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 |
// 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
|
580 |
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
|
581 |
return; |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
582 |
} |
41360ffdcb14
Allow the slave to not respond to the mailbox sync manager configuration
Florian Pose <fp@igh-essen.com>
parents:
1345
diff
changeset
|
583 |
else if (datagram->working_counter != 1) { |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
584 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
585 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 586 |
EC_SLAVE_ERR(slave, "Failed to set sync managers: "); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
587 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
588 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
589 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
590 |
|
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
591 |
ec_fsm_slave_config_enter_boot_preop(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
592 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
593 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
594 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
595 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
596 |
/** Request PREOP state. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
597 |
*/ |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
598 |
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
|
599 |
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
|
600 |
) |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
601 |
{ |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
602 |
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
|
603 |
|
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
604 |
if (fsm->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
|
605 |
ec_fsm_change_start(fsm->fsm_change, fsm->slave, EC_SLAVE_STATE_PREOP); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
606 |
} else { // BOOT |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
607 |
ec_fsm_change_start(fsm->fsm_change, fsm->slave, 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
|
608 |
} |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
609 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
610 |
ec_fsm_change_exec(fsm->fsm_change); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
611 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
612 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
613 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
614 |
|
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
615 |
/** 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
|
616 |
*/ |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
617 |
void ec_fsm_slave_config_state_boot_preop( |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
618 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
619 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
620 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
621 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
622 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
623 |
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
|
624 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
625 |
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
|
626 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
627 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
628 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
629 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
630 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
631 |
|
1404 | 632 |
// slave is now in BOOT or PREOP |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
633 |
slave->jiffies_preop = fsm->datagram->jiffies_received; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
634 |
|
1921 | 635 |
EC_SLAVE_DBG(slave, 1, "Now in %s.\n", |
636 |
slave->requested_state != EC_SLAVE_STATE_BOOT ? "PREOP" : "BOOT"); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
637 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
638 |
if (slave->current_state == slave->requested_state) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
639 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
1921 | 640 |
EC_SLAVE_DBG(slave, 1, "Finished configuration.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
641 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
642 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
643 |
|
1491
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
644 |
ec_fsm_slave_config_enter_sdo_conf(fsm); |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
645 |
} |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
646 |
|
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
647 |
/*****************************************************************************/ |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
648 |
|
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
649 |
/** 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
|
650 |
*/ |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
651 |
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
|
652 |
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
|
653 |
) |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
654 |
{ |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
655 |
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
|
656 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
657 |
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
|
658 |
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
|
659 |
return; |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
660 |
} |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
661 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
662 |
// 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
|
663 |
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
|
664 |
ec_fsm_slave_config_enter_soe_conf_preop(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
665 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
666 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
667 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
668 |
// start SDO configuration |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
669 |
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
|
670 |
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
|
671 |
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
|
672 |
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
|
673 |
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
|
674 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request_copy); |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
675 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
830
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 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
678 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
679 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
680 |
/** Slave configuration state: SDO_CONF. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
681 |
*/ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
682 |
void ec_fsm_slave_config_state_sdo_conf( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
683 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
684 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
685 |
{ |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
686 |
if (ec_fsm_coe_exec(fsm->fsm_coe)) return; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
687 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
688 |
if (!ec_fsm_coe_success(fsm->fsm_coe)) { |
1921 | 689 |
EC_SLAVE_ERR(fsm->slave, "SDO configuration failed.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
690 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
691 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
692 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
693 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
694 |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
695 |
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
|
696 |
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
|
697 |
return; |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
698 |
} |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
699 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
700 |
// 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
|
701 |
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
|
702 |
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
|
703 |
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
|
704 |
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
|
705 |
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
|
706 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request_copy); |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
707 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
708 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
709 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
710 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
711 |
// 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
|
712 |
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
|
713 |
} |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
714 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
715 |
/*****************************************************************************/ |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
716 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
717 |
/** 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
|
718 |
*/ |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
719 |
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
|
720 |
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
|
721 |
) |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
722 |
{ |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
723 |
ec_slave_t *slave = fsm->slave; |
1873
219be3742274
Added missing queue_external_datagram(); removed tabs.
Florian Pose <fp@igh-essen.com>
parents:
1849
diff
changeset
|
724 |
ec_fsm_soe_t *fsm_soe = &slave->fsm.fsm_soe; |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
725 |
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
|
726 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
727 |
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
|
728 |
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
|
729 |
return; |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
730 |
} |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
731 |
|
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
732 |
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
|
733 |
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
|
734 |
// start SoE configuration |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
735 |
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
|
736 |
fsm->soe_request = req; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
737 |
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
|
738 |
ec_soe_request_write(&fsm->soe_request_copy); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
739 |
ec_fsm_soe_transfer(fsm_soe, fsm->slave, &fsm->soe_request_copy); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
740 |
ec_fsm_soe_exec(fsm_soe); // execute immediately |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
2044
diff
changeset
|
741 |
ec_slave_mbox_queue_datagrams(slave, fsm_soe->mbox); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
742 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
743 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
744 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
745 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
746 |
// 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
|
747 |
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
|
748 |
} |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
749 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
750 |
/*****************************************************************************/ |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
751 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
752 |
/** 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
|
753 |
*/ |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
754 |
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
|
755 |
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
|
756 |
) |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
757 |
{ |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
758 |
ec_slave_t *slave = fsm->slave; |
1873
219be3742274
Added missing queue_external_datagram(); removed tabs.
Florian Pose <fp@igh-essen.com>
parents:
1849
diff
changeset
|
759 |
ec_fsm_soe_t *fsm_soe = &slave->fsm.fsm_soe; |
1844
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
760 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
761 |
if (ec_fsm_soe_exec(fsm_soe)) { |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
2044
diff
changeset
|
762 |
ec_slave_mbox_queue_datagrams(slave, fsm_soe->mbox); |
1873
219be3742274
Added missing queue_external_datagram(); removed tabs.
Florian Pose <fp@igh-essen.com>
parents:
1849
diff
changeset
|
763 |
return; |
219be3742274
Added missing queue_external_datagram(); removed tabs.
Florian Pose <fp@igh-essen.com>
parents:
1849
diff
changeset
|
764 |
} |
1844
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
765 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
766 |
if (!ec_fsm_soe_success(fsm_soe)) { |
1921 | 767 |
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
|
768 |
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
|
769 |
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
|
770 |
return; |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
771 |
} |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
772 |
|
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
773 |
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
|
774 |
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
|
775 |
return; |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
776 |
} |
b6bd88d4806b
Added ecrt_slave_config_idn() method to store SoE IDN configurations.
Florian Pose <fp@igh-essen.com>
parents:
1822
diff
changeset
|
777 |
|
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
778 |
// 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
|
779 |
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
|
780 |
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
|
781 |
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
|
782 |
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
|
783 |
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
|
784 |
ec_soe_request_write(&fsm->soe_request_copy); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
785 |
ec_fsm_soe_transfer(fsm_soe, fsm->slave, &fsm->soe_request_copy); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
786 |
ec_fsm_soe_exec(fsm_soe); // execute immediately |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
2044
diff
changeset
|
787 |
ec_slave_mbox_queue_datagrams(slave, fsm_soe->mbox); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
788 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
789 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
790 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
791 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
792 |
// 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
|
793 |
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
|
794 |
} |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
795 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
796 |
/*****************************************************************************/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
797 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
798 |
/** PDO_CONF entry function. |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
799 |
*/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
800 |
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
|
801 |
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
|
802 |
) |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
803 |
{ |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
804 |
// Start configuring PDOs |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
805 |
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
|
806 |
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
|
807 |
fsm->state(fsm); // execute immediately |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
808 |
} |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
809 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
810 |
/*****************************************************************************/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
811 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
812 |
/** Slave configuration state: PDO_CONF. |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
813 |
*/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
814 |
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
|
815 |
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
|
816 |
) |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
817 |
{ |
1507
68e89abadd19
Removed unwanted tabulators.
Florian Pose <fp@igh-essen.com>
parents:
1491
diff
changeset
|
818 |
// TODO check for config here |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
819 |
|
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
820 |
if (ec_fsm_pdo_exec(fsm->fsm_pdo)) |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
821 |
return; |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
822 |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
823 |
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
|
824 |
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
|
825 |
return; |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
826 |
} |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
827 |
|
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
828 |
if (!ec_fsm_pdo_success(fsm->fsm_pdo)) { |
1921 | 829 |
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
|
830 |
} |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
831 |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
832 |
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
|
833 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
834 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
835 |
/*****************************************************************************/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
836 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
837 |
/** 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
|
838 |
*/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
839 |
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
|
840 |
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
|
841 |
) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
842 |
{ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
843 |
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
|
844 |
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
|
845 |
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
|
846 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
847 |
if (config && config->watchdog_divider) { |
1921 | 848 |
EC_SLAVE_DBG(slave, 1, "Setting watchdog divider to %u.\n", |
849 |
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
|
850 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
851 |
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
|
852 |
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
|
853 |
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
|
854 |
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
|
855 |
} else { |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
856 |
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
|
857 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
858 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
859 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
860 |
/*****************************************************************************/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
861 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
862 |
/** 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
|
863 |
*/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
864 |
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
|
865 |
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
|
866 |
) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
867 |
{ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
868 |
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
|
869 |
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
|
870 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
871 |
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
|
872 |
return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
873 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
874 |
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
|
875 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 876 |
EC_SLAVE_ERR(slave, "Failed to receive watchdog divider" |
877 |
" 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
|
878 |
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
|
879 |
return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
880 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
881 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
882 |
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
|
883 |
slave->error_flag = 1; |
1921 | 884 |
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
|
885 |
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
|
886 |
return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
887 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
888 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
889 |
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
|
890 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
891 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
892 |
/*****************************************************************************/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
893 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
894 |
/** WATCHDOG entry function |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
895 |
*/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
896 |
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
|
897 |
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
|
898 |
) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
899 |
{ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
900 |
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
|
901 |
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
|
902 |
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
|
903 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
904 |
if (config && config->watchdog_intervals) { |
1921 | 905 |
EC_SLAVE_DBG(slave, 1, "Setting process data" |
906 |
" 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
|
907 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
908 |
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
|
909 |
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
|
910 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
911 |
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
|
912 |
fsm->state = ec_fsm_slave_config_state_watchdog; |
1520
09cf61d61af0
Fixed setting watchdog intervals.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
913 |
} else { |
09cf61d61af0
Fixed setting watchdog intervals.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
914 |
ec_fsm_slave_config_enter_pdo_sync(fsm); |
09cf61d61af0
Fixed setting watchdog intervals.
Florian Pose <fp@igh-essen.com>
parents:
1509
diff
changeset
|
915 |
} |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
916 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
917 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
918 |
/*****************************************************************************/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
919 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
920 |
/** 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
|
921 |
*/ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
922 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
923 |
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
|
924 |
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
|
925 |
) |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
926 |
{ |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
927 |
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
|
928 |
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
|
929 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
930 |
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
|
931 |
return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
932 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
933 |
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
|
934 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 935 |
EC_SLAVE_ERR(slave, "Failed to receive sync manager" |
936 |
" 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
|
937 |
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
|
938 |
return; |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
939 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
940 |
|
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
941 |
if (datagram->working_counter != 1) { |
1921 | 942 |
EC_SLAVE_WARN(slave, "Failed to set process data" |
943 |
" watchdog intervals: "); |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
944 |
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
|
945 |
} |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
946 |
|
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
947 |
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
|
948 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
949 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
950 |
/*****************************************************************************/ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
951 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
952 |
/** Check for PDO sync managers to be configured. |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
953 |
*/ |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
954 |
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
|
955 |
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
|
956 |
) |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
957 |
{ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
958 |
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
|
959 |
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
|
960 |
unsigned int i, 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
|
961 |
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
|
962 |
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
|
963 |
uint16_t size; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
964 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
965 |
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
|
966 |
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
|
967 |
} else { |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
968 |
offset = 0; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
969 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
970 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
971 |
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
|
972 |
// 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
|
973 |
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
|
974 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
975 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
976 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
977 |
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
|
978 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
979 |
// 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
|
980 |
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
|
981 |
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
|
982 |
EC_SYNC_PAGE_SIZE * num_pdo_syncs); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1180
diff
changeset
|
983 |
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
|
984 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
985 |
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
|
986 |
const ec_sync_config_t *sync_config; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
987 |
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
|
988 |
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
|
989 |
|
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
990 |
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
|
991 |
sync_config = &slave->config->sync_configs[sync_index]; |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
992 |
size = ec_pdo_list_total_size(&sync_config->pdos); |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
993 |
} else { |
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
994 |
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
|
995 |
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
|
996 |
} |
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
997 |
|
1509
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
998 |
ec_sync_page(sync, sync_index, size, sync_config, |
a864688e7de5
Added watchdog configuration via application interface (thanks to J. Mohre).
Florian Pose <fp@igh-essen.com>
parents:
1507
diff
changeset
|
999 |
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
|
1000 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1001 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1002 |
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
|
1003 |
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
|
1004 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1005 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1006 |
/*****************************************************************************/ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1007 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
1008 |
/** Configure PDO sync managers. |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1009 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1010 |
void ec_fsm_slave_config_state_pdo_sync( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1011 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1012 |
) |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1013 |
{ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1014 |
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
|
1015 |
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
|
1016 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1017 |
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
|
1018 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1019 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1020 |
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
|
1021 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1022 |
EC_SLAVE_ERR(slave, "Failed to receive process data sync" |
1023 |
" 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
|
1024 |
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
|
1025 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1026 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1027 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1028 |
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
|
1029 |
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
|
1030 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1031 |
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
|
1032 |
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
|
1033 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1034 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
1035 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1036 |
ec_fsm_slave_config_enter_fmmu(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1037 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1038 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1039 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1040 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1041 |
/** Check for FMMUs to be configured. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1042 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1043 |
void ec_fsm_slave_config_enter_fmmu( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1044 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1045 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1046 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1047 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1048 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1049 |
unsigned int i; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1050 |
const ec_fmmu_config_t *fmmu; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1051 |
const ec_sync_t *sync; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1052 |
|
1491
40529f2f60bd
Configure PDO sync managers even if no configuration has been applied.
Florian Pose <fp@igh-essen.com>
parents:
1471
diff
changeset
|
1053 |
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
|
1054 |
ec_fsm_slave_config_enter_safeop(fsm); |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1055 |
return; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1056 |
} |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1057 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1058 |
if (slave->base_fmmu_count < slave->config->used_fmmus) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1059 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1060 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1061 |
EC_SLAVE_ERR(slave, "Slave has less FMMUs (%u)" |
1062 |
" than requested (%u).\n", slave->base_fmmu_count, |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1063 |
slave->config->used_fmmus); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1064 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1065 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1066 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1067 |
if (!slave->base_fmmu_count) { // skip FMMU configuration |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1068 |
ec_fsm_slave_config_enter_dc_cycle(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1069 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1070 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1071 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1072 |
// configure FMMUs |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1073 |
ec_datagram_fpwr(datagram, slave->station_address, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1074 |
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
|
1075 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1076 |
for (i = 0; i < slave->config->used_fmmus; i++) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1077 |
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
|
1078 |
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
|
1079 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1080 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1081 |
EC_SLAVE_ERR(slave, "Failed to determine PDO sync manager" |
1082 |
" for FMMU!\n"); |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1083 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1084 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1085 |
ec_fmmu_config_page(fmmu, sync, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1086 |
datagram->data + EC_FMMU_PAGE_SIZE * i); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1087 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1088 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1089 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1090 |
fsm->state = ec_fsm_slave_config_state_fmmu; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1091 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1092 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1093 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1094 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1095 |
/** Slave configuration state: FMMU. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1096 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1097 |
void ec_fsm_slave_config_state_fmmu( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1098 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1099 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1100 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1101 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1102 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1103 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1104 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1105 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1106 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1107 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1108 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1109 |
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
|
1110 |
ec_datagram_print_state(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1111 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1112 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1113 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1114 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1115 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1116 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1117 |
EC_SLAVE_ERR(slave, "Failed to set FMMUs: "); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1118 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1119 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1120 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1121 |
|
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1122 |
ec_fsm_slave_config_enter_dc_cycle(fsm); |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1123 |
} |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1124 |
|
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1125 |
/*****************************************************************************/ |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1126 |
|
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1127 |
/** Check for DC to be configured. |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1128 |
*/ |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1129 |
void ec_fsm_slave_config_enter_dc_cycle( |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1130 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1131 |
) |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1132 |
{ |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1133 |
ec_datagram_t *datagram = fsm->datagram; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1134 |
ec_slave_t *slave = fsm->slave; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1135 |
ec_slave_config_t *config = slave->config; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1136 |
|
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1137 |
if (!config) { // config removed in the meantime |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1138 |
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
|
1139 |
return; |
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1392
diff
changeset
|
1140 |
} |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1141 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1142 |
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
|
1143 |
if (!slave->base_dc_supported || !slave->has_dc_system_time) { |
1921 | 1144 |
EC_SLAVE_WARN(slave, "Slave seems not to support" |
1145 |
" distributed clocks!\n"); |
|
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1146 |
} |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1147 |
|
1921 | 1148 |
EC_SLAVE_DBG(slave, 1, "Setting DC cycle times to %u / %u.\n", |
1149 |
config->dc_sync[0].cycle_time, config->dc_sync[1].cycle_time); |
|
1458 | 1150 |
|
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1151 |
// set DC cycle times |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1152 |
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
|
1153 |
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
|
1154 |
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
|
1155 |
fsm->retries = EC_FSM_RETRIES; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1156 |
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
|
1157 |
} else { |
1404 | 1158 |
// DC are unused |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1392
diff
changeset
|
1159 |
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
|
1160 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1161 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1162 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1163 |
/*****************************************************************************/ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1164 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1165 |
/** Slave configuration state: DC CYCLE. |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1166 |
*/ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1167 |
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
|
1168 |
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
|
1169 |
) |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1170 |
{ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1171 |
ec_datagram_t *datagram = fsm->datagram; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1172 |
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
|
1173 |
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
|
1174 |
|
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
|
1175 |
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
|
1176 |
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
|
1177 |
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
|
1178 |
} |
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
|
1179 |
|
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
|
1180 |
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
|
1181 |
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
|
1182 |
|
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
|
1183 |
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
|
1184 |
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
|
1185 |
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
|
1186 |
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
|
1187 |
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
|
1188 |
} |
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
|
1189 |
|
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
|
1190 |
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
|
1191 |
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
|
1192 |
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
|
1193 |
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
|
1194 |
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
|
1195 |
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
|
1196 |
} |
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
|
1197 |
|
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
|
1198 |
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
|
1199 |
|
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
|
1200 |
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
|
1201 |
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
|
1202 |
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
|
1203 |
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
|
1204 |
} |
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
|
1205 |
|
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
|
1206 |
/*****************************************************************************/ |
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
|
1207 |
|
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
|
1208 |
/** 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
|
1209 |
*/ |
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
|
1210 |
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
|
1211 |
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
|
1212 |
) |
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
|
1213 |
{ |
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
|
1214 |
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
|
1215 |
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
|
1216 |
ec_master_t *master = slave->master; |
1412 | 1217 |
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
|
1218 |
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
|
1219 |
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
|
1220 |
ec_sync_signal_t *sync0 = &config->dc_sync[0]; |
1396
9d04cc08f40f
DC sync reference clock to application time. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1392
diff
changeset
|
1221 |
u64 start_time; |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1222 |
|
1412 | 1223 |
if (!config) { // config removed in the meantime |
1224 |
ec_fsm_slave_config_reconfigure(fsm); |
|
1225 |
return; |
|
1226 |
} |
|
1227 |
||
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1228 |
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
|
1229 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1230 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1231 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1232 |
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
|
1233 |
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
|
1234 |
ec_datagram_print_state(datagram); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1235 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1236 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1237 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1238 |
if (datagram->working_counter != 1) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1239 |
slave->error_flag = 1; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1240 |
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
|
1241 |
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
|
1242 |
ec_datagram_print_wc_error(datagram); |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1243 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1244 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1245 |
|
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
|
1246 |
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
|
1247 |
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
|
1248 |
|
2003
a7ff6c28a432
Re-enabled waiting for clock synchronity before setting dc offsets. (changeset b0dcdfbd4238)
Martin Troxler <ch1010277@ch10lt194>
parents:
1995
diff
changeset
|
1249 |
if (abs_sync_diff > EC_DC_MAX_SYNC_DIFF_NS) { |
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
|
1250 |
|
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
|
1251 |
if (diff_ms >= EC_DC_SYNC_WAIT_MS) { |
1931 | 1252 |
EC_SLAVE_WARN(slave, "Slave did not sync after %lu ms.\n", |
1253 |
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
|
1254 |
} else { |
1931 | 1255 |
EC_SLAVE_DBG(slave, 1, "Sync after %4lu ms: %10u ns\n", |
1256 |
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
|
1257 |
|
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
|
1258 |
// 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
|
1259 |
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
|
1260 |
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
|
1261 |
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
|
1262 |
} |
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
|
1263 |
} else { |
1931 | 1264 |
EC_SLAVE_DBG(slave, 1, "%u ns difference after %lu ms.\n", |
1265 |
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
|
1266 |
} |
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
|
1267 |
|
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1268 |
// 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
|
1269 |
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
|
1270 |
// 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
|
1271 |
|
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
|
1272 |
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
|
1273 |
// 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
|
1274 |
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
|
1275 |
u64 diff, start; |
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
|
1276 |
u32 remainder; |
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
|
1277 |
|
1436
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1278 |
diff = start_time - master->app_start_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
|
1279 |
remainder = do_div(diff, sync0->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
|
1280 |
|
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
|
1281 |
start = start_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
|
1282 |
sync0->cycle_time - 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
|
1283 |
|
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
|
1284 |
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
|
1285 |
master->app_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
|
1286 |
EC_SLAVE_DBG(slave, 1, " start_time=%llu\n", 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
|
1287 |
EC_SLAVE_DBG(slave, 1, " cycle_time=%u\n", sync0->cycle_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
|
1288 |
EC_SLAVE_DBG(slave, 1, " shift_time=%u\n", sync0->shift_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
|
1289 |
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
|
1290 |
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
|
1291 |
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
|
1292 |
} else { |
1921 | 1293 |
EC_SLAVE_WARN(slave, "No application time supplied." |
1294 |
" 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
|
1295 |
} |
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1296 |
} |
08eaf72409bb
Use application start time as a common reference for cyclic generation
Florian Pose <fp@igh-essen.com>
parents:
1430
diff
changeset
|
1297 |
|
1921 | 1298 |
EC_SLAVE_DBG(slave, 1, "Setting DC cyclic operation" |
1299 |
" 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
|
1300 |
|
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1301 |
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
|
1302 |
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
|
1303 |
fsm->retries = EC_FSM_RETRIES; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1304 |
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
|
1305 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1306 |
|
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 |
/** Slave configuration state: DC START. |
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 |
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
|
1312 |
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
|
1313 |
) |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1314 |
{ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1315 |
ec_datagram_t *datagram = fsm->datagram; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1316 |
ec_slave_t *slave = fsm->slave; |
1407
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1317 |
ec_slave_config_t *config = slave->config; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1318 |
|
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1319 |
if (!config) { // config removed in the meantime |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1320 |
ec_fsm_slave_config_reconfigure(fsm); |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1321 |
return; |
e3974f72d31e
Improved DC configuration.
Florian Pose <fp@igh-essen.com>
parents:
1406
diff
changeset
|
1322 |
} |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1323 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1324 |
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
|
1325 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1326 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1327 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1328 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1329 |
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
|
1330 |
ec_datagram_print_state(datagram); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1331 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1332 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1333 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1334 |
if (datagram->working_counter != 1) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1335 |
slave->error_flag = 1; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1336 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1337 |
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
|
1338 |
ec_datagram_print_wc_error(datagram); |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1339 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1340 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1341 |
|
1921 | 1342 |
EC_SLAVE_DBG(slave, 1, "Setting DC AssignActivate to 0x%04x.\n", |
1343 |
config->dc_assign_activate); |
|
1458 | 1344 |
|
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1345 |
// 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
|
1346 |
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
|
1347 |
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
|
1348 |
fsm->retries = EC_FSM_RETRIES; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1349 |
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
|
1350 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1351 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1352 |
/*****************************************************************************/ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1353 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1354 |
/** Slave configuration state: DC ASSIGN. |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1355 |
*/ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1356 |
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
|
1357 |
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
|
1358 |
) |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1359 |
{ |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1360 |
ec_datagram_t *datagram = fsm->datagram; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1361 |
ec_slave_t *slave = fsm->slave; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1362 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1363 |
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
|
1364 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1365 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1366 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1367 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1368 |
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
|
1369 |
ec_datagram_print_state(datagram); |
1392
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1370 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1371 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1372 |
|
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1373 |
if (datagram->working_counter != 1) { |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1374 |
slave->error_flag = 1; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1375 |
fsm->state = ec_fsm_slave_config_state_error; |
1921 | 1376 |
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
|
1377 |
ec_datagram_print_wc_error(datagram); |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1378 |
return; |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1379 |
} |
8fcc1d0987c1
DC cyclic operation and slave configuration. TBC...
Florian Pose <fp@igh-essen.com>
parents:
1374
diff
changeset
|
1380 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1381 |
ec_fsm_slave_config_enter_safeop(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1382 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1383 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1384 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1385 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1386 |
/** Request SAFEOP state. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1387 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1388 |
void ec_fsm_slave_config_enter_safeop( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1389 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1390 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1391 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1392 |
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
|
1393 |
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
|
1394 |
ec_fsm_change_exec(fsm->fsm_change); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1395 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1396 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1397 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1398 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1399 |
/** Slave configuration state: SAFEOP. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1400 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1401 |
void ec_fsm_slave_config_state_safeop( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1402 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1403 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1404 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1405 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1406 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1407 |
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
|
1408 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1409 |
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
|
1410 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1411 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1412 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1413 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1414 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1415 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1416 |
// slave is now in SAFEOP |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1417 |
|
1921 | 1418 |
EC_SLAVE_DBG(slave, 1, "Now in SAFEOP.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1419 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1420 |
if (fsm->slave->current_state == fsm->slave->requested_state) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1421 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
1921 | 1422 |
EC_SLAVE_DBG(slave, 1, "Finished configuration.\n"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1423 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1424 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1425 |
|
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1426 |
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
|
1427 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1428 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1429 |
/*****************************************************************************/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1430 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1431 |
/** 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
|
1432 |
*/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1433 |
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
|
1434 |
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
|
1435 |
) |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1436 |
{ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1437 |
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
|
1438 |
ec_fsm_soe_t *fsm_soe = &slave->fsm.fsm_soe; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1439 |
ec_soe_request_t *req; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1440 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1441 |
if (!slave->config) { |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1442 |
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
|
1443 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1444 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1445 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1446 |
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
|
1447 |
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
|
1448 |
// start SoE configuration |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1449 |
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
|
1450 |
fsm->soe_request = req; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1451 |
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
|
1452 |
ec_soe_request_write(&fsm->soe_request_copy); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1453 |
ec_fsm_soe_transfer(fsm_soe, fsm->slave, &fsm->soe_request_copy); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1454 |
ec_fsm_soe_exec(fsm_soe); // execute immediately |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
2044
diff
changeset
|
1455 |
ec_slave_mbox_queue_datagrams(slave, fsm_soe->mbox); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1456 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1457 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1458 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1459 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1460 |
// 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
|
1461 |
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
|
1462 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1463 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1464 |
/*****************************************************************************/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1465 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1466 |
/** Slave configuration state: SOE_CONF. |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1467 |
*/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1468 |
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
|
1469 |
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
|
1470 |
) |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1471 |
{ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1472 |
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
|
1473 |
ec_fsm_soe_t *fsm_soe = &slave->fsm.fsm_soe; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1474 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1475 |
if (ec_fsm_soe_exec(fsm_soe)) { |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
2044
diff
changeset
|
1476 |
ec_slave_mbox_queue_datagrams(slave, fsm_soe->mbox); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1477 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1478 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1479 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1480 |
if (!ec_fsm_soe_success(fsm_soe)) { |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1481 |
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
|
1482 |
fsm->slave->error_flag = 1; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1483 |
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
|
1484 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1485 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1486 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1487 |
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
|
1488 |
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
|
1489 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1490 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1491 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1492 |
// 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
|
1493 |
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
|
1494 |
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
|
1495 |
ec_soe_request_t, list); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1496 |
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
|
1497 |
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
|
1498 |
ec_soe_request_write(&fsm->soe_request_copy); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1499 |
ec_fsm_soe_transfer(fsm_soe, fsm->slave, &fsm->soe_request_copy); |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1500 |
ec_fsm_soe_exec(fsm_soe); // execute immediately |
2045
ff2a13a4603c
Reduced frame size when sending to mailbox, uses 2 datagrams. Enabled with configure option --enable-mboxframesize
Martin Troxler <ch1010277@ch10pc446>
parents:
2044
diff
changeset
|
1501 |
ec_slave_mbox_queue_datagrams(slave, fsm_soe->mbox); |
1944
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1502 |
return; |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1503 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1504 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1505 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1506 |
// 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
|
1507 |
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
|
1508 |
} |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1509 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1510 |
/*****************************************************************************/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1511 |
|
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1512 |
/** Bring slave to OP. |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1513 |
*/ |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1514 |
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
|
1515 |
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
|
1516 |
) |
73896ef6d077
Added state parameter to ecrt_slave_config_idn().
Florian Pose <fp@igh-essen.com>
parents:
1931
diff
changeset
|
1517 |
{ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1518 |
// set state to OP |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1519 |
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
|
1520 |
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
|
1521 |
ec_fsm_change_exec(fsm->fsm_change); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1522 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1523 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1524 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1525 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1526 |
/** Slave configuration state: OP |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1527 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1528 |
void ec_fsm_slave_config_state_op( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1529 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1530 |
) |
830
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 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1533 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1534 |
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
|
1535 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
1536 |
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
|
1537 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1538 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1539 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1540 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1541 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1542 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1543 |
// slave is now in OP |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1544 |
|
1921 | 1545 |
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
|
1546 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1547 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1548 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1549 |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1550 |
/*****************************************************************************/ |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1551 |
|
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1552 |
/** 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
|
1553 |
*/ |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1554 |
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
|
1555 |
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
|
1556 |
) |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1557 |
{ |
1921 | 1558 |
EC_SLAVE_DBG(fsm->slave, 1, "Slave configuration detached during " |
1559 |
"configuration. Reconfiguring."); |
|
1318
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1560 |
|
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1561 |
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
|
1562 |
} |
76b4014391bd
merge -r1583:1593 branches/stable-1.4: Fixed detaching oops.
Florian Pose <fp@igh-essen.com>
parents:
1277
diff
changeset
|
1563 |
|
830
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 |
* Common state functions |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1566 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1567 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1568 |
/** State: ERROR. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1569 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1570 |
void ec_fsm_slave_config_state_error( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1571 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1572 |
) |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1573 |
{ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1574 |
} |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1575 |
|
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1576 |
/*****************************************************************************/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1577 |
|
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1578 |
/** State: END. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1579 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1580 |
void ec_fsm_slave_config_state_end( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1581 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1582 |
) |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1583 |
{ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1584 |
} |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1585 |
|
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
1586 |
/*****************************************************************************/ |