65 /**< PREOP state (mailbox communication, no IO) */ |
65 /**< PREOP state (mailbox communication, no IO) */ |
66 EC_SLAVE_STATE_SAVEOP = 0x04, |
66 EC_SLAVE_STATE_SAVEOP = 0x04, |
67 /**< SAVEOP (mailbox communication and input update) */ |
67 /**< SAVEOP (mailbox communication and input update) */ |
68 EC_SLAVE_STATE_OP = 0x08, |
68 EC_SLAVE_STATE_OP = 0x08, |
69 /**< OP (mailbox communication and input/output update) */ |
69 /**< OP (mailbox communication and input/output update) */ |
70 EC_ACK = 0x10 |
70 EC_SLAVE_STATE_ACK_ERR = 0x10 |
71 /**< Acknoledge bit (no state) */ |
71 /**< Acknowledge/Error bit (no actual state) */ |
72 } |
72 } |
73 ec_slave_state_t; |
73 ec_slave_state_t; |
74 |
74 |
75 /*****************************************************************************/ |
75 /*****************************************************************************/ |
76 |
76 |
114 unsigned int index; /**< sync manager index */ |
114 unsigned int index; /**< sync manager index */ |
115 uint16_t physical_start_address; /**< physical start address */ |
115 uint16_t physical_start_address; /**< physical start address */ |
116 uint16_t length; /**< data length in bytes */ |
116 uint16_t length; /**< data length in bytes */ |
117 uint8_t control_register; /**< control register value */ |
117 uint8_t control_register; /**< control register value */ |
118 uint8_t enable; /**< enable bit */ |
118 uint8_t enable; /**< enable bit */ |
|
119 uint16_t est_length; /**< Estimated length. This is no field of the SII, |
|
120 but it is used to calculate the length via |
|
121 PDO ranges */ |
119 } |
122 } |
120 ec_sii_sync_t; |
123 ec_sii_sync_t; |
121 |
124 |
122 /*****************************************************************************/ |
125 /*****************************************************************************/ |
123 |
126 |
166 ec_sii_pdo_entry_t; |
169 ec_sii_pdo_entry_t; |
167 |
170 |
168 /*****************************************************************************/ |
171 /*****************************************************************************/ |
169 |
172 |
170 /** |
173 /** |
171 CANopen SDO. |
|
172 */ |
|
173 |
|
174 typedef struct |
|
175 { |
|
176 struct list_head list; /**< list item */ |
|
177 uint16_t index; /**< SDO index */ |
|
178 uint8_t object_code; /**< object code */ |
|
179 char *name; /**< SDO name */ |
|
180 struct list_head entries; /**< entry list */ |
|
181 } |
|
182 ec_sdo_t; |
|
183 |
|
184 /*****************************************************************************/ |
|
185 |
|
186 /** |
|
187 CANopen SDO entry. |
|
188 */ |
|
189 |
|
190 typedef struct |
|
191 { |
|
192 struct list_head list; /**< list item */ |
|
193 uint8_t subindex; /**< entry subindex */ |
|
194 uint16_t data_type; /**< entry data type */ |
|
195 uint16_t bit_length; /**< entry length in bit */ |
|
196 char *name; /**< entry name */ |
|
197 } |
|
198 ec_sdo_entry_t; |
|
199 |
|
200 /*****************************************************************************/ |
|
201 |
|
202 typedef struct |
|
203 { |
|
204 struct list_head list; /**< list item */ |
|
205 uint16_t index; /**< SDO index */ |
|
206 uint8_t subindex; /**< SDO subindex */ |
|
207 uint8_t *data; /**< pointer to SDO data */ |
|
208 size_t size; /**< size of SDO data */ |
|
209 } |
|
210 ec_sdo_data_t; |
|
211 |
|
212 /*****************************************************************************/ |
|
213 |
|
214 /** |
|
215 FMMU configuration. |
174 FMMU configuration. |
216 */ |
175 */ |
217 |
176 |
218 typedef struct |
177 typedef struct |
219 { |
178 { |
|
179 unsigned int index; /**< FMMU index */ |
220 const ec_domain_t *domain; /**< domain */ |
180 const ec_domain_t *domain; /**< domain */ |
221 const ec_sii_sync_t *sync; /**< sync manager */ |
181 const ec_sii_sync_t *sync; /**< sync manager */ |
222 uint32_t logical_start_address; /**< logical start address */ |
182 uint32_t logical_start_address; /**< logical start address */ |
223 } |
183 } |
224 ec_fmmu_t; |
184 ec_fmmu_t; |
225 |
185 |
226 /*****************************************************************************/ |
186 /*****************************************************************************/ |
227 |
187 |
228 /** |
188 /** |
229 Variable-sized field information. |
|
230 */ |
|
231 |
|
232 typedef struct |
|
233 { |
|
234 struct list_head list; /**< list item */ |
|
235 const ec_sii_pdo_t *pdo; /**< PDO */ |
|
236 size_t size; /**< field size */ |
|
237 } |
|
238 ec_varsize_t; |
|
239 |
|
240 /*****************************************************************************/ |
|
241 |
|
242 /** |
|
243 EtherCAT slave. |
189 EtherCAT slave. |
244 */ |
190 */ |
245 |
191 |
246 struct ec_slave |
192 struct ec_slave |
247 { |
193 { |
249 struct kobject kobj; /**< kobject */ |
195 struct kobject kobj; /**< kobject */ |
250 ec_master_t *master; /**< master owning the slave */ |
196 ec_master_t *master; /**< master owning the slave */ |
251 |
197 |
252 ec_slave_state_t requested_state; /**< requested slave state */ |
198 ec_slave_state_t requested_state; /**< requested slave state */ |
253 ec_slave_state_t current_state; /**< current slave state */ |
199 ec_slave_state_t current_state; /**< current slave state */ |
|
200 unsigned int configured; /**< the slave was configured by this master */ |
254 unsigned int error_flag; /**< stop processing after an error */ |
201 unsigned int error_flag; /**< stop processing after an error */ |
255 unsigned int online; /**< non-zero, if the slave responds. */ |
202 unsigned int online; /**< non-zero, if the slave responds. */ |
256 uint8_t registered; /**< true, if slave has been registered */ |
|
257 |
203 |
258 // addresses |
204 // addresses |
259 uint16_t ring_position; /**< ring position */ |
205 uint16_t ring_position; /**< ring position */ |
260 uint16_t station_address; /**< configured station address */ |
206 uint16_t station_address; /**< configured station address */ |
261 uint16_t coupler_index; /**< index of the last bus coupler */ |
207 uint16_t coupler_index; /**< index of the last bus coupler */ |
300 char *sii_name; /**< slave name acc. to EEPROM */ |
246 char *sii_name; /**< slave name acc. to EEPROM */ |
301 |
247 |
302 ec_fmmu_t fmmus[EC_MAX_FMMUS]; /**< FMMU configurations */ |
248 ec_fmmu_t fmmus[EC_MAX_FMMUS]; /**< FMMU configurations */ |
303 uint8_t fmmu_count; /**< number of FMMUs used */ |
249 uint8_t fmmu_count; /**< number of FMMUs used */ |
304 |
250 |
305 struct list_head sdo_dictionary; /**< SDO directory list */ |
251 struct kobject sdo_kobj; /**< kobject for SDOs */ |
|
252 struct list_head sdo_dictionary; /**< SDO dictionary list */ |
306 struct list_head sdo_confs; /**< list of SDO configurations */ |
253 struct list_head sdo_confs; /**< list of SDO configurations */ |
307 |
254 uint8_t sdo_dictionary_fetched; /**< dictionary has been fetched */ |
308 struct list_head varsize_fields; /**< size information for variable-sized |
255 unsigned long jiffies_preop; /**< time, the slave went to PREOP */ |
309 data fields. */ |
|
310 }; |
256 }; |
311 |
257 |
312 /*****************************************************************************/ |
258 /*****************************************************************************/ |
313 |
259 |
314 // slave construction/destruction |
260 // slave construction/destruction |
315 int ec_slave_init(ec_slave_t *, ec_master_t *, uint16_t, uint16_t); |
261 int ec_slave_init(ec_slave_t *, ec_master_t *, uint16_t, uint16_t); |
316 void ec_slave_clear(struct kobject *); |
262 void ec_slave_destroy(ec_slave_t *); |
|
263 |
|
264 void ec_slave_reset(ec_slave_t *); |
317 |
265 |
318 int ec_slave_prepare_fmmu(ec_slave_t *, const ec_domain_t *, |
266 int ec_slave_prepare_fmmu(ec_slave_t *, const ec_domain_t *, |
319 const ec_sii_sync_t *); |
267 const ec_sii_sync_t *); |
320 |
268 |
321 // CoE |
269 void ec_slave_request_state(ec_slave_t *, ec_slave_state_t); |
322 //int ec_slave_fetch_sdo_list(ec_slave_t *); |
|
323 |
270 |
324 // SII categories |
271 // SII categories |
325 int ec_slave_fetch_strings(ec_slave_t *, const uint8_t *); |
272 int ec_slave_fetch_strings(ec_slave_t *, const uint8_t *); |
326 void ec_slave_fetch_general(ec_slave_t *, const uint8_t *); |
273 void ec_slave_fetch_general(ec_slave_t *, const uint8_t *); |
327 int ec_slave_fetch_sync(ec_slave_t *, const uint8_t *, size_t); |
274 int ec_slave_fetch_sync(ec_slave_t *, const uint8_t *, size_t); |
334 const ec_sii_sync_t *); |
281 const ec_sii_sync_t *); |
335 |
282 |
336 int ec_slave_is_coupler(const ec_slave_t *); |
283 int ec_slave_is_coupler(const ec_slave_t *); |
337 int ec_slave_has_subbus(const ec_slave_t *); |
284 int ec_slave_has_subbus(const ec_slave_t *); |
338 |
285 |
|
286 int ec_slave_validate(const ec_slave_t *, uint32_t, uint32_t); |
|
287 |
|
288 void ec_slave_sdo_dict_info(const ec_slave_t *, |
|
289 unsigned int *, unsigned int *); |
|
290 |
339 /*****************************************************************************/ |
291 /*****************************************************************************/ |
340 |
292 |
341 #endif |
293 #endif |