author | Florian Pose <fp@igh-essen.com> |
Tue, 07 Apr 2009 09:37:07 +0000 | |
changeset 1380 | c2b0ef67e829 |
parent 1379 | cbceb0e2f2a0 |
child 1419 | 8fc38c37d86e |
permissions | -rw-r--r-- |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
1326
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
11 |
* published by the Free Software Foundation. |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
12 |
* |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
16 |
* Public License for more details. |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
17 |
* |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
ef907b0b5125
merge -c1603 branches/stable-1.4: Changed licence headers to avoid conflicts with the GPL; restricted licence to GPLv2 only.
Florian Pose <fp@igh-essen.com>
parents:
1225
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* |
1363
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
22 |
* --- |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
23 |
* |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
11c0b2caa253
Improved and added license headers.
Florian Pose <fp@igh-essen.com>
parents:
1338
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
\file |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
EtherCAT slave state machines. |
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 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
#include "globals.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
#include "master.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
#include "mailbox.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
#include "slave_config.h" |
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 |
#include "fsm_slave_scan.h" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
void ec_fsm_slave_scan_state_start(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
void ec_fsm_slave_scan_state_address(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
void ec_fsm_slave_scan_state_state(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
49 |
void ec_fsm_slave_scan_state_base(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
void ec_fsm_slave_scan_state_datalink(ec_fsm_slave_scan_t *); |
872 | 51 |
void ec_fsm_slave_scan_state_sii_size(ec_fsm_slave_scan_t *); |
52 |
void ec_fsm_slave_scan_state_sii_data(ec_fsm_slave_scan_t *); |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
53 |
void ec_fsm_slave_scan_state_preop(ec_fsm_slave_scan_t *); |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
54 |
void ec_fsm_slave_scan_state_sync(ec_fsm_slave_scan_t *); |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
55 |
void ec_fsm_slave_scan_state_pdos(ec_fsm_slave_scan_t *); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
56 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
57 |
void ec_fsm_slave_scan_state_end(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
58 |
void ec_fsm_slave_scan_state_error(ec_fsm_slave_scan_t *); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
59 |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
60 |
void ec_fsm_slave_scan_enter_preop(ec_fsm_slave_scan_t *); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
61 |
void ec_fsm_slave_scan_enter_pdos(ec_fsm_slave_scan_t *); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
62 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
63 |
/*****************************************************************************/ |
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 |
/** Constructor. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
66 |
*/ |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
67 |
void ec_fsm_slave_scan_init( |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
68 |
ec_fsm_slave_scan_t *fsm, /**< Slave scanning state machine. */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
69 |
ec_datagram_t *datagram, /**< Datagram to use. */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
70 |
ec_fsm_slave_config_t *fsm_slave_config, /**< Slave configuration |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
71 |
state machine to use. */ |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
72 |
ec_fsm_pdo_t *fsm_pdo /**< PDO configuration machine to use. */ |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
75 |
fsm->datagram = datagram; |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
76 |
fsm->fsm_slave_config = fsm_slave_config; |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
77 |
fsm->fsm_pdo = fsm_pdo; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
78 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
79 |
// init sub state machines |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
ec_fsm_sii_init(&fsm->fsm_sii, fsm->datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
/** Destructor. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
void ec_fsm_slave_scan_clear(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
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 |
// clear sub state machines |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
ec_fsm_sii_clear(&fsm->fsm_sii); |
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 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
* Start slave scan state machine. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
void ec_fsm_slave_scan_start( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
100 |
ec_fsm_slave_scan_t *fsm, /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
ec_slave_t *slave /**< slave to configure */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
fsm->slave = slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
fsm->state = ec_fsm_slave_scan_state_start; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
|
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 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
\return false, if state machine has terminated |
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 |
int ec_fsm_slave_scan_running(const ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
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 |
return fsm->state != ec_fsm_slave_scan_state_end |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
&& fsm->state != ec_fsm_slave_scan_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
|
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 |
Executes the current state of the state machine. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
If the state machine's datagram is not sent or received yet, the execution |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
125 |
of the state machine is delayed to the next cycle. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
\return false, if state machine has terminated |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
int ec_fsm_slave_scan_exec(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
if (fsm->datagram->state == EC_DATAGRAM_SENT |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
|| fsm->datagram->state == EC_DATAGRAM_QUEUED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
// datagram was not sent or received yet. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
return ec_fsm_slave_scan_running(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
fsm->state(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
return ec_fsm_slave_scan_running(fsm); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
\return true, if the state machine terminated gracefully |
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 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
int ec_fsm_slave_scan_success(const ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
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 |
return fsm->state == ec_fsm_slave_scan_state_end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
/****************************************************************************** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
* slave scan state machine |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
Slave scan state: START. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
First state of the slave state machine. Writes the station address to the |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
slave, according to its ring position. |
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 |
void ec_fsm_slave_scan_state_start(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
// write station address |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
ec_datagram_apwr(fsm->datagram, fsm->slave->ring_position, 0x0010, 2); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
EC_WRITE_U16(fsm->datagram->data, fsm->slave->station_address); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
fsm->state = ec_fsm_slave_scan_state_address; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
|
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 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
Slave scan state: ADDRESS. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
177 |
void ec_fsm_slave_scan_state_address(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
182 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
fsm->state = ec_fsm_slave_scan_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
186 |
EC_ERR("Failed to receive station address datagram for slave %u" |
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
187 |
" (datagram state %u)\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
fsm->slave->ring_position, datagram->state); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
return; |
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 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
194 |
fsm->state = ec_fsm_slave_scan_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
195 |
EC_ERR("Failed to write station address on slave %u: ", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
196 |
fsm->slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
197 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
198 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
199 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
// Read AL state |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0130, 2); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
203 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
fsm->state = ec_fsm_slave_scan_state_state; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
Slave scan state: STATE. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
void ec_fsm_slave_scan_state_state( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
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 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
ec_slave_t *slave = fsm->slave; |
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 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
222 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
223 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
fsm->state = ec_fsm_slave_scan_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
226 |
EC_ERR("Failed to receive AL state datagram from slave %u" |
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
227 |
" (datagram state %u).\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
fsm->slave->ring_position, datagram->state); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
fsm->state = ec_fsm_slave_scan_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
235 |
EC_ERR("Failed to read AL state of slave %u: ", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
fsm->slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
slave->current_state = EC_READ_U8(datagram->data); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
char state_str[EC_STATE_STRING_SIZE]; |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
244 |
ec_state_string(slave->current_state, state_str, 0); |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
245 |
EC_WARN("Slave %u has state error bit set (%s)!\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
slave->ring_position, state_str); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
// read base data |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
250 |
ec_datagram_fprd(datagram, fsm->slave->station_address, 0x0000, 12); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
251 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
fsm->state = ec_fsm_slave_scan_state_base; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
257 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
Slave scan state: BASE. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
*/ |
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 |
void ec_fsm_slave_scan_state_base(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
265 |
ec_slave_t *slave = fsm->slave; |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
266 |
u8 octet; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
267 |
int i; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
273 |
fsm->state = ec_fsm_slave_scan_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
274 |
EC_ERR("Failed to receive base data datagram for slave %u" |
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
275 |
" (datagram state %u).\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
276 |
slave->ring_position, datagram->state); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
277 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
278 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
279 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
280 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
281 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
282 |
fsm->state = ec_fsm_slave_scan_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
283 |
EC_ERR("Failed to read base data from slave %u: ", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
284 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
285 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
286 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
287 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
288 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
289 |
slave->base_type = EC_READ_U8 (datagram->data); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
290 |
slave->base_revision = EC_READ_U8 (datagram->data + 1); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
291 |
slave->base_build = EC_READ_U16(datagram->data + 2); |
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
292 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
293 |
slave->base_fmmu_count = EC_READ_U8 (datagram->data + 4); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
294 |
if (slave->base_fmmu_count > EC_MAX_FMMUS) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
295 |
EC_WARN("Slave %u has more FMMUs (%u) than the master can" |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
296 |
" handle (%u).\n", slave->ring_position, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
297 |
slave->base_fmmu_count, EC_MAX_FMMUS); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
298 |
slave->base_fmmu_count = EC_MAX_FMMUS; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
299 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
300 |
|
1379
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
301 |
slave->base_sync_count = EC_READ_U8 (datagram->data + 5); |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
302 |
if (slave->base_sync_count > EC_MAX_SYNC_MANAGERS) { |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
303 |
EC_WARN("Slave %u provides more sync managers (%u) than the master can" |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
304 |
" handle (%u).\n", slave->ring_position, |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
305 |
slave->base_sync_count, EC_MAX_SYNC_MANAGERS); |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
306 |
slave->base_sync_count = EC_MAX_SYNC_MANAGERS; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
307 |
} |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
308 |
|
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
309 |
octet = EC_READ_U8(datagram->data + 7); |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
310 |
for (i = 0; i < EC_MAX_PORTS; i++) { |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
311 |
slave->base_ports[i] = (octet >> (2 * i)) & 0x03; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
312 |
} |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
313 |
|
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
314 |
octet = EC_READ_U8(datagram->data + 8); |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
315 |
slave->base_fmmu_bit_operation = octet & 0x01; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
316 |
slave->base_dc_supported = (octet >> 2) & 0x01; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
317 |
slave->base_dc_range = ((octet >> 3) & 0x01) ? EC_DC_64 : EC_DC_32; |
cbceb0e2f2a0
Reading more base information (incl. whether DC supported).
Florian Pose <fp@igh-essen.com>
parents:
1363
diff
changeset
|
318 |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
319 |
// read data link status |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
320 |
ec_datagram_fprd(datagram, slave->station_address, 0x0110, 2); |
1225
4d5b739edcb5
Introduced ec_datagram_zero().
Florian Pose <fp@igh-essen.com>
parents:
1174
diff
changeset
|
321 |
ec_datagram_zero(datagram); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
322 |
fsm->retries = EC_FSM_RETRIES; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
323 |
fsm->state = ec_fsm_slave_scan_state_datalink; |
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 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
327 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
328 |
/** |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
329 |
Slave scan state: DATALINK. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
330 |
*/ |
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 |
void ec_fsm_slave_scan_state_datalink(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
333 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
334 |
ec_datagram_t *datagram = fsm->datagram; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
335 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
336 |
uint16_t dl_status; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
337 |
unsigned int i; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
338 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
339 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
340 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
341 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
342 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
343 |
fsm->state = ec_fsm_slave_scan_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
344 |
EC_ERR("Failed to receive DL status datagram from slave %u" |
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
345 |
" (datagram state %u).\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
346 |
slave->ring_position, datagram->state); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
347 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
348 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
349 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
350 |
if (datagram->working_counter != 1) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
351 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
352 |
fsm->state = ec_fsm_slave_scan_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
353 |
EC_ERR("Failed to read DL status from slave %u: ", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
354 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
355 |
ec_datagram_print_wc_error(datagram); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
356 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
357 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
358 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
359 |
dl_status = EC_READ_U16(datagram->data); |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
1000
diff
changeset
|
360 |
for (i = 0; i < EC_MAX_PORTS; i++) { |
1000
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
361 |
slave->ports[i].dl_link = dl_status & (1 << (4 + i)) ? 1 : 0; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
362 |
slave->ports[i].dl_loop = dl_status & (1 << (8 + i * 2)) ? 1 : 0; |
5746fdd1ca2e
Store slaves in an array instead of a list.
Florian Pose <fp@igh-essen.com>
parents:
998
diff
changeset
|
363 |
slave->ports[i].dl_signal = dl_status & (1 << (9 + i * 2)) ? 1 : 0; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
364 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
365 |
|
872 | 366 |
// Start fetching SII size |
367 |
||
368 |
fsm->sii_offset = EC_FIRST_SII_CATEGORY_OFFSET; // first category header |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
369 |
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
370 |
EC_FSM_SII_USE_CONFIGURED_ADDRESS); |
872 | 371 |
fsm->state = ec_fsm_slave_scan_state_sii_size; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
372 |
fsm->state(fsm); // execute state immediately |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
373 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
374 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
375 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
376 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
377 |
/** |
872 | 378 |
Slave scan state: SII SIZE. |
379 |
*/ |
|
380 |
||
381 |
void ec_fsm_slave_scan_state_sii_size(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
382 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
383 |
ec_slave_t *slave = fsm->slave; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
384 |
uint16_t cat_type, cat_size; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
385 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
386 |
if (ec_fsm_sii_exec(&fsm->fsm_sii)) return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
387 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
388 |
if (!ec_fsm_sii_success(&fsm->fsm_sii)) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
389 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
390 |
fsm->state = ec_fsm_slave_scan_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
391 |
EC_ERR("Failed to read SII size of slave %u.\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
392 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
393 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
394 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
395 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
396 |
cat_type = EC_READ_U16(fsm->fsm_sii.value); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
397 |
cat_size = EC_READ_U16(fsm->fsm_sii.value + 2); |
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 |
if (cat_type != 0xFFFF) { // not the last category |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
400 |
off_t next_offset = 2UL + fsm->sii_offset + cat_size; |
872 | 401 |
if (next_offset >= EC_MAX_SII_SIZE) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
402 |
EC_WARN("SII size of slave %u exceeds" |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
403 |
" %u words (0xffff limiter missing?).\n", |
872 | 404 |
slave->ring_position, EC_MAX_SII_SIZE); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
405 |
// cut off category data... |
977 | 406 |
slave->sii_nwords = EC_FIRST_SII_CATEGORY_OFFSET; |
872 | 407 |
goto alloc_sii; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
408 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
409 |
fsm->sii_offset = next_offset; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
410 |
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
411 |
EC_FSM_SII_USE_CONFIGURED_ADDRESS); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
412 |
ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
413 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
414 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
415 |
|
977 | 416 |
slave->sii_nwords = fsm->sii_offset + 1; |
872 | 417 |
|
418 |
alloc_sii: |
|
977 | 419 |
if (slave->sii_words) { |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
420 |
EC_WARN("Freeing old SII data on slave %u...\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
421 |
slave->ring_position); |
977 | 422 |
kfree(slave->sii_words); |
423 |
} |
|
424 |
||
425 |
if (!(slave->sii_words = |
|
998
05a24788f3b2
Replaced a few GFP_ATOMIC allocations with GFP_KERNEL ones.
Florian Pose <fp@igh-essen.com>
parents:
986
diff
changeset
|
426 |
(uint16_t *) kmalloc(slave->sii_nwords * 2, GFP_KERNEL))) { |
977 | 427 |
EC_ERR("Failed to allocate %u words of SII data for slave %u.\n", |
428 |
slave->sii_nwords, slave->ring_position); |
|
429 |
slave->sii_nwords = 0; |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
430 |
slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
431 |
fsm->state = ec_fsm_slave_scan_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
432 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
433 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
434 |
|
872 | 435 |
// Start fetching SII contents |
436 |
||
437 |
fsm->state = ec_fsm_slave_scan_state_sii_data; |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
438 |
fsm->sii_offset = 0x0000; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
439 |
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
440 |
EC_FSM_SII_USE_CONFIGURED_ADDRESS); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
441 |
ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
442 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
443 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
444 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
445 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
446 |
/** |
872 | 447 |
Slave scan state: SII DATA. |
448 |
*/ |
|
449 |
||
450 |
void ec_fsm_slave_scan_state_sii_data(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
451 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
452 |
ec_slave_t *slave = fsm->slave; |
977 | 453 |
uint16_t *cat_word, cat_type, cat_size; |
830
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 |
if (ec_fsm_sii_exec(&fsm->fsm_sii)) return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
456 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
457 |
if (!ec_fsm_sii_success(&fsm->fsm_sii)) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
458 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
459 |
fsm->state = ec_fsm_slave_scan_state_error; |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
460 |
EC_ERR("Failed to fetch SII contents of slave %u.\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
461 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
462 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
463 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
464 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
465 |
// 2 words fetched |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
466 |
|
977 | 467 |
if (fsm->sii_offset + 2 <= slave->sii_nwords) { // 2 words fit |
468 |
memcpy(slave->sii_words + fsm->sii_offset, fsm->fsm_sii.value, 4); |
|
469 |
} else { // copy the last word |
|
470 |
memcpy(slave->sii_words + fsm->sii_offset, fsm->fsm_sii.value, 2); |
|
471 |
} |
|
472 |
||
473 |
if (fsm->sii_offset + 2 < slave->sii_nwords) { |
|
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
474 |
// fetch the next 2 words |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
475 |
fsm->sii_offset += 2; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
476 |
ec_fsm_sii_read(&fsm->fsm_sii, slave, fsm->sii_offset, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
477 |
EC_FSM_SII_USE_CONFIGURED_ADDRESS); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
478 |
ec_fsm_sii_exec(&fsm->fsm_sii); // execute state immediately |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
479 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
480 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
481 |
|
872 | 482 |
// Evaluate SII contents |
870
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
841
diff
changeset
|
483 |
|
fbd5924690ee
Allow multiple sync manager categories.
Florian Pose <fp@igh-essen.com>
parents:
841
diff
changeset
|
484 |
ec_slave_clear_sync_managers(slave); |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
485 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
486 |
slave->sii.alias = |
977 | 487 |
EC_READ_U16(slave->sii_words + 0x0004); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
488 |
slave->sii.vendor_id = |
977 | 489 |
EC_READ_U32(slave->sii_words + 0x0008); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
490 |
slave->sii.product_code = |
977 | 491 |
EC_READ_U32(slave->sii_words + 0x000A); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
492 |
slave->sii.revision_number = |
977 | 493 |
EC_READ_U32(slave->sii_words + 0x000C); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
494 |
slave->sii.serial_number = |
977 | 495 |
EC_READ_U32(slave->sii_words + 0x000E); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
496 |
slave->sii.boot_rx_mailbox_offset = |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
497 |
EC_READ_U16(slave->sii_words + 0x0014); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
498 |
slave->sii.boot_rx_mailbox_size = |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
499 |
EC_READ_U16(slave->sii_words + 0x0015); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
500 |
slave->sii.boot_tx_mailbox_offset = |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
501 |
EC_READ_U16(slave->sii_words + 0x0016); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
502 |
slave->sii.boot_tx_mailbox_size = |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
503 |
EC_READ_U16(slave->sii_words + 0x0017); |
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
504 |
slave->sii.std_rx_mailbox_offset = |
977 | 505 |
EC_READ_U16(slave->sii_words + 0x0018); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
506 |
slave->sii.std_rx_mailbox_size = |
977 | 507 |
EC_READ_U16(slave->sii_words + 0x0019); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
508 |
slave->sii.std_tx_mailbox_offset = |
977 | 509 |
EC_READ_U16(slave->sii_words + 0x001A); |
1337
0253c74d0940
merge -c1619 branches/1.4-foe: Implemented going to bootstrap state BOOT.
Florian Pose <fp@igh-essen.com>
parents:
1327
diff
changeset
|
510 |
slave->sii.std_tx_mailbox_size = |
977 | 511 |
EC_READ_U16(slave->sii_words + 0x001B); |
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
512 |
slave->sii.mailbox_protocols = |
977 | 513 |
EC_READ_U16(slave->sii_words + 0x001C); |
514 |
||
515 |
if (slave->sii_nwords == EC_FIRST_SII_CATEGORY_OFFSET) { |
|
872 | 516 |
// sii does not contain category data |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
517 |
fsm->state = ec_fsm_slave_scan_state_end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
518 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
519 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
520 |
|
977 | 521 |
if (slave->sii_nwords < EC_FIRST_SII_CATEGORY_OFFSET + 1) { |
872 | 522 |
EC_ERR("Unexpected end of SII data in slave %u:" |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
523 |
" First category header missing.\n", |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
524 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
525 |
goto end; |
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 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
528 |
// evaluate category data |
977 | 529 |
cat_word = slave->sii_words + EC_FIRST_SII_CATEGORY_OFFSET; |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
530 |
while (EC_READ_U16(cat_word) != 0xFFFF) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
531 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
532 |
// type and size words must fit |
977 | 533 |
if (cat_word + 2 - slave->sii_words > slave->sii_nwords) { |
872 | 534 |
EC_ERR("Unexpected end of SII data in slave %u:" |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
535 |
" Category header incomplete.\n", |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
536 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
537 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
538 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
539 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
540 |
cat_type = EC_READ_U16(cat_word) & 0x7FFF; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
541 |
cat_size = EC_READ_U16(cat_word + 1); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
542 |
cat_word += 2; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
543 |
|
977 | 544 |
if (cat_word + cat_size - slave->sii_words > slave->sii_nwords) { |
872 | 545 |
EC_WARN("Unexpected end of SII data in slave %u:" |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
546 |
" Category data incomplete.\n", |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
547 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
548 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
549 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
550 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
551 |
switch (cat_type) { |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
552 |
case 0x000A: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
553 |
if (ec_slave_fetch_sii_strings(slave, (uint8_t *) cat_word, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
554 |
cat_size * 2)) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
555 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
556 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
557 |
case 0x001E: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
558 |
if (ec_slave_fetch_sii_general(slave, (uint8_t *) cat_word, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
559 |
cat_size * 2)) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
560 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
561 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
562 |
case 0x0028: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
563 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
564 |
case 0x0029: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
565 |
if (ec_slave_fetch_sii_syncs(slave, (uint8_t *) cat_word, |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
566 |
cat_size * 2)) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
567 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
568 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
569 |
case 0x0032: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
570 |
if (ec_slave_fetch_sii_pdos( slave, (uint8_t *) cat_word, |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
571 |
cat_size * 2, EC_DIR_INPUT)) // TxPDO |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
572 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
573 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
574 |
case 0x0033: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
575 |
if (ec_slave_fetch_sii_pdos( slave, (uint8_t *) cat_word, |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
576 |
cat_size * 2, EC_DIR_OUTPUT)) // RxPDO |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
577 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
578 |
break; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
579 |
default: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
580 |
if (fsm->slave->master->debug_level) |
986
a486591ba86b
Replaced misleading %i by %u.
Florian Pose <fp@igh-essen.com>
parents:
977
diff
changeset
|
581 |
EC_WARN("Unknown category type 0x%04X in slave %u.\n", |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
582 |
cat_type, slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
583 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
584 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
585 |
cat_word += cat_size; |
977 | 586 |
if (cat_word - slave->sii_words >= slave->sii_nwords) { |
872 | 587 |
EC_WARN("Unexpected end of SII data in slave %u:" |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
588 |
" Next category header missing.\n", |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
589 |
slave->ring_position); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
590 |
goto end; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
591 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
592 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
593 |
|
834
0791aac03180
Separated SII data from slave.
Florian Pose <fp@igh-essen.com>
parents:
831
diff
changeset
|
594 |
if (slave->sii.mailbox_protocols & EC_MBOX_COE) { |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
595 |
ec_fsm_slave_scan_enter_preop(fsm); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
596 |
} else { |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
597 |
fsm->state = ec_fsm_slave_scan_state_end; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
598 |
} |
830
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
599 |
return; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
600 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
601 |
end: |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
602 |
EC_ERR("Failed to analyze category data.\n"); |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
603 |
fsm->slave->error_flag = 1; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
604 |
fsm->state = ec_fsm_slave_scan_state_error; |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
605 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
606 |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
607 |
/*****************************************************************************/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
608 |
|
841 | 609 |
/** Enter slave scan state PREOP. |
610 |
*/ |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
611 |
void ec_fsm_slave_scan_enter_preop( |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
612 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
613 |
) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
614 |
{ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
615 |
ec_slave_t *slave = fsm->slave; |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
616 |
uint8_t current_state = slave->current_state & EC_SLAVE_STATE_MASK; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
617 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
618 |
if (current_state != EC_SLAVE_STATE_PREOP |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
619 |
&& current_state != EC_SLAVE_STATE_SAFEOP |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
620 |
&& current_state != EC_SLAVE_STATE_OP) { |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
621 |
if (slave->master->debug_level) { |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
622 |
char str[EC_STATE_STRING_SIZE]; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
623 |
ec_state_string(current_state, str, 0); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
624 |
EC_DBG("Slave %u is not in the state to do mailbox com (%s)," |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
625 |
" setting to PREOP.\n", slave->ring_position, str); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
626 |
} |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
627 |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
628 |
fsm->state = ec_fsm_slave_scan_state_preop; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
629 |
ec_slave_request_state(slave, EC_SLAVE_STATE_PREOP); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
630 |
ec_fsm_slave_config_start(fsm->fsm_slave_config, slave); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
631 |
ec_fsm_slave_config_exec(fsm->fsm_slave_config); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
632 |
} else { |
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
633 |
if (slave->master->debug_level) |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
634 |
EC_DBG("Reading mailbox syncmanager configuration of slave %u.\n", |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
635 |
slave->ring_position); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
636 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
637 |
/* Scan current sync manager configuration to get configured mailbox |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
638 |
* sizes. */ |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
639 |
ec_datagram_fprd(fsm->datagram, slave->station_address, 0x0800, |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
640 |
EC_SYNC_PAGE_SIZE * 2); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
641 |
fsm->retries = EC_FSM_RETRIES; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
642 |
fsm->state = ec_fsm_slave_scan_state_sync; |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
643 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
644 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
645 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
646 |
/*****************************************************************************/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
647 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
648 |
/** Slave scan state: PREOP. |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
649 |
*/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
650 |
void ec_fsm_slave_scan_state_preop( |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
651 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
652 |
) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
653 |
{ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
654 |
if (ec_fsm_slave_config_exec(fsm->fsm_slave_config)) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
655 |
return; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
656 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
657 |
if (!ec_fsm_slave_config_success(fsm->fsm_slave_config)) { |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
658 |
fsm->state = ec_fsm_slave_scan_state_error; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
659 |
return; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
660 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
661 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
662 |
ec_fsm_slave_scan_enter_pdos(fsm); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
663 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
664 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
665 |
/*****************************************************************************/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
666 |
|
1338
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
667 |
/** Slave scan state: SYNC. |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
668 |
*/ |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
669 |
void ec_fsm_slave_scan_state_sync( |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
670 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
671 |
) |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
672 |
{ |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
673 |
ec_datagram_t *datagram = fsm->datagram; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
674 |
ec_slave_t *slave = fsm->slave; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
675 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
676 |
if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
677 |
return; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
678 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
679 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
680 |
fsm->state = ec_fsm_slave_scan_state_error; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
681 |
EC_ERR("Failed to receive sync manager configuration datagram" |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
682 |
" from slave %u (datagram state %u).\n", |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
683 |
slave->ring_position, datagram->state); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
684 |
return; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
685 |
} |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
686 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
687 |
if (datagram->working_counter != 1) { |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
688 |
fsm->slave->error_flag = 1; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
689 |
fsm->state = ec_fsm_slave_scan_state_error; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
690 |
EC_ERR("Failed to read DL status from slave %u: ", |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
691 |
slave->ring_position); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
692 |
ec_datagram_print_wc_error(datagram); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
693 |
return; |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
694 |
} |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
695 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
696 |
slave->configured_rx_mailbox_offset = EC_READ_U16(datagram->data); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
697 |
slave->configured_rx_mailbox_size = EC_READ_U16(datagram->data + 2); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
698 |
slave->configured_tx_mailbox_offset = EC_READ_U16(datagram->data + 8); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
699 |
slave->configured_tx_mailbox_size = EC_READ_U16(datagram->data + 10); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
700 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
701 |
if (slave->master->debug_level) { |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
702 |
EC_DBG("Mailbox configuration of slave %u:\n", slave->ring_position); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
703 |
EC_DBG(" RX offset=0x%04x size=%u\n", |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
704 |
slave->configured_rx_mailbox_offset, |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
705 |
slave->configured_rx_mailbox_size); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
706 |
EC_DBG(" TX offset=0x%04x size=%u\n", |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
707 |
slave->configured_tx_mailbox_offset, |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
708 |
slave->configured_tx_mailbox_size); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
709 |
} |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
710 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
711 |
ec_fsm_slave_scan_enter_pdos(fsm); |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
712 |
} |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
713 |
|
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
714 |
/*****************************************************************************/ |
eb31b5a135da
merge -c1621 branches/1.4-foe: Introduced configured_[tr]x_mailbox(size|offset) members of slave.
Florian Pose <fp@igh-essen.com>
parents:
1337
diff
changeset
|
715 |
|
841 | 716 |
/** Enter slave scan state PDOS. |
717 |
*/ |
|
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
718 |
void ec_fsm_slave_scan_enter_pdos( |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
719 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
720 |
) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
721 |
{ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
722 |
ec_slave_t *slave = fsm->slave; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
723 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
724 |
if (slave->master->debug_level) |
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
725 |
EC_DBG("Scanning PDO assignment and mapping of slave %u.\n", |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
726 |
slave->ring_position); |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
727 |
fsm->state = ec_fsm_slave_scan_state_pdos; |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
728 |
ec_fsm_pdo_start_reading(fsm->fsm_pdo, slave); |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
729 |
ec_fsm_pdo_exec(fsm->fsm_pdo); // execute immediately |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
730 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
731 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
732 |
/*****************************************************************************/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
733 |
|
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
734 |
/** Slave scan state: PDOS. |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
735 |
*/ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
736 |
void ec_fsm_slave_scan_state_pdos( |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
737 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
738 |
) |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
739 |
{ |
1174
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
740 |
if (ec_fsm_pdo_exec(fsm->fsm_pdo)) |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
741 |
return; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
742 |
|
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
743 |
if (!ec_fsm_pdo_success(fsm->fsm_pdo)) { |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
744 |
fsm->state = ec_fsm_slave_scan_state_error; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
745 |
return; |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
746 |
} |
235f34ca50e2
Major Pdo configuration change: Read mapping of unknown Pdos during
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
747 |
|
1327
4d179b06dd3c
merge -c1604 branches/stable-1.4: Fixed spelling of EtherCAT terms.
Florian Pose <fp@igh-essen.com>
parents:
1326
diff
changeset
|
748 |
// reading PDO configuration finished |
831
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
749 |
fsm->state = ec_fsm_slave_scan_state_end; |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
diff
changeset
|
750 |
} |
ded9519c8d6e
Reading of Pdo mapping via CoE during scan.
Florian Pose <fp@igh-essen.com>
parents:
830
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 |
* Common state functions |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
754 |
*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
755 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
756 |
/** State: ERROR. |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
757 |
*/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
758 |
void ec_fsm_slave_scan_state_error( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
759 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
760 |
) |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
761 |
{ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
762 |
} |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
763 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
764 |
/*****************************************************************************/ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
765 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
766 |
/** State: END. |
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 |
void ec_fsm_slave_scan_state_end( |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
769 |
ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
770 |
) |
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 |
|
d83d92e1a919
Separated slave state machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
774 |
/*****************************************************************************/ |