50 void ec_fsm_master_state_broadcast(ec_fsm_master_t *); |
50 void ec_fsm_master_state_broadcast(ec_fsm_master_t *); |
51 void ec_fsm_master_state_read_state(ec_fsm_master_t *); |
51 void ec_fsm_master_state_read_state(ec_fsm_master_t *); |
52 void ec_fsm_master_state_acknowledge(ec_fsm_master_t *); |
52 void ec_fsm_master_state_acknowledge(ec_fsm_master_t *); |
53 void ec_fsm_master_state_configure_slave(ec_fsm_master_t *); |
53 void ec_fsm_master_state_configure_slave(ec_fsm_master_t *); |
54 void ec_fsm_master_state_clear_addresses(ec_fsm_master_t *); |
54 void ec_fsm_master_state_clear_addresses(ec_fsm_master_t *); |
|
55 void ec_fsm_master_state_dc_measure_delays(ec_fsm_master_t *); |
55 void ec_fsm_master_state_scan_slave(ec_fsm_master_t *); |
56 void ec_fsm_master_state_scan_slave(ec_fsm_master_t *); |
56 void ec_fsm_master_state_write_sii(ec_fsm_master_t *); |
57 void ec_fsm_master_state_write_sii(ec_fsm_master_t *); |
57 void ec_fsm_master_state_sdo_dictionary(ec_fsm_master_t *); |
58 void ec_fsm_master_state_sdo_dictionary(ec_fsm_master_t *); |
58 void ec_fsm_master_state_sdo_request(ec_fsm_master_t *); |
59 void ec_fsm_master_state_sdo_request(ec_fsm_master_t *); |
59 void ec_fsm_master_state_reg_request(ec_fsm_master_t *); |
60 void ec_fsm_master_state_reg_request(ec_fsm_master_t *); |
768 |
769 |
769 if (datagram->working_counter != master->slave_count) { |
770 if (datagram->working_counter != master->slave_count) { |
770 EC_WARN("Failed to clear all station addresses: Cleared %u of %u", |
771 EC_WARN("Failed to clear all station addresses: Cleared %u of %u", |
771 datagram->working_counter, master->slave_count); |
772 datagram->working_counter, master->slave_count); |
772 } |
773 } |
|
774 |
|
775 if (master->debug_level) |
|
776 EC_DBG("Sending broadcast-write to measure transmission delays.\n"); |
|
777 |
|
778 ec_datagram_bwr(datagram, 0x0900, 1); |
|
779 ec_datagram_zero(datagram); |
|
780 fsm->retries = EC_FSM_RETRIES; |
|
781 fsm->state = ec_fsm_master_state_dc_measure_delays; |
|
782 } |
|
783 |
|
784 /*****************************************************************************/ |
|
785 |
|
786 /** Master state: DC MEASURE DELAYS. |
|
787 */ |
|
788 void ec_fsm_master_state_dc_measure_delays( |
|
789 ec_fsm_master_t *fsm /**< Master state machine. */ |
|
790 ) |
|
791 { |
|
792 ec_master_t *master = fsm->master; |
|
793 ec_datagram_t *datagram = fsm->datagram; |
|
794 |
|
795 if (datagram->state == EC_DATAGRAM_TIMED_OUT && fsm->retries--) |
|
796 return; |
|
797 |
|
798 if (datagram->state != EC_DATAGRAM_RECEIVED) { |
|
799 EC_ERR("Failed to receive delay measuring datagram (state %u).\n", |
|
800 datagram->state); |
|
801 master->scan_busy = 0; |
|
802 wake_up_interruptible(&master->scan_queue); |
|
803 ec_fsm_master_restart(fsm); |
|
804 return; |
|
805 } |
|
806 |
|
807 if (master->debug_level) |
|
808 EC_DBG("%u slaves responded to delay measuring.\n", |
|
809 datagram->working_counter); |
773 |
810 |
774 EC_INFO("Scanning bus.\n"); |
811 EC_INFO("Scanning bus.\n"); |
775 |
812 |
776 // begin scanning of slaves |
813 // begin scanning of slaves |
777 fsm->slave = master->slaves; |
814 fsm->slave = master->slaves; |