master/master.c
changeset 435 779a18d12e6c
parent 430 74754f45d5fa
child 441 ffa13db95e10
equal deleted inserted replaced
434:0180d8277311 435:779a18d12e6c
   553 {
   553 {
   554     ec_fsm_t *fsm = &master->fsm;
   554     ec_fsm_t *fsm = &master->fsm;
   555 
   555 
   556     ec_fsm_startup(fsm); // init startup state machine
   556     ec_fsm_startup(fsm); // init startup state machine
   557 
   557 
   558     do {
   558     while (ec_fsm_exec(fsm)) {
   559         ec_fsm_execute(fsm);
       
   560         ec_master_sync_io(master);
   559         ec_master_sync_io(master);
   561     }
   560     }
   562     while (ec_fsm_startup_running(fsm));
       
   563 
   561 
   564     if (!ec_fsm_startup_success(fsm)) {
   562     if (!ec_fsm_startup_success(fsm)) {
   565         ec_master_clear_slaves(master);
   563         ec_master_clear_slaves(master);
   566         return -1;
   564         return -1;
   567     }
   565     }
   667 
   665 
   668     cycles_start = get_cycles();
   666     cycles_start = get_cycles();
   669     ecrt_master_receive(master);
   667     ecrt_master_receive(master);
   670 
   668 
   671     // execute master state machine
   669     // execute master state machine
   672     ec_fsm_execute(&master->fsm);
   670     ec_fsm_exec(&master->fsm);
   673 
   671 
   674     ecrt_master_send(master);
   672     ecrt_master_send(master);
   675     cycles_end = get_cycles();
   673     cycles_end = get_cycles();
   676 
   674 
   677     // release master lock
   675     // release master lock
  1244         }
  1242         }
  1245     }
  1243     }
  1246 
  1244 
  1247     ec_fsm_configuration(fsm); // init configuration state machine
  1245     ec_fsm_configuration(fsm); // init configuration state machine
  1248 
  1246 
  1249     do {
  1247     while (ec_fsm_exec(fsm)) {
  1250         ec_fsm_execute(fsm);
       
  1251         ec_master_sync_io(master);
  1248         ec_master_sync_io(master);
  1252     }
  1249     }
  1253     while (ec_fsm_configuration_running(fsm));
       
  1254 
  1250 
  1255     if (!ec_fsm_configuration_success(fsm)) {
  1251     if (!ec_fsm_configuration_success(fsm)) {
  1256         return -1;
  1252         return -1;
  1257     }
  1253     }
  1258 
  1254 
  1277         slave->requested_state = EC_SLAVE_STATE_INIT;
  1273         slave->requested_state = EC_SLAVE_STATE_INIT;
  1278     }
  1274     }
  1279 
  1275 
  1280     ec_fsm_configuration(fsm); // init configuration state machine
  1276     ec_fsm_configuration(fsm); // init configuration state machine
  1281 
  1277 
  1282     do {
  1278     while (ec_fsm_exec(fsm)) {
  1283         ec_fsm_execute(fsm);
       
  1284         ec_master_sync_io(master);
  1279         ec_master_sync_io(master);
  1285     }
  1280     }
  1286     while (ec_fsm_configuration_running(fsm));
       
  1287 }
  1281 }
  1288 
  1282 
  1289 /*****************************************************************************/
  1283 /*****************************************************************************/
  1290 
  1284 
  1291 /**
  1285 /**
  1427 {
  1421 {
  1428     // output statistics
  1422     // output statistics
  1429     ec_master_output_stats(master);
  1423     ec_master_output_stats(master);
  1430 
  1424 
  1431     // execute master state machine
  1425     // execute master state machine
  1432     ec_fsm_execute(&master->fsm);
  1426     ec_fsm_exec(&master->fsm);
  1433 }
  1427 }
  1434 
  1428 
  1435 /*****************************************************************************/
  1429 /*****************************************************************************/
  1436 
  1430 
  1437 /**
  1431 /**