author | Florian Pose <fp@igh-essen.com> |
Mon, 26 Jan 2009 12:04:49 +0000 | |
branch | 1.4-foe |
changeset 1713 | df6cdc79ea56 |
parent 1711 | 2b017fcc1c6d |
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 |
* |
1685
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
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 |
* |
1685
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
11 |
* published by the Free Software Foundation. |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
12 |
* |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
16 |
* Public License for more details. |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
17 |
* |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
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 |
* |
1685
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
22 |
* Using the EtherCAT technology and brand is permitted in compliance with |
399ef727bf62
Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1677
diff
changeset
|
23 |
* the industrial property and similar rights of Beckhoff Automation GmbH. |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
27 |
/** \file |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
28 |
* |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
29 |
* EtherCAT slave configuration state machine. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
30 |
*/ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
#include "globals.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
#include "master.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
#include "mailbox.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include "slave_config.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#include "fsm_slave_config.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
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
|
43 |
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
|
44 |
void ec_fsm_slave_config_state_clear_fmmus(ec_fsm_slave_config_t *); |
1710
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
45 |
void ec_fsm_slave_config_state_clear_sync(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
void ec_fsm_slave_config_state_mbox_sync(ec_fsm_slave_config_t *); |
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
47 |
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
|
48 |
void ec_fsm_slave_config_state_sdo_conf(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
|
49 |
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
|
50 |
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
|
51 |
void ec_fsm_slave_config_state_fmmu(ec_fsm_slave_config_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
52 |
void ec_fsm_slave_config_state_safeop(ec_fsm_slave_config_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
53 |
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
|
54 |
|
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
55 |
void ec_fsm_slave_config_enter_init(ec_fsm_slave_config_t *); |
1710
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
56 |
void ec_fsm_slave_config_enter_clear_sync(ec_fsm_slave_config_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
void ec_fsm_slave_config_enter_mbox_sync(ec_fsm_slave_config_t *); |
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
58 |
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
|
59 |
void ec_fsm_slave_config_enter_sdo_conf(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
|
60 |
void ec_fsm_slave_config_enter_pdo_conf(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
|
61 |
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
|
62 |
void ec_fsm_slave_config_enter_fmmu(ec_fsm_slave_config_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
void ec_fsm_slave_config_enter_safeop(ec_fsm_slave_config_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
64 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
65 |
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
|
66 |
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
|
67 |
|
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
68 |
void ec_fsm_slave_config_reconfigure(ec_fsm_slave_config_t *); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
69 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
70 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
71 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
72 |
/** Constructor. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
*/ |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
74 |
void ec_fsm_slave_config_init( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
75 |
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
|
76 |
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
|
77 |
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
|
78 |
ec_fsm_coe_t *fsm_coe, /**< CoE state machine to use. */ |
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
79 |
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
|
80 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
{ |
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
82 |
ec_sdo_request_init(&fsm->request_copy); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
83 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
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
|
85 |
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
|
86 |
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
|
87 |
fsm->fsm_pdo = fsm_pdo; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
/** Destructor. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
*/ |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
94 |
void ec_fsm_slave_config_clear( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
95 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
96 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
{ |
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
98 |
ec_sdo_request_clear(&fsm->request_copy); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
103 |
/** Start slave configuration state machine. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
104 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
105 |
void ec_fsm_slave_config_start( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
106 |
ec_fsm_slave_config_t *fsm, /**< slave state machine */ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
ec_slave_t *slave /**< slave to configure */ |
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 |
fsm->slave = slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
fsm->state = ec_fsm_slave_config_state_start; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
/** |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
117 |
* \return false, if state machine has terminated |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
118 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
119 |
int ec_fsm_slave_config_running( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
120 |
const ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
121 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
return fsm->state != ec_fsm_slave_config_state_end |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
&& fsm->state != ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
|
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 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
129 |
/** Executes the current state of the state machine. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
130 |
* |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
131 |
* 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
|
132 |
* of the state machine is delayed to the next cycle. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
133 |
* |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
134 |
* \return false, if state machine has terminated |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
135 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
136 |
int ec_fsm_slave_config_exec( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
137 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
138 |
) |
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 |
if (fsm->datagram->state == EC_DATAGRAM_SENT |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
|| fsm->datagram->state == EC_DATAGRAM_QUEUED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
// datagram was not sent or received yet. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
return ec_fsm_slave_config_running(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
fsm->state(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
return ec_fsm_slave_config_running(fsm); |
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 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
/** |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
153 |
* \return true, if the state machine terminated gracefully |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
154 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
155 |
int ec_fsm_slave_config_success( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
156 |
const ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
157 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
return fsm->state == ec_fsm_slave_config_state_end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
|
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 |
* Slave configuration state machine |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
166 |
/** Slave configuration state: START. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
167 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
168 |
void ec_fsm_slave_config_state_start( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
169 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
170 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
if (fsm->slave->master->debug_level) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
173 |
EC_DBG("Configuring slave %u...\n", fsm->slave->ring_position); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
} |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
175 |
|
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
176 |
ec_fsm_slave_config_enter_init(fsm); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
177 |
} |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
178 |
|
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
179 |
/*****************************************************************************/ |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
180 |
|
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
181 |
/** Start state change to INIT. |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
182 |
*/ |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
183 |
void ec_fsm_slave_config_enter_init( |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
184 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
185 |
) |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
186 |
{ |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
187 |
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
|
188 |
ec_fsm_change_exec(fsm->fsm_change); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
fsm->state = ec_fsm_slave_config_state_init; |
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 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
194 |
/** Slave configuration state: INIT. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
195 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
196 |
void ec_fsm_slave_config_state_init( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
197 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
198 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
ec_master_t *master = fsm->slave->master; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
204 |
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
|
205 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
206 |
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
|
207 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
if (master->debug_level) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
214 |
EC_DBG("Slave %u is now in INIT.\n", slave->ring_position); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
if (!slave->base_fmmu_count) { // skip FMMU configuration |
1710
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
218 |
ec_fsm_slave_config_enter_clear_sync(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
if (master->debug_level) |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
223 |
EC_DBG("Clearing FMMU configurations of slave %u...\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
// clear FMMU configurations |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
ec_datagram_fpwr(datagram, slave->station_address, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
0x0600, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
memset(datagram->data, 0x00, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
fsm->state = ec_fsm_slave_config_state_clear_fmmus; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
236 |
/** Slave configuration state: CLEAR FMMU. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
237 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
238 |
void ec_fsm_slave_config_state_clear_fmmus( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
239 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
240 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
fsm->state = ec_fsm_slave_config_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
249 |
EC_ERR("Failed receive FMMU clearing datagram for slave %u.\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
fsm->slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
fsm->state = ec_fsm_slave_config_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
257 |
EC_ERR("Failed to clear FMMUs of slave %u: ", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
fsm->slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
|
1710
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
263 |
ec_fsm_slave_config_enter_clear_sync(fsm); |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
264 |
} |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
265 |
|
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
266 |
/*****************************************************************************/ |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
267 |
|
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
268 |
/** Clear the sync manager configurations. |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
269 |
*/ |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
270 |
void ec_fsm_slave_config_enter_clear_sync( |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
271 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
272 |
) |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
273 |
{ |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
274 |
ec_slave_t *slave = fsm->slave; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
275 |
ec_datagram_t *datagram = fsm->datagram; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
276 |
size_t sync_size; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
277 |
|
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
278 |
if (!slave->sii.sync_count) { |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
279 |
// no mailbox protocols supported |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
280 |
ec_fsm_slave_config_enter_mbox_sync(fsm); |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
281 |
return; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
282 |
} |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
283 |
|
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
284 |
sync_size = EC_SYNC_PAGE_SIZE * slave->sii.sync_count; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
285 |
|
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
286 |
// clear sync manager configurations |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
287 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0800, sync_size); |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
288 |
memset(datagram->data, 0x00, sync_size); |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
289 |
fsm->retries = EC_FSM_RETRIES; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
290 |
fsm->state = ec_fsm_slave_config_state_clear_sync; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
291 |
} |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
292 |
|
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
293 |
/*****************************************************************************/ |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
294 |
|
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
295 |
/** Slave configuration state: CLEAR SYNC. |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
296 |
*/ |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
297 |
void ec_fsm_slave_config_state_clear_sync( |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
298 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
299 |
) |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
300 |
{ |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
301 |
ec_datagram_t *datagram = fsm->datagram; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
302 |
|
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
303 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
304 |
return; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
305 |
|
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
306 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
307 |
fsm->state = ec_fsm_slave_config_state_error; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
308 |
EC_ERR("Failed receive sync manager clearing datagram" |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
309 |
" for slave %u.\n", fsm->slave->ring_position); |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
310 |
return; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
311 |
} |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
312 |
|
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
313 |
if (datagram->working_counter != 1) { |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
314 |
fsm->slave->error_flag = 1; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
315 |
fsm->state = ec_fsm_slave_config_state_error; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
316 |
EC_ERR("Failed to clear sync manager configurations of slave %u: ", |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
317 |
fsm->slave->ring_position); |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
318 |
ec_datagram_print_wc_error(datagram); |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
319 |
return; |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
320 |
} |
4522459bb5a4
merge -c1617 branches/stable-1.4
Florian Pose <fp@igh-essen.com>
parents:
1709
diff
changeset
|
321 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
322 |
ec_fsm_slave_config_enter_mbox_sync(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
323 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
324 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
325 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
326 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
327 |
/** Check for mailbox sync managers to be configured. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
328 |
*/ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
329 |
void ec_fsm_slave_config_enter_mbox_sync( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
330 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
331 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
332 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
333 |
ec_master_t *master = fsm->slave->master; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
334 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
335 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
336 |
unsigned int i; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
337 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
338 |
// slave is now in INIT |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
339 |
if (slave->current_state == slave->requested_state) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
340 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
341 |
if (master->debug_level) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
342 |
EC_DBG("Finished configuration of slave %u.\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
343 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
344 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
345 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
346 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
347 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
348 |
if (!slave->sii.mailbox_protocols) { |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
349 |
// no mailbox protocols supported |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
350 |
if (master->debug_level) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
351 |
EC_DBG("Slave %u does not support mailbox communication.\n", |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
352 |
slave->ring_position); |
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
353 |
ec_fsm_slave_config_enter_boot_preop(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
354 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
355 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
356 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
357 |
if (master->debug_level) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
358 |
EC_DBG("Configuring mailbox sync managers of slave %u.\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
359 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
360 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
361 |
|
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
362 |
if (slave->requested_state == EC_SLAVE_STATE_BOOT) { |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
363 |
ec_sync_t sync; |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
364 |
|
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
365 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0800, |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
366 |
EC_SYNC_PAGE_SIZE * 2); |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
367 |
memset(datagram->data, 0x00, EC_SYNC_PAGE_SIZE * 2); |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
368 |
|
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
369 |
ec_sync_init(&sync, slave); |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
370 |
sync.physical_start_address = slave->sii.boot_rx_mailbox_offset; |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
371 |
sync.control_register = 0x26; |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
372 |
sync.enable = 1; |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
373 |
ec_sync_page(&sync, 0, slave->sii.boot_rx_mailbox_size, |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
374 |
EC_DIR_INVALID, // use default direction |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
375 |
datagram->data); |
1711
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
376 |
slave->configured_rx_mailbox_offset = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
377 |
slave->sii.boot_rx_mailbox_offset; |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
378 |
slave->configured_rx_mailbox_size = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
379 |
slave->sii.boot_rx_mailbox_size; |
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
380 |
|
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
381 |
ec_sync_init(&sync, slave); |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
382 |
sync.physical_start_address = slave->sii.boot_tx_mailbox_offset; |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
383 |
sync.control_register = 0x22; |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
384 |
sync.enable = 1; |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
385 |
ec_sync_page(&sync, 1, slave->sii.boot_tx_mailbox_size, |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
386 |
EC_DIR_INVALID, // use default direction |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
387 |
datagram->data + EC_SYNC_PAGE_SIZE); |
1711
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
388 |
slave->configured_tx_mailbox_offset = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
389 |
slave->sii.boot_tx_mailbox_offset; |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
390 |
slave->configured_tx_mailbox_size = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
391 |
slave->sii.boot_tx_mailbox_size; |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
392 |
|
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
393 |
} 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
|
394 |
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
|
395 |
EC_SYNC_PAGE_SIZE * slave->sii.sync_count); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
396 |
memset(datagram->data, 0x00, |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
397 |
EC_SYNC_PAGE_SIZE * slave->sii.sync_count); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
398 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
399 |
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
|
400 |
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
|
401 |
slave->sii.syncs[i].default_length, |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
402 |
EC_DIR_INVALID, // use default direction |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
403 |
datagram->data + EC_SYNC_PAGE_SIZE * i); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
404 |
} |
1711
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
405 |
|
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
406 |
slave->configured_rx_mailbox_offset = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
407 |
slave->sii.syncs[0].physical_start_address; |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
408 |
slave->configured_rx_mailbox_size = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
409 |
slave->sii.syncs[0].default_length; |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
410 |
slave->configured_tx_mailbox_offset = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
411 |
slave->sii.syncs[1].physical_start_address; |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
412 |
slave->configured_tx_mailbox_size = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
413 |
slave->sii.syncs[1].default_length; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
414 |
} else { // no mailbox sync manager configurations provided |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
415 |
ec_sync_t sync; |
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 |
if (master->debug_level) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
418 |
EC_DBG("Slave %u does not provide" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
419 |
" mailbox sync manager configurations.\n", |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
420 |
slave->ring_position); |
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 |
ec_datagram_fpwr(datagram, slave->station_address, 0x0800, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
423 |
EC_SYNC_PAGE_SIZE * 2); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
424 |
memset(datagram->data, 0x00, EC_SYNC_PAGE_SIZE * 2); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
425 |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
426 |
ec_sync_init(&sync, slave); |
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
427 |
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
|
428 |
sync.control_register = 0x26; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
429 |
sync.enable = 1; |
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
430 |
ec_sync_page(&sync, 0, 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
|
431 |
EC_DIR_INVALID, // use default direction |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
432 |
datagram->data); |
1711
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
433 |
slave->configured_rx_mailbox_offset = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
434 |
slave->sii.std_rx_mailbox_offset; |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
435 |
slave->configured_rx_mailbox_size = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
436 |
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
|
437 |
|
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
438 |
ec_sync_init(&sync, slave); |
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
439 |
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
|
440 |
sync.control_register = 0x22; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
441 |
sync.enable = 1; |
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
442 |
ec_sync_page(&sync, 1, slave->sii.std_tx_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
|
443 |
EC_DIR_INVALID, // use default direction |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
444 |
datagram->data + EC_SYNC_PAGE_SIZE); |
1711
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
445 |
slave->configured_tx_mailbox_offset = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
446 |
slave->sii.boot_tx_mailbox_offset; |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
447 |
slave->configured_tx_mailbox_size = |
2b017fcc1c6d
Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1710
diff
changeset
|
448 |
slave->sii.boot_tx_mailbox_size; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
449 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
450 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
451 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
452 |
fsm->state = ec_fsm_slave_config_state_mbox_sync; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
453 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
454 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
455 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
456 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
457 |
/** Slave configuration state: SYNC. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
458 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
459 |
void ec_fsm_slave_config_state_mbox_sync( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
460 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
461 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
462 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
463 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
464 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
465 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
466 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
467 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
468 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
469 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
470 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
471 |
EC_ERR("Failed to receive sync manager configuration datagram for" |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
472 |
" slave %u (datagram state %u).\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
473 |
slave->ring_position, datagram->state); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
474 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
475 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
476 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
477 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
478 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
479 |
fsm->state = ec_fsm_slave_config_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
480 |
EC_ERR("Failed to set sync managers of slave %u: ", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
481 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
482 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
483 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
484 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
485 |
|
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
486 |
ec_fsm_slave_config_enter_boot_preop(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
487 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
488 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
489 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
490 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
491 |
/** Request PREOP state. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
492 |
*/ |
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
493 |
void ec_fsm_slave_config_enter_boot_preop( |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
494 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
495 |
) |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
496 |
{ |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
497 |
fsm->state = ec_fsm_slave_config_state_boot_preop; |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
498 |
|
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
499 |
if (fsm->slave->requested_state != EC_SLAVE_STATE_BOOT) { |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
500 |
ec_fsm_change_start(fsm->fsm_change, fsm->slave, EC_SLAVE_STATE_PREOP); |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
501 |
} else { // BOOT |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
502 |
ec_fsm_change_start(fsm->fsm_change, fsm->slave, EC_SLAVE_STATE_BOOT); |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
503 |
} |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
504 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
505 |
ec_fsm_change_exec(fsm->fsm_change); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
506 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
507 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
508 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
509 |
|
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
510 |
/** Slave configuration state: BOOT/PREOP. |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
511 |
*/ |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
512 |
void ec_fsm_slave_config_state_boot_preop( |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
513 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
514 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
515 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
516 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
517 |
ec_master_t *master = fsm->slave->master; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
518 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
519 |
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
|
520 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
521 |
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
|
522 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
523 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
524 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
525 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
526 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
527 |
|
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
528 |
// slave is now in BOOT/PREOP |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
529 |
slave->jiffies_preop = fsm->datagram->jiffies_received; |
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 |
if (master->debug_level) { |
1709
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
532 |
EC_DBG("Slave %u is now in %s.\n", slave->ring_position, |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
533 |
slave->requested_state != EC_SLAVE_STATE_BOOT |
63e4bc918640
Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1686
diff
changeset
|
534 |
? "PREOP" : "BOOT"); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
535 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
536 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
537 |
if (slave->current_state == slave->requested_state) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
538 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
539 |
if (master->debug_level) { |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
540 |
EC_DBG("Finished configuration of slave %u.\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
541 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
542 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
543 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
544 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
545 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
546 |
if (!slave->config) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
547 |
EC_DBG("Slave %u is not configured.\n", slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
548 |
ec_fsm_slave_config_enter_safeop(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
549 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
550 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
551 |
|
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
552 |
ec_fsm_slave_config_enter_sdo_conf(fsm); |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
553 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
554 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
555 |
/*****************************************************************************/ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
556 |
|
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
557 |
/** Check for SDO configurations to be applied. |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
558 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
559 |
void ec_fsm_slave_config_enter_sdo_conf( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
560 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
561 |
) |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
562 |
{ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
563 |
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
|
564 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
565 |
// No CoE configuration to be applied? |
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
566 |
if (list_empty(&slave->config->sdo_configs)) { // skip SDO configuration |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
567 |
ec_fsm_slave_config_enter_pdo_conf(fsm); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
568 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
569 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
570 |
|
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
571 |
// start SDO configuration |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
572 |
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
|
573 |
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
|
574 |
ec_sdo_request_t, list); |
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
575 |
ec_sdo_request_copy(&fsm->request_copy, fsm->request); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
576 |
ecrt_sdo_request_write(&fsm->request_copy); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
577 |
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
|
578 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
579 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
580 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
581 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
582 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
583 |
/** Slave configuration state: SDO_CONF. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
584 |
*/ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
585 |
void ec_fsm_slave_config_state_sdo_conf( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
586 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
587 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
588 |
{ |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
589 |
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
|
590 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
591 |
if (!ec_fsm_coe_success(fsm->fsm_coe)) { |
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
592 |
EC_ERR("SDO configuration failed for slave %u.\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
593 |
fsm->slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
594 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
595 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
596 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
597 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
598 |
|
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
599 |
if (!fsm->slave->config) { // config removed in the meantime |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
600 |
ec_fsm_slave_config_reconfigure(fsm); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
601 |
return; |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
602 |
} |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
603 |
|
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
604 |
// 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
|
605 |
if (fsm->request->list.next != &fsm->slave->config->sdo_configs) { |
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
606 |
fsm->request = list_entry(fsm->request->list.next, |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
607 |
ec_sdo_request_t, list); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
608 |
ec_sdo_request_copy(&fsm->request_copy, fsm->request); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
609 |
ecrt_sdo_request_write(&fsm->request_copy); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
610 |
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
|
611 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
612 |
return; |
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 |
|
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
615 |
// All SDOs are now configured. |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
616 |
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
|
617 |
} |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
618 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
619 |
/*****************************************************************************/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
620 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
621 |
/** PDO_CONF entry function. |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
622 |
*/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
623 |
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
|
624 |
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
|
625 |
) |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
626 |
{ |
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
627 |
// Start configuring PDOs |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
628 |
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
|
629 |
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
|
630 |
fsm->state(fsm); // execute immediately |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
631 |
} |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
632 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
633 |
/*****************************************************************************/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
634 |
|
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
635 |
/** Slave configuration state: PDO_CONF. |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
636 |
*/ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
637 |
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
|
638 |
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
|
639 |
) |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
640 |
{ |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
641 |
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
|
642 |
return; |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
643 |
|
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
644 |
if (!fsm->slave->config) { // config removed in the meantime |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
645 |
ec_fsm_slave_config_reconfigure(fsm); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
646 |
return; |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
647 |
} |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
648 |
|
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
649 |
if (!ec_fsm_pdo_success(fsm->fsm_pdo)) { |
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
650 |
EC_WARN("PDO configuration failed on slave %u.\n", |
1180
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
651 |
fsm->slave->ring_position); |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
652 |
} |
846907b8cc4b
Configure Pdos before configuring the Pdo sync managers,
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
653 |
|
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
654 |
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
|
655 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
656 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
657 |
/*****************************************************************************/ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
658 |
|
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
659 |
/** Check for PDO sync managers to be configured. |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
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 |
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
|
662 |
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
|
663 |
) |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
664 |
{ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
665 |
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
|
666 |
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
|
667 |
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
|
668 |
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
|
669 |
const ec_sync_t *sync; |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
670 |
const ec_sync_config_t *sync_config; |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
671 |
uint16_t size; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
672 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
673 |
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
|
674 |
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
|
675 |
} else { |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
676 |
offset = 0; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
677 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
678 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
679 |
if (slave->sii.sync_count <= offset) { |
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
680 |
// 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
|
681 |
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
|
682 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
683 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
684 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
685 |
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
|
686 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
687 |
// 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
|
688 |
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
|
689 |
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
|
690 |
EC_SYNC_PAGE_SIZE * num_pdo_syncs); |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
691 |
memset(datagram->data, 0x00, EC_SYNC_PAGE_SIZE * num_pdo_syncs); |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
692 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
693 |
for (i = 0; i < num_pdo_syncs; 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
|
694 |
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
|
695 |
sync = &slave->sii.syncs[sync_index]; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
696 |
sync_config = &slave->config->sync_configs[sync_index]; |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
697 |
size = ec_pdo_list_total_size(&sync_config->pdos); |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
698 |
ec_sync_page(sync, sync_index, size, sync_config->dir, |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1053
diff
changeset
|
699 |
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
|
700 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
701 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
702 |
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
|
703 |
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
|
704 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
705 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
706 |
/*****************************************************************************/ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
707 |
|
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
708 |
/** Configure PDO sync managers. |
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
709 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
710 |
void ec_fsm_slave_config_state_pdo_sync( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
711 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
712 |
) |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
713 |
{ |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
714 |
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
|
715 |
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
|
716 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
717 |
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
|
718 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
719 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
720 |
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
|
721 |
fsm->state = ec_fsm_slave_config_state_error; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
722 |
EC_ERR("Failed to receive process data sync manager configuration" |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
723 |
" datagram for slave %u (datagram state %u).\n", |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
724 |
slave->ring_position, datagram->state); |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
725 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
726 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
727 |
|
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
728 |
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
|
729 |
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
|
730 |
fsm->state = ec_fsm_slave_config_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
731 |
EC_ERR("Failed to set process data sync managers of slave %u: ", |
888
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
732 |
slave->ring_position); |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
733 |
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
|
734 |
return; |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
735 |
} |
f0db19108bba
Moved Pdo sync manager configuration before Pdo assignment in slave
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
736 |
|
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
737 |
if (!fsm->slave->config) { // config removed in the meantime |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
738 |
ec_fsm_slave_config_reconfigure(fsm); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
739 |
return; |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
740 |
} |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
741 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
742 |
ec_fsm_slave_config_enter_fmmu(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
743 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
744 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
745 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
746 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
747 |
/** Check for FMMUs to be configured. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
748 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
749 |
void ec_fsm_slave_config_enter_fmmu( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
750 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
751 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
752 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
753 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
754 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
755 |
unsigned int i; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
756 |
const ec_fmmu_config_t *fmmu; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
757 |
const ec_sync_t *sync; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
758 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
759 |
if (slave->base_fmmu_count < slave->config->used_fmmus) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
760 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
761 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
762 |
EC_ERR("Slave %u has less FMMUs (%u) than requested (%u).\n", |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
763 |
slave->ring_position, slave->base_fmmu_count, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
764 |
slave->config->used_fmmus); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
765 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
766 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
767 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
768 |
if (!slave->base_fmmu_count) { // skip FMMU configuration |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
769 |
ec_fsm_slave_config_enter_safeop(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
770 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
771 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
772 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
773 |
// configure FMMUs |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
774 |
ec_datagram_fpwr(datagram, slave->station_address, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
775 |
0x0600, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
776 |
memset(datagram->data, 0x00, EC_FMMU_PAGE_SIZE * slave->base_fmmu_count); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
777 |
for (i = 0; i < slave->config->used_fmmus; i++) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
778 |
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
|
779 |
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
|
780 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
781 |
fsm->state = ec_fsm_slave_config_state_error; |
1686
e206f4485f60
Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1685
diff
changeset
|
782 |
EC_ERR("Failed to determine PDO sync manager for FMMU on slave" |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
783 |
" %u!\n", slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
784 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
785 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
786 |
ec_fmmu_config_page(fmmu, sync, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
787 |
datagram->data + EC_FMMU_PAGE_SIZE * i); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
788 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
789 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
790 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
791 |
fsm->state = ec_fsm_slave_config_state_fmmu; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
792 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
793 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
794 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
795 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
796 |
/** Slave configuration state: FMMU. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
797 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
798 |
void ec_fsm_slave_config_state_fmmu( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
799 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
800 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
801 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
802 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
803 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
804 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
805 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
806 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
807 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
808 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
809 |
fsm->state = ec_fsm_slave_config_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
810 |
EC_ERR("Failed to receive FMMUs datagram for slave %u" |
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
811 |
" (datagram state %u).\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
812 |
slave->ring_position, datagram->state); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
813 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
814 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
815 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
816 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
817 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
818 |
fsm->state = ec_fsm_slave_config_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
819 |
EC_ERR("Failed to set FMMUs of slave %u: ", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
820 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
821 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
822 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
823 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
824 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
825 |
ec_fsm_slave_config_enter_safeop(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
826 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
827 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
828 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
829 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
830 |
/** Request SAFEOP state. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
831 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
832 |
void ec_fsm_slave_config_enter_safeop( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
833 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
834 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
835 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
836 |
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
|
837 |
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
|
838 |
ec_fsm_change_exec(fsm->fsm_change); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
839 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
840 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
841 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
842 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
843 |
/** Slave configuration state: SAFEOP. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
844 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
845 |
void ec_fsm_slave_config_state_safeop( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
846 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
847 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
848 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
849 |
ec_master_t *master = fsm->slave->master; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
850 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
851 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
852 |
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
|
853 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
854 |
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
|
855 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
856 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
857 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
858 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
859 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
860 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
861 |
// slave is now in SAFEOP |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
862 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
863 |
if (master->debug_level) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
864 |
EC_DBG("Slave %u is now in SAFEOP.\n", slave->ring_position); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
865 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
866 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
867 |
if (fsm->slave->current_state == fsm->slave->requested_state) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
868 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
869 |
if (master->debug_level) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
870 |
EC_DBG("Finished configuration of slave %u.\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
871 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
872 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
873 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
874 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
875 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
876 |
// set state to OP |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
877 |
fsm->state = ec_fsm_slave_config_state_op; |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
878 |
ec_fsm_change_start(fsm->fsm_change, slave, EC_SLAVE_STATE_OP); |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
879 |
ec_fsm_change_exec(fsm->fsm_change); // execute immediately |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
880 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
881 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
882 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
883 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
884 |
/** Slave configuration state: OP |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
885 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
886 |
void ec_fsm_slave_config_state_op( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
887 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
888 |
) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
889 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
890 |
ec_master_t *master = fsm->slave->master; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
891 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
892 |
|
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
893 |
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
|
894 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1173
diff
changeset
|
895 |
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
|
896 |
if (!fsm->fsm_change->spontaneous_change) |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
897 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
898 |
fsm->state = ec_fsm_slave_config_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
899 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
900 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
901 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
902 |
// slave is now in OP |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
903 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
904 |
if (master->debug_level) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
905 |
EC_DBG("Slave %u is now in OP.\n", slave->ring_position); |
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
908
diff
changeset
|
906 |
EC_DBG("Finished configuration of slave %u.\n", slave->ring_position); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
907 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
908 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
909 |
fsm->state = ec_fsm_slave_config_state_end; // successful |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
910 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
911 |
|
1677
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
912 |
/*****************************************************************************/ |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
913 |
|
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
914 |
/** Reconfigure the slave starting at INIT. |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
915 |
*/ |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
916 |
void ec_fsm_slave_config_reconfigure( |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
917 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
918 |
) |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
919 |
{ |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
920 |
if (fsm->slave->master->debug_level) { |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
921 |
EC_DBG("Slave configuration for slave %u detached during " |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
922 |
"configuration. Reconfiguring.", fsm->slave->ring_position); |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
923 |
} |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
924 |
|
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
925 |
ec_fsm_slave_config_enter_init(fsm); // reconfigure |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
926 |
} |
e1a31667fa48
Fixed kernel oops concerning slave configuration detaching.
Florian Pose <fp@igh-essen.com>
parents:
1647
diff
changeset
|
927 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
928 |
/****************************************************************************** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
929 |
* Common state functions |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
930 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
931 |
|
1064
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
932 |
/** State: ERROR. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
933 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
934 |
void ec_fsm_slave_config_state_error( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
935 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
936 |
) |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
937 |
{ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
938 |
} |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
939 |
|
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
940 |
/*****************************************************************************/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
941 |
|
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
942 |
/** State: END. |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
943 |
*/ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
944 |
void ec_fsm_slave_config_state_end( |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
945 |
ec_fsm_slave_config_t *fsm /**< slave state machine */ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
946 |
) |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
947 |
{ |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
948 |
} |
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
949 |
|
5f27403587a8
Avoid duplicate reconfiguration.
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
950 |
/*****************************************************************************/ |