author | Florian Pose <fp@igh-essen.com> |
Thu, 31 Jul 2008 09:30:38 +0000 | |
changeset 1173 | 2ec9651a6c89 |
parent 1082 | ff06c58e269c |
permissions | -rw-r--r-- |
799 | 1 |
/****************************************************************************** |
2 |
* |
|
3 |
* $Id$ |
|
4 |
* |
|
5 |
* Copyright (C) 2006 Florian Pose, Ingenieurgemeinschaft IgH |
|
6 |
* |
|
7 |
* This file is part of the IgH EtherCAT Master. |
|
8 |
* |
|
9 |
* The IgH EtherCAT Master is free software; you can redistribute it |
|
10 |
* and/or modify it under the terms of the GNU General Public License |
|
11 |
* as published by the Free Software Foundation; either version 2 of the |
|
12 |
* License, or (at your option) any later version. |
|
13 |
* |
|
14 |
* The IgH EtherCAT Master is distributed in the hope that it will be |
|
15 |
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
17 |
* GNU General Public License for more details. |
|
18 |
* |
|
19 |
* You should have received a copy of the GNU General Public License |
|
20 |
* along with the IgH EtherCAT Master; if not, write to the Free Software |
|
21 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
22 |
* |
|
23 |
* The right to use EtherCAT Technology is granted and comes free of |
|
24 |
* charge under condition of compatibility of product made by |
|
25 |
* Licensee. People intending to distribute/sell products based on the |
|
26 |
* code, have to sign an agreement to guarantee that products using |
|
27 |
* software based on IgH EtherCAT master stay compatible with the actual |
|
28 |
* EtherCAT specification (which are released themselves as an open |
|
29 |
* standard) as the (only) precondition to have the right to use EtherCAT |
|
30 |
* Technology, IP and trade marks. |
|
31 |
* |
|
32 |
*****************************************************************************/ |
|
33 |
||
34 |
/** \file |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
35 |
* EtherCAT Pdo mapping state machine. |
799 | 36 |
*/ |
37 |
||
38 |
/*****************************************************************************/ |
|
39 |
||
40 |
#include "globals.h" |
|
41 |
#include "master.h" |
|
42 |
#include "mailbox.h" |
|
43 |
#include "slave_config.h" |
|
44 |
||
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
45 |
#include "fsm_pdo_mapping.h" |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
46 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
47 |
/*****************************************************************************/ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
48 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
49 |
void ec_fsm_pdo_mapping_state_start(ec_fsm_pdo_mapping_t *); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
50 |
void ec_fsm_pdo_mapping_state_zero_count(ec_fsm_pdo_mapping_t *); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
51 |
void ec_fsm_pdo_mapping_state_add_entry(ec_fsm_pdo_mapping_t *); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
52 |
void ec_fsm_pdo_mapping_state_entry_count(ec_fsm_pdo_mapping_t *); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
53 |
void ec_fsm_pdo_mapping_state_end(ec_fsm_pdo_mapping_t *); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
54 |
void ec_fsm_pdo_mapping_state_error(ec_fsm_pdo_mapping_t *); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
55 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
56 |
void ec_fsm_pdo_mapping_next_pdo(ec_fsm_pdo_mapping_t *); |
799 | 57 |
|
58 |
/*****************************************************************************/ |
|
59 |
||
60 |
/** Constructor. |
|
61 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
62 |
void ec_fsm_pdo_mapping_init( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
63 |
ec_fsm_pdo_mapping_t *fsm, /**< Pdo mapping state machine. */ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
64 |
ec_fsm_coe_t *fsm_coe /**< CoE state machine to use. */ |
799 | 65 |
) |
66 |
{ |
|
67 |
fsm->fsm_coe = fsm_coe; |
|
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
68 |
ec_sdo_request_init(&fsm->request); |
799 | 69 |
} |
70 |
||
71 |
/*****************************************************************************/ |
|
72 |
||
73 |
/** Destructor. |
|
74 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
75 |
void ec_fsm_pdo_mapping_clear( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
76 |
ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
799 | 77 |
) |
78 |
{ |
|
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
79 |
ec_sdo_request_clear(&fsm->request); |
799 | 80 |
} |
81 |
||
82 |
/*****************************************************************************/ |
|
83 |
||
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
84 |
/** Start Pdo mapping state machine. |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
85 |
*/ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
86 |
void ec_fsm_pdo_mapping_start( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
87 |
ec_fsm_pdo_mapping_t *fsm, /**< Pdo mapping state machine. */ |
799 | 88 |
ec_slave_t *slave /**< slave to configure */ |
89 |
) |
|
90 |
{ |
|
91 |
fsm->slave = slave; |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
92 |
fsm->state = ec_fsm_pdo_mapping_state_start; |
799 | 93 |
} |
94 |
||
95 |
/*****************************************************************************/ |
|
96 |
||
97 |
/** Get running state. |
|
98 |
* |
|
99 |
* \return false, if state machine has terminated |
|
100 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
101 |
int ec_fsm_pdo_mapping_running( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
102 |
const ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
103 |
) |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
104 |
{ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
105 |
return fsm->state != ec_fsm_pdo_mapping_state_end |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
106 |
&& fsm->state != ec_fsm_pdo_mapping_state_error; |
799 | 107 |
} |
108 |
||
109 |
/*****************************************************************************/ |
|
110 |
||
111 |
/** Executes the current state. |
|
112 |
* |
|
113 |
* \return false, if state machine has terminated |
|
114 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
115 |
int ec_fsm_pdo_mapping_exec( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
116 |
ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
799 | 117 |
) |
118 |
{ |
|
119 |
fsm->state(fsm); |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
120 |
return ec_fsm_pdo_mapping_running(fsm); |
799 | 121 |
} |
122 |
||
123 |
/*****************************************************************************/ |
|
124 |
||
125 |
/** Get execution result. |
|
126 |
* |
|
127 |
* \return true, if the state machine terminated gracefully |
|
128 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
129 |
int ec_fsm_pdo_mapping_success( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
130 |
const ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
131 |
) |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
132 |
{ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
133 |
return fsm->state == ec_fsm_pdo_mapping_state_end; |
799 | 134 |
} |
135 |
||
136 |
/****************************************************************************** |
|
137 |
* State functions. |
|
138 |
*****************************************************************************/ |
|
139 |
||
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
140 |
/** Start Pdo mapping. |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
141 |
*/ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
142 |
void ec_fsm_pdo_mapping_state_start( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
143 |
ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
799 | 144 |
) |
145 |
{ |
|
146 |
if (!fsm->slave->config) { |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
147 |
fsm->state = ec_fsm_pdo_mapping_state_end; |
799 | 148 |
return; |
149 |
} |
|
150 |
||
151 |
fsm->pdo = NULL; |
|
890
1115793a76ed
Debug messaged on configuring assignment and mapping.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
152 |
fsm->num_configured_pdos = 0; |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
153 |
ec_fsm_pdo_mapping_next_pdo(fsm); |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
154 |
} |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
155 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
156 |
/*****************************************************************************/ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
157 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
158 |
/** Process mapping of next Pdo. |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
159 |
*/ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
160 |
void ec_fsm_pdo_mapping_next_pdo( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
161 |
ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
799 | 162 |
) |
163 |
{ |
|
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
164 |
uint8_t sync_index; |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
165 |
const ec_pdo_list_t *pdos; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
166 |
const ec_pdo_t *pdo, *assigned_pdo; |
799 | 167 |
|
1082
ff06c58e269c
Renamed ecrt_slave_config_sync_managers() to ecrt_slave_config_pdos();
Florian Pose <fp@igh-essen.com>
parents:
1055
diff
changeset
|
168 |
for (sync_index = 0; sync_index < EC_MAX_SYNC_MANAGERS; sync_index++) { |
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
169 |
pdos = &fsm->slave->config->sync_configs[sync_index].pdos; |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
170 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
171 |
list_for_each_entry(pdo, &pdos->list, list) { |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
172 |
if (fsm->pdo) { // there was a Pdo mapping changed in the last run |
890
1115793a76ed
Debug messaged on configuring assignment and mapping.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
173 |
if (pdo == fsm->pdo) // this is the previously configured Pdo |
801
6b1e2b0ed8bc
Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents:
800
diff
changeset
|
174 |
fsm->pdo = NULL; // take the next one |
799 | 175 |
} else { |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
176 |
if ((assigned_pdo = ec_slave_find_pdo(fsm->slave, pdo->index))) |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
177 |
if (ec_pdo_equal_entries(pdo, assigned_pdo)) |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
178 |
continue; // Pdo entries mapped correctly |
799 | 179 |
|
180 |
fsm->pdo = pdo; |
|
890
1115793a76ed
Debug messaged on configuring assignment and mapping.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
181 |
fsm->num_configured_pdos++; |
801
6b1e2b0ed8bc
Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents:
800
diff
changeset
|
182 |
break; |
799 | 183 |
} |
184 |
} |
|
185 |
} |
|
186 |
||
801
6b1e2b0ed8bc
Cleaned up Pdo mapping and configuration state machines.
Florian Pose <fp@igh-essen.com>
parents:
800
diff
changeset
|
187 |
if (!fsm->pdo) { |
890
1115793a76ed
Debug messaged on configuring assignment and mapping.
Florian Pose <fp@igh-essen.com>
parents:
879
diff
changeset
|
188 |
if (fsm->slave->master->debug_level && !fsm->num_configured_pdos) |
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
189 |
EC_DBG("Pdo mappings are already configured correctly.\n"); |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
190 |
fsm->state = ec_fsm_pdo_mapping_state_end; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
191 |
return; |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
192 |
} |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
193 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
194 |
// Pdo mapping has to be changed. Does the slave support this? |
877 | 195 |
if (!(fsm->slave->sii.mailbox_protocols & EC_MBOX_COE) |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
196 |
|| (fsm->slave->sii.has_general |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
197 |
&& !fsm->slave->sii.coe_details.enable_pdo_configuration)) { |
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
198 |
EC_WARN("Slave %u does not support Pdo mapping configuration!\n", |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
199 |
fsm->slave->ring_position); |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
200 |
fsm->state = ec_fsm_pdo_mapping_state_error; |
835
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
201 |
return; |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
202 |
} |
23fd8b510803
Evaluate CoE details from general category; moved current consumption
Florian Pose <fp@igh-essen.com>
parents:
814
diff
changeset
|
203 |
|
799 | 204 |
if (fsm->slave->master->debug_level) { |
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
205 |
EC_DBG("Changing mapping of Pdo 0x%04X.\n", fsm->pdo->index); |
799 | 206 |
} |
207 |
||
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
208 |
if (ec_sdo_request_alloc(&fsm->request, 4)) { |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
209 |
fsm->state = ec_fsm_pdo_mapping_state_error; |
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
210 |
return; |
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
211 |
} |
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
212 |
|
814 | 213 |
// set mapped Pdo count to zero |
875
c5df898a3618
Fixed access to data pointers in Pdo config and Pdo mapping FSM's.
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
214 |
EC_WRITE_U8(fsm->request.data, 0); |
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
215 |
fsm->request.data_size = 1; |
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
216 |
ec_sdo_request_address(&fsm->request, fsm->pdo->index, 0); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
217 |
ecrt_sdo_request_write(&fsm->request); |
799 | 218 |
if (fsm->slave->master->debug_level) |
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
219 |
EC_DBG("Setting entry count to zero.\n"); |
799 | 220 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
221 |
fsm->state = ec_fsm_pdo_mapping_state_zero_count; |
859
233e32f428e1
Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
222 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request); |
799 | 223 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
224 |
} |
|
225 |
||
226 |
/*****************************************************************************/ |
|
227 |
||
228 |
/** Process next Pdo entry. |
|
229 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
230 |
ec_pdo_entry_t *ec_fsm_pdo_mapping_next_entry( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
231 |
const ec_fsm_pdo_mapping_t *fsm, /**< Pdo mapping state machine. */ |
799 | 232 |
const struct list_head *list /**< current entry list item */ |
233 |
) |
|
234 |
{ |
|
235 |
list = list->next; |
|
236 |
if (list == &fsm->pdo->entries) |
|
237 |
return NULL; // no next entry |
|
238 |
return list_entry(list, ec_pdo_entry_t, list); |
|
239 |
} |
|
240 |
||
241 |
/*****************************************************************************/ |
|
242 |
||
243 |
/** Starts to add a Pdo entry. |
|
244 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
245 |
void ec_fsm_pdo_mapping_add_entry( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
246 |
ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
799 | 247 |
) |
248 |
{ |
|
249 |
uint32_t value; |
|
250 |
||
1055
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
251 |
if (fsm->slave->master->debug_level) |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
252 |
EC_DBG("Mapping Pdo entry 0x%04X:%02X (%u bit) at position %u.\n", |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
253 |
fsm->entry->index, fsm->entry->subindex, |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
254 |
fsm->entry->bit_length, fsm->entry_count); |
2be8918682fa
Store sync manager configurations in ec_slave_config_t instead of Pdo
Florian Pose <fp@igh-essen.com>
parents:
926
diff
changeset
|
255 |
|
799 | 256 |
value = fsm->entry->index << 16 |
257 |
| fsm->entry->subindex << 8 | fsm->entry->bit_length; |
|
875
c5df898a3618
Fixed access to data pointers in Pdo config and Pdo mapping FSM's.
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
258 |
EC_WRITE_U32(fsm->request.data, value); |
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
259 |
fsm->request.data_size = 4; |
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
260 |
ec_sdo_request_address(&fsm->request, fsm->pdo->index, fsm->entry_count); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
261 |
ecrt_sdo_request_write(&fsm->request); |
799 | 262 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
263 |
fsm->state = ec_fsm_pdo_mapping_state_add_entry; |
859
233e32f428e1
Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
264 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request); |
799 | 265 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
266 |
} |
|
267 |
||
268 |
/*****************************************************************************/ |
|
269 |
||
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
270 |
/** Set the number of mapped entries to zero. |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
271 |
*/ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
272 |
void ec_fsm_pdo_mapping_state_zero_count( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
273 |
ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
799 | 274 |
) |
275 |
{ |
|
276 |
if (ec_fsm_coe_exec(fsm->fsm_coe)) return; |
|
277 |
||
278 |
if (!ec_fsm_coe_success(fsm->fsm_coe)) { |
|
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
279 |
EC_WARN("Failed to clear mapping of Pdo 0x%04X.\n", fsm->pdo->index); |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
280 |
fsm->state = ec_fsm_pdo_mapping_state_error; |
799 | 281 |
return; |
282 |
} |
|
283 |
||
284 |
// find first entry |
|
285 |
if (!(fsm->entry = |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
286 |
ec_fsm_pdo_mapping_next_entry(fsm, &fsm->pdo->entries))) { |
799 | 287 |
if (fsm->slave->master->debug_level) |
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
288 |
EC_DBG("No entries to map.\n"); |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
289 |
ec_fsm_pdo_mapping_next_pdo(fsm); |
799 | 290 |
return; |
291 |
} |
|
292 |
||
293 |
// add first entry |
|
294 |
fsm->entry_count = 1; |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
295 |
ec_fsm_pdo_mapping_add_entry(fsm); |
799 | 296 |
} |
297 |
||
298 |
/*****************************************************************************/ |
|
299 |
||
300 |
/** Add a Pdo entry. |
|
301 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
302 |
void ec_fsm_pdo_mapping_state_add_entry( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
303 |
ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
799 | 304 |
) |
305 |
{ |
|
306 |
if (ec_fsm_coe_exec(fsm->fsm_coe)) return; |
|
307 |
||
308 |
if (!ec_fsm_coe_success(fsm->fsm_coe)) { |
|
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
309 |
EC_WARN("Failed to map Pdo entry 0x%04X:%02X at 0x%04X:%02X.\n", |
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
310 |
fsm->entry->index, fsm->entry->subindex, fsm->pdo->index, |
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
311 |
fsm->entry_count); |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
312 |
fsm->state = ec_fsm_pdo_mapping_state_error; |
799 | 313 |
return; |
314 |
} |
|
315 |
||
316 |
// find next entry |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
317 |
if (!(fsm->entry = ec_fsm_pdo_mapping_next_entry(fsm, &fsm->entry->list))) { |
799 | 318 |
// No more entries to add. Write entry count. |
875
c5df898a3618
Fixed access to data pointers in Pdo config and Pdo mapping FSM's.
Florian Pose <fp@igh-essen.com>
parents:
859
diff
changeset
|
319 |
EC_WRITE_U8(fsm->request.data, fsm->entry_count); |
854
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
320 |
fsm->request.data_size = 1; |
f4f53be425ac
Removed ec_sdodata_t; CoE state machines work on ec_sdo_request_t.
Florian Pose <fp@igh-essen.com>
parents:
835
diff
changeset
|
321 |
ec_sdo_request_address(&fsm->request, fsm->pdo->index, 0); |
858
69122084d066
Basic reading realtime Sdo access working.
Florian Pose <fp@igh-essen.com>
parents:
854
diff
changeset
|
322 |
ecrt_sdo_request_write(&fsm->request); |
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
323 |
|
799 | 324 |
if (fsm->slave->master->debug_level) |
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
325 |
EC_DBG("Setting number of Pdo entries to %u.\n", fsm->entry_count); |
799 | 326 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
327 |
fsm->state = ec_fsm_pdo_mapping_state_entry_count; |
859
233e32f428e1
Replaced ec_fsm_coe_\(upload\|download\)() with ec_fsm_coe_transfer();
Florian Pose <fp@igh-essen.com>
parents:
858
diff
changeset
|
328 |
ec_fsm_coe_transfer(fsm->fsm_coe, fsm->slave, &fsm->request); |
799 | 329 |
ec_fsm_coe_exec(fsm->fsm_coe); // execute immediately |
330 |
return; |
|
331 |
} |
|
332 |
||
333 |
// add next entry |
|
334 |
fsm->entry_count++; |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
335 |
ec_fsm_pdo_mapping_add_entry(fsm); |
799 | 336 |
} |
337 |
||
338 |
/*****************************************************************************/ |
|
339 |
||
340 |
/** Set the number of entries. |
|
341 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
342 |
void ec_fsm_pdo_mapping_state_entry_count( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
343 |
ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
799 | 344 |
) |
345 |
{ |
|
346 |
if (ec_fsm_coe_exec(fsm->fsm_coe)) return; |
|
347 |
||
348 |
if (!ec_fsm_coe_success(fsm->fsm_coe)) { |
|
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
349 |
EC_WARN("Failed to set number of entries for Pdo 0x%04X.\n", |
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
350 |
fsm->pdo->index); |
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
351 |
fsm->state = ec_fsm_pdo_mapping_state_error; |
799 | 352 |
return; |
353 |
} |
|
354 |
||
355 |
if (fsm->slave->master->debug_level) |
|
1173
2ec9651a6c89
Only warn (and do not abort) if Pdo assignment/mapping configuration
Florian Pose <fp@igh-essen.com>
parents:
1082
diff
changeset
|
356 |
EC_DBG("Pdo mapping configuration successful.\n"); |
799 | 357 |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
358 |
ec_fsm_pdo_mapping_next_pdo(fsm); |
799 | 359 |
} |
360 |
||
361 |
/****************************************************************************** |
|
362 |
* Common state functions |
|
363 |
*****************************************************************************/ |
|
364 |
||
365 |
/** State: ERROR. |
|
366 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
367 |
void ec_fsm_pdo_mapping_state_error( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
368 |
ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
799 | 369 |
) |
370 |
{ |
|
371 |
} |
|
372 |
||
373 |
/*****************************************************************************/ |
|
374 |
||
375 |
/** State: END. |
|
376 |
*/ |
|
879
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
377 |
void ec_fsm_pdo_mapping_state_end( |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
378 |
ec_fsm_pdo_mapping_t *fsm /**< Pdo mapping state machine. */ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
379 |
) |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
380 |
{ |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
381 |
} |
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
382 |
|
9b395c5646ab
Changed terms "Pdo mapping" -> "Pdo assignment" and "Pdo configuration"
Florian Pose <fp@igh-essen.com>
parents:
877
diff
changeset
|
383 |
/*****************************************************************************/ |