46 void ec_fsm_slave_scan_state_start(ec_fsm_slave_scan_t *); |
46 void ec_fsm_slave_scan_state_start(ec_fsm_slave_scan_t *); |
47 void ec_fsm_slave_scan_state_address(ec_fsm_slave_scan_t *); |
47 void ec_fsm_slave_scan_state_address(ec_fsm_slave_scan_t *); |
48 void ec_fsm_slave_scan_state_state(ec_fsm_slave_scan_t *); |
48 void ec_fsm_slave_scan_state_state(ec_fsm_slave_scan_t *); |
49 void ec_fsm_slave_scan_state_base(ec_fsm_slave_scan_t *); |
49 void ec_fsm_slave_scan_state_base(ec_fsm_slave_scan_t *); |
50 void ec_fsm_slave_scan_state_dc_cap(ec_fsm_slave_scan_t *); |
50 void ec_fsm_slave_scan_state_dc_cap(ec_fsm_slave_scan_t *); |
|
51 void ec_fsm_slave_scan_state_dc_times(ec_fsm_slave_scan_t *); |
51 void ec_fsm_slave_scan_state_datalink(ec_fsm_slave_scan_t *); |
52 void ec_fsm_slave_scan_state_datalink(ec_fsm_slave_scan_t *); |
52 void ec_fsm_slave_scan_state_sii_size(ec_fsm_slave_scan_t *); |
53 void ec_fsm_slave_scan_state_sii_size(ec_fsm_slave_scan_t *); |
53 void ec_fsm_slave_scan_state_sii_data(ec_fsm_slave_scan_t *); |
54 void ec_fsm_slave_scan_state_sii_data(ec_fsm_slave_scan_t *); |
54 void ec_fsm_slave_scan_state_preop(ec_fsm_slave_scan_t *); |
55 void ec_fsm_slave_scan_state_preop(ec_fsm_slave_scan_t *); |
55 void ec_fsm_slave_scan_state_sync(ec_fsm_slave_scan_t *); |
56 void ec_fsm_slave_scan_state_sync(ec_fsm_slave_scan_t *); |
255 fsm->state = ec_fsm_slave_scan_state_base; |
256 fsm->state = ec_fsm_slave_scan_state_base; |
256 } |
257 } |
257 |
258 |
258 /*****************************************************************************/ |
259 /*****************************************************************************/ |
259 |
260 |
260 /** |
261 /** Slave scan state: BASE. |
261 Slave scan state: BASE. |
262 */ |
262 */ |
263 void ec_fsm_slave_scan_state_base( |
263 |
264 ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
264 void ec_fsm_slave_scan_state_base(ec_fsm_slave_scan_t *fsm /**< slave state machine */) |
265 ) |
265 { |
266 { |
266 ec_datagram_t *datagram = fsm->datagram; |
267 ec_datagram_t *datagram = fsm->datagram; |
267 ec_slave_t *slave = fsm->slave; |
268 ec_slave_t *slave = fsm->slave; |
268 u8 octet; |
269 u8 octet; |
269 int i; |
270 int i; |
370 fsm->state = ec_fsm_slave_scan_state_error; |
371 fsm->state = ec_fsm_slave_scan_state_error; |
371 EC_ERR("Failed to determine, if system time register is " |
372 EC_ERR("Failed to determine, if system time register is " |
372 "supported by slave %u: ", slave->ring_position); |
373 "supported by slave %u: ", slave->ring_position); |
373 ec_datagram_print_wc_error(datagram); |
374 ec_datagram_print_wc_error(datagram); |
374 return; |
375 return; |
|
376 } |
|
377 |
|
378 // read DC port receive times |
|
379 ec_datagram_fprd(datagram, slave->station_address, 0x0900, 16); |
|
380 ec_datagram_zero(datagram); |
|
381 fsm->retries = EC_FSM_RETRIES; |
|
382 fsm->state = ec_fsm_slave_scan_state_dc_times; |
|
383 } |
|
384 |
|
385 /*****************************************************************************/ |
|
386 |
|
387 /** |
|
388 Slave scan state: DC TIMES. |
|
389 */ |
|
390 |
|
391 void ec_fsm_slave_scan_state_dc_times( |
|
392 ec_fsm_slave_scan_t *fsm /**< slave state machine */ |
|
393 ) |
|
394 { |
|
395 ec_datagram_t *datagram = fsm->datagram; |
|
396 ec_slave_t *slave = fsm->slave; |
|
397 int i; |
|
398 |
|
399 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
|
400 return; |
|
401 |
|
402 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
|
403 fsm->state = ec_fsm_slave_scan_state_error; |
|
404 EC_ERR("Failed to receive system time datagram for slave %u" |
|
405 " (datagram state %u).\n", |
|
406 slave->ring_position, datagram->state); |
|
407 return; |
|
408 } |
|
409 |
|
410 if (datagram->working_counter != 1) { |
|
411 fsm->slave->error_flag = 1; |
|
412 fsm->state = ec_fsm_slave_scan_state_error; |
|
413 EC_ERR("Failed to get DC receive times of slave %u: ", |
|
414 slave->ring_position); |
|
415 ec_datagram_print_wc_error(datagram); |
|
416 return; |
|
417 } |
|
418 |
|
419 for (i = 0; i < EC_MAX_PORTS; i++) { |
|
420 slave->dc_receive_times[i] = EC_READ_U32(datagram->data + 4 * i); |
375 } |
421 } |
376 |
422 |
377 ec_fsm_slave_scan_enter_datalink(fsm); |
423 ec_fsm_slave_scan_enter_datalink(fsm); |
378 } |
424 } |
379 |
425 |