master/fsm_master.c
changeset 834 0791aac03180
parent 831 ded9519c8d6e
child 849 4b712ec8929d
equal deleted inserted replaced
833:5dca670ae4dd 834:0791aac03180
   501 
   501 
   502     if (master->mode == EC_MASTER_MODE_IDLE) {
   502     if (master->mode == EC_MASTER_MODE_IDLE) {
   503 
   503 
   504         // check, if slaves have an Sdo dictionary to read out.
   504         // check, if slaves have an Sdo dictionary to read out.
   505         list_for_each_entry(slave, &master->slaves, list) {
   505         list_for_each_entry(slave, &master->slaves, list) {
   506             if (!(slave->sii_mailbox_protocols & EC_MBOX_COE)
   506             if (!(slave->sii.mailbox_protocols & EC_MBOX_COE)
   507                 || slave->sdo_dictionary_fetched
   507                 || slave->sdo_dictionary_fetched
   508                 || slave->current_state == EC_SLAVE_STATE_INIT
   508                 || slave->current_state == EC_SLAVE_STATE_INIT
   509                 || jiffies - slave->jiffies_preop < EC_WAIT_SDO_DICT * HZ
   509                 || jiffies - slave->jiffies_preop < EC_WAIT_SDO_DICT * HZ
   510                 || slave->online_state == EC_SLAVE_OFFLINE
   510                 || slave->online_state == EC_SLAVE_OFFLINE
   511                 || slave->error_flag) continue;
   511                 || slave->error_flag) continue;
   671                slave->ring_position);
   671                slave->ring_position);
   672         fsm->state = ec_fsm_master_state_error;
   672         fsm->state = ec_fsm_master_state_error;
   673         return;
   673         return;
   674     }
   674     }
   675 
   675 
   676     if (EC_READ_U32(fsm->fsm_sii.value) != slave->sii_vendor_id) {
   676     if (EC_READ_U32(fsm->fsm_sii.value) != slave->sii.vendor_id) {
   677         EC_ERR("Slave %i has an invalid vendor ID!\n", slave->ring_position);
   677         EC_ERR("Slave %i has an invalid vendor ID!\n", slave->ring_position);
   678         fsm->state = ec_fsm_master_state_error;
   678         fsm->state = ec_fsm_master_state_error;
   679         return;
   679         return;
   680     }
   680     }
   681 
   681 
   736                slave->ring_position);
   736                slave->ring_position);
   737         fsm->state = ec_fsm_master_state_error;
   737         fsm->state = ec_fsm_master_state_error;
   738         return;
   738         return;
   739     }
   739     }
   740 
   740 
   741     if (EC_READ_U32(fsm->fsm_sii.value) != slave->sii_product_code) {
   741     if (EC_READ_U32(fsm->fsm_sii.value) != slave->sii.product_code) {
   742         EC_ERR("Slave %i: invalid product code!\n", slave->ring_position);
   742         EC_ERR("Slave %i: invalid product code!\n", slave->ring_position);
   743         EC_ERR("expected 0x%08X, got 0x%08X.\n", slave->sii_product_code,
   743         EC_ERR("expected 0x%08X, got 0x%08X.\n", slave->sii.product_code,
   744                EC_READ_U32(fsm->fsm_sii.value));
   744                EC_READ_U32(fsm->fsm_sii.value));
   745         fsm->state = ec_fsm_master_state_error;
   745         fsm->state = ec_fsm_master_state_error;
   746         return;
   746         return;
   747     }
   747     }
   748 
   748 
   863 
   863 
   864     if (ec_fsm_slave_scan_exec(&fsm->fsm_slave_scan)) // execute slave state machine
   864     if (ec_fsm_slave_scan_exec(&fsm->fsm_slave_scan)) // execute slave state machine
   865         return;
   865         return;
   866 
   866 
   867 #ifdef EC_EOE
   867 #ifdef EC_EOE
   868     if (slave->sii_mailbox_protocols & EC_MBOX_EOE) {
   868     if (slave->sii.mailbox_protocols & EC_MBOX_EOE) {
   869         // create EoE handler for this slave
   869         // create EoE handler for this slave
   870         ec_eoe_t *eoe;
   870         ec_eoe_t *eoe;
   871         if (!(eoe = kmalloc(sizeof(ec_eoe_t), GFP_KERNEL))) {
   871         if (!(eoe = kmalloc(sizeof(ec_eoe_t), GFP_KERNEL))) {
   872             EC_ERR("Failed to allocate EoE handler memory for slave %u!\n",
   872             EC_ERR("Failed to allocate EoE handler memory for slave %u!\n",
   873                     slave->ring_position);
   873                     slave->ring_position);