author | Florian Pose <fp@igh-essen.com> |
Tue, 23 Feb 2010 13:18:31 +0100 | |
changeset 1821 | 40321a37d085 |
parent 1804 | 742607c464c4 |
child 1831 | 1875b9fea0ba |
permissions | -rw-r--r-- |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
1 |
/****************************************************************************** |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
2 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
3 |
* $Id$ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
4 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
5 |
* Copyright (C) 2006-2008 Florian Pose, Ingenieurgemeinschaft IgH |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
6 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
7 |
* This file is part of the IgH EtherCAT Master. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
8 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it and/or |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
10 |
* modify it under the terms of the GNU General Public License version 2, as |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
11 |
* published by the Free Software Foundation. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
12 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
13 |
* The IgH EtherCAT Master is distributed in the hope that it will be useful, |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
16 |
* Public License for more details. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
17 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
18 |
* You should have received a copy of the GNU General Public License along |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
19 |
* with the IgH EtherCAT Master; if not, write to the Free Software |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
20 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
21 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
22 |
* --- |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
23 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
24 |
* The license mentioned above concerns the source code only. Using the |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
25 |
* EtherCAT technology and brand is only permitted in compliance with the |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
26 |
* industrial property and similar rights of Beckhoff Automation GmbH. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
27 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
28 |
*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
29 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
30 |
/** \file |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
31 |
* EtherCAT slave (SDO) state machine. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
32 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
33 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
34 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
35 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
36 |
#include "globals.h" |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
37 |
#include "master.h" |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
38 |
#include "mailbox.h" |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
39 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
40 |
#include "fsm_slave.h" |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
41 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
42 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
43 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
44 |
void ec_fsm_slave_state_idle(ec_fsm_slave_t *); |
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
45 |
void ec_fsm_slave_state_ready(ec_fsm_slave_t *); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
46 |
int ec_fsm_slave_action_process_sdo(ec_fsm_slave_t *); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
47 |
int ec_fsm_slave_action_process_foe(ec_fsm_slave_t *); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
48 |
void ec_fsm_slave_state_sdo_request(ec_fsm_slave_t *); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
49 |
void ec_fsm_slave_state_foe_request(ec_fsm_slave_t *); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
50 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
51 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
52 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
53 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
54 |
/** Constructor. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
55 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
56 |
void ec_fsm_slave_init( |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
57 |
ec_fsm_slave_t *fsm, /**< Slave state machine. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
58 |
ec_slave_t *slave, /**< EtherCAT slave. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
59 |
ec_datagram_t *datagram /**< Datagram object to use. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
60 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
61 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
62 |
fsm->slave = slave; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
63 |
fsm->datagram = datagram; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
64 |
fsm->datagram->data_size = 0; |
1804 | 65 |
|
66 |
if (slave->master->debug_level) |
|
67 |
EC_DBG("Init FSM for slave %u...\n", slave->ring_position); |
|
68 |
||
69 |
fsm->state = ec_fsm_slave_state_idle; |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
70 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
71 |
// init sub-state-machines |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
72 |
ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
73 |
ec_fsm_foe_init(&fsm->fsm_foe, fsm->datagram); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
74 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
75 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
76 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
77 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
78 |
/** Destructor. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
79 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
80 |
void ec_fsm_slave_clear( |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
81 |
ec_fsm_slave_t *fsm /**< Master state machine. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
82 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
83 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
84 |
// clear sub-state machines |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
85 |
ec_fsm_coe_clear(&fsm->fsm_coe); |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
86 |
ec_fsm_foe_clear(&fsm->fsm_foe); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
87 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
88 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
89 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
90 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
91 |
/** Executes the current state of the state machine. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
92 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
93 |
* If the state machine's datagram is not sent or received yet, the execution |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
94 |
* of the state machine is delayed to the next cycle. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
95 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
96 |
void ec_fsm_slave_exec( |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
97 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
98 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
99 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
100 |
if (fsm->datagram->state == EC_DATAGRAM_SENT |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
101 |
|| fsm->datagram->state == EC_DATAGRAM_QUEUED) { |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
102 |
// datagram was not sent or received yet. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
103 |
return; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
104 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
105 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
106 |
fsm->state(fsm); |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
107 |
return; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
108 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
109 |
|
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
110 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
111 |
/*****************************************************************************/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
112 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
113 |
/** Sets the current state of the state machine to READY |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
114 |
* |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
115 |
*/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
116 |
void ec_fsm_slave_ready( |
1804 | 117 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
118 |
) |
|
119 |
{ |
|
120 |
if (fsm->state == ec_fsm_slave_state_idle) { |
|
121 |
if (fsm->slave->master->debug_level) { |
|
122 |
EC_DBG("Slave %u ready for SDO/FOE.\n", |
|
123 |
fsm->slave->ring_position); |
|
124 |
} |
|
125 |
fsm->state = ec_fsm_slave_state_ready; |
|
126 |
} |
|
127 |
return; |
|
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
128 |
} |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
129 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
130 |
/****************************************************************************** |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
131 |
* Slave state machine |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
132 |
*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
133 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
134 |
/*****************************************************************************/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
135 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
136 |
/** Slave state: IDLE. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
137 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
138 |
* |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
139 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
140 |
void ec_fsm_slave_state_idle( |
1804 | 141 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
142 |
) |
|
143 |
{ |
|
144 |
// do nothing |
|
1601
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
145 |
} |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
146 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
147 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
148 |
/*****************************************************************************/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
149 |
|
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
150 |
/** Slave state: READY. |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
151 |
* |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
152 |
* |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
153 |
*/ |
a784812c787f
master FSM enables slave FSM
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1598
diff
changeset
|
154 |
void ec_fsm_slave_state_ready( |
1804 | 155 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
156 |
) |
|
157 |
{ |
|
158 |
// Check for pending external SDO requests |
|
159 |
if (ec_fsm_slave_action_process_sdo(fsm)) |
|
160 |
return; |
|
161 |
||
162 |
// Check for pending FOE requests |
|
163 |
if (ec_fsm_slave_action_process_foe(fsm)) |
|
164 |
return; |
|
165 |
} |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
166 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
167 |
/*****************************************************************************/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
168 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
169 |
/** Check for pending SDO requests and process one. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
170 |
* |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
171 |
* \return non-zero, if an SDO request is processed. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
172 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
173 |
int ec_fsm_slave_action_process_sdo( |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
174 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
175 |
) |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
176 |
{ |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
177 |
ec_slave_t *slave = fsm->slave; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
178 |
ec_master_t *master = slave->master; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
179 |
ec_master_sdo_request_t *request, *next; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
180 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
181 |
// search the first external request to be processed |
1596
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
182 |
list_for_each_entry_safe(request, next, &slave->slave_sdo_requests, list) { |
1598
5ad4eb4963a6
Postpone SDO request when slave is in INIT
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1597
diff
changeset
|
183 |
|
1604
699bd70f7bfe
undone changes of revision 1547: Abort SDO/FOE requests when slave is in INIT
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1601
diff
changeset
|
184 |
list_del_init(&request->list); // dequeue |
1804 | 185 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
186 |
EC_WARN("Aborting SDO request, slave %u has ERROR.\n", |
|
187 |
slave->ring_position); |
|
188 |
request->req.state = EC_INT_REQUEST_FAILURE; |
|
189 |
wake_up(&slave->sdo_queue); |
|
190 |
fsm->sdo_request = NULL; |
|
191 |
fsm->state = ec_fsm_slave_state_idle; |
|
192 |
return 0; |
|
193 |
} |
|
194 |
||
195 |
if (slave->current_state == EC_SLAVE_STATE_INIT) { |
|
196 |
EC_WARN("Aborting SDO request, slave %u is in INIT.\n", |
|
197 |
slave->ring_position); |
|
198 |
request->req.state = EC_INT_REQUEST_FAILURE; |
|
199 |
wake_up(&slave->sdo_queue); |
|
200 |
fsm->sdo_request = NULL; |
|
201 |
fsm->state = ec_fsm_slave_state_idle; |
|
202 |
return 0; |
|
203 |
} |
|
204 |
||
205 |
request->req.state = EC_INT_REQUEST_BUSY; |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
206 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
207 |
// Found pending SDO request. Execute it! |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
208 |
if (master->debug_level) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
209 |
EC_DBG("Processing SDO request for slave %u...\n", |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
210 |
slave->ring_position); |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
211 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
212 |
// Start SDO transfer |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
213 |
fsm->sdo_request = &request->req; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
214 |
fsm->state = ec_fsm_slave_state_sdo_request; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
215 |
ec_fsm_coe_transfer(&fsm->fsm_coe, slave, &request->req); |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
216 |
ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
217 |
ec_master_queue_external_datagram(fsm->slave->master,fsm->datagram); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
218 |
return 1; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
219 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
220 |
return 0; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
221 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
222 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
223 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
224 |
/*****************************************************************************/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
225 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
226 |
/** Check for pending FOE requests and process one. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
227 |
* |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
228 |
* \return non-zero, if an FOE request is processed. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
229 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
230 |
int ec_fsm_slave_action_process_foe( |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
231 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
232 |
) |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
233 |
{ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
234 |
ec_slave_t *slave = fsm->slave; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
235 |
ec_master_t *master = slave->master; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
236 |
ec_master_foe_request_t *request, *next; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
237 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
238 |
// search the first request to be processed |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
239 |
list_for_each_entry_safe(request, next, &slave->foe_requests, list) { |
1804 | 240 |
if (slave->current_state & EC_SLAVE_STATE_ACK_ERR) { |
241 |
EC_WARN("Aborting FOE request, slave %u has ERROR.\n", |
|
242 |
slave->ring_position); |
|
243 |
request->req.state = EC_INT_REQUEST_FAILURE; |
|
244 |
wake_up(&slave->sdo_queue); |
|
245 |
fsm->sdo_request = NULL; |
|
246 |
fsm->state = ec_fsm_slave_state_idle; |
|
247 |
return 0; |
|
248 |
} |
|
249 |
list_del_init(&request->list); // dequeue |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
250 |
request->req.state = EC_INT_REQUEST_BUSY; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
251 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
252 |
if (master->debug_level) |
1804 | 253 |
EC_DBG("Processing FOE request for slave %u.\n", |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
254 |
slave->ring_position); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
255 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
256 |
fsm->foe_request = &request->req; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
257 |
fsm->state = ec_fsm_slave_state_foe_request; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
258 |
ec_fsm_foe_transfer(&fsm->fsm_foe, slave, &request->req); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
259 |
ec_fsm_foe_exec(&fsm->fsm_foe); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
260 |
ec_master_queue_external_datagram(fsm->slave->master,fsm->datagram); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
261 |
return 1; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
262 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
263 |
return 0; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
264 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
265 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
266 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
267 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
268 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
269 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
270 |
/** Slave state: SDO_REQUEST. |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
271 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
272 |
void ec_fsm_slave_state_sdo_request( |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
273 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
274 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
275 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
276 |
ec_slave_t *slave = fsm->slave; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
277 |
ec_master_t *master = slave->master; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
278 |
ec_sdo_request_t *request = fsm->sdo_request; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
279 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
280 |
if (ec_fsm_coe_exec(&fsm->fsm_coe)) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
281 |
{ |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
282 |
ec_master_queue_external_datagram(fsm->slave->master,fsm->datagram); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
283 |
return; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
284 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
285 |
if (!ec_fsm_coe_success(&fsm->fsm_coe)) { |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
286 |
EC_DBG("Failed to process SDO request for slave %u.\n", |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
287 |
fsm->slave->ring_position); |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
288 |
request->state = EC_INT_REQUEST_FAILURE; |
1804 | 289 |
wake_up(&slave->sdo_queue); |
290 |
fsm->sdo_request = NULL; |
|
291 |
fsm->state = ec_fsm_slave_state_idle; |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
292 |
return; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
293 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
294 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
295 |
if (master->debug_level) |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
296 |
EC_DBG("Finished SDO request for slave %u.\n", |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
297 |
fsm->slave->ring_position); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
298 |
|
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
299 |
// SDO request finished |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
300 |
request->state = EC_INT_REQUEST_SUCCESS; |
1596
ea8d2b4ee742
Moved sdo request queue to slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1583
diff
changeset
|
301 |
wake_up(&slave->sdo_queue); |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
302 |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
303 |
fsm->sdo_request = NULL; |
1804 | 304 |
fsm->state = ec_fsm_slave_state_ready; |
305 |
} |
|
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
306 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
307 |
/*****************************************************************************/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
308 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
309 |
/** Slave state: FOE REQUEST. |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
310 |
*/ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
311 |
void ec_fsm_slave_state_foe_request( |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
312 |
ec_fsm_slave_t *fsm /**< Slave state machine. */ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
313 |
) |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
314 |
{ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
315 |
ec_slave_t *slave = fsm->slave; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
316 |
ec_master_t *master = slave->master; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
317 |
ec_foe_request_t *request = fsm->foe_request; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
318 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
319 |
if (ec_fsm_foe_exec(&fsm->fsm_foe)) |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
320 |
{ |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
321 |
ec_master_queue_external_datagram(fsm->slave->master,fsm->datagram); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
322 |
return; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
323 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
324 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
325 |
if (!ec_fsm_foe_success(&fsm->fsm_foe)) { |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
326 |
EC_ERR("Failed to handle FoE request to slave %u.\n", |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
327 |
slave->ring_position); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
328 |
request->state = EC_INT_REQUEST_FAILURE; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
329 |
wake_up(&slave->foe_queue); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
330 |
fsm->foe_request = NULL; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
331 |
fsm->state = ec_fsm_slave_state_idle; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
332 |
return; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
333 |
} |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
334 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
335 |
// finished transferring FoE |
1583
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
336 |
if (master->debug_level) |
1597
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
337 |
EC_DBG("Successfully transferred %u bytes of FoE data from/to" |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
338 |
" slave %u.\n", request->data_size, slave->ring_position); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
339 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
340 |
request->state = EC_INT_REQUEST_SUCCESS; |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
341 |
wake_up(&slave->foe_queue); |
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
342 |
|
491dea6f4fd7
Moved FOE request queue and fsm into slaves
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
1596
diff
changeset
|
343 |
fsm->foe_request = NULL; |
1804 | 344 |
fsm->state = ec_fsm_slave_state_ready; |
345 |
} |
|
346 |
||
347 |
/*****************************************************************************/ |