author | Florian Pose <fp@igh-essen.com> |
Tue, 05 Jan 2010 13:44:46 +0100 | |
changeset 1592 | 0f070a230401 |
parent 1583 | 017fa8fd9ac1 |
child 1596 | ea8d2b4ee742 |
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 *); |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
45 |
void ec_fsm_slave_state_sdo_request(ec_fsm_slave_t *); |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
46 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
47 |
|
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 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
49 |
|
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 |
/** 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
|
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 |
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
) |
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 |
{ |
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 |
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
|
59 |
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
|
60 |
fsm->datagram->data_size = 0; |
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 |
fsm->state = ec_fsm_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
|
62 |
|
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 |
// 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
|
64 |
ec_fsm_coe_init(&fsm->fsm_coe, fsm->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
|
65 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
66 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
67 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
68 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
69 |
/** 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
|
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 |
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
|
72 |
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
|
73 |
) |
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 |
// 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
|
76 |
ec_fsm_coe_clear(&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
|
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 |
|
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 |
|
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 |
/** 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
|
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 |
* 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
|
84 |
* 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
|
85 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
86 |
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
|
87 |
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
|
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 |
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
|
91 |
|| 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
|
92 |
// 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
|
93 |
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
|
94 |
} |
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 |
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
|
97 |
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
|
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 |
/****************************************************************************** |
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 |
* 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
|
102 |
*****************************************************************************/ |
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 |
|
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 |
/** 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
|
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 |
* Check for pending SDO requests and process one. |
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 |
* |
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 |
void ec_fsm_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
|
110 |
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
|
111 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
112 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
117 |
// search the first matching external request to be processed |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
118 |
list_for_each_entry_safe(request, next, &master->slave_sdo_requests, list) { |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
119 |
if (request->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
|
120 |
continue; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
121 |
list_del_init(&request->list); // dequeue |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
122 |
request->req.state = EC_INT_REQUEST_BUSY; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
123 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
124 |
if (slave->current_state == EC_SLAVE_STATE_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
|
125 |
EC_ERR("Discarding SDO request, slave %u is in INIT.\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
|
126 |
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
|
127 |
request->req.state = EC_INT_REQUEST_FAILURE; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
128 |
wake_up(&master->sdo_queue); |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
129 |
continue; |
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 |
|
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 |
// 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
|
133 |
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
|
134 |
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
|
135 |
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
|
136 |
|
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 |
// 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
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
ec_fsm_coe_exec(&fsm->fsm_coe); // execute immediately |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
142 |
ec_master_queue_sdo_datagram(fsm->slave->master,fsm->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
|
143 |
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
|
144 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
145 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
146 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
147 |
/*****************************************************************************/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
148 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
149 |
/** 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
|
150 |
*/ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
151 |
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
|
152 |
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
|
153 |
) |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
154 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
155 |
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
|
156 |
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
|
157 |
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
|
158 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
159 |
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
|
160 |
{ |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
161 |
ec_master_queue_sdo_datagram(fsm->slave->master,fsm->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
|
162 |
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
|
163 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
164 |
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
|
165 |
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
|
166 |
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
|
167 |
request->state = EC_INT_REQUEST_FAILURE; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
168 |
wake_up(&master->sdo_queue); |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
169 |
fsm->sdo_request = NULL; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
170 |
fsm->state = ec_fsm_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
|
171 |
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
|
172 |
} |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
173 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
174 |
// 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
|
175 |
request->state = EC_INT_REQUEST_SUCCESS; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
176 |
wake_up(&master->sdo_queue); |
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 |
|
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 |
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
|
179 |
EC_DBG("Finished 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
|
180 |
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
|
181 |
|
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
182 |
fsm->sdo_request = NULL; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
183 |
fsm->datagram->data_size = 0; |
017fa8fd9ac1
Each slave got its own SDO state machine (faster handling of external SDO requests)
Martin Troxler <martin.troxler@komaxgroup.com>
parents:
diff
changeset
|
184 |
fsm->state = ec_fsm_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
|
185 |
} |