author | Florian Pose <fp@igh-essen.com> |
Wed, 18 Oct 2006 13:19:21 +0000 | |
changeset 417 | a4193f7ba5b4 |
parent 411 | 42d239bab6ae |
child 419 | cf724fc82a00 |
permissions | -rw-r--r-- |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
12 |
* License, or (at your option) any later version. |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* GNU General Public License for more details. |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
246
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0bf7c769de06
Changed license headers and added EtherCAT license notice.
Florian Pose <fp@igh-essen.com>
parents:
238
diff
changeset
|
31 |
* |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/** |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
\file |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
EtherCAT finite state machines. |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
*/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include "globals.h" |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include "fsm.h" |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "master.h" |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
44 |
#include "mailbox.h" |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
void ec_fsm_master_start(ec_fsm_t *); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
49 |
void ec_fsm_master_broadcast(ec_fsm_t *); |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
50 |
void ec_fsm_master_read_states(ec_fsm_t *); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
51 |
void ec_fsm_master_validate_vendor(ec_fsm_t *); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
52 |
void ec_fsm_master_validate_product(ec_fsm_t *); |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
53 |
void ec_fsm_master_rewrite_addresses(ec_fsm_t *); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
54 |
void ec_fsm_master_configure_slave(ec_fsm_t *); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
55 |
void ec_fsm_master_scan_slaves(ec_fsm_t *); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
56 |
void ec_fsm_master_write_eeprom(ec_fsm_t *); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
57 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
58 |
void ec_fsm_startup_start(ec_fsm_t *); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
59 |
void ec_fsm_startup_broadcast(ec_fsm_t *); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
60 |
void ec_fsm_startup_scan(ec_fsm_t *); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
61 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
62 |
void ec_fsm_configuration_start(ec_fsm_t *); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
63 |
void ec_fsm_configuration_conf(ec_fsm_t *); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
64 |
|
308
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
65 |
void ec_fsm_slavescan_start(ec_fsm_t *); |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
66 |
void ec_fsm_slavescan_address(ec_fsm_t *); |
308
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
67 |
void ec_fsm_slavescan_state(ec_fsm_t *); |
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
68 |
void ec_fsm_slavescan_base(ec_fsm_t *); |
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
69 |
void ec_fsm_slavescan_datalink(ec_fsm_t *); |
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
70 |
void ec_fsm_slavescan_eeprom_size(ec_fsm_t *); |
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
71 |
void ec_fsm_slavescan_eeprom_data(ec_fsm_t *); |
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
72 |
|
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
73 |
void ec_fsm_slaveconf_init(ec_fsm_t *); |
308
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
74 |
void ec_fsm_slaveconf_sync(ec_fsm_t *); |
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
75 |
void ec_fsm_slaveconf_preop(ec_fsm_t *); |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
76 |
void ec_fsm_slaveconf_sdodict(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
77 |
void ec_fsm_slaveconf_sdoconf(ec_fsm_t *); |
308
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
78 |
void ec_fsm_slaveconf_fmmu(ec_fsm_t *); |
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
79 |
void ec_fsm_slaveconf_saveop(ec_fsm_t *); |
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
80 |
void ec_fsm_slaveconf_op(ec_fsm_t *); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
void ec_fsm_sii_start_reading(ec_fsm_t *); |
269 | 83 |
void ec_fsm_sii_read_check(ec_fsm_t *); |
84 |
void ec_fsm_sii_read_fetch(ec_fsm_t *); |
|
85 |
void ec_fsm_sii_start_writing(ec_fsm_t *); |
|
86 |
void ec_fsm_sii_write_check(ec_fsm_t *); |
|
87 |
void ec_fsm_sii_write_check2(ec_fsm_t *); |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
88 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
89 |
void ec_fsm_change_start(ec_fsm_t *); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
90 |
void ec_fsm_change_check(ec_fsm_t *); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
91 |
void ec_fsm_change_status(ec_fsm_t *); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
92 |
void ec_fsm_change_code(ec_fsm_t *); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
93 |
void ec_fsm_change_ack(ec_fsm_t *); |
311
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
94 |
void ec_fsm_change_check_ack(ec_fsm_t *); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
95 |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
96 |
void ec_fsm_coe_dict_start(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
97 |
void ec_fsm_coe_dict_request(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
98 |
void ec_fsm_coe_dict_check(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
99 |
void ec_fsm_coe_dict_response(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
100 |
void ec_fsm_coe_dict_desc_request(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
101 |
void ec_fsm_coe_dict_desc_check(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
102 |
void ec_fsm_coe_dict_desc_response(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
103 |
void ec_fsm_coe_dict_entry_request(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
104 |
void ec_fsm_coe_dict_entry_check(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
105 |
void ec_fsm_coe_dict_entry_response(ec_fsm_t *); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
106 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
107 |
void ec_fsm_coe_down_start(ec_fsm_t *); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
108 |
void ec_fsm_coe_down_request(ec_fsm_t *); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
109 |
void ec_fsm_coe_down_check(ec_fsm_t *); |
339 | 110 |
void ec_fsm_coe_down_response(ec_fsm_t *); |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
111 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
112 |
void ec_fsm_end(ec_fsm_t *); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
113 |
void ec_fsm_error(ec_fsm_t *); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
114 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
115 |
void ec_canopen_abort_msg(uint32_t); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
116 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
|
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
119 |
/** |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
120 |
Constructor. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
121 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
122 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
123 |
int ec_fsm_init(ec_fsm_t *fsm, /**< finite state machine */ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
124 |
ec_master_t *master /**< EtherCAT master */ |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
125 |
) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
{ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
fsm->master = master; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
fsm->master_state = ec_fsm_master_start; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
fsm->master_slaves_responding = 0; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
fsm->master_slave_states = EC_SLAVE_STATE_UNKNOWN; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
131 |
fsm->master_validation = 0; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
133 |
ec_datagram_init(&fsm->datagram); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
134 |
if (ec_datagram_prealloc(&fsm->datagram, EC_MAX_DATA_SIZE)) { |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
135 |
EC_ERR("Failed to allocate FSM datagram.\n"); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
return -1; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
return 0; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
|
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
144 |
/** |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
145 |
Destructor. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
146 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
147 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
148 |
void ec_fsm_clear(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
150 |
ec_datagram_clear(&fsm->datagram); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
|
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
155 |
/** |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
156 |
Resets the state machine. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
157 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
158 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
159 |
void ec_fsm_reset(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
{ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
fsm->master_state = ec_fsm_master_start; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
fsm->master_slaves_responding = 0; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
163 |
fsm->master_slave_states = EC_SLAVE_STATE_UNKNOWN; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
164 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
|
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
168 |
/** |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
169 |
Executes the current state of the state machine. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
170 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
171 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
172 |
void ec_fsm_execute(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
{ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
fsm->master_state(fsm); |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
177 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
178 |
|
343
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
179 |
/** |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
180 |
Initializes the master startup state machine. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
181 |
*/ |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
182 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
183 |
void ec_fsm_startup(ec_fsm_t *fsm) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
184 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
185 |
fsm->master_state = ec_fsm_startup_start; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
186 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
187 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
188 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
189 |
|
343
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
190 |
/** |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
191 |
Returns the running state of the master startup state machine. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
192 |
\return non-zero if not terminated yet. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
193 |
*/ |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
194 |
|
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
195 |
int ec_fsm_startup_running(ec_fsm_t *fsm /**< Finite state machine */) |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
196 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
197 |
return fsm->master_state != ec_fsm_end && |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
198 |
fsm->master_state != ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
199 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
200 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
201 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
202 |
|
343
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
203 |
/** |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
204 |
Returns, if the master startup state machine terminated with success. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
205 |
\return non-zero if successful. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
206 |
*/ |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
207 |
|
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
208 |
int ec_fsm_startup_success(ec_fsm_t *fsm /**< Finite state machine */) |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
209 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
210 |
return fsm->master_state == ec_fsm_end; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
211 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
212 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
213 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
214 |
|
343
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
215 |
/** |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
216 |
Initializes the master configuration state machine. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
217 |
*/ |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
218 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
219 |
void ec_fsm_configuration(ec_fsm_t *fsm) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
220 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
221 |
fsm->master_state = ec_fsm_configuration_start; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
222 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
223 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
224 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
225 |
|
343
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
226 |
/** |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
227 |
Returns the running state of the master configuration state machine. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
228 |
\return non-zero if not terminated yet. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
229 |
*/ |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
230 |
|
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
231 |
int ec_fsm_configuration_running(ec_fsm_t *fsm /**< Finite state machine */) |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
232 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
233 |
return fsm->master_state != ec_fsm_end && |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
234 |
fsm->master_state != ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
235 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
236 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
237 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
238 |
|
343
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
239 |
/** |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
240 |
Returns, if the master confuguration state machine terminated with success. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
241 |
\return non-zero if successful. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
242 |
*/ |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
243 |
|
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
244 |
int ec_fsm_configuration_success(ec_fsm_t *fsm /**< Finite state machine */) |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
245 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
246 |
return fsm->master_state == ec_fsm_end; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
247 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
248 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
/****************************************************************************** |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
250 |
* master startup state machine |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
251 |
*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
252 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
253 |
/** |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
254 |
Master state: START. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
255 |
Starts with getting slave count and slave states. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
256 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
257 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
258 |
void ec_fsm_startup_start(ec_fsm_t *fsm) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
259 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
260 |
ec_datagram_brd(&fsm->datagram, 0x0130, 2); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
261 |
ec_master_queue_datagram(fsm->master, &fsm->datagram); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
262 |
fsm->master_state = ec_fsm_startup_broadcast; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
263 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
264 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
265 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
266 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
267 |
/** |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
268 |
Master state: BROADCAST. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
269 |
Processes the broadcast read slave count and slaves states. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
270 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
271 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
272 |
void ec_fsm_startup_broadcast(ec_fsm_t *fsm /**< finite state machine */) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
273 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
274 |
ec_datagram_t *datagram = &fsm->datagram; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
275 |
unsigned int i; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
276 |
ec_slave_t *slave; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
277 |
ec_master_t *master = fsm->master; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
278 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
279 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
397
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
280 |
EC_ERR("Failed to receive broadcast datagram.\n"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
281 |
fsm->master_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
282 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
283 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
284 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
285 |
EC_INFO("Scanning bus.\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
286 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
287 |
ec_master_clear_slaves(master); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
288 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
289 |
master->slave_count = datagram->working_counter; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
290 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
291 |
if (!master->slave_count) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
292 |
// no slaves present -> finish state machine. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
293 |
fsm->master_state = ec_fsm_end; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
294 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
295 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
296 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
297 |
// init slaves |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
298 |
for (i = 0; i < master->slave_count; i++) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
299 |
if (!(slave = (ec_slave_t *) kmalloc(sizeof(ec_slave_t), |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
300 |
GFP_KERNEL))) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
301 |
EC_ERR("Failed to allocate slave %i!\n", i); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
302 |
fsm->master_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
303 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
304 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
305 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
306 |
if (ec_slave_init(slave, master, i, i + 1)) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
307 |
fsm->master_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
308 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
309 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
310 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
311 |
if (kobject_add(&slave->kobj)) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
312 |
EC_ERR("Failed to add kobject.\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
313 |
kobject_put(&slave->kobj); // free |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
314 |
fsm->master_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
315 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
316 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
317 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
318 |
list_add_tail(&slave->list, &master->slaves); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
319 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
320 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
321 |
// begin scanning of slaves |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
322 |
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
323 |
fsm->slave_state = ec_fsm_slavescan_start; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
324 |
fsm->master_state = ec_fsm_startup_scan; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
325 |
fsm->master_state(fsm); // execute immediately |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
326 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
327 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
328 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
329 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
330 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
331 |
/** |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
332 |
Master state: SCAN. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
333 |
Executes the sub-statemachine for the scanning of a slave. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
334 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
335 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
336 |
void ec_fsm_startup_scan(ec_fsm_t *fsm /**< finite state machine */) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
337 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
338 |
ec_master_t *master = fsm->master; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
339 |
ec_slave_t *slave = fsm->slave; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
340 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
341 |
fsm->slave_state(fsm); // execute slave state machine |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
342 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
343 |
if (fsm->slave_state == ec_fsm_error) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
344 |
EC_ERR("Slave scanning failed.\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
345 |
fsm->master_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
346 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
347 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
348 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
349 |
if (fsm->slave_state != ec_fsm_end) return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
350 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
351 |
// another slave to scan? |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
352 |
if (slave->list.next != &master->slaves) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
353 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
354 |
fsm->slave_state = ec_fsm_slavescan_start; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
355 |
fsm->slave_state(fsm); // execute immediately |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
356 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
357 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
358 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
359 |
EC_INFO("Bus scanning completed.\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
360 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
361 |
ec_master_calc_addressing(master); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
362 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
363 |
fsm->master_state = ec_fsm_end; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
364 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
365 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
366 |
/****************************************************************************** |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
367 |
* master configuration state machine |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
368 |
*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
369 |
|
343
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
370 |
/** |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
371 |
Master configuration state machine: START. |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
372 |
*/ |
b3858d25ba4b
Added missing code documentation.
Florian Pose <fp@igh-essen.com>
parents:
339
diff
changeset
|
373 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
374 |
void ec_fsm_configuration_start(ec_fsm_t *fsm /**< finite state machine */) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
375 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
376 |
ec_master_t *master = fsm->master; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
377 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
378 |
if (list_empty(&master->slaves)) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
379 |
fsm->master_state = ec_fsm_end; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
380 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
381 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
382 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
383 |
// begin configuring slaves |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
384 |
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
385 |
fsm->slave_state = ec_fsm_slaveconf_init; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
386 |
fsm->change_new = EC_SLAVE_STATE_INIT; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
387 |
fsm->change_state = ec_fsm_change_start; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
388 |
fsm->master_state = ec_fsm_configuration_conf; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
389 |
fsm->master_state(fsm); // execute immediately |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
390 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
391 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
392 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
393 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
394 |
/** |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
395 |
Master state: CONF. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
396 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
397 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
398 |
void ec_fsm_configuration_conf(ec_fsm_t *fsm /**< finite state machine */) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
399 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
400 |
ec_master_t *master = fsm->master; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
401 |
ec_slave_t *slave = fsm->slave; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
402 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
403 |
fsm->slave_state(fsm); // execute slave's state machine |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
404 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
405 |
if (fsm->slave_state == ec_fsm_error) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
406 |
fsm->master_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
407 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
408 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
409 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
410 |
if (fsm->slave_state != ec_fsm_end) return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
411 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
412 |
// another slave to configure? |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
413 |
if (slave->list.next != &master->slaves) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
414 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
415 |
fsm->slave_state = ec_fsm_slaveconf_init; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
416 |
fsm->change_new = EC_SLAVE_STATE_INIT; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
417 |
fsm->change_state = ec_fsm_change_start; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
418 |
fsm->master_state(fsm); // execute immediately |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
419 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
420 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
421 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
422 |
fsm->master_state = ec_fsm_end; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
423 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
424 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
425 |
/****************************************************************************** |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
426 |
* operation / idle state machine |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
427 |
*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
428 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
429 |
/** |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
430 |
Master state: START. |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
431 |
Starts with getting slave count and slave states. |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
432 |
*/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
433 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
434 |
void ec_fsm_master_start(ec_fsm_t *fsm) |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
435 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
436 |
ec_datagram_brd(&fsm->datagram, 0x0130, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
437 |
ec_master_queue_datagram(fsm->master, &fsm->datagram); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
438 |
fsm->master_state = ec_fsm_master_broadcast; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
439 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
440 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
441 |
/*****************************************************************************/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
442 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
443 |
/** |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
444 |
Master state: BROADCAST. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
445 |
Processes the broadcast read slave count and slaves states. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
446 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
447 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
448 |
void ec_fsm_master_broadcast(ec_fsm_t *fsm /**< finite state machine */) |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
449 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
450 |
ec_datagram_t *datagram = &fsm->datagram; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
451 |
unsigned int topology_change, states_change, i; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
452 |
ec_slave_t *slave; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
453 |
ec_master_t *master = fsm->master; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
454 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
455 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
456 |
if (!master->device->link_state) { |
254
986afccca9ea
Link down treated as topology change in state machine.
Florian Pose <fp@igh-essen.com>
parents:
251
diff
changeset
|
457 |
fsm->master_slaves_responding = 0; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
458 |
list_for_each_entry(slave, &master->slaves, list) { |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
459 |
slave->online = 0; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
460 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
461 |
} |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
462 |
fsm->master_state = ec_fsm_master_start; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
463 |
fsm->master_state(fsm); // execute immediately |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
464 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
465 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
466 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
467 |
topology_change = (datagram->working_counter != |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
468 |
fsm->master_slaves_responding); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
469 |
states_change = (EC_READ_U8(datagram->data) != fsm->master_slave_states); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
470 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
471 |
fsm->master_slave_states = EC_READ_U8(datagram->data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
472 |
fsm->master_slaves_responding = datagram->working_counter; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
473 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
474 |
if (topology_change) { |
262
636d43737371
Corrected output at slave count change.
Florian Pose <fp@igh-essen.com>
parents:
260
diff
changeset
|
475 |
EC_INFO("%i slave%s responding.\n", |
636d43737371
Corrected output at slave count change.
Florian Pose <fp@igh-essen.com>
parents:
260
diff
changeset
|
476 |
fsm->master_slaves_responding, |
636d43737371
Corrected output at slave count change.
Florian Pose <fp@igh-essen.com>
parents:
260
diff
changeset
|
477 |
fsm->master_slaves_responding == 1 ? "" : "s"); |
636d43737371
Corrected output at slave count change.
Florian Pose <fp@igh-essen.com>
parents:
260
diff
changeset
|
478 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
479 |
if (master->mode == EC_MASTER_MODE_OPERATION) { |
262
636d43737371
Corrected output at slave count change.
Florian Pose <fp@igh-essen.com>
parents:
260
diff
changeset
|
480 |
if (fsm->master_slaves_responding == master->slave_count) { |
636d43737371
Corrected output at slave count change.
Florian Pose <fp@igh-essen.com>
parents:
260
diff
changeset
|
481 |
fsm->master_validation = 1; // start validation later |
636d43737371
Corrected output at slave count change.
Florian Pose <fp@igh-essen.com>
parents:
260
diff
changeset
|
482 |
} |
636d43737371
Corrected output at slave count change.
Florian Pose <fp@igh-essen.com>
parents:
260
diff
changeset
|
483 |
else { |
636d43737371
Corrected output at slave count change.
Florian Pose <fp@igh-essen.com>
parents:
260
diff
changeset
|
484 |
EC_WARN("Invalid slave count. Bus in tainted state.\n"); |
636d43737371
Corrected output at slave count change.
Florian Pose <fp@igh-essen.com>
parents:
260
diff
changeset
|
485 |
} |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
486 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
487 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
488 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
489 |
if (states_change) { |
403
7bb931deccd9
Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents:
402
diff
changeset
|
490 |
char states[EC_STATE_STRING_SIZE]; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
491 |
ec_state_string(fsm->master_slave_states, states); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
492 |
EC_INFO("Slave states: %s.\n", states); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
493 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
494 |
|
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
304
diff
changeset
|
495 |
// topology change in idle mode: clear all slaves and scan the bus |
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
304
diff
changeset
|
496 |
if (topology_change && master->mode == EC_MASTER_MODE_IDLE) { |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
497 |
EC_INFO("Scanning bus.\n"); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
498 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
499 |
ec_master_eoe_stop(master); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
500 |
ec_master_clear_slaves(master); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
501 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
502 |
master->slave_count = datagram->working_counter; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
503 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
504 |
if (!master->slave_count) { |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
505 |
// no slaves present -> finish state machine. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
506 |
fsm->master_state = ec_fsm_master_start; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
507 |
fsm->master_state(fsm); // execute immediately |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
508 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
509 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
510 |
|
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
511 |
// init slaves |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
512 |
for (i = 0; i < master->slave_count; i++) { |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
513 |
if (!(slave = (ec_slave_t *) kmalloc(sizeof(ec_slave_t), |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
514 |
GFP_ATOMIC))) { |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
515 |
EC_ERR("Failed to allocate slave %i!\n", i); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
516 |
ec_master_clear_slaves(master); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
517 |
fsm->master_state = ec_fsm_master_start; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
518 |
fsm->master_state(fsm); // execute immediately |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
519 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
520 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
521 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
522 |
if (ec_slave_init(slave, master, i, i + 1)) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
523 |
// freeing of "slave" already done |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
524 |
ec_master_clear_slaves(master); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
525 |
fsm->master_state = ec_fsm_master_start; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
526 |
fsm->master_state(fsm); // execute immediately |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
527 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
528 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
529 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
530 |
if (kobject_add(&slave->kobj)) { |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
531 |
EC_ERR("Failed to add kobject.\n"); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
532 |
kobject_put(&slave->kobj); // free |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
533 |
ec_master_clear_slaves(master); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
534 |
fsm->master_state = ec_fsm_master_start; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
535 |
fsm->master_state(fsm); // execute immediately |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
536 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
537 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
538 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
539 |
list_add_tail(&slave->list, &master->slaves); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
540 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
541 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
542 |
// begin scanning of slaves |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
543 |
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list); |
308
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
544 |
fsm->slave_state = ec_fsm_slavescan_start; |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
545 |
fsm->master_state = ec_fsm_master_scan_slaves; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
546 |
fsm->master_state(fsm); // execute immediately |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
547 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
548 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
549 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
550 |
// fetch state from each slave |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
551 |
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
552 |
ec_datagram_nprd(&fsm->datagram, fsm->slave->station_address, 0x0130, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
553 |
ec_master_queue_datagram(master, &fsm->datagram); |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
554 |
fsm->master_state = ec_fsm_master_read_states; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
555 |
} |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
556 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
557 |
/*****************************************************************************/ |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
558 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
559 |
/** |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
560 |
Master action: PROC_STATES. |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
561 |
Processes the slave states. |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
562 |
*/ |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
563 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
564 |
void ec_fsm_master_action_process_states(ec_fsm_t *fsm |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
565 |
/**< finite state machine */ |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
566 |
) |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
567 |
{ |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
568 |
ec_master_t *master = fsm->master; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
569 |
ec_slave_t *slave; |
403
7bb931deccd9
Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents:
402
diff
changeset
|
570 |
char old_state[EC_STATE_STRING_SIZE], new_state[EC_STATE_STRING_SIZE]; |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
571 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
572 |
// check if any slaves are not in the state, they're supposed to be |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
573 |
list_for_each_entry(slave, &master->slaves, list) { |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
574 |
if (slave->error_flag || |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
575 |
!slave->online || |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
576 |
slave->requested_state == EC_SLAVE_STATE_UNKNOWN || |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
577 |
slave->current_state == slave->requested_state) continue; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
578 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
579 |
ec_state_string(slave->current_state, old_state); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
580 |
ec_state_string(slave->requested_state, new_state); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
581 |
EC_INFO("Changing state of slave %i from %s to %s.\n", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
582 |
slave->ring_position, old_state, new_state); |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
583 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
584 |
fsm->slave = slave; |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
585 |
fsm->slave_state = ec_fsm_slaveconf_init; |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
586 |
fsm->change_new = EC_SLAVE_STATE_INIT; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
587 |
fsm->change_state = ec_fsm_change_start; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
588 |
fsm->master_state = ec_fsm_master_configure_slave; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
589 |
fsm->master_state(fsm); // execute immediately |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
590 |
return; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
591 |
} |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
592 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
593 |
// Check, if EoE processing has to be started |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
594 |
ec_master_eoe_start(master); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
595 |
|
306
45886de3db87
Renamed FREERUN mode to IDLE mode.
Florian Pose <fp@igh-essen.com>
parents:
304
diff
changeset
|
596 |
if (master->mode == EC_MASTER_MODE_IDLE) { |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
597 |
// nothing to configure. check for pending EEPROM write operations. |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
598 |
list_for_each_entry(slave, &master->slaves, list) { |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
599 |
if (!slave->new_eeprom_data) continue; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
600 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
601 |
if (!slave->online || slave->error_flag) { |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
602 |
kfree(slave->new_eeprom_data); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
603 |
slave->new_eeprom_data = NULL; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
604 |
EC_ERR("Discarding EEPROM data, slave %i not ready.\n", |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
605 |
slave->ring_position); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
606 |
continue; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
607 |
} |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
608 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
609 |
// found pending EEPROM write operation. execute it! |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
610 |
EC_INFO("Writing EEPROM of slave %i...\n", slave->ring_position); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
611 |
fsm->sii_offset = 0x0000; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
612 |
memcpy(fsm->sii_value, slave->new_eeprom_data, 2); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
613 |
fsm->sii_mode = 1; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
614 |
fsm->sii_state = ec_fsm_sii_start_writing; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
615 |
fsm->slave = slave; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
616 |
fsm->master_state = ec_fsm_master_write_eeprom; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
617 |
fsm->master_state(fsm); // execute immediately |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
618 |
return; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
619 |
} |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
620 |
} |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
621 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
622 |
// nothing to do. restart master state machine. |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
623 |
fsm->master_state = ec_fsm_master_start; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
624 |
fsm->master_state(fsm); // execute immediately |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
625 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
626 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
627 |
/*****************************************************************************/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
628 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
629 |
/** |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
630 |
Master action: Get state of next slave. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
631 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
632 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
633 |
void ec_fsm_master_action_next_slave_state(ec_fsm_t *fsm |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
634 |
/**< finite state machine */) |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
635 |
{ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
636 |
ec_master_t *master = fsm->master; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
637 |
ec_slave_t *slave = fsm->slave; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
638 |
|
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
639 |
// is there another slave to query? |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
640 |
if (slave->list.next != &master->slaves) { |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
641 |
// process next slave |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
642 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
643 |
ec_datagram_nprd(&fsm->datagram, fsm->slave->station_address, |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
644 |
0x0130, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
645 |
ec_master_queue_datagram(master, &fsm->datagram); |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
646 |
fsm->master_state = ec_fsm_master_read_states; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
647 |
return; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
648 |
} |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
649 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
650 |
// all slave states read |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
651 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
652 |
// check, if a bus validation has to be done |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
653 |
if (fsm->master_validation) { |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
654 |
fsm->master_validation = 0; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
655 |
list_for_each_entry(slave, &master->slaves, list) { |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
656 |
if (slave->online) continue; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
657 |
|
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
658 |
// At least one slave is offline. validate! |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
659 |
EC_INFO("Validating bus.\n"); |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
660 |
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list); |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
661 |
fsm->master_state = ec_fsm_master_validate_vendor; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
662 |
fsm->sii_offset = 0x0008; // vendor ID |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
663 |
fsm->sii_mode = 0; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
664 |
fsm->sii_state = ec_fsm_sii_start_reading; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
665 |
fsm->sii_state(fsm); // execute immediately |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
666 |
return; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
667 |
} |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
668 |
} |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
669 |
|
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
670 |
ec_fsm_master_action_process_states(fsm); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
671 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
672 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
673 |
/*****************************************************************************/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
674 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
675 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
676 |
Master state: READ STATES. |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
677 |
Fetches the AL- and online state of a slave. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
678 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
679 |
|
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
680 |
void ec_fsm_master_read_states(ec_fsm_t *fsm /**< finite state machine */) |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
681 |
{ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
682 |
ec_slave_t *slave = fsm->slave; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
683 |
ec_datagram_t *datagram = &fsm->datagram; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
684 |
uint8_t new_state; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
685 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
686 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
687 |
fsm->master_state = ec_fsm_master_start; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
688 |
fsm->master_state(fsm); // execute immediately |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
689 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
690 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
691 |
|
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
692 |
// did the slave not respond to its station address? |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
693 |
if (datagram->working_counter != 1) { |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
694 |
if (slave->online) { |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
695 |
slave->online = 0; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
696 |
EC_INFO("Slave %i: offline.\n", slave->ring_position); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
697 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
698 |
ec_fsm_master_action_next_slave_state(fsm); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
699 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
700 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
701 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
702 |
// slave responded |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
703 |
new_state = EC_READ_U8(datagram->data); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
704 |
if (!slave->online) { // slave was offline before |
403
7bb931deccd9
Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents:
402
diff
changeset
|
705 |
char cur_state[EC_STATE_STRING_SIZE]; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
706 |
slave->online = 1; |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
290
diff
changeset
|
707 |
slave->error_flag = 0; // clear error flag |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
708 |
slave->current_state = new_state; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
709 |
ec_state_string(slave->current_state, cur_state); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
710 |
EC_INFO("Slave %i: online (%s).\n", slave->ring_position, cur_state); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
711 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
712 |
else if (new_state != slave->current_state) { |
403
7bb931deccd9
Added EC_SLAVE_STATE_ACK_ERR to ec_state_string(); added EC_STATE_STRING_SIZE
Florian Pose <fp@igh-essen.com>
parents:
402
diff
changeset
|
713 |
char old_state[EC_STATE_STRING_SIZE], cur_state[EC_STATE_STRING_SIZE]; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
714 |
ec_state_string(slave->current_state, old_state); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
715 |
ec_state_string(new_state, cur_state); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
716 |
EC_INFO("Slave %i: %s -> %s.\n", |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
717 |
slave->ring_position, old_state, cur_state); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
718 |
slave->current_state = new_state; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
719 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
720 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
721 |
ec_fsm_master_action_next_slave_state(fsm); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
722 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
723 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
724 |
/*****************************************************************************/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
725 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
726 |
/** |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
727 |
Master state: VALIDATE_VENDOR. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
728 |
Validates the vendor ID of a slave. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
729 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
730 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
731 |
void ec_fsm_master_validate_vendor(ec_fsm_t *fsm /**< finite state machine */) |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
732 |
{ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
733 |
ec_slave_t *slave = fsm->slave; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
734 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
735 |
fsm->sii_state(fsm); // execute SII state machine |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
736 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
737 |
if (fsm->sii_state == ec_fsm_error) { |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
738 |
fsm->slave->error_flag = 1; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
739 |
EC_ERR("Failed to validate vendor ID of slave %i.\n", |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
740 |
slave->ring_position); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
741 |
fsm->master_state = ec_fsm_master_start; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
742 |
fsm->master_state(fsm); // execute immediately |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
743 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
744 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
745 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
746 |
if (fsm->sii_state != ec_fsm_end) return; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
747 |
|
269 | 748 |
if (EC_READ_U32(fsm->sii_value) != slave->sii_vendor_id) { |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
749 |
EC_ERR("Slave %i: invalid vendor ID!\n", slave->ring_position); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
750 |
fsm->master_state = ec_fsm_master_start; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
751 |
fsm->master_state(fsm); // execute immediately |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
752 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
753 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
754 |
|
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
755 |
// vendor ID is ok. check product code. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
756 |
fsm->master_state = ec_fsm_master_validate_product; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
757 |
fsm->sii_offset = 0x000A; // product code |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
758 |
fsm->sii_mode = 0; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
759 |
fsm->sii_state = ec_fsm_sii_start_reading; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
760 |
fsm->sii_state(fsm); // execute immediately |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
761 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
762 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
763 |
/*****************************************************************************/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
764 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
765 |
/** |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
766 |
Master action: ADDRESS. |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
767 |
Looks for slave, that have lost their configuration and writes |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
768 |
their station address, so that they can be reconfigured later. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
769 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
770 |
|
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
771 |
void ec_fsm_master_action_addresses(ec_fsm_t *fsm /**< finite state machine */) |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
772 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
773 |
ec_datagram_t *datagram = &fsm->datagram; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
774 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
775 |
while (fsm->slave->online) { |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
776 |
if (fsm->slave->list.next == &fsm->master->slaves) { // last slave? |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
777 |
fsm->master_state = ec_fsm_master_start; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
778 |
fsm->master_state(fsm); // execute immediately |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
779 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
780 |
} |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
781 |
// check next slave |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
782 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
783 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
784 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
785 |
EC_INFO("Reinitializing slave %i.\n", fsm->slave->ring_position); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
786 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
787 |
// write station address |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
788 |
ec_datagram_apwr(datagram, fsm->slave->ring_position, 0x0010, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
789 |
EC_WRITE_U16(datagram->data, fsm->slave->station_address); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
790 |
ec_master_queue_datagram(fsm->master, datagram); |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
791 |
fsm->master_state = ec_fsm_master_rewrite_addresses; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
792 |
} |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
793 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
794 |
/*****************************************************************************/ |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
795 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
796 |
/** |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
797 |
Master state: VALIDATE_PRODUCT. |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
798 |
Validates the product ID of a slave. |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
799 |
*/ |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
800 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
801 |
void ec_fsm_master_validate_product(ec_fsm_t *fsm /**< finite state machine */) |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
802 |
{ |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
803 |
ec_slave_t *slave = fsm->slave; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
804 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
805 |
fsm->sii_state(fsm); // execute SII state machine |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
806 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
807 |
if (fsm->sii_state == ec_fsm_error) { |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
808 |
fsm->slave->error_flag = 1; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
809 |
EC_ERR("Failed to validate product code of slave %i.\n", |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
810 |
slave->ring_position); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
811 |
fsm->master_state = ec_fsm_master_start; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
812 |
fsm->master_state(fsm); // execute immediately |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
813 |
return; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
814 |
} |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
815 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
816 |
if (fsm->sii_state != ec_fsm_end) return; |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
817 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
818 |
if (EC_READ_U32(fsm->sii_value) != slave->sii_product_code) { |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
819 |
EC_ERR("Slave %i: invalid product code!\n", slave->ring_position); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
820 |
EC_ERR("expected 0x%08X, got 0x%08X.\n", slave->sii_product_code, |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
821 |
EC_READ_U32(fsm->sii_value)); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
822 |
fsm->master_state = ec_fsm_master_start; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
823 |
fsm->master_state(fsm); // execute immediately |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
824 |
return; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
825 |
} |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
826 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
827 |
// have all states been validated? |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
828 |
if (slave->list.next == &fsm->master->slaves) { |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
829 |
fsm->slave = list_entry(fsm->master->slaves.next, ec_slave_t, list); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
830 |
// start writing addresses to offline slaves |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
831 |
ec_fsm_master_action_addresses(fsm); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
832 |
return; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
833 |
} |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
834 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
835 |
// validate next slave |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
836 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
837 |
fsm->master_state = ec_fsm_master_validate_vendor; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
838 |
fsm->sii_offset = 0x0008; // vendor ID |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
839 |
fsm->sii_mode = 0; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
840 |
fsm->sii_state = ec_fsm_sii_start_reading; |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
841 |
fsm->sii_state(fsm); // execute immediately |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
842 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
843 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
844 |
/*****************************************************************************/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
845 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
846 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
847 |
Master state: REWRITE ADDRESS. |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
848 |
Checks, if the new station address has been written to the slave. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
849 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
850 |
|
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
851 |
void ec_fsm_master_rewrite_addresses(ec_fsm_t *fsm |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
852 |
/**< finite state machine */ |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
853 |
) |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
854 |
{ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
855 |
ec_slave_t *slave = fsm->slave; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
856 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
857 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
858 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
859 |
|| datagram->working_counter != 1) { |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
860 |
EC_ERR("Failed to write station address on slave %i.\n", |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
861 |
slave->ring_position); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
862 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
863 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
864 |
if (fsm->slave->list.next == &fsm->master->slaves) { // last slave? |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
865 |
fsm->master_state = ec_fsm_master_start; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
866 |
fsm->master_state(fsm); // execute immediately |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
867 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
868 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
869 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
870 |
// check next slave |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
871 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
872 |
// Write new station address to slave |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
873 |
ec_fsm_master_action_addresses(fsm); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
874 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
875 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
876 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
877 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
878 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
879 |
Master state: SCAN SLAVES. |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
880 |
Executes the sub-statemachine for the scanning of a slave. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
881 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
882 |
|
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
883 |
void ec_fsm_master_scan_slaves(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
884 |
{ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
885 |
ec_master_t *master = fsm->master; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
886 |
ec_slave_t *slave = fsm->slave; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
887 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
888 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
889 |
fsm->slave_state(fsm); // execute slave state machine |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
890 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
891 |
if (fsm->slave_state != ec_fsm_end |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
892 |
&& fsm->slave_state != ec_fsm_error) return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
893 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
894 |
// another slave to fetch? |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
895 |
if (slave->list.next != &master->slaves) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
896 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
897 |
fsm->slave_state = ec_fsm_slavescan_start; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
898 |
fsm->slave_state(fsm); // execute immediately |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
899 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
900 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
901 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
902 |
EC_INFO("Bus scanning completed.\n"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
903 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
904 |
ec_master_calc_addressing(master); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
905 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
906 |
// determine initial states. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
907 |
list_for_each_entry(slave, &master->slaves, list) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
908 |
if (ec_slave_is_coupler(slave)) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
909 |
slave->requested_state = EC_SLAVE_STATE_OP; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
910 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
911 |
else { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
912 |
if (master->mode == EC_MASTER_MODE_OPERATION) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
913 |
slave->requested_state = EC_SLAVE_STATE_PREOP; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
914 |
else |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
915 |
slave->requested_state = EC_SLAVE_STATE_INIT; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
916 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
917 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
918 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
919 |
fsm->master_state = ec_fsm_master_start; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
920 |
fsm->master_state(fsm); // execute immediately |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
921 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
922 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
923 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
924 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
925 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
926 |
Master state: CONFIGURE SLAVES. |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
927 |
Starts configuring a slave. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
928 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
929 |
|
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
930 |
void ec_fsm_master_configure_slave(ec_fsm_t *fsm |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
931 |
/**< finite state machine */ |
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
932 |
) |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
933 |
{ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
934 |
fsm->slave_state(fsm); // execute slave's state machine |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
935 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
936 |
if (fsm->slave_state != ec_fsm_end |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
937 |
&& fsm->slave_state != ec_fsm_error) return; |
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
938 |
|
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
939 |
ec_fsm_master_action_process_states(fsm); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
940 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
941 |
|
269 | 942 |
/*****************************************************************************/ |
943 |
||
944 |
/** |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
945 |
Master state: WRITE EEPROM. |
269 | 946 |
*/ |
947 |
||
304
558a6669da90
Better master state machines.
Florian Pose <fp@igh-essen.com>
parents:
301
diff
changeset
|
948 |
void ec_fsm_master_write_eeprom(ec_fsm_t *fsm /**< finite state machine */) |
269 | 949 |
{ |
950 |
ec_slave_t *slave = fsm->slave; |
|
951 |
||
952 |
fsm->sii_state(fsm); // execute SII state machine |
|
953 |
||
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
954 |
if (fsm->sii_state == ec_fsm_error) { |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
955 |
fsm->slave->error_flag = 1; |
269 | 956 |
EC_ERR("Failed to write EEPROM contents to slave %i.\n", |
957 |
slave->ring_position); |
|
958 |
kfree(slave->new_eeprom_data); |
|
959 |
slave->new_eeprom_data = NULL; |
|
960 |
fsm->master_state = ec_fsm_master_start; |
|
961 |
fsm->master_state(fsm); // execute immediately |
|
962 |
return; |
|
963 |
} |
|
964 |
||
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
965 |
if (fsm->sii_state != ec_fsm_end) return; |
269 | 966 |
|
967 |
fsm->sii_offset++; |
|
968 |
if (fsm->sii_offset < slave->new_eeprom_size) { |
|
969 |
memcpy(fsm->sii_value, slave->new_eeprom_data + fsm->sii_offset, 2); |
|
970 |
fsm->sii_state = ec_fsm_sii_start_writing; |
|
971 |
fsm->sii_state(fsm); // execute immediately |
|
972 |
return; |
|
973 |
} |
|
974 |
||
975 |
// finished writing EEPROM |
|
976 |
EC_INFO("Finished writing EEPROM of slave %i.\n", slave->ring_position); |
|
977 |
kfree(slave->new_eeprom_data); |
|
978 |
slave->new_eeprom_data = NULL; |
|
979 |
||
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
980 |
// TODO: Evaluate new EEPROM contents! |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
981 |
|
269 | 982 |
// restart master state machine. |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
983 |
fsm->master_state = ec_fsm_master_start; |
269 | 984 |
fsm->master_state(fsm); // execute immediately |
985 |
return; |
|
986 |
} |
|
987 |
||
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
988 |
/****************************************************************************** |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
989 |
* slave scan state machine |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
990 |
*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
991 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
992 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
993 |
Slave scan state: START. |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
994 |
First state of the slave state machine. Writes the station address to the |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
995 |
slave, according to its ring position. |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
996 |
*/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
997 |
|
308
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
998 |
void ec_fsm_slavescan_start(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
999 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1000 |
ec_datagram_t *datagram = &fsm->datagram; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1001 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1002 |
// write station address |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1003 |
ec_datagram_apwr(datagram, fsm->slave->ring_position, 0x0010, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1004 |
EC_WRITE_U16(datagram->data, fsm->slave->station_address); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1005 |
ec_master_queue_datagram(fsm->master, datagram); |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1006 |
fsm->slave_state = ec_fsm_slavescan_address; |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1007 |
} |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1008 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1009 |
/*****************************************************************************/ |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1010 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1011 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1012 |
Slave scan state: ADDRESS. |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1013 |
*/ |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1014 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1015 |
void ec_fsm_slavescan_address(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1016 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1017 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1018 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1019 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1020 |
|| datagram->working_counter != 1) { |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1021 |
fsm->slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1022 |
fsm->slave_state = ec_fsm_error; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1023 |
EC_ERR("Failed to write station address of slave %i.\n", |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1024 |
fsm->slave->ring_position); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1025 |
return; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1026 |
} |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1027 |
|
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1028 |
// Read AL state |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1029 |
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x0130, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1030 |
ec_master_queue_datagram(fsm->master, datagram); |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1031 |
fsm->slave_state = ec_fsm_slavescan_state; |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1032 |
} |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1033 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1034 |
/*****************************************************************************/ |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1035 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1036 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1037 |
Slave scan state: STATE. |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1038 |
*/ |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1039 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1040 |
void ec_fsm_slavescan_state(ec_fsm_t *fsm /**< finite state machine */) |
255
6b916cce7f27
Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents:
254
diff
changeset
|
1041 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1042 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1043 |
ec_slave_t *slave = fsm->slave; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1044 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1045 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1046 |
|| datagram->working_counter != 1) { |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
290
diff
changeset
|
1047 |
fsm->slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1048 |
fsm->slave_state = ec_fsm_error; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1049 |
EC_ERR("Failed to read AL state of slave %i.\n", |
255
6b916cce7f27
Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents:
254
diff
changeset
|
1050 |
fsm->slave->ring_position); |
6b916cce7f27
Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents:
254
diff
changeset
|
1051 |
return; |
6b916cce7f27
Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents:
254
diff
changeset
|
1052 |
} |
6b916cce7f27
Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents:
254
diff
changeset
|
1053 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1054 |
slave->current_state = EC_READ_U8(datagram->data); |
402
03e31ac14047
Renamed EC_ACK to EC_SLAVE_STATE_ACK_ERR
Florian Pose <fp@igh-essen.com>
parents:
398
diff
changeset
|
1055 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1056 |
EC_WARN("Slave %i has state error bit set (0x%02X)!\n", |
255
6b916cce7f27
Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents:
254
diff
changeset
|
1057 |
slave->ring_position, slave->current_state); |
6b916cce7f27
Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents:
254
diff
changeset
|
1058 |
} |
6b916cce7f27
Read current AL status of slaves while scanning bus.
Florian Pose <fp@igh-essen.com>
parents:
254
diff
changeset
|
1059 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1060 |
// read base data |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1061 |
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x0000, 6); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1062 |
ec_master_queue_datagram(fsm->master, datagram); |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1063 |
fsm->slave_state = ec_fsm_slavescan_base; |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1064 |
} |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1065 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1066 |
/*****************************************************************************/ |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1067 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1068 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1069 |
Slave scan state: BASE. |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1070 |
*/ |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1071 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1072 |
void ec_fsm_slavescan_base(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1073 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1074 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1075 |
ec_slave_t *slave = fsm->slave; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1076 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1077 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1078 |
|| datagram->working_counter != 1) { |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
290
diff
changeset
|
1079 |
fsm->slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1080 |
fsm->slave_state = ec_fsm_error; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1081 |
EC_ERR("Failed to read base data of slave %i.\n", |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1082 |
slave->ring_position); |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1083 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1084 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1085 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1086 |
slave->base_type = EC_READ_U8 (datagram->data); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1087 |
slave->base_revision = EC_READ_U8 (datagram->data + 1); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1088 |
slave->base_build = EC_READ_U16(datagram->data + 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1089 |
slave->base_fmmu_count = EC_READ_U8 (datagram->data + 4); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1090 |
slave->base_sync_count = EC_READ_U8 (datagram->data + 5); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1091 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1092 |
if (slave->base_fmmu_count > EC_MAX_FMMUS) |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1093 |
slave->base_fmmu_count = EC_MAX_FMMUS; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1094 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1095 |
// read data link status |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1096 |
ec_datagram_nprd(datagram, slave->station_address, 0x0110, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1097 |
ec_master_queue_datagram(slave->master, datagram); |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1098 |
fsm->slave_state = ec_fsm_slavescan_datalink; |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1099 |
} |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1100 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1101 |
/*****************************************************************************/ |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1102 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1103 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1104 |
Slave scan state: DATALINK. |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1105 |
*/ |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1106 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1107 |
void ec_fsm_slavescan_datalink(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1108 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1109 |
ec_datagram_t *datagram = &fsm->datagram; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1110 |
ec_slave_t *slave = fsm->slave; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1111 |
uint16_t dl_status; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1112 |
unsigned int i; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1113 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1114 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1115 |
|| datagram->working_counter != 1) { |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
290
diff
changeset
|
1116 |
fsm->slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1117 |
fsm->slave_state = ec_fsm_error; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1118 |
EC_ERR("Failed to read DL status of slave %i.\n", |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1119 |
slave->ring_position); |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1120 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1121 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1122 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1123 |
dl_status = EC_READ_U16(datagram->data); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1124 |
for (i = 0; i < 4; i++) { |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1125 |
slave->dl_link[i] = dl_status & (1 << (4 + i)) ? 1 : 0; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1126 |
slave->dl_loop[i] = dl_status & (1 << (8 + i * 2)) ? 1 : 0; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1127 |
slave->dl_signal[i] = dl_status & (1 << (9 + i * 2)) ? 1 : 0; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1128 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1129 |
|
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1130 |
// Start fetching EEPROM size |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1131 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1132 |
fsm->sii_offset = 0x0040; // first category header |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1133 |
fsm->sii_mode = 1; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1134 |
fsm->sii_state = ec_fsm_sii_start_reading; |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1135 |
fsm->slave_state = ec_fsm_slavescan_eeprom_size; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1136 |
fsm->slave_state(fsm); // execute state immediately |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1137 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1138 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1139 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1140 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1141 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1142 |
Slave scan state: EEPROM SIZE. |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1143 |
*/ |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1144 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1145 |
void ec_fsm_slavescan_eeprom_size(ec_fsm_t *fsm /**< finite state machine */) |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1146 |
{ |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1147 |
ec_slave_t *slave = fsm->slave; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1148 |
uint16_t cat_type, cat_size; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1149 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1150 |
// execute SII state machine |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1151 |
fsm->sii_state(fsm); |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1152 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1153 |
if (fsm->sii_state == ec_fsm_error) { |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1154 |
fsm->slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1155 |
fsm->slave_state = ec_fsm_error; |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1156 |
EC_ERR("Failed to read EEPROM size of slave %i.\n", |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1157 |
slave->ring_position); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1158 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1159 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1160 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1161 |
if (fsm->sii_state != ec_fsm_end) return; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1162 |
|
269 | 1163 |
cat_type = EC_READ_U16(fsm->sii_value); |
1164 |
cat_size = EC_READ_U16(fsm->sii_value + 2); |
|
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1165 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1166 |
if (cat_type != 0xFFFF) { // not the last category |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1167 |
fsm->sii_offset += cat_size + 2; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1168 |
fsm->sii_state = ec_fsm_sii_start_reading; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1169 |
fsm->sii_state(fsm); // execute state immediately |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1170 |
return; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1171 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1172 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1173 |
slave->eeprom_size = (fsm->sii_offset + 1) * 2; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1174 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1175 |
if (slave->eeprom_data) { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1176 |
EC_INFO("Freeing old EEPROM data on slave %i...\n", |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1177 |
slave->ring_position); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1178 |
kfree(slave->eeprom_data); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1179 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1180 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1181 |
if (!(slave->eeprom_data = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1182 |
(uint8_t *) kmalloc(slave->eeprom_size, GFP_ATOMIC))) { |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
290
diff
changeset
|
1183 |
fsm->slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1184 |
fsm->slave_state = ec_fsm_error; |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1185 |
EC_ERR("Failed to allocate EEPROM data on slave %i.\n", |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1186 |
slave->ring_position); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1187 |
return; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1188 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1189 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1190 |
// Start fetching EEPROM contents |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1191 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1192 |
fsm->sii_offset = 0x0000; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1193 |
fsm->sii_mode = 1; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1194 |
fsm->sii_state = ec_fsm_sii_start_reading; |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1195 |
fsm->slave_state = ec_fsm_slavescan_eeprom_data; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1196 |
fsm->slave_state(fsm); // execute state immediately |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1197 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1198 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1199 |
/*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1200 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1201 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1202 |
Slave scan state: EEPROM DATA. |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1203 |
*/ |
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1204 |
|
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1205 |
void ec_fsm_slavescan_eeprom_data(ec_fsm_t *fsm /**< finite state machine */) |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1206 |
{ |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1207 |
ec_slave_t *slave = fsm->slave; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1208 |
uint16_t *cat_word, cat_type, cat_size; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1209 |
|
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1210 |
// execute SII state machine |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1211 |
fsm->sii_state(fsm); |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1212 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1213 |
if (fsm->sii_state == ec_fsm_error) { |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1214 |
fsm->slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1215 |
fsm->slave_state = ec_fsm_error; |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1216 |
EC_ERR("Failed to fetch EEPROM contents of slave %i.\n", |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1217 |
slave->ring_position); |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1218 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1219 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1220 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1221 |
if (fsm->sii_state != ec_fsm_end) return; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1222 |
|
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1223 |
// 2 words fetched |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1224 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1225 |
if (fsm->sii_offset + 2 <= slave->eeprom_size / 2) { // 2 words fit |
269 | 1226 |
memcpy(slave->eeprom_data + fsm->sii_offset * 2, fsm->sii_value, 4); |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1227 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1228 |
else { // copy the last word |
269 | 1229 |
memcpy(slave->eeprom_data + fsm->sii_offset * 2, fsm->sii_value, 2); |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1230 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1231 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1232 |
if (fsm->sii_offset + 2 < slave->eeprom_size / 2) { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1233 |
// fetch the next 2 words |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1234 |
fsm->sii_offset += 2; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1235 |
fsm->sii_state = ec_fsm_sii_start_reading; |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1236 |
fsm->sii_state(fsm); // execute state immediately |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1237 |
return; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1238 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1239 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1240 |
// Evaluate EEPROM contents |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1241 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1242 |
slave->sii_alias = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1243 |
EC_READ_U16(slave->eeprom_data + 2 * 0x0004); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1244 |
slave->sii_vendor_id = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1245 |
EC_READ_U32(slave->eeprom_data + 2 * 0x0008); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1246 |
slave->sii_product_code = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1247 |
EC_READ_U32(slave->eeprom_data + 2 * 0x000A); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1248 |
slave->sii_revision_number = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1249 |
EC_READ_U32(slave->eeprom_data + 2 * 0x000C); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1250 |
slave->sii_serial_number = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1251 |
EC_READ_U32(slave->eeprom_data + 2 * 0x000E); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1252 |
slave->sii_rx_mailbox_offset = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1253 |
EC_READ_U16(slave->eeprom_data + 2 * 0x0018); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1254 |
slave->sii_rx_mailbox_size = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1255 |
EC_READ_U16(slave->eeprom_data + 2 * 0x0019); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1256 |
slave->sii_tx_mailbox_offset = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1257 |
EC_READ_U16(slave->eeprom_data + 2 * 0x001A); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1258 |
slave->sii_tx_mailbox_size = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1259 |
EC_READ_U16(slave->eeprom_data + 2 * 0x001B); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1260 |
slave->sii_mailbox_protocols = |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1261 |
EC_READ_U16(slave->eeprom_data + 2 * 0x001C); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1262 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1263 |
// evaluate category data |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1264 |
cat_word = (uint16_t *) slave->eeprom_data + 0x0040; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1265 |
while (EC_READ_U16(cat_word) != 0xFFFF) { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1266 |
cat_type = EC_READ_U16(cat_word) & 0x7FFF; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1267 |
cat_size = EC_READ_U16(cat_word + 1); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1268 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1269 |
switch (cat_type) { |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1270 |
case 0x000A: |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1271 |
if (ec_slave_fetch_strings(slave, (uint8_t *) (cat_word + 2))) |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1272 |
goto end; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1273 |
break; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1274 |
case 0x001E: |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1275 |
ec_slave_fetch_general(slave, (uint8_t *) (cat_word + 2)); |
266
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1276 |
break; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1277 |
case 0x0028: |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1278 |
break; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1279 |
case 0x0029: |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1280 |
if (ec_slave_fetch_sync(slave, (uint8_t *) (cat_word + 2), |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1281 |
cat_size)) |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1282 |
goto end; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1283 |
break; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1284 |
case 0x0032: |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1285 |
if (ec_slave_fetch_pdo(slave, (uint8_t *) (cat_word + 2), |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1286 |
cat_size, EC_TX_PDO)) |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1287 |
goto end; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1288 |
break; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1289 |
case 0x0033: |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1290 |
if (ec_slave_fetch_pdo(slave, (uint8_t *) (cat_word + 2), |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1291 |
cat_size, EC_RX_PDO)) |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1292 |
goto end; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1293 |
break; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1294 |
default: |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1295 |
EC_WARN("Unknown category type 0x%04X in slave %i.\n", |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1296 |
cat_type, slave->ring_position); |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1297 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1298 |
|
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1299 |
cat_word += cat_size + 2; |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1300 |
} |
0234b0c26c52
Read complete eeprom data from slave and map it into SysFS.
Florian Pose <fp@igh-essen.com>
parents:
262
diff
changeset
|
1301 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1302 |
fsm->slave_state = ec_fsm_end; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1303 |
return; |
310
b7e7709fd40e
Better slave scan sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
309
diff
changeset
|
1304 |
|
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1305 |
end: |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1306 |
EC_ERR("Failed to analyze category data.\n"); |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
290
diff
changeset
|
1307 |
fsm->slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1308 |
fsm->slave_state = ec_fsm_error; |
308
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
1309 |
} |
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
1310 |
|
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
1311 |
/****************************************************************************** |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1312 |
* slave configuration state machine |
308
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
1313 |
*****************************************************************************/ |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1314 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1315 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1316 |
Slave configuration state: INIT. |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1317 |
*/ |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1318 |
|
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1319 |
void ec_fsm_slaveconf_init(ec_fsm_t *fsm /**< finite state machine */) |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1320 |
{ |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1321 |
ec_master_t *master = fsm->master; |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1322 |
ec_slave_t *slave = fsm->slave; |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1323 |
ec_datagram_t *datagram = &fsm->datagram; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1324 |
const ec_sii_sync_t *sync; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1325 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1326 |
fsm->change_state(fsm); // execute state change state machine |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1327 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1328 |
if (fsm->change_state == ec_fsm_error) { |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1329 |
slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1330 |
fsm->slave_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1331 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1332 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1333 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1334 |
if (fsm->change_state != ec_fsm_end) return; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1335 |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1336 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1337 |
EC_DBG("Slave %i is now in INIT.\n", slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1338 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1339 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1340 |
// slave is now in INIT |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1341 |
if (slave->current_state == slave->requested_state) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1342 |
fsm->slave_state = ec_fsm_end; // successful |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1343 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1344 |
EC_DBG("Finished configuration of slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1345 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1346 |
} |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1347 |
return; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1348 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1349 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1350 |
// check and reset CRC fault counters |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1351 |
//ec_slave_check_crc(slave); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1352 |
// TODO: Implement state machine for CRC checking. |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1353 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1354 |
if (!slave->base_sync_count) { // no sync managers |
308
d50b139c8601
Separated slave scan sub state machine and slave configuration sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
306
diff
changeset
|
1355 |
fsm->slave_state = ec_fsm_slaveconf_preop; |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1356 |
fsm->change_new = EC_SLAVE_STATE_PREOP; |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1357 |
fsm->change_state = ec_fsm_change_start; |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1358 |
fsm->change_state(fsm); // execute immediately |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1359 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1360 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1361 |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1362 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1363 |
EC_DBG("Configuring sync managers of slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1364 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1365 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1366 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1367 |
// configure sync managers |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1368 |
ec_datagram_npwr(datagram, slave->station_address, 0x0800, |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1369 |
EC_SYNC_SIZE * slave->base_sync_count); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1370 |
memset(datagram->data, 0x00, EC_SYNC_SIZE * slave->base_sync_count); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1371 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1372 |
list_for_each_entry(sync, &slave->sii_syncs, list) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1373 |
if (sync->index >= slave->base_sync_count) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1374 |
EC_ERR("Invalid sync manager configuration found!"); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1375 |
fsm->slave->error_flag = 1; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1376 |
fsm->slave_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1377 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1378 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1379 |
ec_sync_config(sync, slave, |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1380 |
datagram->data + EC_SYNC_SIZE * sync->index); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1381 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1382 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1383 |
ec_master_queue_datagram(fsm->master, datagram); |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1384 |
fsm->slave_state = ec_fsm_slaveconf_sync; |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1385 |
} |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1386 |
|
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1387 |
/*****************************************************************************/ |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1388 |
|
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1389 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1390 |
Slave configuration state: SYNC. |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1391 |
*/ |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1392 |
|
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1393 |
void ec_fsm_slaveconf_sync(ec_fsm_t *fsm /**< finite state machine */) |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1394 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1395 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1396 |
ec_slave_t *slave = fsm->slave; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1397 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1398 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1399 |
|| datagram->working_counter != 1) { |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1400 |
slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1401 |
fsm->slave_state = ec_fsm_error; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1402 |
EC_ERR("Failed to set sync managers on slave %i.\n", |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1403 |
slave->ring_position); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1404 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1405 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1406 |
|
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1407 |
fsm->slave_state = ec_fsm_slaveconf_preop; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1408 |
fsm->change_new = EC_SLAVE_STATE_PREOP; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1409 |
fsm->change_state = ec_fsm_change_start; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1410 |
fsm->change_state(fsm); // execute immediately |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1411 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1412 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1413 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1414 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1415 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1416 |
Slave configuration state: PREOP. |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1417 |
*/ |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1418 |
|
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1419 |
void ec_fsm_slaveconf_preop(ec_fsm_t *fsm /**< finite state machine */) |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1420 |
{ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1421 |
ec_slave_t *slave = fsm->slave; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1422 |
ec_master_t *master = fsm->master; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1423 |
ec_datagram_t *datagram = &fsm->datagram; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1424 |
unsigned int j; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1425 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1426 |
fsm->change_state(fsm); // execute state change state machine |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1427 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1428 |
if (fsm->change_state == ec_fsm_error) { |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1429 |
slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1430 |
fsm->slave_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1431 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1432 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1433 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1434 |
if (fsm->change_state != ec_fsm_end) return; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1435 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1436 |
// slave is now in PREOP |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1437 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1438 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1439 |
EC_DBG("Slave %i is now in PREOP.\n", slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1440 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1441 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1442 |
if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1443 |
// slave does not support CoE. skip dictionary fetching |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1444 |
// and SDO configuration |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1445 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1446 |
if (slave->current_state == slave->requested_state) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1447 |
fsm->slave_state = ec_fsm_end; // successful |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1448 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1449 |
EC_DBG("Finished configuration of slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1450 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1451 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1452 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1453 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1454 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1455 |
if (!slave->base_fmmu_count) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1456 |
// slave has no FMMUs. skip configuration and go to SAVEOP |
338
469369417422
New transition in slave conf state machine: Skip fmmu and SDO configuration.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1457 |
fsm->slave_state = ec_fsm_slaveconf_saveop; |
469369417422
New transition in slave conf state machine: Skip fmmu and SDO configuration.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1458 |
fsm->change_new = EC_SLAVE_STATE_SAVEOP; |
469369417422
New transition in slave conf state machine: Skip fmmu and SDO configuration.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1459 |
fsm->change_state = ec_fsm_change_start; |
469369417422
New transition in slave conf state machine: Skip fmmu and SDO configuration.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1460 |
fsm->change_state(fsm); // execute immediately |
469369417422
New transition in slave conf state machine: Skip fmmu and SDO configuration.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1461 |
return; |
469369417422
New transition in slave conf state machine: Skip fmmu and SDO configuration.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1462 |
} |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1463 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1464 |
// configure FMMUs |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1465 |
ec_datagram_npwr(datagram, slave->station_address, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1466 |
0x0600, EC_FMMU_SIZE * slave->base_fmmu_count); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1467 |
memset(datagram->data, 0x00, EC_FMMU_SIZE * slave->base_fmmu_count); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1468 |
for (j = 0; j < slave->fmmu_count; j++) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1469 |
ec_fmmu_config(&slave->fmmus[j], slave, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1470 |
datagram->data + EC_FMMU_SIZE * j); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1471 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1472 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1473 |
ec_master_queue_datagram(master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1474 |
fsm->slave_state = ec_fsm_slaveconf_fmmu; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1475 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1476 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1477 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1478 |
if (!list_empty(&slave->sdo_dictionary)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1479 |
// SDO dictionary already fetched |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1480 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1481 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1482 |
EC_DBG("SDO dictionary already present for slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1483 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1484 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1485 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1486 |
if (slave->current_state == slave->requested_state) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1487 |
fsm->slave_state = ec_fsm_end; // successful |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1488 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1489 |
EC_DBG("Finished configuration of slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1490 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1491 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1492 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1493 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1494 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1495 |
if (list_empty(&slave->sdo_confs)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1496 |
// skip SDO configuration |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1497 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1498 |
if (!slave->base_fmmu_count) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1499 |
// slave has no FMMUs. skip configuration and go to SAVEOP |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1500 |
fsm->slave_state = ec_fsm_slaveconf_saveop; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1501 |
fsm->change_new = EC_SLAVE_STATE_SAVEOP; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1502 |
fsm->change_state = ec_fsm_change_start; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1503 |
fsm->change_state(fsm); // execute immediately |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1504 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1505 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1506 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1507 |
// configure FMMUs |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1508 |
ec_datagram_npwr(datagram, slave->station_address, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1509 |
0x0600, EC_FMMU_SIZE * slave->base_fmmu_count); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1510 |
memset(datagram->data, 0x00, EC_FMMU_SIZE * slave->base_fmmu_count); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1511 |
for (j = 0; j < slave->fmmu_count; j++) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1512 |
ec_fmmu_config(&slave->fmmus[j], slave, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1513 |
datagram->data + EC_FMMU_SIZE * j); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1514 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1515 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1516 |
ec_master_queue_datagram(master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1517 |
fsm->slave_state = ec_fsm_slaveconf_fmmu; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1518 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1519 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1520 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1521 |
// start SDO configuration |
338
469369417422
New transition in slave conf state machine: Skip fmmu and SDO configuration.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1522 |
fsm->slave_state = ec_fsm_slaveconf_sdoconf; |
405
61d5d6457fa6
Renamed fsm->sdodata to fsm->coe_sdodata
Florian Pose <fp@igh-essen.com>
parents:
403
diff
changeset
|
1523 |
fsm->coe_sdodata = list_entry(slave->sdo_confs.next, ec_sdo_data_t, list); |
338
469369417422
New transition in slave conf state machine: Skip fmmu and SDO configuration.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1524 |
fsm->coe_state = ec_fsm_coe_down_start; |
469369417422
New transition in slave conf state machine: Skip fmmu and SDO configuration.
Florian Pose <fp@igh-essen.com>
parents:
329
diff
changeset
|
1525 |
fsm->coe_state(fsm); // execute immediately |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1526 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1527 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1528 |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1529 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1530 |
EC_DBG("Fetching SDO dictionary of slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1531 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1532 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1533 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1534 |
// start fetching SDO dictionary |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1535 |
fsm->slave_state = ec_fsm_slaveconf_sdodict; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1536 |
fsm->coe_state = ec_fsm_coe_dict_start; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1537 |
fsm->coe_state(fsm); // execute immediately |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1538 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1539 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1540 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1541 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1542 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1543 |
Slave configuration state: SDODICT. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1544 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1545 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1546 |
void ec_fsm_slaveconf_sdodict(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1547 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1548 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1549 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1550 |
ec_master_t *master = fsm->master; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1551 |
unsigned int j; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1552 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1553 |
fsm->coe_state(fsm); // execute CoE state machine |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1554 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1555 |
if (fsm->coe_state == ec_fsm_error) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1556 |
fsm->slave->error_flag = 1; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1557 |
fsm->slave_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1558 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1559 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1560 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1561 |
if (fsm->coe_state != ec_fsm_end) return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1562 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1563 |
// SDO dictionary fetching finished |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1564 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1565 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1566 |
EC_DBG("Finished fetching SDO dictionary of slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1567 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1568 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1569 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1570 |
if (slave->current_state == slave->requested_state) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1571 |
fsm->slave_state = ec_fsm_end; // successful |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1572 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1573 |
EC_DBG("Finished configuration of slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1574 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1575 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1576 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1577 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1578 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1579 |
if (list_empty(&slave->sdo_confs)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1580 |
// skip SDO configuration |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1581 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1582 |
if (!slave->base_fmmu_count) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1583 |
// slave has no FMMUs. skip configuration. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1584 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1585 |
// set state to SAVEOP |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1586 |
fsm->slave_state = ec_fsm_slaveconf_saveop; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1587 |
fsm->change_new = EC_SLAVE_STATE_SAVEOP; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1588 |
fsm->change_state = ec_fsm_change_start; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1589 |
fsm->change_state(fsm); // execute immediately |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1590 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1591 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1592 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1593 |
// configure FMMUs |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1594 |
ec_datagram_npwr(datagram, slave->station_address, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1595 |
0x0600, EC_FMMU_SIZE * slave->base_fmmu_count); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1596 |
memset(datagram->data, 0x00, EC_FMMU_SIZE * slave->base_fmmu_count); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1597 |
for (j = 0; j < slave->fmmu_count; j++) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1598 |
ec_fmmu_config(&slave->fmmus[j], slave, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1599 |
datagram->data + EC_FMMU_SIZE * j); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1600 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1601 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1602 |
ec_master_queue_datagram(master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1603 |
fsm->slave_state = ec_fsm_slaveconf_fmmu; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1604 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1605 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1606 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1607 |
// start SDO configuration |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1608 |
fsm->slave_state = ec_fsm_slaveconf_sdoconf; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1609 |
fsm->coe_sdodata = list_entry(slave->sdo_confs.next, ec_sdo_data_t, list); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1610 |
fsm->coe_state = ec_fsm_coe_down_start; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1611 |
fsm->coe_state(fsm); // execute immediately |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1612 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1613 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1614 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1615 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1616 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1617 |
Slave configuration state: SDOCONF. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1618 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1619 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1620 |
void ec_fsm_slaveconf_sdoconf(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1621 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1622 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1623 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1624 |
ec_master_t *master = fsm->master; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1625 |
unsigned int j; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1626 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1627 |
fsm->coe_state(fsm); // execute CoE state machine |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1628 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1629 |
if (fsm->coe_state == ec_fsm_error) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1630 |
fsm->slave->error_flag = 1; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1631 |
fsm->slave_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1632 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1633 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1634 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1635 |
if (fsm->coe_state != ec_fsm_end) return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1636 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1637 |
// Another SDO to configure? |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1638 |
if (fsm->coe_sdodata->list.next != &fsm->slave->sdo_confs) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1639 |
fsm->coe_sdodata = list_entry(fsm->coe_sdodata->list.next, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1640 |
ec_sdo_data_t, list); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1641 |
fsm->coe_state = ec_fsm_coe_down_start; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1642 |
fsm->coe_state(fsm); // execute immediately |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1643 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1644 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1645 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1646 |
// All SDOs are now configured. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1647 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1648 |
if (!slave->base_fmmu_count) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1649 |
// slave has no FMMUs. skip configuration. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1650 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1651 |
// set state to SAVEOP |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1652 |
fsm->slave_state = ec_fsm_slaveconf_saveop; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1653 |
fsm->change_new = EC_SLAVE_STATE_SAVEOP; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1654 |
fsm->change_state = ec_fsm_change_start; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1655 |
fsm->change_state(fsm); // execute immediately |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1656 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1657 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1658 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1659 |
// configure FMMUs |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1660 |
ec_datagram_npwr(datagram, slave->station_address, |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1661 |
0x0600, EC_FMMU_SIZE * slave->base_fmmu_count); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1662 |
memset(datagram->data, 0x00, EC_FMMU_SIZE * slave->base_fmmu_count); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1663 |
for (j = 0; j < slave->fmmu_count; j++) { |
275
ba51285d4ef6
Variable-sized data fields, BK1120.
Florian Pose <fp@igh-essen.com>
parents:
269
diff
changeset
|
1664 |
ec_fmmu_config(&slave->fmmus[j], slave, |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1665 |
datagram->data + EC_FMMU_SIZE * j); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1666 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1667 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1668 |
ec_master_queue_datagram(master, datagram); |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1669 |
fsm->slave_state = ec_fsm_slaveconf_fmmu; |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1670 |
} |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1671 |
|
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1672 |
/*****************************************************************************/ |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1673 |
|
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1674 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1675 |
Slave configuration state: FMMU. |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1676 |
*/ |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1677 |
|
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1678 |
void ec_fsm_slaveconf_fmmu(ec_fsm_t *fsm /**< finite state machine */) |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1679 |
{ |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1680 |
ec_datagram_t *datagram = &fsm->datagram; |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1681 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1682 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1683 |
|| datagram->working_counter != 1) { |
291
0b1f877cf3f1
Slave: state_error -> error_flag, error_flag only in slave state machine.
Florian Pose <fp@igh-essen.com>
parents:
290
diff
changeset
|
1684 |
fsm->slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1685 |
fsm->slave_state = ec_fsm_error; |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1686 |
EC_ERR("Failed to set FMMUs on slave %i.\n", |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1687 |
fsm->slave->ring_position); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1688 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1689 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1690 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1691 |
// set state to SAVEOP |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1692 |
fsm->slave_state = ec_fsm_slaveconf_saveop; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1693 |
fsm->change_new = EC_SLAVE_STATE_SAVEOP; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1694 |
fsm->change_state = ec_fsm_change_start; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1695 |
fsm->change_state(fsm); // execute immediately |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1696 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1697 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1698 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1699 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1700 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1701 |
Slave configuration state: SAVEOP. |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1702 |
*/ |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1703 |
|
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1704 |
void ec_fsm_slaveconf_saveop(ec_fsm_t *fsm /**< finite state machine */) |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1705 |
{ |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1706 |
ec_master_t *master = fsm->master; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1707 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1708 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1709 |
fsm->change_state(fsm); // execute state change state machine |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1710 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1711 |
if (fsm->change_state == ec_fsm_error) { |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
1712 |
fsm->slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1713 |
fsm->slave_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1714 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1715 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1716 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1717 |
if (fsm->change_state != ec_fsm_end) return; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1718 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1719 |
// slave is now in SAVEOP |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1720 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1721 |
if (master->debug_level) { |
411 | 1722 |
EC_DBG("Slave %i is now in SAVEOP.\n", slave->ring_position); |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1723 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1724 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1725 |
if (fsm->slave->current_state == fsm->slave->requested_state) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1726 |
fsm->slave_state = ec_fsm_end; // successful |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1727 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1728 |
EC_DBG("Finished configuration of slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1729 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1730 |
} |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1731 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1732 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1733 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1734 |
// set state to OP |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1735 |
fsm->slave_state = ec_fsm_slaveconf_op; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1736 |
fsm->change_new = EC_SLAVE_STATE_OP; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1737 |
fsm->change_state = ec_fsm_change_start; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1738 |
fsm->change_state(fsm); // execute immediately |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1739 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1740 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1741 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1742 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1743 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1744 |
Slave configuration state: OP |
309
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1745 |
*/ |
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1746 |
|
42e69cf31495
Better slaveconf sub state machine.
Florian Pose <fp@igh-essen.com>
parents:
308
diff
changeset
|
1747 |
void ec_fsm_slaveconf_op(ec_fsm_t *fsm /**< finite state machine */) |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1748 |
{ |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1749 |
ec_master_t *master = fsm->master; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1750 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1751 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1752 |
fsm->change_state(fsm); // execute state change state machine |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1753 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1754 |
if (fsm->change_state == ec_fsm_error) { |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1755 |
slave->error_flag = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1756 |
fsm->slave_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1757 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1758 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1759 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1760 |
if (fsm->change_state != ec_fsm_end) return; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1761 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1762 |
// slave is now in OP |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1763 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1764 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1765 |
EC_DBG("Slave %i is now in OP.\n", slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1766 |
EC_DBG("Finished configuration of slave %i.\n", slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1767 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1768 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1769 |
fsm->slave_state = ec_fsm_end; // successful |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1770 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1771 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1772 |
/****************************************************************************** |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1773 |
* SII state machine |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1774 |
*****************************************************************************/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1775 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1776 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1777 |
SII state: START READING. |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1778 |
Starts reading the slave information interface. |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1779 |
*/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1780 |
|
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1781 |
void ec_fsm_sii_start_reading(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1782 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1783 |
ec_datagram_t *datagram = &fsm->datagram; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1784 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1785 |
// initiate read operation |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1786 |
if (fsm->sii_mode) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1787 |
ec_datagram_npwr(datagram, fsm->slave->station_address, 0x502, 4); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1788 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1789 |
else { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1790 |
ec_datagram_apwr(datagram, fsm->slave->ring_position, 0x502, 4); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1791 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1792 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1793 |
EC_WRITE_U8 (datagram->data, 0x00); // read-only access |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1794 |
EC_WRITE_U8 (datagram->data + 1, 0x01); // request read operation |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1795 |
EC_WRITE_U16(datagram->data + 2, fsm->sii_offset); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1796 |
ec_master_queue_datagram(fsm->master, datagram); |
269 | 1797 |
fsm->sii_state = ec_fsm_sii_read_check; |
1798 |
} |
|
1799 |
||
1800 |
/*****************************************************************************/ |
|
1801 |
||
1802 |
/** |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1803 |
SII state: READ CHECK. |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1804 |
Checks, if the SII-read-datagram has been sent and issues a fetch datagram. |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1805 |
*/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1806 |
|
269 | 1807 |
void ec_fsm_sii_read_check(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1808 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1809 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1810 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1811 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1812 |
|| datagram->working_counter != 1) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1813 |
EC_ERR("SII: Reception of read datagram failed.\n"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1814 |
fsm->sii_state = ec_fsm_error; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1815 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1816 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1817 |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1818 |
fsm->sii_start = datagram->cycles_sent; |
397
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1819 |
fsm->sii_check_once_more = 1; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1820 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1821 |
// issue check/fetch datagram |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1822 |
if (fsm->sii_mode) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1823 |
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x502, 10); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1824 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1825 |
else { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1826 |
ec_datagram_aprd(datagram, fsm->slave->ring_position, 0x502, 10); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1827 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1828 |
|
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1829 |
ec_master_queue_datagram(fsm->master, datagram); |
269 | 1830 |
fsm->sii_state = ec_fsm_sii_read_fetch; |
1831 |
} |
|
1832 |
||
1833 |
/*****************************************************************************/ |
|
1834 |
||
1835 |
/** |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1836 |
SII state: READ FETCH. |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1837 |
Fetches the result of an SII-read datagram. |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1838 |
*/ |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1839 |
|
269 | 1840 |
void ec_fsm_sii_read_fetch(ec_fsm_t *fsm /**< finite state machine */) |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1841 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1842 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1843 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1844 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1845 |
|| datagram->working_counter != 1) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1846 |
EC_ERR("SII: Reception of check/fetch datagram failed.\n"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1847 |
fsm->sii_state = ec_fsm_error; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1848 |
return; |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1849 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1850 |
|
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1851 |
// check "busy bit" |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1852 |
if (EC_READ_U8(datagram->data + 1) & 0x81) { |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1853 |
// still busy... timeout? |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1854 |
if (datagram->cycles_received |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1855 |
- fsm->sii_start >= (cycles_t) 10 * cpu_khz) { |
397
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1856 |
if (!fsm->sii_check_once_more) { |
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1857 |
EC_ERR("SII: Read timeout.\n"); |
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1858 |
fsm->sii_state = ec_fsm_error; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1859 |
#if 0 |
397
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1860 |
EC_DBG("SII busy: %02X %02X %02X %02X\n", |
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1861 |
EC_READ_U8(datagram->data + 0), |
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1862 |
EC_READ_U8(datagram->data + 1), |
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1863 |
EC_READ_U8(datagram->data + 2), |
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1864 |
EC_READ_U8(datagram->data + 3)); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1865 |
#endif |
397
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1866 |
return; |
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1867 |
} |
c5d2fb08e43f
Serveral changes to avoid timeouts under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
395
diff
changeset
|
1868 |
fsm->sii_check_once_more = 0; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1869 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1870 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1871 |
// issue check/fetch datagram again |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1872 |
if (fsm->sii_mode) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1873 |
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x502, 10); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1874 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1875 |
else { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1876 |
ec_datagram_aprd(datagram, fsm->slave->ring_position, 0x502, 10); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1877 |
} |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1878 |
ec_master_queue_datagram(fsm->master, datagram); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1879 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1880 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1881 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1882 |
#if 0 |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1883 |
EC_DBG("SII rec: %02X %02X %02X %02X - %02X %02X %02X %02X\n", |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1884 |
EC_READ_U8(datagram->data + 0), EC_READ_U8(datagram->data + 1), |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1885 |
EC_READ_U8(datagram->data + 2), EC_READ_U8(datagram->data + 3), |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1886 |
EC_READ_U8(datagram->data + 6), EC_READ_U8(datagram->data + 7), |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1887 |
EC_READ_U8(datagram->data + 8), EC_READ_U8(datagram->data + 9)); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1888 |
#endif |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1889 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1890 |
// SII value received. |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1891 |
memcpy(fsm->sii_value, datagram->data + 6, 4); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1892 |
fsm->sii_state = ec_fsm_end; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1893 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1894 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1895 |
/*****************************************************************************/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1896 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1897 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1898 |
SII state: START WRITING. |
269 | 1899 |
Starts reading the slave information interface. |
1900 |
*/ |
|
1901 |
||
1902 |
void ec_fsm_sii_start_writing(ec_fsm_t *fsm /**< finite state machine */) |
|
1903 |
{ |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1904 |
ec_datagram_t *datagram = &fsm->datagram; |
269 | 1905 |
|
1906 |
// initiate write operation |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1907 |
ec_datagram_npwr(datagram, fsm->slave->station_address, 0x502, 8); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1908 |
EC_WRITE_U8 (datagram->data, 0x01); // enable write access |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1909 |
EC_WRITE_U8 (datagram->data + 1, 0x02); // request write operation |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1910 |
EC_WRITE_U32(datagram->data + 2, fsm->sii_offset); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1911 |
memcpy(datagram->data + 6, fsm->sii_value, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1912 |
ec_master_queue_datagram(fsm->master, datagram); |
269 | 1913 |
fsm->sii_state = ec_fsm_sii_write_check; |
1914 |
} |
|
1915 |
||
1916 |
/*****************************************************************************/ |
|
1917 |
||
1918 |
/** |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1919 |
SII state: WRITE CHECK. |
269 | 1920 |
*/ |
1921 |
||
1922 |
void ec_fsm_sii_write_check(ec_fsm_t *fsm /**< finite state machine */) |
|
1923 |
{ |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1924 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1925 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1926 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1927 |
|| datagram->working_counter != 1) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1928 |
EC_ERR("SII: Reception of write datagram failed.\n"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1929 |
fsm->sii_state = ec_fsm_error; |
269 | 1930 |
return; |
1931 |
} |
|
1932 |
||
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1933 |
fsm->sii_start = datagram->cycles_sent; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1934 |
fsm->sii_check_once_more = 1; |
269 | 1935 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1936 |
// issue check/fetch datagram |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1937 |
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x502, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1938 |
ec_master_queue_datagram(fsm->master, datagram); |
269 | 1939 |
fsm->sii_state = ec_fsm_sii_write_check2; |
1940 |
} |
|
1941 |
||
1942 |
/*****************************************************************************/ |
|
1943 |
||
1944 |
/** |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
1945 |
SII state: WRITE CHECK 2. |
269 | 1946 |
*/ |
1947 |
||
1948 |
void ec_fsm_sii_write_check2(ec_fsm_t *fsm /**< finite state machine */) |
|
1949 |
{ |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1950 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1951 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1952 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1953 |
|| datagram->working_counter != 1) { |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1954 |
EC_ERR("SII: Reception of write check datagram failed.\n"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1955 |
fsm->sii_state = ec_fsm_error; |
269 | 1956 |
return; |
1957 |
} |
|
1958 |
||
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1959 |
if (EC_READ_U8(datagram->data + 1) & 0x82) { |
269 | 1960 |
// still busy... timeout? |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1961 |
if (datagram->cycles_received |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1962 |
- fsm->sii_start >= (cycles_t) 10 * cpu_khz) { |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1963 |
if (!fsm->sii_check_once_more) { |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1964 |
EC_ERR("SII: Write timeout.\n"); |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1965 |
fsm->sii_state = ec_fsm_error; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1966 |
return; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1967 |
} |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1968 |
fsm->sii_check_once_more = 0; |
269 | 1969 |
} |
1970 |
||
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1971 |
// issue check/fetch datagram again |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1972 |
ec_master_queue_datagram(fsm->master, datagram); |
395
8b1194e51cf2
BUGFIX: Added returns after timeout in SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
391
diff
changeset
|
1973 |
return; |
8b1194e51cf2
BUGFIX: Added returns after timeout in SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
391
diff
changeset
|
1974 |
} |
8b1194e51cf2
BUGFIX: Added returns after timeout in SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
391
diff
changeset
|
1975 |
|
8b1194e51cf2
BUGFIX: Added returns after timeout in SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
391
diff
changeset
|
1976 |
if (EC_READ_U8(datagram->data + 1) & 0x40) { |
269 | 1977 |
EC_ERR("SII: Write operation failed!\n"); |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1978 |
fsm->sii_state = ec_fsm_error; |
395
8b1194e51cf2
BUGFIX: Added returns after timeout in SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
391
diff
changeset
|
1979 |
return; |
8b1194e51cf2
BUGFIX: Added returns after timeout in SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
391
diff
changeset
|
1980 |
} |
8b1194e51cf2
BUGFIX: Added returns after timeout in SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
391
diff
changeset
|
1981 |
|
8b1194e51cf2
BUGFIX: Added returns after timeout in SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
391
diff
changeset
|
1982 |
// success |
8b1194e51cf2
BUGFIX: Added returns after timeout in SII state machine.
Florian Pose <fp@igh-essen.com>
parents:
391
diff
changeset
|
1983 |
fsm->sii_state = ec_fsm_end; |
238
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1984 |
} |
b4960499098f
Added finite state machine (FSM) processing.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1985 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1986 |
/****************************************************************************** |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
1987 |
* state change state machine |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1988 |
*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1989 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1990 |
/** |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1991 |
Change state: START. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1992 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1993 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
1994 |
void ec_fsm_change_start(ec_fsm_t *fsm /**< finite state machine */) |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1995 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
1996 |
ec_datagram_t *datagram = &fsm->datagram; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1997 |
ec_slave_t *slave = fsm->slave; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
1998 |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
1999 |
fsm->change_take_time = 1; |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2000 |
|
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2001 |
// write new state to slave |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2002 |
ec_datagram_npwr(datagram, slave->station_address, 0x0120, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2003 |
EC_WRITE_U16(datagram->data, fsm->change_new); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2004 |
ec_master_queue_datagram(fsm->master, datagram); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2005 |
fsm->change_state = ec_fsm_change_check; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2006 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2007 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2008 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2009 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2010 |
/** |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2011 |
Change state: CHECK. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2012 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2013 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2014 |
void ec_fsm_change_check(ec_fsm_t *fsm /**< finite state machine */) |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2015 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2016 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2017 |
ec_slave_t *slave = fsm->slave; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2018 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2019 |
if (datagram->state != EC_DATAGRAM_RECEIVED) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2020 |
fsm->change_state = ec_fsm_error; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2021 |
EC_ERR("Failed to send state datagram to slave %i!\n", |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2022 |
fsm->slave->ring_position); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
2023 |
return; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
2024 |
} |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
2025 |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2026 |
if (fsm->change_take_time) { |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2027 |
fsm->change_take_time = 0; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2028 |
fsm->change_jiffies = datagram->jiffies_sent; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2029 |
} |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2030 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2031 |
if (datagram->working_counter != 1) { |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2032 |
if (datagram->jiffies_received - fsm->change_jiffies >= 3 * HZ) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2033 |
fsm->change_state = ec_fsm_error; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2034 |
EC_ERR("Failed to set state 0x%02X on slave %i: Slave did not" |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2035 |
" respond.\n", fsm->change_new, fsm->slave->ring_position); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2036 |
return; |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2037 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2038 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2039 |
// repeat writing new state to slave |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2040 |
ec_datagram_npwr(datagram, slave->station_address, 0x0120, 2); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2041 |
EC_WRITE_U16(datagram->data, fsm->change_new); |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2042 |
ec_master_queue_datagram(fsm->master, datagram); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2043 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2044 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2045 |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2046 |
fsm->change_take_time = 1; |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2047 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2048 |
// read AL status from slave |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2049 |
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2050 |
ec_master_queue_datagram(fsm->master, datagram); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2051 |
fsm->change_state = ec_fsm_change_status; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2052 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2053 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2054 |
/*****************************************************************************/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2055 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2056 |
/** |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2057 |
Change state: STATUS. |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2058 |
*/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2059 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2060 |
void ec_fsm_change_status(ec_fsm_t *fsm /**< finite state machine */) |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2061 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2062 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2063 |
ec_slave_t *slave = fsm->slave; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2064 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2065 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2066 |
|| datagram->working_counter != 1) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2067 |
fsm->change_state = ec_fsm_error; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2068 |
EC_ERR("Failed to check state 0x%02X on slave %i.\n", |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2069 |
fsm->change_new, slave->ring_position); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2070 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2071 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2072 |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2073 |
if (fsm->change_take_time) { |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2074 |
fsm->change_take_time = 0; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2075 |
fsm->change_jiffies = datagram->jiffies_sent; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2076 |
} |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2077 |
|
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2078 |
slave->current_state = EC_READ_U8(datagram->data); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2079 |
|
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2080 |
if (slave->current_state == fsm->change_new) { |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2081 |
// state has been set successfully |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2082 |
fsm->change_state = ec_fsm_end; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2083 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2084 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2085 |
|
402
03e31ac14047
Renamed EC_ACK to EC_SLAVE_STATE_ACK_ERR
Florian Pose <fp@igh-essen.com>
parents:
398
diff
changeset
|
2086 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2087 |
// state change error |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2088 |
EC_ERR("Failed to set state 0x%02X - Slave %i refused state change" |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2089 |
" (code 0x%02X)!\n", fsm->change_new, slave->ring_position, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2090 |
slave->current_state); |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2091 |
// fetch AL status error code |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2092 |
ec_datagram_nprd(datagram, slave->station_address, 0x0134, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2093 |
ec_master_queue_datagram(fsm->master, datagram); |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2094 |
fsm->change_state = ec_fsm_change_code; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2095 |
return; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2096 |
} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2097 |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2098 |
if (datagram->jiffies_received |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2099 |
- fsm->change_jiffies >= 100 * HZ / 1000) { // 100ms |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2100 |
// timeout while checking |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2101 |
fsm->change_state = ec_fsm_error; |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2102 |
EC_ERR("Timeout while setting state 0x%02X on slave %i.\n", |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2103 |
fsm->change_new, slave->ring_position); |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2104 |
return; |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2105 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2106 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2107 |
// still old state: check again |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2108 |
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2109 |
ec_master_queue_datagram(fsm->master, datagram); |
260
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2110 |
} |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2111 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2112 |
/*****************************************************************************/ |
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2113 |
|
5fe7df7f2433
Correct behaviour of master state machine in RT mode.
Florian Pose <fp@igh-essen.com>
parents:
259
diff
changeset
|
2114 |
/** |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2115 |
Application layer status messages. |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2116 |
*/ |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2117 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2118 |
const ec_code_msg_t al_status_messages[] = { |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2119 |
{0x0001, "Unspecified error"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2120 |
{0x0011, "Invalud requested state change"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2121 |
{0x0012, "Unknown requested state"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2122 |
{0x0013, "Bootstrap not supported"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2123 |
{0x0014, "No valid firmware"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2124 |
{0x0015, "Invalid mailbox configuration"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2125 |
{0x0016, "Invalid mailbox configuration"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2126 |
{0x0017, "Invalid sync manager configuration"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2127 |
{0x0018, "No valid inputs available"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2128 |
{0x0019, "No valid outputs"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2129 |
{0x001A, "Synchronisation error"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2130 |
{0x001B, "Sync manager watchdog"}, |
297
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2131 |
{0x001C, "Invalid sync manager types"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2132 |
{0x001D, "Invalid output configuration"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2133 |
{0x001E, "Invalid input configuration"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2134 |
{0x001F, "Invalid watchdog configuration"}, |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2135 |
{0x0020, "Slave needs cold start"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2136 |
{0x0021, "Slave needs INIT"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2137 |
{0x0022, "Slave needs PREOP"}, |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2138 |
{0x0023, "Slave needs SAVEOP"}, |
297
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2139 |
{0x0030, "Invalid DC SYNCH configuration"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2140 |
{0x0031, "Invalid DC latch configuration"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2141 |
{0x0032, "PLL error"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2142 |
{0x0033, "Invalid DC IO error"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2143 |
{0x0034, "Invalid DC timeout error"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2144 |
{0x0042, "MBOX EOE"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2145 |
{0x0043, "MBOX COE"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2146 |
{0x0044, "MBOX FOE"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2147 |
{0x0045, "MBOX SOE"}, |
ac2a057a8ef2
Added missing AL status code messages.
Florian Pose <fp@igh-essen.com>
parents:
293
diff
changeset
|
2148 |
{0x004F, "MBOX VOE"}, |
251
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2149 |
{} |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2150 |
}; |
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2151 |
|
c1d0b63a9302
EoE in Free-Run mode; Finished slave configuration state machine.
Florian Pose <fp@igh-essen.com>
parents:
246
diff
changeset
|
2152 |
/*****************************************************************************/ |
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2153 |
|
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2154 |
/** |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2155 |
Change state: CODE. |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2156 |
*/ |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2157 |
|
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2158 |
void ec_fsm_change_code(ec_fsm_t *fsm /**< finite state machine */) |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2159 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2160 |
ec_datagram_t *datagram = &fsm->datagram; |
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2161 |
ec_slave_t *slave = fsm->slave; |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2162 |
uint32_t code; |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2163 |
const ec_code_msg_t *al_msg; |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2164 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2165 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2166 |
|| datagram->working_counter != 1) { |
407
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2167 |
EC_WARN("Reception of AL status code datagram failed.\n"); |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2168 |
} |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2169 |
else { |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2170 |
if ((code = EC_READ_U16(datagram->data))) { |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2171 |
for (al_msg = al_status_messages; al_msg->code; al_msg++) { |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2172 |
if (al_msg->code != code) continue; |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2173 |
EC_ERR("AL status message 0x%04X: \"%s\".\n", |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2174 |
al_msg->code, al_msg->message); |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2175 |
break; |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2176 |
} |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2177 |
if (!al_msg->code) |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2178 |
EC_ERR("Unknown AL status code 0x%04X.\n", code); |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2179 |
} |
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2180 |
} |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2181 |
|
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2182 |
// acknowledge "old" slave state |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2183 |
ec_datagram_npwr(datagram, slave->station_address, 0x0120, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2184 |
EC_WRITE_U16(datagram->data, slave->current_state); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2185 |
ec_master_queue_datagram(fsm->master, datagram); |
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2186 |
fsm->change_state = ec_fsm_change_ack; |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2187 |
} |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2188 |
|
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2189 |
/*****************************************************************************/ |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2190 |
|
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2191 |
/** |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2192 |
Change state: ACK. |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2193 |
*/ |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2194 |
|
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2195 |
void ec_fsm_change_ack(ec_fsm_t *fsm /**< finite state machine */) |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2196 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2197 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2198 |
ec_slave_t *slave = fsm->slave; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2199 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2200 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2201 |
|| datagram->working_counter != 1) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2202 |
fsm->change_state = ec_fsm_error; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2203 |
EC_ERR("Reception of state ack datagram failed.\n"); |
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2204 |
return; |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2205 |
} |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2206 |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2207 |
fsm->change_take_time = 1; |
301 | 2208 |
|
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2209 |
// read new AL status |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2210 |
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2211 |
ec_master_queue_datagram(fsm->master, datagram); |
311
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
2212 |
fsm->change_state = ec_fsm_change_check_ack; |
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
2213 |
} |
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
2214 |
|
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
2215 |
/*****************************************************************************/ |
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
2216 |
|
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
2217 |
/** |
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
2218 |
Change state: CHECK ACK. |
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
2219 |
*/ |
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
2220 |
|
197489292da8
Renamed ACK2 state to CHECK ACK.
Florian Pose <fp@igh-essen.com>
parents:
310
diff
changeset
|
2221 |
void ec_fsm_change_check_ack(ec_fsm_t *fsm /**< finite state machine */) |
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2222 |
{ |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2223 |
ec_datagram_t *datagram = &fsm->datagram; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2224 |
ec_slave_t *slave = fsm->slave; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2225 |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2226 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2227 |
|| datagram->working_counter != 1) { |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2228 |
fsm->change_state = ec_fsm_error; |
293
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2229 |
EC_ERR("Reception of state ack check datagram failed.\n"); |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2230 |
return; |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2231 |
} |
14aeb79aa992
Renamed command structure to datagram.
Florian Pose <fp@igh-essen.com>
parents:
292
diff
changeset
|
2232 |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2233 |
if (fsm->change_take_time) { |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2234 |
fsm->change_take_time = 0; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2235 |
fsm->change_jiffies = datagram->jiffies_sent; |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2236 |
} |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2237 |
|
407
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2238 |
slave->current_state = EC_READ_U8(datagram->data); |
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2239 |
|
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2240 |
if (!(slave->current_state & EC_SLAVE_STATE_ACK_ERR)) { |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2241 |
fsm->change_state = ec_fsm_error; |
407
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2242 |
EC_INFO("Acknowledged state 0x%02X on slave %i.\n", |
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2243 |
slave->current_state, slave->ring_position); |
292
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
2244 |
return; |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
2245 |
} |
2cf6ae0a2419
Minor changes in fsm.c and slave.c
Florian Pose <fp@igh-essen.com>
parents:
291
diff
changeset
|
2246 |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2247 |
if (datagram->jiffies_received |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2248 |
- fsm->change_jiffies >= 100 * HZ / 1000) { // 100ms |
301 | 2249 |
// timeout while checking |
2250 |
slave->current_state = EC_SLAVE_STATE_UNKNOWN; |
|
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
2251 |
fsm->change_state = ec_fsm_error; |
407
b73c9f7be5a1
BUGFIX: Fixed faulty state acknowledge behavior.
Florian Pose <fp@igh-essen.com>
parents:
405
diff
changeset
|
2252 |
EC_ERR("Timeout while acknowledging state 0x%02X on slave %i.\n", |
301 | 2253 |
fsm->change_new, slave->ring_position); |
2254 |
return; |
|
2255 |
} |
|
2256 |
||
2257 |
// reread new AL status |
|
2258 |
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2); |
|
2259 |
ec_master_queue_datagram(fsm->master, datagram); |
|
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2260 |
} |
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
2261 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2262 |
/****************************************************************************** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2263 |
* CoE dictionary state machine |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2264 |
*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2265 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2266 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2267 |
CoE state: DICT START. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2268 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2269 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2270 |
void ec_fsm_coe_dict_start(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2271 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2272 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2273 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2274 |
uint8_t *data; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2275 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2276 |
if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 8))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2277 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2278 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2279 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2280 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2281 |
EC_WRITE_U16(data, 0x8 << 12); // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2282 |
EC_WRITE_U8 (data + 2, 0x01); // Get OD List Request |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2283 |
EC_WRITE_U8 (data + 3, 0x00); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2284 |
EC_WRITE_U16(data + 4, 0x0000); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2285 |
EC_WRITE_U16(data + 6, 0x0001); // deliver all SDOs! |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2286 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2287 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2288 |
fsm->coe_state = ec_fsm_coe_dict_request; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2289 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2290 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2291 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2292 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2293 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2294 |
CoE state: DICT REQUEST. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2295 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2296 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2297 |
void ec_fsm_coe_dict_request(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2298 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2299 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2300 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2301 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2302 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2303 |
|| datagram->working_counter != 1) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2304 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2305 |
EC_ERR("Reception of CoE dictionary request failed.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2306 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2307 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2308 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2309 |
fsm->coe_start = datagram->cycles_sent; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2310 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2311 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2312 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2313 |
fsm->coe_state = ec_fsm_coe_dict_check; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2314 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2315 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2316 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2317 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2318 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2319 |
CoE state: DICT CHECK. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2320 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2321 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2322 |
void ec_fsm_coe_dict_check(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2323 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2324 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2325 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2326 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2327 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2328 |
|| datagram->working_counter != 1) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2329 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2330 |
EC_ERR("Reception of CoE mailbox check datagram failed.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2331 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2332 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2333 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2334 |
if (!ec_slave_mbox_check(datagram)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2335 |
if (datagram->cycles_received |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2336 |
- fsm->coe_start >= (cycles_t) 100 * cpu_khz) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2337 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2338 |
EC_ERR("Timeout while checking SDO dictionary on slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2339 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2340 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2341 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2342 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2343 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2344 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2345 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2346 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2347 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2348 |
// Fetch response |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2349 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2350 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2351 |
fsm->coe_state = ec_fsm_coe_dict_response; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2352 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2353 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2354 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2355 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2356 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2357 |
CoE state: DICT RESPONSE. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2358 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2359 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2360 |
void ec_fsm_coe_dict_response(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2361 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2362 |
ec_master_t *master = fsm->master; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2363 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2364 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2365 |
uint8_t *data, mbox_prot; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2366 |
size_t rec_size; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2367 |
unsigned int sdo_count, i; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2368 |
uint16_t sdo_index; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2369 |
ec_sdo_t *sdo; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2370 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2371 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2372 |
|| datagram->working_counter != 1) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2373 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2374 |
EC_ERR("Reception of CoE dictionary response failed.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2375 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2376 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2377 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2378 |
if (!(data = ec_slave_mbox_fetch(slave, datagram, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2379 |
&mbox_prot, &rec_size))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2380 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2381 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2382 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2383 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2384 |
if (mbox_prot != 0x03) { // CoE |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2385 |
EC_WARN("Received mailbox protocol 0x%02X as response.\n", mbox_prot); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2386 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2387 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2388 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2389 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2390 |
if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2391 |
(EC_READ_U8(data + 2) & 0x7F) == 0x07) { // error response |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2392 |
EC_ERR("SDO information error response at slave %i!\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2393 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2394 |
ec_canopen_abort_msg(EC_READ_U32(data + 6)); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2395 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2396 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2397 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2398 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2399 |
if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2400 |
(EC_READ_U8 (data + 2) & 0x7F) != 0x02) { // Get OD List response |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2401 |
EC_ERR("Invalid SDO list response at slave %i!\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2402 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2403 |
ec_print_data(data, rec_size); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2404 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2405 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2406 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2407 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2408 |
if (rec_size < 8) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2409 |
EC_ERR("Invalid data size!\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2410 |
ec_print_data(data, rec_size); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2411 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2412 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2413 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2414 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2415 |
sdo_count = (rec_size - 8) / 2; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2416 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2417 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2418 |
EC_DBG("Fetching %i SDOs.\n", sdo_count); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2419 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2420 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2421 |
for (i = 0; i < sdo_count; i++) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2422 |
sdo_index = EC_READ_U16(data + 8 + i * 2); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2423 |
if (!sdo_index) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2424 |
// sometimes index is 0... ??? |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2425 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2426 |
EC_DBG("Received SDO with index 0x0000.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2427 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2428 |
continue; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2429 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2430 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2431 |
if (!(sdo = (ec_sdo_t *) kmalloc(sizeof(ec_sdo_t), GFP_ATOMIC))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2432 |
EC_ERR("Failed to allocate memory for SDO!\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2433 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2434 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2435 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2436 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2437 |
if (ec_sdo_init(sdo, sdo_index, slave)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2438 |
EC_ERR("Failed to init SDO!\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2439 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2440 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2441 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2442 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2443 |
if (kobject_add(&sdo->kobj)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2444 |
EC_ERR("Failed to add kobject.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2445 |
kobject_put(&sdo->kobj); // free |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2446 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2447 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2448 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2449 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2450 |
list_add_tail(&sdo->list, &slave->sdo_dictionary); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2451 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2452 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2453 |
if (EC_READ_U8(data + 2) & 0x80) { // more messages waiting. check again. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2454 |
fsm->coe_start = datagram->cycles_sent; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2455 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2456 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2457 |
fsm->coe_state = ec_fsm_coe_dict_check; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2458 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2459 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2460 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2461 |
if (list_empty(&slave->sdo_dictionary)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2462 |
// no SDOs in dictionary. finished. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2463 |
fsm->coe_state = ec_fsm_end; // success |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2464 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2465 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2466 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2467 |
// fetch SDO descriptions |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2468 |
fsm->coe_sdo = list_entry(slave->sdo_dictionary.next, ec_sdo_t, list); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2469 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2470 |
if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 8))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2471 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2472 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2473 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2474 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2475 |
EC_WRITE_U16(data, 0x8 << 12); // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2476 |
EC_WRITE_U8 (data + 2, 0x03); // Get object description request |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2477 |
EC_WRITE_U8 (data + 3, 0x00); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2478 |
EC_WRITE_U16(data + 4, 0x0000); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2479 |
EC_WRITE_U16(data + 6, fsm->coe_sdo->index); // SDO index |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2480 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2481 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2482 |
fsm->coe_state = ec_fsm_coe_dict_desc_request; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2483 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2484 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2485 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2486 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2487 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2488 |
CoE state: DICT DESC REQUEST. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2489 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2490 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2491 |
void ec_fsm_coe_dict_desc_request(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2492 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2493 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2494 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2495 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2496 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2497 |
|| datagram->working_counter != 1) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2498 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2499 |
EC_ERR("Reception of CoE SDO description request failed.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2500 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2501 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2502 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2503 |
fsm->coe_start = datagram->cycles_sent; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2504 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2505 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2506 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2507 |
fsm->coe_state = ec_fsm_coe_dict_desc_check; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2508 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2509 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2510 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2511 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2512 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2513 |
CoE state: DICT DESC CHECK. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2514 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2515 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2516 |
void ec_fsm_coe_dict_desc_check(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2517 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2518 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2519 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2520 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2521 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2522 |
|| datagram->working_counter != 1) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2523 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2524 |
EC_ERR("Reception of CoE mailbox check datagram failed.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2525 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2526 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2527 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2528 |
if (!ec_slave_mbox_check(datagram)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2529 |
if (datagram->cycles_received |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2530 |
- fsm->coe_start >= (cycles_t) 100 * cpu_khz) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2531 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2532 |
EC_ERR("Timeout while checking SDO description on slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2533 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2534 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2535 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2536 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2537 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2538 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2539 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2540 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2541 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2542 |
// Fetch response |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2543 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2544 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2545 |
fsm->coe_state = ec_fsm_coe_dict_desc_response; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2546 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2547 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2548 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2549 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2550 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2551 |
CoE state: DICT DESC RESPONSE. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2552 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2553 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2554 |
void ec_fsm_coe_dict_desc_response(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2555 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2556 |
ec_master_t *master = fsm->master; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2557 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2558 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2559 |
ec_sdo_t *sdo = fsm->coe_sdo; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2560 |
uint8_t *data, mbox_prot; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2561 |
size_t rec_size, name_size; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2562 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2563 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2564 |
|| datagram->working_counter != 1) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2565 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2566 |
EC_ERR("Reception of CoE SDO description response failed.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2567 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2568 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2569 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2570 |
if (!(data = ec_slave_mbox_fetch(slave, datagram, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2571 |
&mbox_prot, &rec_size))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2572 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2573 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2574 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2575 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2576 |
if (mbox_prot != 0x03) { // CoE |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2577 |
EC_WARN("Received mailbox protocol 0x%02X as response.\n", mbox_prot); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2578 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2579 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2580 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2581 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2582 |
if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2583 |
(EC_READ_U8 (data + 2) & 0x7F) == 0x07) { // error response |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2584 |
EC_ERR("SDO information error response at slave %i while" |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2585 |
" fetching SDO 0x%04X!\n", slave->ring_position, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2586 |
sdo->index); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2587 |
ec_canopen_abort_msg(EC_READ_U32(data + 6)); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2588 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2589 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2590 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2591 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2592 |
if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2593 |
(EC_READ_U8 (data + 2) & 0x7F) != 0x04 || // Object desc. response |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2594 |
EC_READ_U16(data + 6) != sdo->index) { // SDO index |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2595 |
EC_ERR("Invalid object description response at slave %i while" |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2596 |
" fetching SDO 0x%04X!\n", slave->ring_position, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2597 |
sdo->index); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2598 |
ec_print_data(data, rec_size); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2599 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2600 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2601 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2602 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2603 |
if (rec_size < 12) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2604 |
EC_ERR("Invalid data size!\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2605 |
ec_print_data(data, rec_size); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2606 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2607 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2608 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2609 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2610 |
sdo->subindices = EC_READ_U8(data + 10); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2611 |
sdo->object_code = EC_READ_U8(data + 11); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2612 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2613 |
name_size = rec_size - 12; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2614 |
if (name_size) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2615 |
if (!(sdo->name = kmalloc(name_size + 1, GFP_ATOMIC))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2616 |
EC_ERR("Failed to allocate SDO name!\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2617 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2618 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2619 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2620 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2621 |
memcpy(sdo->name, data + 12, name_size); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2622 |
sdo->name[name_size] = 0; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2623 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2624 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2625 |
if (EC_READ_U8(data + 2) & 0x80) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2626 |
EC_ERR("Fragment follows (not implemented)!\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2627 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2628 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2629 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2630 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2631 |
if (!sdo->subindices) { // no entries |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2632 |
// another SDO description to fetch? |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2633 |
if (fsm->coe_sdo->list.next != &slave->sdo_dictionary) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2634 |
fsm->coe_sdo = list_entry(fsm->coe_sdo->list.next, ec_sdo_t, list); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2635 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2636 |
if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 8))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2637 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2638 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2639 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2640 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2641 |
EC_WRITE_U16(data, 0x8 << 12); // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2642 |
EC_WRITE_U8 (data + 2, 0x03); // Get object description request |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2643 |
EC_WRITE_U8 (data + 3, 0x00); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2644 |
EC_WRITE_U16(data + 4, 0x0000); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2645 |
EC_WRITE_U16(data + 6, fsm->coe_sdo->index); // SDO index |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2646 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2647 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2648 |
fsm->coe_state = ec_fsm_coe_dict_desc_request; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2649 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2650 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2651 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2652 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2653 |
EC_DBG("Finished fetching SDO descriptions.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2654 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2655 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2656 |
fsm->coe_state = ec_fsm_end; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2657 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2658 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2659 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2660 |
fsm->coe_subindex = 1; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2661 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2662 |
if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 10))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2663 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2664 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2665 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2666 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2667 |
EC_WRITE_U16(data, 0x8 << 12); // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2668 |
EC_WRITE_U8 (data + 2, 0x05); // Get entry description request |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2669 |
EC_WRITE_U8 (data + 3, 0x00); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2670 |
EC_WRITE_U16(data + 4, 0x0000); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2671 |
EC_WRITE_U16(data + 6, sdo->index); // SDO index |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2672 |
EC_WRITE_U8 (data + 8, fsm->coe_subindex); // SDO subindex |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2673 |
EC_WRITE_U8 (data + 9, 0x00); // value info (no values) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2674 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2675 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2676 |
fsm->coe_state = ec_fsm_coe_dict_entry_request; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2677 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2678 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2679 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2680 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2681 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2682 |
CoE state: DICT ENTRY REQUEST. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2683 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2684 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2685 |
void ec_fsm_coe_dict_entry_request(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2686 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2687 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2688 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2689 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2690 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2691 |
|| datagram->working_counter != 1) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2692 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2693 |
EC_ERR("Reception of CoE SDO entry request failed.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2694 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2695 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2696 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2697 |
fsm->coe_start = datagram->cycles_sent; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2698 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2699 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2700 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2701 |
fsm->coe_state = ec_fsm_coe_dict_entry_check; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2702 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2703 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2704 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2705 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2706 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2707 |
CoE state: DICT ENTRY CHECK. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2708 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2709 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2710 |
void ec_fsm_coe_dict_entry_check(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2711 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2712 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2713 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2714 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2715 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2716 |
|| datagram->working_counter != 1) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2717 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2718 |
EC_ERR("Reception of CoE mailbox check datagram failed.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2719 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2720 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2721 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2722 |
if (!ec_slave_mbox_check(datagram)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2723 |
if (datagram->cycles_received |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2724 |
- fsm->coe_start >= (cycles_t) 100 * cpu_khz) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2725 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2726 |
EC_ERR("Timeout while checking SDO entry on slave %i.\n", |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2727 |
slave->ring_position); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2728 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2729 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2730 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2731 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2732 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2733 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2734 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2735 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2736 |
// Fetch response |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2737 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2738 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2739 |
fsm->coe_state = ec_fsm_coe_dict_entry_response; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2740 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2741 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2742 |
/*****************************************************************************/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2743 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2744 |
/** |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2745 |
CoE state: DICT ENTRY RESPONSE. |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2746 |
*/ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2747 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2748 |
void ec_fsm_coe_dict_entry_response(ec_fsm_t *fsm /**< finite state machine */) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2749 |
{ |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2750 |
ec_master_t *master = fsm->master; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2751 |
ec_datagram_t *datagram = &fsm->datagram; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2752 |
ec_slave_t *slave = fsm->slave; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2753 |
ec_sdo_t *sdo = fsm->coe_sdo; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2754 |
uint8_t *data, mbox_prot; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2755 |
size_t rec_size, data_size; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2756 |
ec_sdo_entry_t *entry; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2757 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2758 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2759 |
|| datagram->working_counter != 1) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2760 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2761 |
EC_ERR("Reception of CoE SDO description response failed.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2762 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2763 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2764 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2765 |
if (!(data = ec_slave_mbox_fetch(slave, datagram, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2766 |
&mbox_prot, &rec_size))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2767 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2768 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2769 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2770 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2771 |
if (mbox_prot != 0x03) { // CoE |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2772 |
EC_WARN("Received mailbox protocol 0x%02X as response.\n", mbox_prot); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2773 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2774 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2775 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2776 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2777 |
if (EC_READ_U16(data) >> 12 == 0x8 && // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2778 |
(EC_READ_U8 (data + 2) & 0x7F) == 0x07) { // error response |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2779 |
EC_ERR("SDO information error response at slave %i while" |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2780 |
" fetching SDO entry 0x%04X:%i!\n", slave->ring_position, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2781 |
sdo->index, fsm->coe_subindex); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2782 |
ec_canopen_abort_msg(EC_READ_U32(data + 6)); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2783 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2784 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2785 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2786 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2787 |
if (EC_READ_U16(data) >> 12 != 0x8 || // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2788 |
(EC_READ_U8(data + 2) & 0x7F) != 0x06 || // Entry desc. response |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2789 |
EC_READ_U16(data + 6) != sdo->index || // SDO index |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2790 |
EC_READ_U8(data + 8) != fsm->coe_subindex) { // SDO subindex |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2791 |
EC_ERR("Invalid entry description response at slave %i while" |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2792 |
" fetching SDO entry 0x%04X:%i!\n", slave->ring_position, |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2793 |
sdo->index, fsm->coe_subindex); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2794 |
ec_print_data(data, rec_size); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2795 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2796 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2797 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2798 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2799 |
if (rec_size < 16) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2800 |
EC_ERR("Invalid data size!\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2801 |
ec_print_data(data, rec_size); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2802 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2803 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2804 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2805 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2806 |
data_size = rec_size - 16; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2807 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2808 |
if (!(entry = (ec_sdo_entry_t *) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2809 |
kmalloc(sizeof(ec_sdo_entry_t), GFP_ATOMIC))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2810 |
EC_ERR("Failed to allocate entry!\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2811 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2812 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2813 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2814 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2815 |
if (ec_sdo_entry_init(entry, fsm->coe_subindex, sdo)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2816 |
EC_ERR("Failed to init entry!\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2817 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2818 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2819 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2820 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2821 |
entry->data_type = EC_READ_U16(data + 10); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2822 |
entry->bit_length = EC_READ_U16(data + 12); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2823 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2824 |
if (data_size) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2825 |
if (!(entry->description = kmalloc(data_size + 1, GFP_ATOMIC))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2826 |
EC_ERR("Failed to allocate SDO entry name!\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2827 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2828 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2829 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2830 |
memcpy(entry->description, data + 16, data_size); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2831 |
entry->description[data_size] = 0; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2832 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2833 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2834 |
if (kobject_add(&entry->kobj)) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2835 |
EC_ERR("Failed to add kobject.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2836 |
kobject_put(&entry->kobj); // free |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2837 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2838 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2839 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2840 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2841 |
list_add_tail(&entry->list, &sdo->entries); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2842 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2843 |
if (fsm->coe_subindex < sdo->subindices) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2844 |
fsm->coe_subindex++; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2845 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2846 |
if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 10))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2847 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2848 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2849 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2850 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2851 |
EC_WRITE_U16(data, 0x8 << 12); // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2852 |
EC_WRITE_U8 (data + 2, 0x05); // Get entry description request |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2853 |
EC_WRITE_U8 (data + 3, 0x00); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2854 |
EC_WRITE_U16(data + 4, 0x0000); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2855 |
EC_WRITE_U16(data + 6, sdo->index); // SDO index |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2856 |
EC_WRITE_U8 (data + 8, fsm->coe_subindex); // SDO subindex |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2857 |
EC_WRITE_U8 (data + 9, 0x00); // value info (no values) |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2858 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2859 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2860 |
fsm->coe_state = ec_fsm_coe_dict_entry_request; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2861 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2862 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2863 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2864 |
// another SDO description to fetch? |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2865 |
if (fsm->coe_sdo->list.next != &slave->sdo_dictionary) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2866 |
fsm->coe_sdo = list_entry(fsm->coe_sdo->list.next, ec_sdo_t, list); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2867 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2868 |
if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, 8))) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2869 |
fsm->coe_state = ec_fsm_error; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2870 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2871 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2872 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2873 |
EC_WRITE_U16(data, 0x8 << 12); // SDO information |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2874 |
EC_WRITE_U8 (data + 2, 0x03); // Get object description request |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2875 |
EC_WRITE_U8 (data + 3, 0x00); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2876 |
EC_WRITE_U16(data + 4, 0x0000); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2877 |
EC_WRITE_U16(data + 6, fsm->coe_sdo->index); // SDO index |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2878 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2879 |
ec_master_queue_datagram(fsm->master, datagram); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2880 |
fsm->coe_state = ec_fsm_coe_dict_desc_request; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2881 |
return; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2882 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2883 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2884 |
if (master->debug_level) { |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2885 |
EC_DBG("Finished fetching SDO descriptions.\n"); |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2886 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2887 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2888 |
fsm->coe_state = ec_fsm_end; |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2889 |
} |
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2890 |
|
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2891 |
/****************************************************************************** |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2892 |
* CoE state machine |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2893 |
*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2894 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2895 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2896 |
CoE state: DOWN START. |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2897 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2898 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2899 |
void ec_fsm_coe_down_start(ec_fsm_t *fsm /**< finite state machine */) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2900 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2901 |
ec_datagram_t *datagram = &fsm->datagram; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2902 |
ec_slave_t *slave = fsm->slave; |
405
61d5d6457fa6
Renamed fsm->sdodata to fsm->coe_sdodata
Florian Pose <fp@igh-essen.com>
parents:
403
diff
changeset
|
2903 |
ec_sdo_data_t *sdodata = fsm->coe_sdodata; |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2904 |
uint8_t *data; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2905 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2906 |
EC_INFO("Downloading SDO 0x%04X:%i to slave %i.\n", |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2907 |
sdodata->index, sdodata->subindex, slave->ring_position); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2908 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2909 |
if (slave->sii_rx_mailbox_size < 6 + 10 + sdodata->size) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2910 |
EC_ERR("SDO fragmenting not supported yet!\n"); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2911 |
fsm->coe_state = ec_fsm_error; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2912 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2913 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2914 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2915 |
if (!(data = ec_slave_mbox_prepare_send(slave, datagram, 0x03, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2916 |
sdodata->size + 10))) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2917 |
fsm->coe_state = ec_fsm_error; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2918 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2919 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2920 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2921 |
EC_WRITE_U16(data, 0x2 << 12); // SDO request |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2922 |
EC_WRITE_U8 (data + 2, (0x1 // size specified |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2923 |
| 0x1 << 5)); // Download request |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2924 |
EC_WRITE_U16(data + 3, sdodata->index); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2925 |
EC_WRITE_U8 (data + 5, sdodata->subindex); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2926 |
EC_WRITE_U32(data + 6, sdodata->size); |
390
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
344
diff
changeset
|
2927 |
memcpy(data + 10, sdodata->data, sdodata->size); |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2928 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2929 |
ec_master_queue_datagram(fsm->master, datagram); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2930 |
fsm->coe_state = ec_fsm_coe_down_request; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2931 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2932 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2933 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2934 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2935 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2936 |
CoE state: DOWN REQUEST. |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2937 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2938 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2939 |
void ec_fsm_coe_down_request(ec_fsm_t *fsm /**< finite state machine */) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2940 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2941 |
ec_datagram_t *datagram = &fsm->datagram; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2942 |
ec_slave_t *slave = fsm->slave; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2943 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2944 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2945 |
|| datagram->working_counter != 1) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2946 |
fsm->coe_state = ec_fsm_error; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2947 |
EC_ERR("Reception of CoE download request failed.\n"); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2948 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2949 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2950 |
|
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2951 |
fsm->coe_start = datagram->cycles_sent; |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2952 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2953 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2954 |
ec_master_queue_datagram(fsm->master, datagram); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2955 |
fsm->coe_state = ec_fsm_coe_down_check; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2956 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2957 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2958 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2959 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2960 |
/** |
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2961 |
CoE state: DOWN CHECK. |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2962 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2963 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2964 |
void ec_fsm_coe_down_check(ec_fsm_t *fsm /**< finite state machine */) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2965 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2966 |
ec_datagram_t *datagram = &fsm->datagram; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2967 |
ec_slave_t *slave = fsm->slave; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2968 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2969 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2970 |
|| datagram->working_counter != 1) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2971 |
fsm->coe_state = ec_fsm_error; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2972 |
EC_ERR("Reception of CoE mailbox check datagram failed.\n"); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2973 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2974 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2975 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2976 |
if (!ec_slave_mbox_check(datagram)) { |
398
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2977 |
if (datagram->cycles_received |
ff37601361a8
Fixed serveral races while starting up under high CPU load.
Florian Pose <fp@igh-essen.com>
parents:
397
diff
changeset
|
2978 |
- fsm->coe_start >= (cycles_t) 100 * cpu_khz) { |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2979 |
fsm->coe_state = ec_fsm_error; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2980 |
EC_ERR("Timeout while checking SDO configuration on slave %i.\n", |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2981 |
slave->ring_position); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2982 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2983 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2984 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2985 |
ec_slave_mbox_prepare_check(slave, datagram); // can not fail. |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2986 |
ec_master_queue_datagram(fsm->master, datagram); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2987 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2988 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2989 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2990 |
// Fetch response |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2991 |
ec_slave_mbox_prepare_fetch(slave, datagram); // can not fail. |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
2992 |
ec_master_queue_datagram(fsm->master, datagram); |
339 | 2993 |
fsm->coe_state = ec_fsm_coe_down_response; |
2994 |
} |
|
2995 |
||
2996 |
/*****************************************************************************/ |
|
2997 |
||
2998 |
/** |
|
409
bc4c852e1b93
Implemented fetching of SDO dictionary.
Florian Pose <fp@igh-essen.com>
parents:
407
diff
changeset
|
2999 |
CoE state: DOWN RESPONSE. |
339 | 3000 |
*/ |
3001 |
||
3002 |
void ec_fsm_coe_down_response(ec_fsm_t *fsm /**< finite state machine */) |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3003 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3004 |
ec_datagram_t *datagram = &fsm->datagram; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3005 |
ec_slave_t *slave = fsm->slave; |
391
7d67195702dd
Removed additional loop in coe_down FSM; renamed mbox_type to mbox_prot.
Florian Pose <fp@igh-essen.com>
parents:
390
diff
changeset
|
3006 |
uint8_t *data, mbox_prot; |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3007 |
size_t rec_size; |
405
61d5d6457fa6
Renamed fsm->sdodata to fsm->coe_sdodata
Florian Pose <fp@igh-essen.com>
parents:
403
diff
changeset
|
3008 |
ec_sdo_data_t *sdodata = fsm->coe_sdodata; |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3009 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3010 |
if (datagram->state != EC_DATAGRAM_RECEIVED |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3011 |
|| datagram->working_counter != 1) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3012 |
fsm->coe_state = ec_fsm_error; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3013 |
EC_ERR("Reception of CoE download response failed.\n"); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3014 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3015 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3016 |
|
390
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
344
diff
changeset
|
3017 |
if (!(data = ec_slave_mbox_fetch(slave, datagram, |
391
7d67195702dd
Removed additional loop in coe_down FSM; renamed mbox_type to mbox_prot.
Florian Pose <fp@igh-essen.com>
parents:
390
diff
changeset
|
3018 |
&mbox_prot, &rec_size))) { |
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3019 |
fsm->coe_state = ec_fsm_error; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3020 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3021 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3022 |
|
391
7d67195702dd
Removed additional loop in coe_down FSM; renamed mbox_type to mbox_prot.
Florian Pose <fp@igh-essen.com>
parents:
390
diff
changeset
|
3023 |
if (mbox_prot != 0x03) { // CoE |
7d67195702dd
Removed additional loop in coe_down FSM; renamed mbox_type to mbox_prot.
Florian Pose <fp@igh-essen.com>
parents:
390
diff
changeset
|
3024 |
EC_WARN("Received mailbox protocol 0x%02X as response.\n", mbox_prot); |
7d67195702dd
Removed additional loop in coe_down FSM; renamed mbox_type to mbox_prot.
Florian Pose <fp@igh-essen.com>
parents:
390
diff
changeset
|
3025 |
fsm->coe_state = ec_fsm_error; |
390
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
344
diff
changeset
|
3026 |
return; |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
344
diff
changeset
|
3027 |
} |
685c267d80d8
Fixed mailbox bug, added mailbox error codes.
Florian Pose <fp@igh-essen.com>
parents:
344
diff
changeset
|
3028 |
|
329
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3029 |
if (rec_size < 6) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3030 |
fsm->coe_state = ec_fsm_error; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3031 |
EC_ERR("Received data is too small (%i bytes):\n", rec_size); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3032 |
ec_print_data(data, rec_size); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3033 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3034 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3035 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3036 |
if (EC_READ_U16(data) >> 12 == 0x2 && // SDO request |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3037 |
EC_READ_U8 (data + 2) >> 5 == 0x4) { // abort SDO transfer request |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3038 |
fsm->coe_state = ec_fsm_error; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3039 |
EC_ERR("SDO download 0x%04X:%X (%i bytes) aborted on slave %i.\n", |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3040 |
sdodata->index, sdodata->subindex, sdodata->size, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3041 |
slave->ring_position); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3042 |
if (rec_size < 10) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3043 |
EC_ERR("Incomplete Abort command:\n"); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3044 |
ec_print_data(data, rec_size); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3045 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3046 |
else |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3047 |
ec_canopen_abort_msg(EC_READ_U32(data + 6)); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3048 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3049 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3050 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3051 |
if (EC_READ_U16(data) >> 12 != 0x3 || // SDO response |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3052 |
EC_READ_U8 (data + 2) >> 5 != 0x3 || // Download response |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3053 |
EC_READ_U16(data + 3) != sdodata->index || // index |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3054 |
EC_READ_U8 (data + 5) != sdodata->subindex) { // subindex |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3055 |
fsm->coe_state = ec_fsm_error; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3056 |
EC_ERR("SDO download 0x%04X:%X (%i bytes) failed:\n", |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3057 |
sdodata->index, sdodata->subindex, sdodata->size); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3058 |
EC_ERR("Invalid SDO download response at slave %i!\n", |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3059 |
slave->ring_position); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3060 |
ec_print_data(data, rec_size); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3061 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3062 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3063 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3064 |
fsm->coe_state = ec_fsm_end; // success |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3065 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3066 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3067 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3068 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3069 |
/** |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3070 |
SDO abort messages. |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3071 |
The "abort SDO transfer request" supplies an abort code, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3072 |
which can be translated to clear text. This table does |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3073 |
the mapping of the codes and messages. |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3074 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3075 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3076 |
const ec_code_msg_t sdo_abort_messages[] = { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3077 |
{0x05030000, "Toggle bit not changed"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3078 |
{0x05040000, "SDO protocol timeout"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3079 |
{0x05040001, "Client/Server command specifier not valid or unknown"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3080 |
{0x05040005, "Out of memory"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3081 |
{0x06010000, "Unsupported access to an object"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3082 |
{0x06010001, "Attempt to read a write-only object"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3083 |
{0x06010002, "Attempt to write a read-only object"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3084 |
{0x06020000, "This object does not exist in the object directory"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3085 |
{0x06040041, "The object cannot be mapped into the PDO"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3086 |
{0x06040042, "The number and length of the objects to be mapped would" |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3087 |
" exceed the PDO length"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3088 |
{0x06040043, "General parameter incompatibility reason"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3089 |
{0x06040047, "Gerneral internal incompatibility in device"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3090 |
{0x06060000, "Access failure due to a hardware error"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3091 |
{0x06070010, "Data type does not match, length of service parameter does" |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3092 |
" not match"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3093 |
{0x06070012, "Data type does not match, length of service parameter too" |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3094 |
" high"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3095 |
{0x06070013, "Data type does not match, length of service parameter too" |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3096 |
" low"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3097 |
{0x06090011, "Subindex does not exist"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3098 |
{0x06090030, "Value range of parameter exceeded"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3099 |
{0x06090031, "Value of parameter written too high"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3100 |
{0x06090032, "Value of parameter written too low"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3101 |
{0x06090036, "Maximum value is less than minimum value"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3102 |
{0x08000000, "General error"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3103 |
{0x08000020, "Data cannot be transferred or stored to the application"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3104 |
{0x08000021, "Data cannot be transferred or stored to the application" |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3105 |
" because of local control"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3106 |
{0x08000022, "Data cannot be transferred or stored to the application" |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3107 |
" because of the present device state"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3108 |
{0x08000023, "Object dictionary dynamic generation fails or no object" |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3109 |
" dictionary is present"}, |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3110 |
{} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3111 |
}; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3112 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3113 |
/*****************************************************************************/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3114 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3115 |
/** |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3116 |
Outputs an SDO abort message. |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3117 |
*/ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3118 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3119 |
void ec_canopen_abort_msg(uint32_t abort_code) |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3120 |
{ |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3121 |
const ec_code_msg_t *abort_msg; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3122 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3123 |
for (abort_msg = sdo_abort_messages; abort_msg->code; abort_msg++) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3124 |
if (abort_msg->code == abort_code) { |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3125 |
EC_ERR("SDO abort message 0x%08X: \"%s\".\n", |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3126 |
abort_msg->code, abort_msg->message); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3127 |
return; |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3128 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3129 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3130 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3131 |
EC_ERR("Unknown SDO abort code 0x%08X.\n", abort_code); |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3132 |
} |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3133 |
|
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3134 |
/****************************************************************************** |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3135 |
* Common state functions |
d004349777fc
SDO configuration interface, SDO download state machine.
Florian Pose <fp@igh-essen.com>
parents:
325
diff
changeset
|
3136 |
*****************************************************************************/ |
286
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
3137 |
|
f3352378b4d4
Added missing documentation.
Florian Pose <fp@igh-essen.com>
parents:
275
diff
changeset
|
3138 |
/** |
325
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3139 |
State: ERROR. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3140 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3141 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3142 |
void ec_fsm_error(ec_fsm_t *fsm /**< finite state machine */) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3143 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3144 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3145 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3146 |
/*****************************************************************************/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3147 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3148 |
/** |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3149 |
State: END. |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3150 |
*/ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3151 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3152 |
void ec_fsm_end(ec_fsm_t *fsm /**< finite state machine */) |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3153 |
{ |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3154 |
} |
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3155 |
|
7833cf70c4f2
VERSION 1.1: New realtime interface, only state machines.
Florian Pose <fp@igh-essen.com>
parents:
312
diff
changeset
|
3156 |
/*****************************************************************************/ |