master/fsm_master.c
changeset 1963 6aaf77798445
parent 1961 48f536aefc18
child 1995 7d748d9cf9e8
child 2100 da4640f9776d
equal deleted inserted replaced
1962:df9b00bda8dc 1963:6aaf77798445
    83     fsm->datagram = datagram;
    83     fsm->datagram = datagram;
    84     fsm->state = ec_fsm_master_state_start;
    84     fsm->state = ec_fsm_master_state_start;
    85     fsm->idle = 0;
    85     fsm->idle = 0;
    86     fsm->link_state = 0;
    86     fsm->link_state = 0;
    87     fsm->slaves_responding = 0;
    87     fsm->slaves_responding = 0;
    88     fsm->topology_change_pending = 0;
    88     fsm->rescan_required = 0;
    89     fsm->slave_states = EC_SLAVE_STATE_UNKNOWN;
    89     fsm->slave_states = EC_SLAVE_STATE_UNKNOWN;
    90 
    90 
    91     // init sub-state-machines
    91     // init sub-state-machines
    92     ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram);
    92     ec_fsm_coe_init(&fsm->fsm_coe, fsm->datagram);
    93     ec_fsm_pdo_init(&fsm->fsm_pdo, &fsm->fsm_coe);
    93     ec_fsm_pdo_init(&fsm->fsm_pdo, &fsm->fsm_coe);
   199     if (datagram->state == EC_DATAGRAM_TIMED_OUT)
   199     if (datagram->state == EC_DATAGRAM_TIMED_OUT)
   200         return; // always retry
   200         return; // always retry
   201 
   201 
   202     // bus topology change?
   202     // bus topology change?
   203     if (datagram->working_counter != fsm->slaves_responding) {
   203     if (datagram->working_counter != fsm->slaves_responding) {
   204         fsm->topology_change_pending = 1;
   204         fsm->rescan_required = 1;
   205         fsm->slaves_responding = datagram->working_counter;
   205         fsm->slaves_responding = datagram->working_counter;
   206         EC_MASTER_INFO(master, "%u slave(s) responding.\n",
   206         EC_MASTER_INFO(master, "%u slave(s) responding.\n",
   207                 fsm->slaves_responding);
   207                 fsm->slaves_responding);
   208     }
   208     }
   209 
   209 
   235         }
   235         }
   236     } else {
   236     } else {
   237         fsm->slave_states = 0x00;
   237         fsm->slave_states = 0x00;
   238     }
   238     }
   239 
   239 
   240     if (fsm->topology_change_pending) {
   240     if (fsm->rescan_required) {
   241         down(&master->scan_sem);
   241         down(&master->scan_sem);
   242         if (!master->allow_scan) {
   242         if (!master->allow_scan) {
   243             up(&master->scan_sem);
   243             up(&master->scan_sem);
   244         } else {
   244         } else {
   245             master->scan_busy = 1;
   245             master->scan_busy = 1;
   246             up(&master->scan_sem);
   246             up(&master->scan_sem);
   247 
   247 
   248             // topology change when scan is allowed:
       
   249             // clear all slaves and scan the bus
   248             // clear all slaves and scan the bus
   250             fsm->topology_change_pending = 0;
   249             fsm->rescan_required = 0;
   251             fsm->idle = 0;
   250             fsm->idle = 0;
   252             fsm->scan_jiffies = jiffies;
   251             fsm->scan_jiffies = jiffies;
   253 
   252 
   254 #ifdef EC_EOE
   253 #ifdef EC_EOE
   255             ec_master_eoe_stop(master);
   254             ec_master_eoe_stop(master);
   628     if (datagram->working_counter != 1) {
   627     if (datagram->working_counter != 1) {
   629         if (!slave->error_flag) {
   628         if (!slave->error_flag) {
   630             slave->error_flag = 1;
   629             slave->error_flag = 1;
   631             EC_SLAVE_DBG(slave, 1, "Slave did not respond to state query.\n");
   630             EC_SLAVE_DBG(slave, 1, "Slave did not respond to state query.\n");
   632         }
   631         }
   633         fsm->topology_change_pending = 1;
   632         fsm->rescan_required = 1;
   634         ec_fsm_master_restart(fsm);
   633         ec_fsm_master_restart(fsm);
   635         return;
   634         return;
   636     }
   635     }
   637 
   636 
   638     // A single slave responded
   637     // A single slave responded