author | Florian Pose <fp@igh-essen.com> |
Wed, 02 Aug 2006 16:39:39 +0000 | |
branch | stable-1.0 |
changeset 1625 | 49d577ddcb08 |
parent 1624 | 9dc190591c0f |
permissions | -rw-r--r-- |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
2 |
* |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
3 |
* $Id$ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
4 |
* |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
6 |
* |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
8 |
* |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
10 |
* and/or modify it under the terms of the GNU General Public License |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
12 |
* License, or (at your option) any later version. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
13 |
* |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
17 |
* GNU General Public License for more details. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
18 |
* |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
19 |
* You should have received a copy of the GNU General Public License |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
22 |
* |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
24 |
* charge under condition of compatibility of product made by |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
25 |
* Licensee. People intending to distribute/sell products based on the |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
26 |
* code, have to sign an agreement to guarantee that products using |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
28 |
* EtherCAT specification (which are released themselves as an open |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
30 |
* Technology, IP and trade marks. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
31 |
* |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
32 |
*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
33 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
34 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
35 |
\file |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
36 |
EtherCAT finite state machines. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
37 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
38 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
39 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
40 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
41 |
#include "globals.h" |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
42 |
#include "fsm.h" |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
43 |
#include "master.h" |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
44 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
45 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
46 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
47 |
void ec_fsm_master_start(ec_fsm_t *); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
48 |
void ec_fsm_master_broadcast(ec_fsm_t *); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
49 |
void ec_fsm_master_read_states(ec_fsm_t *); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
50 |
void ec_fsm_master_validate_vendor(ec_fsm_t *); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
51 |
void ec_fsm_master_validate_product(ec_fsm_t *); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
52 |
void ec_fsm_master_rewrite_addresses(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
53 |
void ec_fsm_master_configure_slave(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
54 |
void ec_fsm_master_scan_slaves(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
55 |
void ec_fsm_master_write_eeprom(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
56 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
57 |
void ec_fsm_slavescan_start(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
58 |
void ec_fsm_slavescan_address(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
59 |
void ec_fsm_slavescan_state(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
60 |
void ec_fsm_slavescan_base(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
61 |
void ec_fsm_slavescan_datalink(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
62 |
void ec_fsm_slavescan_eeprom_size(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
63 |
void ec_fsm_slavescan_eeprom_data(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
64 |
void ec_fsm_slavescan_end(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
65 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
66 |
void ec_fsm_slaveconf_init(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
67 |
void ec_fsm_slaveconf_sync(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
68 |
void ec_fsm_slaveconf_preop(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
69 |
void ec_fsm_slaveconf_fmmu(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
70 |
void ec_fsm_slaveconf_saveop(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
71 |
void ec_fsm_slaveconf_op(ec_fsm_t *); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
72 |
void ec_fsm_slaveconf_end(ec_fsm_t *); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
73 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
74 |
void ec_fsm_sii_start_reading(ec_fsm_t *); |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
75 |
void ec_fsm_sii_read_check(ec_fsm_t *); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
76 |
void ec_fsm_sii_read_fetch(ec_fsm_t *); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
77 |
void ec_fsm_sii_start_writing(ec_fsm_t *); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
78 |
void ec_fsm_sii_write_check(ec_fsm_t *); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
79 |
void ec_fsm_sii_write_check2(ec_fsm_t *); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
80 |
void ec_fsm_sii_end(ec_fsm_t *); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
81 |
void ec_fsm_sii_error(ec_fsm_t *); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
82 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
83 |
void ec_fsm_change_start(ec_fsm_t *); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
84 |
void ec_fsm_change_check(ec_fsm_t *); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
85 |
void ec_fsm_change_status(ec_fsm_t *); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
86 |
void ec_fsm_change_code(ec_fsm_t *); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
87 |
void ec_fsm_change_ack(ec_fsm_t *); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
88 |
void ec_fsm_change_check_ack(ec_fsm_t *); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
89 |
void ec_fsm_change_end(ec_fsm_t *); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
90 |
void ec_fsm_change_error(ec_fsm_t *); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
91 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
92 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
93 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
94 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
95 |
Constructor. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
96 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
97 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
98 |
int ec_fsm_init(ec_fsm_t *fsm, /**< finite state machine */ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
99 |
ec_master_t *master /**< EtherCAT master */ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
100 |
) |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
101 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
102 |
fsm->master = master; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
103 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
104 |
fsm->master_slaves_responding = 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
105 |
fsm->master_slave_states = EC_SLAVE_STATE_UNKNOWN; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
106 |
fsm->master_validation = 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
107 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
108 |
ec_datagram_init(&fsm->datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
109 |
if (ec_datagram_prealloc(&fsm->datagram, EC_MAX_DATA_SIZE)) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
110 |
EC_ERR("Failed to allocate FSM datagram.\n"); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
111 |
return -1; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
112 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
113 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
114 |
return 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
115 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
116 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
117 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
118 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
119 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
120 |
Destructor. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
121 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
122 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
123 |
void ec_fsm_clear(ec_fsm_t *fsm /**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
124 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
125 |
ec_datagram_clear(&fsm->datagram); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
126 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
127 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
128 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
129 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
130 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
131 |
Resets the state machine. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
132 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
133 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
134 |
void ec_fsm_reset(ec_fsm_t *fsm /**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
135 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
136 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
137 |
fsm->master_slaves_responding = 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
138 |
fsm->master_slave_states = EC_SLAVE_STATE_UNKNOWN; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
139 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
140 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
141 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
142 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
143 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
144 |
Executes the current state of the state machine. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
145 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
146 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
147 |
void ec_fsm_execute(ec_fsm_t *fsm /**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
148 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
149 |
fsm->master_state(fsm); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
150 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
151 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
152 |
/****************************************************************************** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
153 |
* master state machine |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
154 |
*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
155 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
156 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
157 |
Master state: START. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
158 |
Starts with getting slave count and slave states. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
159 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
160 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
161 |
void ec_fsm_master_start(ec_fsm_t *fsm) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
162 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
163 |
ec_datagram_brd(&fsm->datagram, 0x0130, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
164 |
ec_master_queue_datagram(fsm->master, &fsm->datagram); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
165 |
fsm->master_state = ec_fsm_master_broadcast; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
166 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
167 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
168 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
169 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
170 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
171 |
Master state: BROADCAST. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
172 |
Processes the broadcast read slave count and slaves states. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
173 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
174 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
175 |
void ec_fsm_master_broadcast(ec_fsm_t *fsm /**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
176 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
177 |
ec_datagram_t *datagram = &fsm->datagram; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
178 |
unsigned int topology_change, states_change, i; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
179 |
ec_slave_t *slave; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
180 |
ec_master_t *master = fsm->master; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
181 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
182 |
if (datagram->state != EC_CMD_RECEIVED) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
183 |
if (!master->device->link_state) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
184 |
fsm->master_slaves_responding = 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
185 |
list_for_each_entry(slave, &master->slaves, list) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
186 |
slave->online = 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
187 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
188 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
189 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
190 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
191 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
192 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
193 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
194 |
topology_change = (datagram->working_counter != |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
195 |
fsm->master_slaves_responding); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
196 |
states_change = (EC_READ_U8(datagram->data) != fsm->master_slave_states); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
197 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
198 |
fsm->master_slave_states = EC_READ_U8(datagram->data); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
199 |
fsm->master_slaves_responding = datagram->working_counter; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
200 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
201 |
if (topology_change) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
202 |
EC_INFO("%i slave%s responding.\n", |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
203 |
fsm->master_slaves_responding, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
204 |
fsm->master_slaves_responding == 1 ? "" : "s"); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
205 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
206 |
if (master->mode == EC_MASTER_MODE_RUNNING) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
207 |
if (fsm->master_slaves_responding == master->slave_count) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
208 |
fsm->master_validation = 1; // start validation later |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
209 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
210 |
else { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
211 |
EC_WARN("Invalid slave count. Bus in tainted state.\n"); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
212 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
213 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
214 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
215 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
216 |
if (states_change) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
217 |
EC_INFO("Slave states: "); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
218 |
ec_print_states(fsm->master_slave_states); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
219 |
printk(".\n"); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
220 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
221 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
222 |
// topology change in idle mode: clear all slaves and scan the bus |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
223 |
if (topology_change && master->mode == EC_MASTER_MODE_IDLE) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
224 |
EC_INFO("Scanning bus.\n"); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
225 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
226 |
ec_master_eoe_stop(master); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
227 |
ec_master_clear_slaves(master); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
228 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
229 |
if (!fsm->master_slaves_responding) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
230 |
// no slaves present -> finish state machine. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
231 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
232 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
233 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
234 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
235 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
236 |
// init slaves |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
237 |
for (i = 0; i < fsm->master_slaves_responding; i++) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
238 |
if (!(slave = (ec_slave_t *) kmalloc(sizeof(ec_slave_t), |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
239 |
GFP_ATOMIC))) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
240 |
EC_ERR("Failed to allocate slave %i!\n", i); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
241 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
242 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
243 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
244 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
245 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
246 |
if (ec_slave_init(slave, master, i, i + 1)) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
247 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
248 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
249 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
250 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
251 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
252 |
if (kobject_add(&slave->kobj)) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
253 |
EC_ERR("Failed to add kobject.\n"); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
254 |
kobject_put(&slave->kobj); // free |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
255 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
256 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
257 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
258 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
259 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
260 |
list_add_tail(&slave->list, &master->slaves); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
261 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
262 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
263 |
// begin scanning of slaves |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
264 |
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
265 |
fsm->slave_state = ec_fsm_slavescan_start; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
266 |
fsm->master_state = ec_fsm_master_scan_slaves; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
267 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
268 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
269 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
270 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
271 |
// fetch state from each slave |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
272 |
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
273 |
ec_datagram_nprd(&fsm->datagram, fsm->slave->station_address, 0x0130, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
274 |
ec_master_queue_datagram(master, &fsm->datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
275 |
fsm->master_state = ec_fsm_master_read_states; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
276 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
277 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
278 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
279 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
280 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
281 |
Master action: PROC_STATES. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
282 |
Processes the slave states. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
283 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
284 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
285 |
void ec_fsm_master_action_process_states(ec_fsm_t *fsm |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
286 |
/**< finite state machine */ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
287 |
) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
288 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
289 |
ec_master_t *master = fsm->master; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
290 |
ec_slave_t *slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
291 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
292 |
// check if any slaves are not in the state, they're supposed to be |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
293 |
list_for_each_entry(slave, &master->slaves, list) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
294 |
if (slave->error_flag || |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
295 |
!slave->online || |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
296 |
slave->requested_state == EC_SLAVE_STATE_UNKNOWN || |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
297 |
slave->current_state == slave->requested_state) continue; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
298 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
299 |
EC_INFO("Changing state of slave %i from ", slave->ring_position); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
300 |
ec_print_states(slave->current_state); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
301 |
printk(" to "); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
302 |
ec_print_states(slave->requested_state); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
303 |
printk(".\n"); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
304 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
305 |
fsm->slave = slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
306 |
fsm->slave_state = ec_fsm_slaveconf_init; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
307 |
fsm->change_new = EC_SLAVE_STATE_INIT; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
308 |
fsm->change_state = ec_fsm_change_start; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
309 |
fsm->master_state = ec_fsm_master_configure_slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
310 |
fsm->master_state(fsm); // execute immediately |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
311 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
312 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
313 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
314 |
if (master->mode == EC_MASTER_MODE_IDLE) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
315 |
// nothing to configure. check for pending EEPROM write operations. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
316 |
list_for_each_entry(slave, &master->slaves, list) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
317 |
if (!slave->new_eeprom_data) continue; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
318 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
319 |
if (!slave->online || slave->error_flag) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
320 |
kfree(slave->new_eeprom_data); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
321 |
slave->new_eeprom_data = NULL; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
322 |
EC_ERR("Discarding EEPROM data, slave %i not ready.\n", |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
323 |
slave->ring_position); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
324 |
continue; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
325 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
326 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
327 |
// found pending EEPROM write operation. execute it! |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
328 |
EC_INFO("Writing EEPROM of slave %i...\n", slave->ring_position); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
329 |
fsm->sii_offset = 0x0000; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
330 |
memcpy(fsm->sii_value, slave->new_eeprom_data, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
331 |
fsm->sii_mode = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
332 |
fsm->sii_state = ec_fsm_sii_start_writing; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
333 |
fsm->slave = slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
334 |
fsm->master_state = ec_fsm_master_write_eeprom; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
335 |
fsm->master_state(fsm); // execute immediately |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
336 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
337 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
338 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
339 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
340 |
// nothing to do. restart master state machine. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
341 |
fsm->master_state = ec_fsm_master_start; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
342 |
fsm->master_state(fsm); // execute immediately |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
343 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
344 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
345 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
346 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
347 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
348 |
Master action: Get state of next slave. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
349 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
350 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
351 |
void ec_fsm_master_action_next_slave_state(ec_fsm_t *fsm |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
352 |
/**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
353 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
354 |
ec_master_t *master = fsm->master; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
355 |
ec_slave_t *slave = fsm->slave; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
356 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
357 |
// is there another slave to query? |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
358 |
if (slave->list.next != &master->slaves) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
359 |
// process next slave |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
360 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
361 |
ec_datagram_nprd(&fsm->datagram, fsm->slave->station_address, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
362 |
0x0130, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
363 |
ec_master_queue_datagram(master, &fsm->datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
364 |
fsm->master_state = ec_fsm_master_read_states; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
365 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
366 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
367 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
368 |
// all slave states read |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
369 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
370 |
// check, if a bus validation has to be done |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
371 |
if (fsm->master_validation) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
372 |
fsm->master_validation = 0; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
373 |
list_for_each_entry(slave, &master->slaves, list) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
374 |
if (slave->online) continue; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
375 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
376 |
// At least one slave is offline. validate! |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
377 |
EC_INFO("Validating bus.\n"); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
378 |
fsm->slave = list_entry(master->slaves.next, ec_slave_t, list); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
379 |
fsm->master_state = ec_fsm_master_validate_vendor; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
380 |
fsm->sii_offset = 0x0008; // vendor ID |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
381 |
fsm->sii_mode = 0; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
382 |
fsm->sii_state = ec_fsm_sii_start_reading; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
383 |
fsm->sii_state(fsm); // execute immediately |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
384 |
return; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
385 |
} |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
386 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
387 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
388 |
ec_fsm_master_action_process_states(fsm); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
389 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
390 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
391 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
392 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
393 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
394 |
Master state: STATES. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
395 |
Fetches the AL- and online state of a slave. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
396 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
397 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
398 |
void ec_fsm_master_read_states(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
399 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
400 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
401 |
ec_datagram_t *datagram = &fsm->datagram; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
402 |
uint8_t new_state; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
403 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
404 |
if (datagram->state != EC_CMD_RECEIVED) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
405 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
406 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
407 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
408 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
409 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
410 |
// did the slave not respond to its station address? |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
411 |
if (datagram->working_counter != 1) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
412 |
if (slave->online) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
413 |
slave->online = 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
414 |
EC_INFO("Slave %i: offline.\n", slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
415 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
416 |
ec_fsm_master_action_next_slave_state(fsm); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
417 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
418 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
419 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
420 |
// slave responded |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
421 |
new_state = EC_READ_U8(datagram->data); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
422 |
if (!slave->online) { // slave was offline before |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
423 |
slave->online = 1; |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
424 |
slave->error_flag = 0; // clear error flag |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
425 |
slave->current_state = new_state; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
426 |
EC_INFO("Slave %i: online (", slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
427 |
ec_print_states(new_state); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
428 |
printk(").\n"); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
429 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
430 |
else if (new_state != slave->current_state) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
431 |
EC_INFO("Slave %i: ", slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
432 |
ec_print_states(slave->current_state); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
433 |
printk(" -> "); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
434 |
ec_print_states(new_state); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
435 |
printk(".\n"); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
436 |
slave->current_state = new_state; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
437 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
438 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
439 |
ec_fsm_master_action_next_slave_state(fsm); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
440 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
441 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
442 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
443 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
444 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
445 |
Master state: VALIDATE_VENDOR. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
446 |
Validates the vendor ID of a slave. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
447 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
448 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
449 |
void ec_fsm_master_validate_vendor(ec_fsm_t *fsm /**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
450 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
451 |
ec_slave_t *slave = fsm->slave; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
452 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
453 |
fsm->sii_state(fsm); // execute SII state machine |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
454 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
455 |
if (fsm->sii_state == ec_fsm_sii_error) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
456 |
fsm->slave->error_flag = 1; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
457 |
EC_ERR("Failed to validate vendor ID of slave %i.\n", |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
458 |
slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
459 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
460 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
461 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
462 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
463 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
464 |
if (fsm->sii_state != ec_fsm_sii_end) return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
465 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
466 |
if (EC_READ_U32(fsm->sii_value) != slave->sii_vendor_id) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
467 |
EC_ERR("Slave %i: invalid vendor ID!\n", slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
468 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
469 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
470 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
471 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
472 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
473 |
// vendor ID is ok. check product code. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
474 |
fsm->master_state = ec_fsm_master_validate_product; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
475 |
fsm->sii_offset = 0x000A; // product code |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
476 |
fsm->sii_mode = 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
477 |
fsm->sii_state = ec_fsm_sii_start_reading; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
478 |
fsm->sii_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
479 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
480 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
481 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
482 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
483 |
/** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
484 |
Master action: ADDRESS. |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
485 |
Looks for slave, that have lost their configuration and writes |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
486 |
their station address, so that they can be reconfigured later. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
487 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
488 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
489 |
void ec_fsm_master_action_addresses(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
490 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
491 |
ec_datagram_t *datagram = &fsm->datagram; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
492 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
493 |
while (fsm->slave->online) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
494 |
if (fsm->slave->list.next == &fsm->master->slaves) { // last slave? |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
495 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
496 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
497 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
498 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
499 |
// check next slave |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
500 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
501 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
502 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
503 |
EC_INFO("Reinitializing slave %i.\n", fsm->slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
504 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
505 |
// write station address |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
506 |
ec_datagram_apwr(datagram, fsm->slave->ring_position, 0x0010, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
507 |
EC_WRITE_U16(datagram->data, fsm->slave->station_address); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
508 |
ec_master_queue_datagram(fsm->master, datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
509 |
fsm->master_state = ec_fsm_master_rewrite_addresses; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
510 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
511 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
512 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
513 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
514 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
515 |
Master state: VALIDATE_PRODUCT. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
516 |
Validates the product ID of a slave. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
517 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
518 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
519 |
void ec_fsm_master_validate_product(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
520 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
521 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
522 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
523 |
fsm->sii_state(fsm); // execute SII state machine |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
524 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
525 |
if (fsm->sii_state == ec_fsm_sii_error) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
526 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
527 |
EC_ERR("Failed to validate product code of slave %i.\n", |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
528 |
slave->ring_position); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
529 |
fsm->master_state = ec_fsm_master_start; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
530 |
fsm->master_state(fsm); // execute immediately |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
531 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
532 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
533 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
534 |
if (fsm->sii_state != ec_fsm_sii_end) return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
535 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
536 |
if (EC_READ_U32(fsm->sii_value) != slave->sii_product_code) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
537 |
EC_ERR("Slave %i: invalid product code!\n", slave->ring_position); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
538 |
EC_ERR("expected 0x%08X, got 0x%08X.\n", slave->sii_product_code, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
539 |
EC_READ_U32(fsm->sii_value)); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
540 |
fsm->master_state = ec_fsm_master_start; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
541 |
fsm->master_state(fsm); // execute immediately |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
542 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
543 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
544 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
545 |
// have all states been validated? |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
546 |
if (slave->list.next == &fsm->master->slaves) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
547 |
fsm->slave = list_entry(fsm->master->slaves.next, ec_slave_t, list); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
548 |
// start writing addresses to offline slaves |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
549 |
ec_fsm_master_action_addresses(fsm); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
550 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
551 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
552 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
553 |
// validate next slave |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
554 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
555 |
fsm->master_state = ec_fsm_master_validate_vendor; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
556 |
fsm->sii_offset = 0x0008; // vendor ID |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
557 |
fsm->sii_mode = 0; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
558 |
fsm->sii_state = ec_fsm_sii_start_reading; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
559 |
fsm->sii_state(fsm); // execute immediately |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
560 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
561 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
562 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
563 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
564 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
565 |
Master state: ADDRESS. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
566 |
Checks, if the new station address has been written to the slave. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
567 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
568 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
569 |
void ec_fsm_master_rewrite_addresses(ec_fsm_t *fsm |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
570 |
/**< finite state machine */ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
571 |
) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
572 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
573 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
574 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
575 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
576 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
577 |
EC_ERR("Failed to write station address on slave %i.\n", |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
578 |
slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
579 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
580 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
581 |
if (fsm->slave->list.next == &fsm->master->slaves) { // last slave? |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
582 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
583 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
584 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
585 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
586 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
587 |
// check next slave |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
588 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
589 |
// Write new station address to slave |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
590 |
ec_fsm_master_action_addresses(fsm); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
591 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
592 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
593 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
594 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
595 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
596 |
Master state: SCAN. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
597 |
Executes the sub-statemachine for the scanning of a slave. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
598 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
599 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
600 |
void ec_fsm_master_scan_slaves(ec_fsm_t *fsm /**< finite state machine */) |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
601 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
602 |
ec_master_t *master = fsm->master; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
603 |
ec_slave_t *slave = fsm->slave; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
604 |
uint16_t coupler_index, coupler_subindex; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
605 |
uint16_t reverse_coupler_index, current_coupler_index; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
606 |
ec_slave_ident_t *ident; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
607 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
608 |
fsm->slave_state(fsm); // execute slave state machine |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
609 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
610 |
if (fsm->slave_state != ec_fsm_slavescan_end) return; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
611 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
612 |
// have all slaves been fetched? |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
613 |
if (slave->list.next == &master->slaves) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
614 |
EC_INFO("Bus scanning completed.\n"); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
615 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
616 |
// identify all slaves and calculate coupler addressing |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
617 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
618 |
coupler_index = 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
619 |
reverse_coupler_index = 0xFFFF; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
620 |
current_coupler_index = 0x3FFF; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
621 |
coupler_subindex = 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
622 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
623 |
list_for_each_entry(slave, &master->slaves, list) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
624 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
625 |
// search for identification in "database" |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
626 |
ident = slave_idents; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
627 |
while (ident->type) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
628 |
if (ident->vendor_id == slave->sii_vendor_id |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
629 |
&& ident->product_code == slave->sii_product_code) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
630 |
slave->type = ident->type; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
631 |
break; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
632 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
633 |
ident++; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
634 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
635 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
636 |
if (!slave->type) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
637 |
EC_WARN("Unknown slave device (vendor 0x%08X," |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
638 |
" code 0x%08X) at position %i.\n", |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
639 |
slave->sii_vendor_id, slave->sii_product_code, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
640 |
slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
641 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
642 |
else { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
643 |
// if the slave is a bus coupler, change adressing base |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
644 |
if (slave->type->special == EC_TYPE_BUS_COUPLER) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
645 |
if (slave->sii_alias) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
646 |
current_coupler_index = reverse_coupler_index--; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
647 |
else |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
648 |
current_coupler_index = coupler_index++; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
649 |
coupler_subindex = 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
650 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
651 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
652 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
653 |
// determine initial state. |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
654 |
if ((slave->type && |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
655 |
(slave->type->special == EC_TYPE_BUS_COUPLER || |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
656 |
slave->type->special == EC_TYPE_INFRA))) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
657 |
slave->requested_state = EC_SLAVE_STATE_OP; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
658 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
659 |
else { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
660 |
if (master->mode == EC_MASTER_MODE_RUNNING) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
661 |
slave->requested_state = EC_SLAVE_STATE_PREOP; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
662 |
else |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
663 |
slave->requested_state = EC_SLAVE_STATE_INIT; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
664 |
} |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
665 |
slave->error_flag = 0; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
666 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
667 |
// calculate coupler-based slave address |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
668 |
slave->coupler_index = current_coupler_index; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
669 |
slave->coupler_subindex = coupler_subindex; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
670 |
coupler_subindex++; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
671 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
672 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
673 |
if (master->mode == EC_MASTER_MODE_IDLE) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
674 |
// start EoE processing |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
675 |
ec_master_eoe_start(master); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
676 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
677 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
678 |
fsm->master_state = ec_fsm_master_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
679 |
fsm->master_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
680 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
681 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
682 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
683 |
// process next slave |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
684 |
fsm->slave = list_entry(fsm->slave->list.next, ec_slave_t, list); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
685 |
fsm->slave_state = ec_fsm_slavescan_start; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
686 |
fsm->slave_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
687 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
688 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
689 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
690 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
691 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
692 |
Master state: CONF. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
693 |
Starts configuring a slave. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
694 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
695 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
696 |
void ec_fsm_master_configure_slave(ec_fsm_t *fsm |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
697 |
/**< finite state machine */ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
698 |
) |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
699 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
700 |
fsm->slave_state(fsm); // execute slave's state machine |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
701 |
if (fsm->slave_state != ec_fsm_slaveconf_end) return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
702 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
703 |
ec_fsm_master_action_process_states(fsm); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
704 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
705 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
706 |
/*****************************************************************************/ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
707 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
708 |
/** |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
709 |
Master state: EEPROM. |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
710 |
*/ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
711 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
712 |
void ec_fsm_master_write_eeprom(ec_fsm_t *fsm /**< finite state machine */) |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
713 |
{ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
714 |
ec_slave_t *slave = fsm->slave; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
715 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
716 |
fsm->sii_state(fsm); // execute SII state machine |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
717 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
718 |
if (fsm->sii_state == ec_fsm_sii_error) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
719 |
fsm->slave->error_flag = 1; |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
720 |
EC_ERR("Failed to write EEPROM contents to slave %i.\n", |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
721 |
slave->ring_position); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
722 |
kfree(slave->new_eeprom_data); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
723 |
slave->new_eeprom_data = NULL; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
724 |
fsm->master_state = ec_fsm_master_start; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
725 |
fsm->master_state(fsm); // execute immediately |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
726 |
return; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
727 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
728 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
729 |
if (fsm->sii_state != ec_fsm_sii_end) return; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
730 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
731 |
fsm->sii_offset++; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
732 |
if (fsm->sii_offset < slave->new_eeprom_size) { |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
733 |
memcpy(fsm->sii_value, slave->new_eeprom_data + fsm->sii_offset, 2); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
734 |
fsm->sii_state = ec_fsm_sii_start_writing; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
735 |
fsm->sii_state(fsm); // execute immediately |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
736 |
return; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
737 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
738 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
739 |
// finished writing EEPROM |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
740 |
EC_INFO("Finished writing EEPROM of slave %i.\n", slave->ring_position); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
741 |
kfree(slave->new_eeprom_data); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
742 |
slave->new_eeprom_data = NULL; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
743 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
744 |
// restart master state machine. |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
745 |
fsm->master_state = ec_fsm_master_start; // TODO: Evaluate new contents! |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
746 |
fsm->master_state(fsm); // execute immediately |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
747 |
return; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
748 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
749 |
|
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
750 |
/****************************************************************************** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
751 |
* slave scan sub state machine |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
752 |
*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
753 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
754 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
755 |
Slave state: START_READING. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
756 |
First state of the slave state machine. Writes the station address to the |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
757 |
slave, according to its ring position. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
758 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
759 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
760 |
void ec_fsm_slavescan_start(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
761 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
762 |
ec_datagram_t *datagram = &fsm->datagram; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
763 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
764 |
// write station address |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
765 |
ec_datagram_apwr(datagram, fsm->slave->ring_position, 0x0010, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
766 |
EC_WRITE_U16(datagram->data, fsm->slave->station_address); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
767 |
ec_master_queue_datagram(fsm->master, datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
768 |
fsm->slave_state = ec_fsm_slavescan_address; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
769 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
770 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
771 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
772 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
773 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
774 |
Slave state: ADDRESS. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
775 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
776 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
777 |
void ec_fsm_slavescan_address(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
778 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
779 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
780 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
781 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
782 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
783 |
fsm->slave_state = ec_fsm_slavescan_end; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
784 |
EC_ERR("Failed to write station address of slave %i.\n", |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
785 |
fsm->slave->ring_position); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
786 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
787 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
788 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
789 |
// Read AL state |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
790 |
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x0130, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
791 |
ec_master_queue_datagram(fsm->master, datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
792 |
fsm->slave_state = ec_fsm_slavescan_state; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
793 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
794 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
795 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
796 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
797 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
798 |
Slave state: STATE. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
799 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
800 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
801 |
void ec_fsm_slavescan_state(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
802 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
803 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
804 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
805 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
806 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
807 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
808 |
fsm->slave_state = ec_fsm_slavescan_end; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
809 |
EC_ERR("Failed to read AL state of slave %i.\n", |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
810 |
fsm->slave->ring_position); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
811 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
812 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
813 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
814 |
slave->current_state = EC_READ_U8(datagram->data); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
815 |
if (slave->current_state & EC_ACK) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
816 |
EC_WARN("Slave %i has state error bit set (0x%02X)!\n", |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
817 |
slave->ring_position, slave->current_state); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
818 |
slave->current_state &= 0x0F; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
819 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
820 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
821 |
// read base data |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
822 |
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x0000, 6); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
823 |
ec_master_queue_datagram(fsm->master, datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
824 |
fsm->slave_state = ec_fsm_slavescan_base; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
825 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
826 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
827 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
828 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
829 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
830 |
Slave state: BASE. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
831 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
832 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
833 |
void ec_fsm_slavescan_base(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
834 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
835 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
836 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
837 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
838 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
839 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
840 |
fsm->slave_state = ec_fsm_slavescan_end; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
841 |
EC_ERR("Failed to read base data of slave %i.\n", |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
842 |
slave->ring_position); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
843 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
844 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
845 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
846 |
slave->base_type = EC_READ_U8 (datagram->data); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
847 |
slave->base_revision = EC_READ_U8 (datagram->data + 1); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
848 |
slave->base_build = EC_READ_U16(datagram->data + 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
849 |
slave->base_fmmu_count = EC_READ_U8 (datagram->data + 4); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
850 |
slave->base_sync_count = EC_READ_U8 (datagram->data + 5); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
851 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
852 |
if (slave->base_fmmu_count > EC_MAX_FMMUS) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
853 |
slave->base_fmmu_count = EC_MAX_FMMUS; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
854 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
855 |
// read data link status |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
856 |
ec_datagram_nprd(datagram, slave->station_address, 0x0110, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
857 |
ec_master_queue_datagram(slave->master, datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
858 |
fsm->slave_state = ec_fsm_slavescan_datalink; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
859 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
860 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
861 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
862 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
863 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
864 |
Slave state: DATALINK. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
865 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
866 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
867 |
void ec_fsm_slavescan_datalink(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
868 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
869 |
ec_datagram_t *datagram = &fsm->datagram; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
870 |
ec_slave_t *slave = fsm->slave; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
871 |
uint16_t dl_status; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
872 |
unsigned int i; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
873 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
874 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
875 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
876 |
fsm->slave_state = ec_fsm_slavescan_end; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
877 |
EC_ERR("Failed to read DL status of slave %i.\n", |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
878 |
slave->ring_position); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
879 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
880 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
881 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
882 |
dl_status = EC_READ_U16(datagram->data); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
883 |
for (i = 0; i < 4; i++) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
884 |
slave->dl_link[i] = dl_status & (1 << (4 + i)) ? 1 : 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
885 |
slave->dl_loop[i] = dl_status & (1 << (8 + i * 2)) ? 1 : 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
886 |
slave->dl_signal[i] = dl_status & (1 << (9 + i * 2)) ? 1 : 0; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
887 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
888 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
889 |
// Start fetching EEPROM size |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
890 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
891 |
fsm->sii_offset = 0x0040; // first category header |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
892 |
fsm->sii_mode = 1; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
893 |
fsm->sii_state = ec_fsm_sii_start_reading; |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
894 |
fsm->slave_state = ec_fsm_slavescan_eeprom_size; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
895 |
fsm->slave_state(fsm); // execute state immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
896 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
897 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
898 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
899 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
900 |
/** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
901 |
Slave state: EEPROM_SIZE. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
902 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
903 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
904 |
void ec_fsm_slavescan_eeprom_size(ec_fsm_t *fsm /**< finite state machine */) |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
905 |
{ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
906 |
ec_slave_t *slave = fsm->slave; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
907 |
uint16_t cat_type, cat_size; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
908 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
909 |
// execute SII state machine |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
910 |
fsm->sii_state(fsm); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
911 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
912 |
if (fsm->sii_state == ec_fsm_sii_error) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
913 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
914 |
fsm->slave_state = ec_fsm_slavescan_end; |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
915 |
EC_ERR("Failed to read EEPROM size of slave %i.\n", |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
916 |
slave->ring_position); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
917 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
918 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
919 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
920 |
if (fsm->sii_state != ec_fsm_sii_end) return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
921 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
922 |
cat_type = EC_READ_U16(fsm->sii_value); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
923 |
cat_size = EC_READ_U16(fsm->sii_value + 2); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
924 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
925 |
if (cat_type != 0xFFFF) { // not the last category |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
926 |
fsm->sii_offset += cat_size + 2; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
927 |
fsm->sii_state = ec_fsm_sii_start_reading; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
928 |
fsm->sii_state(fsm); // execute state immediately |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
929 |
return; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
930 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
931 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
932 |
slave->eeprom_size = (fsm->sii_offset + 1) * 2; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
933 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
934 |
if (slave->eeprom_data) { |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
935 |
EC_INFO("Freeing old EEPROM data on slave %i...\n", |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
936 |
slave->ring_position); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
937 |
kfree(slave->eeprom_data); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
938 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
939 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
940 |
if (!(slave->eeprom_data = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
941 |
(uint8_t *) kmalloc(slave->eeprom_size, GFP_ATOMIC))) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
942 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
943 |
fsm->slave_state = ec_fsm_slavescan_end; |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
944 |
EC_ERR("Failed to allocate EEPROM data on slave %i.\n", |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
945 |
slave->ring_position); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
946 |
return; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
947 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
948 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
949 |
// Start fetching EEPROM contents |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
950 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
951 |
fsm->sii_offset = 0x0000; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
952 |
fsm->sii_mode = 1; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
953 |
fsm->sii_state = ec_fsm_sii_start_reading; |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
954 |
fsm->slave_state = ec_fsm_slavescan_eeprom_data; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
955 |
fsm->slave_state(fsm); // execute state immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
956 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
957 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
958 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
959 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
960 |
/** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
961 |
Slave state: EEPROM_DATA. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
962 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
963 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
964 |
void ec_fsm_slavescan_eeprom_data(ec_fsm_t *fsm /**< finite state machine */) |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
965 |
{ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
966 |
ec_slave_t *slave = fsm->slave; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
967 |
uint16_t *cat_word, cat_type, cat_size; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
968 |
|
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
969 |
// execute SII state machine |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
970 |
fsm->sii_state(fsm); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
971 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
972 |
if (fsm->sii_state == ec_fsm_sii_error) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
973 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
974 |
fsm->slave_state = ec_fsm_slavescan_end; |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
975 |
EC_ERR("Failed to fetch EEPROM contents of slave %i.\n", |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
976 |
slave->ring_position); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
977 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
978 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
979 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
980 |
if (fsm->sii_state != ec_fsm_sii_end) return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
981 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
982 |
// 2 words fetched |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
983 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
984 |
if (fsm->sii_offset + 2 <= slave->eeprom_size / 2) { // 2 words fit |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
985 |
memcpy(slave->eeprom_data + fsm->sii_offset * 2, fsm->sii_value, 4); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
986 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
987 |
else { // copy the last word |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
988 |
memcpy(slave->eeprom_data + fsm->sii_offset * 2, fsm->sii_value, 2); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
989 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
990 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
991 |
if (fsm->sii_offset + 2 < slave->eeprom_size / 2) { |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
992 |
// fetch the next 2 words |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
993 |
fsm->sii_offset += 2; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
994 |
fsm->sii_state = ec_fsm_sii_start_reading; |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
995 |
fsm->sii_state(fsm); // execute state immediately |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
996 |
return; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
997 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
998 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
999 |
// Evaluate EEPROM contents |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1000 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1001 |
slave->sii_alias = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1002 |
EC_READ_U16(slave->eeprom_data + 2 * 0x0004); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1003 |
slave->sii_vendor_id = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1004 |
EC_READ_U32(slave->eeprom_data + 2 * 0x0008); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1005 |
slave->sii_product_code = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1006 |
EC_READ_U32(slave->eeprom_data + 2 * 0x000A); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1007 |
slave->sii_revision_number = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1008 |
EC_READ_U32(slave->eeprom_data + 2 * 0x000C); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1009 |
slave->sii_serial_number = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1010 |
EC_READ_U32(slave->eeprom_data + 2 * 0x000E); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1011 |
slave->sii_rx_mailbox_offset = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1012 |
EC_READ_U16(slave->eeprom_data + 2 * 0x0018); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1013 |
slave->sii_rx_mailbox_size = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1014 |
EC_READ_U16(slave->eeprom_data + 2 * 0x0019); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1015 |
slave->sii_tx_mailbox_offset = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1016 |
EC_READ_U16(slave->eeprom_data + 2 * 0x001A); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1017 |
slave->sii_tx_mailbox_size = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1018 |
EC_READ_U16(slave->eeprom_data + 2 * 0x001B); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1019 |
slave->sii_mailbox_protocols = |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1020 |
EC_READ_U16(slave->eeprom_data + 2 * 0x001C); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1021 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1022 |
// evaluate category data |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1023 |
cat_word = (uint16_t *) slave->eeprom_data + 0x0040; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1024 |
while (EC_READ_U16(cat_word) != 0xFFFF) { |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1025 |
cat_type = EC_READ_U16(cat_word) & 0x7FFF; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1026 |
cat_size = EC_READ_U16(cat_word + 1); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1027 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1028 |
switch (cat_type) { |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1029 |
case 0x000A: |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1030 |
if (ec_slave_fetch_strings(slave, (uint8_t *) (cat_word + 2))) |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1031 |
goto end; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1032 |
break; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1033 |
case 0x001E: |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1034 |
if (ec_slave_fetch_general(slave, (uint8_t *) (cat_word + 2))) |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1035 |
goto end; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1036 |
break; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1037 |
case 0x0028: |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1038 |
break; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1039 |
case 0x0029: |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1040 |
if (ec_slave_fetch_sync(slave, (uint8_t *) (cat_word + 2), |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1041 |
cat_size)) |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1042 |
goto end; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1043 |
break; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1044 |
case 0x0032: |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1045 |
if (ec_slave_fetch_pdo(slave, (uint8_t *) (cat_word + 2), |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1046 |
cat_size, EC_TX_PDO)) |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1047 |
goto end; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1048 |
break; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1049 |
case 0x0033: |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1050 |
if (ec_slave_fetch_pdo(slave, (uint8_t *) (cat_word + 2), |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1051 |
cat_size, EC_RX_PDO)) |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1052 |
goto end; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1053 |
break; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1054 |
default: |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1055 |
EC_WARN("Unknown category type 0x%04X in slave %i.\n", |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1056 |
cat_type, slave->ring_position); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1057 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1058 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1059 |
cat_word += cat_size + 2; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1060 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1061 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1062 |
fsm->slave_state = ec_fsm_slavescan_end; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1063 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1064 |
end: |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1065 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1066 |
fsm->slave_state = ec_fsm_slavescan_end; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1067 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1068 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1069 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1070 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1071 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1072 |
Slave state: END. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1073 |
End state of the slave state machine. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1074 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1075 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1076 |
void ec_fsm_slavescan_end(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1077 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1078 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1079 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1080 |
/****************************************************************************** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1081 |
* slave configuration sub state machine |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1082 |
*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1083 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1084 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1085 |
Slave state: INIT. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1086 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1087 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1088 |
void ec_fsm_slaveconf_init(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1089 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1090 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1091 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1092 |
const ec_sync_t *sync; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1093 |
ec_eeprom_sync_t *eeprom_sync, mbox_sync; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1094 |
unsigned int j; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1095 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1096 |
fsm->change_state(fsm); // execute state change state machine |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1097 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1098 |
if (fsm->change_state == ec_fsm_change_error) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1099 |
slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1100 |
fsm->slave_state = ec_fsm_slaveconf_end; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1101 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1102 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1103 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1104 |
if (fsm->change_state != ec_fsm_change_end) return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1105 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1106 |
// slave is now in INIT |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1107 |
if (slave->current_state == slave->requested_state) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1108 |
fsm->slave_state = ec_fsm_slaveconf_end; // successful |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1109 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1110 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1111 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1112 |
// check for slave registration |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1113 |
if (!slave->type) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1114 |
EC_WARN("Slave %i has unknown type!\n", slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1115 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1116 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1117 |
// check and reset CRC fault counters |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1118 |
//ec_slave_check_crc(slave); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1119 |
// TODO! |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1120 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1121 |
if (!slave->base_sync_count) { // no sync managers |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1122 |
fsm->slave_state = ec_fsm_slaveconf_preop; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1123 |
fsm->change_new = EC_SLAVE_STATE_PREOP; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1124 |
fsm->change_state = ec_fsm_change_start; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1125 |
fsm->change_state(fsm); // execute immediately |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1126 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1127 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1128 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1129 |
// configure sync managers |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1130 |
ec_datagram_npwr(datagram, slave->station_address, 0x0800, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1131 |
EC_SYNC_SIZE * slave->base_sync_count); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1132 |
memset(datagram->data, 0x00, EC_SYNC_SIZE * slave->base_sync_count); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1133 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1134 |
// does the slave supply sync manager configurations in its EEPROM? |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1135 |
if (!list_empty(&slave->eeprom_syncs)) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1136 |
list_for_each_entry(eeprom_sync, &slave->eeprom_syncs, list) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1137 |
if (eeprom_sync->index >= slave->base_sync_count) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1138 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1139 |
fsm->slave_state = ec_fsm_slaveconf_end; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1140 |
EC_ERR("Invalid sync manager configuration found!"); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1141 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1142 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1143 |
ec_eeprom_sync_config(eeprom_sync, slave, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1144 |
datagram->data + EC_SYNC_SIZE |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1145 |
* eeprom_sync->index); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1146 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1147 |
} |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1148 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1149 |
// known slave type, take type's SM information |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1150 |
else if (slave->type) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1151 |
for (j = 0; slave->type->sync_managers[j] && j < EC_MAX_SYNC; j++) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1152 |
sync = slave->type->sync_managers[j]; |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1153 |
ec_sync_config(sync, slave, datagram->data + EC_SYNC_SIZE * j); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1154 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1155 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1156 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1157 |
// unknown type, but slave has mailbox |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1158 |
else if (slave->sii_mailbox_protocols) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1159 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1160 |
// guess mailbox settings |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1161 |
mbox_sync.physical_start_address = |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1162 |
slave->sii_rx_mailbox_offset; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1163 |
mbox_sync.length = slave->sii_rx_mailbox_size; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1164 |
mbox_sync.control_register = 0x26; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1165 |
mbox_sync.enable = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1166 |
ec_eeprom_sync_config(&mbox_sync, slave, datagram->data); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1167 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1168 |
mbox_sync.physical_start_address = |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1169 |
slave->sii_tx_mailbox_offset; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1170 |
mbox_sync.length = slave->sii_tx_mailbox_size; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1171 |
mbox_sync.control_register = 0x22; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1172 |
mbox_sync.enable = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1173 |
ec_eeprom_sync_config(&mbox_sync, slave, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1174 |
datagram->data + EC_SYNC_SIZE); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1175 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1176 |
EC_INFO("Mailbox configured for unknown slave %i\n", |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1177 |
slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1178 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1179 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1180 |
ec_master_queue_datagram(fsm->master, datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1181 |
fsm->slave_state = ec_fsm_slaveconf_sync; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1182 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1183 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1184 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1185 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1186 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1187 |
Slave state: SYNC. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1188 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1189 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1190 |
void ec_fsm_slaveconf_sync(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1191 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1192 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1193 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1194 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1195 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1196 |
slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1197 |
fsm->slave_state = ec_fsm_slaveconf_end; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1198 |
EC_ERR("Failed to set sync managers on slave %i.\n", |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1199 |
slave->ring_position); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1200 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1201 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1202 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1203 |
fsm->slave_state = ec_fsm_slaveconf_preop; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1204 |
fsm->change_new = EC_SLAVE_STATE_PREOP; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1205 |
fsm->change_state = ec_fsm_change_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1206 |
fsm->change_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1207 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1208 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1209 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1210 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1211 |
/** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1212 |
Slave state: PREOP. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1213 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1214 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1215 |
void ec_fsm_slaveconf_preop(ec_fsm_t *fsm /**< finite state machine */) |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1216 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1217 |
ec_slave_t *slave = fsm->slave; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1218 |
ec_master_t *master = fsm->master; |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1219 |
ec_datagram_t *datagram = &fsm->datagram; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1220 |
unsigned int j; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1221 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1222 |
fsm->change_state(fsm); // execute state change state machine |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1223 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1224 |
if (fsm->change_state == ec_fsm_change_error) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1225 |
slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1226 |
fsm->slave_state = ec_fsm_slaveconf_end; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1227 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1228 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1229 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1230 |
if (fsm->change_state != ec_fsm_change_end) return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1231 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1232 |
// slave is now in PREOP |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1233 |
if (slave->current_state == slave->requested_state) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1234 |
fsm->slave_state = ec_fsm_slaveconf_end; // successful |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1235 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1236 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1237 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1238 |
// stop activation here for slaves without type |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1239 |
if (!slave->type) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1240 |
fsm->slave_state = ec_fsm_slaveconf_end; // successful |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1241 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1242 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1243 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1244 |
if (!slave->base_fmmu_count) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1245 |
fsm->slave_state = ec_fsm_slaveconf_saveop; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1246 |
fsm->change_new = EC_SLAVE_STATE_SAVEOP; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1247 |
fsm->change_state = ec_fsm_change_start; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1248 |
fsm->change_state(fsm); // execute immediately |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1249 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1250 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1251 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1252 |
// configure FMMUs |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1253 |
ec_datagram_npwr(datagram, slave->station_address, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1254 |
0x0600, EC_FMMU_SIZE * slave->base_fmmu_count); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1255 |
memset(datagram->data, 0x00, EC_FMMU_SIZE * slave->base_fmmu_count); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1256 |
for (j = 0; j < slave->fmmu_count; j++) { |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1257 |
ec_fmmu_config(&slave->fmmus[j], slave, |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1258 |
datagram->data + EC_FMMU_SIZE * j); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1259 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1260 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1261 |
ec_master_queue_datagram(master, datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1262 |
fsm->slave_state = ec_fsm_slaveconf_fmmu; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1263 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1264 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1265 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1266 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1267 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1268 |
Slave state: FMMU. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1269 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1270 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1271 |
void ec_fsm_slaveconf_fmmu(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1272 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1273 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1274 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1275 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1276 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1277 |
fsm->slave_state = ec_fsm_slaveconf_end; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1278 |
EC_ERR("Failed to set FMMUs on slave %i.\n", |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1279 |
fsm->slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1280 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1281 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1282 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1283 |
// set state to SAVEOP |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1284 |
fsm->slave_state = ec_fsm_slaveconf_saveop; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1285 |
fsm->change_new = EC_SLAVE_STATE_SAVEOP; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1286 |
fsm->change_state = ec_fsm_change_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1287 |
fsm->change_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1288 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1289 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1290 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1291 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1292 |
/** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1293 |
Slave state: SAVEOP. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1294 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1295 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1296 |
void ec_fsm_slaveconf_saveop(ec_fsm_t *fsm /**< finite state machine */) |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1297 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1298 |
fsm->change_state(fsm); // execute state change state machine |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1299 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1300 |
if (fsm->change_state == ec_fsm_change_error) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1301 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1302 |
fsm->slave_state = ec_fsm_slaveconf_end; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1303 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1304 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1305 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1306 |
if (fsm->change_state != ec_fsm_change_end) return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1307 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1308 |
// slave is now in SAVEOP |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1309 |
if (fsm->slave->current_state == fsm->slave->requested_state) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1310 |
fsm->slave_state = ec_fsm_slaveconf_end; // successful |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1311 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1312 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1313 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1314 |
// set state to OP |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1315 |
fsm->slave_state = ec_fsm_slaveconf_op; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1316 |
fsm->change_new = EC_SLAVE_STATE_OP; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1317 |
fsm->change_state = ec_fsm_change_start; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1318 |
fsm->change_state(fsm); // execute immediately |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1319 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1320 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1321 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1322 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1323 |
/** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1324 |
Slave state: OP |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1325 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1326 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1327 |
void ec_fsm_slaveconf_op(ec_fsm_t *fsm /**< finite state machine */) |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1328 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1329 |
fsm->change_state(fsm); // execute state change state machine |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1330 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1331 |
if (fsm->change_state == ec_fsm_change_error) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1332 |
fsm->slave->error_flag = 1; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1333 |
fsm->slave_state = ec_fsm_slaveconf_end; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1334 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1335 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1336 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1337 |
if (fsm->change_state != ec_fsm_change_end) return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1338 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1339 |
// slave is now in OP |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1340 |
fsm->slave_state = ec_fsm_slaveconf_end; // successful |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1341 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1342 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1343 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1344 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1345 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1346 |
Slave state: END. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1347 |
End state of the slave state machine. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1348 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1349 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1350 |
void ec_fsm_slaveconf_end(ec_fsm_t *fsm /**< finite state machine */) |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1351 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1352 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1353 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1354 |
/****************************************************************************** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1355 |
* SII sub state machine |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1356 |
*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1357 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1358 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1359 |
SII state: START_READING. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1360 |
Starts reading the slave information interface. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1361 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1362 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1363 |
void ec_fsm_sii_start_reading(ec_fsm_t *fsm /**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1364 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1365 |
ec_datagram_t *datagram = &fsm->datagram; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1366 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1367 |
// initiate read operation |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1368 |
if (fsm->sii_mode) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1369 |
ec_datagram_npwr(datagram, fsm->slave->station_address, 0x502, 4); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1370 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1371 |
else { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1372 |
ec_datagram_apwr(datagram, fsm->slave->ring_position, 0x502, 4); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1373 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1374 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1375 |
EC_WRITE_U8 (datagram->data, 0x00); // read-only access |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1376 |
EC_WRITE_U8 (datagram->data + 1, 0x01); // request read operation |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1377 |
EC_WRITE_U16(datagram->data + 2, fsm->sii_offset); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1378 |
ec_master_queue_datagram(fsm->master, datagram); |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1379 |
fsm->sii_state = ec_fsm_sii_read_check; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1380 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1381 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1382 |
/*****************************************************************************/ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1383 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1384 |
/** |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1385 |
SII state: READ_CHECK. |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1386 |
Checks, if the SII-read-datagram has been sent and issues a fetch datagram. |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1387 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1388 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1389 |
void ec_fsm_sii_read_check(ec_fsm_t *fsm /**< finite state machine */) |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1390 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1391 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1392 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1393 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1394 |
EC_ERR("SII: Reception of read datagram failed.\n"); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1395 |
fsm->sii_state = ec_fsm_sii_error; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1396 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1397 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1398 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1399 |
fsm->sii_start = get_cycles(); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1400 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1401 |
// issue check/fetch datagram |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1402 |
if (fsm->sii_mode) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1403 |
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x502, 10); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1404 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1405 |
else { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1406 |
ec_datagram_aprd(datagram, fsm->slave->ring_position, 0x502, 10); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1407 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1408 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1409 |
ec_master_queue_datagram(fsm->master, datagram); |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1410 |
fsm->sii_state = ec_fsm_sii_read_fetch; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1411 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1412 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1413 |
/*****************************************************************************/ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1414 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1415 |
/** |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1416 |
SII state: READ_FETCH. |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1417 |
Fetches the result of an SII-read datagram. |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1418 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1419 |
|
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1420 |
void ec_fsm_sii_read_fetch(ec_fsm_t *fsm /**< finite state machine */) |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1421 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1422 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1423 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1424 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1425 |
EC_ERR("SII: Reception of check/fetch datagram failed.\n"); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1426 |
fsm->sii_state = ec_fsm_sii_error; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1427 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1428 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1429 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1430 |
// check "busy bit" |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1431 |
if (EC_READ_U8(datagram->data + 1) & 0x81) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1432 |
// still busy... timeout? |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1433 |
if (get_cycles() - fsm->sii_start >= (cycles_t) 10 * cpu_khz) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1434 |
EC_ERR("SII: Timeout.\n"); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1435 |
fsm->sii_state = ec_fsm_sii_error; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1436 |
#if 0 |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1437 |
EC_DBG("SII busy: %02X %02X %02X %02X\n", |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1438 |
EC_READ_U8(datagram->data + 0), |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1439 |
EC_READ_U8(datagram->data + 1), |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1440 |
EC_READ_U8(datagram->data + 2), |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1441 |
EC_READ_U8(datagram->data + 3)); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1442 |
#endif |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1443 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1444 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1445 |
// issue check/fetch datagram again |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1446 |
if (fsm->sii_mode) { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1447 |
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x502, 10); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1448 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1449 |
else { |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1450 |
ec_datagram_aprd(datagram, fsm->slave->ring_position, 0x502, 10); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1451 |
} |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1452 |
ec_master_queue_datagram(fsm->master, datagram); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1453 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1454 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1455 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1456 |
#if 0 |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1457 |
EC_DBG("SII rec: %02X %02X %02X %02X - %02X %02X %02X %02X\n", |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1458 |
EC_READ_U8(datagram->data + 0), EC_READ_U8(datagram->data + 1), |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1459 |
EC_READ_U8(datagram->data + 2), EC_READ_U8(datagram->data + 3), |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1460 |
EC_READ_U8(datagram->data + 6), EC_READ_U8(datagram->data + 7), |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1461 |
EC_READ_U8(datagram->data + 8), EC_READ_U8(datagram->data + 9)); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1462 |
#endif |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1463 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1464 |
// SII value received. |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1465 |
memcpy(fsm->sii_value, datagram->data + 6, 4); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1466 |
fsm->sii_state = ec_fsm_sii_end; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1467 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1468 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1469 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1470 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1471 |
/** |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1472 |
SII state: START_WRITING. |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1473 |
Starts reading the slave information interface. |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1474 |
*/ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1475 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1476 |
void ec_fsm_sii_start_writing(ec_fsm_t *fsm /**< finite state machine */) |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1477 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1478 |
ec_datagram_t *datagram = &fsm->datagram; |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1479 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1480 |
// initiate write operation |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1481 |
ec_datagram_npwr(datagram, fsm->slave->station_address, 0x502, 8); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1482 |
EC_WRITE_U8 (datagram->data, 0x01); // enable write access |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1483 |
EC_WRITE_U8 (datagram->data + 1, 0x02); // request write operation |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1484 |
EC_WRITE_U32(datagram->data + 2, fsm->sii_offset); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1485 |
memcpy(datagram->data + 6, fsm->sii_value, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1486 |
ec_master_queue_datagram(fsm->master, datagram); |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1487 |
fsm->sii_state = ec_fsm_sii_write_check; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1488 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1489 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1490 |
/*****************************************************************************/ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1491 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1492 |
/** |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1493 |
SII state: WRITE_CHECK. |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1494 |
*/ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1495 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1496 |
void ec_fsm_sii_write_check(ec_fsm_t *fsm /**< finite state machine */) |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1497 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1498 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1499 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1500 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1501 |
EC_ERR("SII: Reception of write datagram failed.\n"); |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1502 |
fsm->sii_state = ec_fsm_sii_error; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1503 |
return; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1504 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1505 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1506 |
fsm->sii_start = get_cycles(); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1507 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1508 |
// issue check/fetch datagram |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1509 |
ec_datagram_nprd(datagram, fsm->slave->station_address, 0x502, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1510 |
ec_master_queue_datagram(fsm->master, datagram); |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1511 |
fsm->sii_state = ec_fsm_sii_write_check2; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1512 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1513 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1514 |
/*****************************************************************************/ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1515 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1516 |
/** |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1517 |
SII state: WRITE_CHECK2. |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1518 |
*/ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1519 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1520 |
void ec_fsm_sii_write_check2(ec_fsm_t *fsm /**< finite state machine */) |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1521 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1522 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1523 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1524 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1525 |
EC_ERR("SII: Reception of write check datagram failed.\n"); |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1526 |
fsm->sii_state = ec_fsm_sii_error; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1527 |
return; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1528 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1529 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1530 |
if (EC_READ_U8(datagram->data + 1) & 0x82) { |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1531 |
// still busy... timeout? |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1532 |
if (get_cycles() - fsm->sii_start >= (cycles_t) 10 * cpu_khz) { |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1533 |
EC_ERR("SII: Write timeout.\n"); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1534 |
fsm->sii_state = ec_fsm_sii_error; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1535 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1536 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1537 |
// issue check/fetch datagram again |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1538 |
ec_master_queue_datagram(fsm->master, datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1539 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1540 |
else if (EC_READ_U8(datagram->data + 1) & 0x40) { |
1621
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1541 |
EC_ERR("SII: Write operation failed!\n"); |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1542 |
fsm->sii_state = ec_fsm_sii_error; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1543 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1544 |
else { // success |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1545 |
fsm->sii_state = ec_fsm_sii_end; |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1546 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1547 |
} |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1548 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1549 |
/*****************************************************************************/ |
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1550 |
|
4bbe090553f7
MERGE trunk -r428:447 -> branches/stable-1.0 (Complete EEPROM data, unloading buxfix, variable data, bridging)
Florian Pose <fp@igh-essen.com>
parents:
1619
diff
changeset
|
1551 |
/** |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1552 |
SII state: END. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1553 |
End state of the slave SII state machine. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1554 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1555 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1556 |
void ec_fsm_sii_end(ec_fsm_t *fsm /**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1557 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1558 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1559 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1560 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1561 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1562 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1563 |
SII state: ERROR. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1564 |
End state of the slave SII state machine. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1565 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1566 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1567 |
void ec_fsm_sii_error(ec_fsm_t *fsm /**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1568 |
{ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1569 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1570 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1571 |
/****************************************************************************** |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1572 |
* state change sub state machine |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1573 |
*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1574 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1575 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1576 |
Change state: START. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1577 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1578 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1579 |
void ec_fsm_change_start(ec_fsm_t *fsm /**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1580 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1581 |
ec_datagram_t *datagram = &fsm->datagram; |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1582 |
ec_slave_t *slave = fsm->slave; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1583 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1584 |
// write new state to slave |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1585 |
ec_datagram_npwr(datagram, slave->station_address, 0x0120, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1586 |
EC_WRITE_U16(datagram->data, fsm->change_new); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1587 |
ec_master_queue_datagram(fsm->master, datagram); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1588 |
fsm->change_state = ec_fsm_change_check; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1589 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1590 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1591 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1592 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1593 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1594 |
Change state: CHECK. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1595 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1596 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1597 |
void ec_fsm_change_check(ec_fsm_t *fsm /**< finite state machine */) |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1598 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1599 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1600 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1601 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1602 |
if (datagram->state != EC_CMD_RECEIVED) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1603 |
fsm->change_state = ec_fsm_change_error; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1604 |
EC_ERR("Failed to send state datagram to slave %i!\n", |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1605 |
fsm->slave->ring_position); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1606 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1607 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1608 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1609 |
if (datagram->working_counter != 1) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1610 |
fsm->change_state = ec_fsm_change_error; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1611 |
EC_ERR("Failed to set state 0x%02X on slave %i: Slave did not" |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1612 |
" respond.\n", fsm->change_new, fsm->slave->ring_position); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1613 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1614 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1615 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1616 |
fsm->change_start = get_cycles(); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1617 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1618 |
// read AL status from slave |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1619 |
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1620 |
ec_master_queue_datagram(fsm->master, datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1621 |
fsm->change_state = ec_fsm_change_status; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1622 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1623 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1624 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1625 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1626 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1627 |
Change state: STATUS. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1628 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1629 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1630 |
void ec_fsm_change_status(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1631 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1632 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1633 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1634 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1635 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1636 |
fsm->change_state = ec_fsm_change_error; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1637 |
EC_ERR("Failed to check state 0x%02X on slave %i.\n", |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1638 |
fsm->change_new, slave->ring_position); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1639 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1640 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1641 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1642 |
slave->current_state = EC_READ_U8(datagram->data); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1643 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1644 |
if (slave->current_state == fsm->change_new) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1645 |
// state has been set successfully |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1646 |
fsm->change_state = ec_fsm_change_end; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1647 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1648 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1649 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1650 |
if (slave->current_state & 0x10) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1651 |
// state change error |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1652 |
fsm->change_new = slave->current_state & 0x0F; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1653 |
EC_ERR("Failed to set state 0x%02X - Slave %i refused state change" |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1654 |
" (code 0x%02X)!\n", fsm->change_new, slave->ring_position, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1655 |
slave->current_state); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1656 |
// fetch AL status error code |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1657 |
ec_datagram_nprd(datagram, slave->station_address, 0x0134, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1658 |
ec_master_queue_datagram(fsm->master, datagram); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1659 |
fsm->change_state = ec_fsm_change_code; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1660 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1661 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1662 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1663 |
if (get_cycles() - fsm->change_start >= (cycles_t) 10 * cpu_khz) { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1664 |
// timeout while checking |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1665 |
fsm->change_state = ec_fsm_change_error; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1666 |
EC_ERR("Timeout while setting state 0x%02X on slave %i.\n", |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1667 |
fsm->change_new, slave->ring_position); |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1668 |
return; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1669 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1670 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1671 |
// still old state: check again |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1672 |
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1673 |
ec_master_queue_datagram(fsm->master, datagram); |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1674 |
} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1675 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1676 |
/*****************************************************************************/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1677 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1678 |
/** |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1679 |
Application layer status messages. |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1680 |
*/ |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1681 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1682 |
const ec_code_msg_t al_status_messages[] = { |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1683 |
{0x0001, "Unspecified error"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1684 |
{0x0011, "Invalud requested state change"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1685 |
{0x0012, "Unknown requested state"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1686 |
{0x0013, "Bootstrap not supported"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1687 |
{0x0014, "No valid firmware"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1688 |
{0x0015, "Invalid mailbox configuration"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1689 |
{0x0016, "Invalid mailbox configuration"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1690 |
{0x0017, "Invalid sync manager configuration"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1691 |
{0x0018, "No valid inputs available"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1692 |
{0x0019, "No valid outputs"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1693 |
{0x001A, "Synchronisation error"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1694 |
{0x001B, "Sync manager watchdog"}, |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1695 |
{0x001C, "Invalid sync manager types"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1696 |
{0x001D, "Invalid output configuration"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1697 |
{0x001E, "Invalid input configuration"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1698 |
{0x001F, "Invalid watchdog configuration"}, |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1699 |
{0x0020, "Slave needs cold start"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1700 |
{0x0021, "Slave needs INIT"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1701 |
{0x0022, "Slave needs PREOP"}, |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1702 |
{0x0023, "Slave needs SAVEOP"}, |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1703 |
{0x0030, "Invalid DC SYNCH configuration"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1704 |
{0x0031, "Invalid DC latch configuration"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1705 |
{0x0032, "PLL error"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1706 |
{0x0033, "Invalid DC IO error"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1707 |
{0x0034, "Invalid DC timeout error"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1708 |
{0x0042, "MBOX EOE"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1709 |
{0x0043, "MBOX COE"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1710 |
{0x0044, "MBOX FOE"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1711 |
{0x0045, "MBOX SOE"}, |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1712 |
{0x004F, "MBOX VOE"}, |
1619
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1713 |
{} |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1714 |
}; |
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1715 |
|
0d4119024f55
MERGE -r361:425 trunk -> branches/stable-1.0: EoE, License, State machines.
Florian Pose <fp@igh-essen.com>
parents:
diff
changeset
|
1716 |
/*****************************************************************************/ |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1717 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1718 |
/** |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1719 |
Change state: CODE. |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1720 |
*/ |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1721 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1722 |
void ec_fsm_change_code(ec_fsm_t *fsm /**< finite state machine */) |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1723 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1724 |
ec_datagram_t *datagram = &fsm->datagram; |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1725 |
ec_slave_t *slave = fsm->slave; |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1726 |
uint32_t code; |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1727 |
const ec_code_msg_t *al_msg; |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1728 |
|
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1729 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1730 |
fsm->change_state = ec_fsm_change_error; |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1731 |
EC_ERR("Reception of AL status code datagram failed.\n"); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1732 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1733 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1734 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1735 |
if ((code = EC_READ_U16(datagram->data))) { |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1736 |
for (al_msg = al_status_messages; al_msg->code; al_msg++) { |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1737 |
if (al_msg->code != code) continue; |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1738 |
EC_ERR("AL status message 0x%04X: \"%s\".\n", |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1739 |
al_msg->code, al_msg->message); |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1740 |
break; |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1741 |
} |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1742 |
if (!al_msg->code) |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1743 |
EC_ERR("Unknown AL status code 0x%04X.\n", code); |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1744 |
} |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1745 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1746 |
// acknowledge "old" slave state |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1747 |
ec_datagram_npwr(datagram, slave->station_address, 0x0120, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1748 |
EC_WRITE_U16(datagram->data, slave->current_state); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1749 |
ec_master_queue_datagram(fsm->master, datagram); |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1750 |
fsm->change_state = ec_fsm_change_ack; |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1751 |
} |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1752 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1753 |
/*****************************************************************************/ |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1754 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1755 |
/** |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1756 |
Change state: ACK. |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1757 |
*/ |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1758 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1759 |
void ec_fsm_change_ack(ec_fsm_t *fsm /**< finite state machine */) |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1760 |
{ |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1761 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1762 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1763 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1764 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1765 |
fsm->change_state = ec_fsm_change_error; |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1766 |
EC_ERR("Reception of state ack datagram failed.\n"); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1767 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1768 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1769 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1770 |
fsm->change_start = get_cycles(); |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1771 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1772 |
// read new AL status |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1773 |
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1774 |
ec_master_queue_datagram(fsm->master, datagram); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1775 |
fsm->change_state = ec_fsm_change_check_ack; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1776 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1777 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1778 |
/*****************************************************************************/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1779 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1780 |
/** |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1781 |
Change state: CHECK ACK. |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1782 |
*/ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1783 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1784 |
void ec_fsm_change_check_ack(ec_fsm_t *fsm /**< finite state machine */) |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1785 |
{ |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1786 |
ec_datagram_t *datagram = &fsm->datagram; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1787 |
ec_slave_t *slave = fsm->slave; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1788 |
ec_slave_state_t ack_state; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1789 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1790 |
if (datagram->state != EC_CMD_RECEIVED || datagram->working_counter != 1) { |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1791 |
fsm->change_state = ec_fsm_change_error; |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1792 |
EC_ERR("Reception of state ack check datagram failed.\n"); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1793 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1794 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1795 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1796 |
ack_state = EC_READ_U8(datagram->data); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1797 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1798 |
if (ack_state == slave->current_state) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1799 |
fsm->change_state = ec_fsm_change_error; |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1800 |
EC_INFO("Acknowleged state 0x%02X on slave %i.\n", |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1801 |
slave->current_state, slave->ring_position); |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1802 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1803 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1804 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1805 |
if (get_cycles() - fsm->change_start >= (cycles_t) 100 * cpu_khz) { |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1806 |
// timeout while checking |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1807 |
slave->current_state = EC_SLAVE_STATE_UNKNOWN; |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1808 |
fsm->change_state = ec_fsm_change_error; |
1624
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1809 |
EC_ERR("Timeout while acknowleging state 0x%02X on slave %i.\n", |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1810 |
fsm->change_new, slave->ring_position); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1811 |
return; |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1812 |
} |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1813 |
|
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1814 |
// reread new AL status |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1815 |
ec_datagram_nprd(datagram, slave->station_address, 0x0130, 2); |
9dc190591c0f
MERGE trunk -r452:489 -> stable-1.0 (datagrams, bugfixes, EEPROM info, idle mode)
Florian Pose <fp@igh-essen.com>
parents:
1623
diff
changeset
|
1816 |
ec_master_queue_datagram(fsm->master, datagram); |
1623
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1817 |
} |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1818 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1819 |
/*****************************************************************************/ |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1820 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1821 |
/** |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1822 |
Change state: END. |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1823 |
*/ |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1824 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1825 |
void ec_fsm_change_end(ec_fsm_t *fsm /**< finite state machine */) |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1826 |
{ |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1827 |
} |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1828 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1829 |
/*****************************************************************************/ |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1830 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1831 |
/** |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1832 |
Change state: ERROR. |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1833 |
*/ |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1834 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1835 |
void ec_fsm_change_error(ec_fsm_t *fsm /**< finite state machine */) |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1836 |
{ |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1837 |
} |
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1838 |
|
05622513f627
MERGE trunk -r450:451 -> branches/stable-1.0 (docs)
Florian Pose <fp@igh-essen.com>
parents:
1621
diff
changeset
|
1839 |
/*****************************************************************************/ |