Do-Schleifen ersetzt.
This commit is contained in:
parent
a63d1c52a4
commit
290d5d86a4
|
|
@ -194,8 +194,10 @@ int ecrt_slave_sdo_read(ec_slave_t *slave, /**< EtherCAT-Slave */
|
|||
start = get_cycles();
|
||||
timeout = cpu_khz; // 1ms
|
||||
|
||||
do
|
||||
while (1)
|
||||
{
|
||||
udelay(10);
|
||||
|
||||
ec_command_init_nprd(&command, slave->station_address, 0x808, 8);
|
||||
if (unlikely(ec_master_simple_io(master, &command))) {
|
||||
EC_ERR("Mailbox checking failed on slave %i!\n",
|
||||
|
|
@ -208,12 +210,12 @@ int ecrt_slave_sdo_read(ec_slave_t *slave, /**< EtherCAT-Slave */
|
|||
if (EC_READ_U8(command.data + 5) & 8) { // Written bit is high
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (likely((end - start) < timeout));
|
||||
|
||||
if (unlikely((end - start) >= timeout)) {
|
||||
EC_ERR("Mailbox check on slave %i timed out.\n", slave->ring_position);
|
||||
return -1;
|
||||
if (unlikely((end - start) >= timeout)) {
|
||||
EC_ERR("Mailbox check on slave %i timed out.\n",
|
||||
slave->ring_position);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ec_command_init_nprd(&command, slave->station_address, 0x18F6, 0xF6);
|
||||
|
|
|
|||
|
|
@ -369,13 +369,15 @@ int ec_master_simple_io(ec_master_t *master, /**< EtherCAT-Master */
|
|||
unsigned int response_tries_left;
|
||||
|
||||
response_tries_left = 10;
|
||||
do
|
||||
|
||||
while (1)
|
||||
{
|
||||
ec_master_queue_command(master, command);
|
||||
ecrt_master_sync_io(master);
|
||||
|
||||
if (command->state == EC_CMD_RECEIVED) {
|
||||
break;
|
||||
if (likely(command->working_counter))
|
||||
return 0;
|
||||
}
|
||||
else if (command->state == EC_CMD_TIMEOUT) {
|
||||
EC_ERR("Simple-IO TIMEOUT!\n");
|
||||
|
|
@ -388,15 +390,12 @@ int ec_master_simple_io(ec_master_t *master, /**< EtherCAT-Master */
|
|||
|
||||
// Keine direkte Antwort. Dem Slave Zeit lassen...
|
||||
udelay(10);
|
||||
}
|
||||
while (unlikely(!command->working_counter && --response_tries_left));
|
||||
|
||||
if (unlikely(!response_tries_left)) {
|
||||
EC_ERR("No response in simple-IO!\n");
|
||||
return -1;
|
||||
if (unlikely(--response_tries_left)) {
|
||||
EC_ERR("No response in simple-IO!\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -860,7 +859,8 @@ void ecrt_master_sync_io(ec_master_t *master)
|
|||
t_start = get_cycles(); // Sendezeit nehmen
|
||||
t_timeout = master->timeout * cpu_khz / 1000;
|
||||
|
||||
do {
|
||||
while (1)
|
||||
{
|
||||
ec_device_call_isr(master->device);
|
||||
|
||||
t_end = get_cycles(); // Aktuelle Zeit nehmen
|
||||
|
|
@ -873,7 +873,9 @@ void ecrt_master_sync_io(ec_master_t *master)
|
|||
else if (command->state == EC_CMD_SENT)
|
||||
commands_sent++;
|
||||
}
|
||||
} while (commands_sent);
|
||||
|
||||
if (!commands_sent) break;
|
||||
}
|
||||
|
||||
// Zeit abgelaufen. Alle verbleibenden Kommandos entfernen.
|
||||
list_for_each_entry_safe(command, next, &master->commands, list) {
|
||||
|
|
@ -983,10 +985,10 @@ void ecrt_master_prepare_async_io(ec_master_t *master)
|
|||
t_timeout = master->timeout * cpu_khz / 1000;
|
||||
|
||||
// Aktiv warten!
|
||||
do {
|
||||
while (1) {
|
||||
t_end = get_cycles();
|
||||
if (t_end - t_start >= t_timeout) break;
|
||||
}
|
||||
while (t_end - t_start < t_timeout);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -152,8 +152,10 @@ int ec_slave_sii_read(ec_slave_t *slave,
|
|||
start = get_cycles();
|
||||
timeout = cpu_khz; // 1ms
|
||||
|
||||
do
|
||||
while (1)
|
||||
{
|
||||
udelay(10);
|
||||
|
||||
ec_command_init_nprd(&command, slave->station_address, 0x502, 10);
|
||||
if (unlikely(ec_master_simple_io(slave->master, &command))) {
|
||||
EC_ERR("Getting SII-read status failed on slave %i!\n",
|
||||
|
|
@ -165,17 +167,14 @@ int ec_slave_sii_read(ec_slave_t *slave,
|
|||
|
||||
if (likely((EC_READ_U8(command.data + 1) & 0x81) == 0)) {
|
||||
memcpy(target, command.data + 6, 4);
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (unlikely((end - start) >= timeout)) {
|
||||
EC_ERR("SSI-read. Slave %i timed out!\n", slave->ring_position);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
while (likely((end - start) < timeout));
|
||||
|
||||
if (unlikely((end - start) >= timeout)) {
|
||||
EC_ERR("SSI-read. Slave %i timed out!\n", slave->ring_position);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
@ -208,8 +207,10 @@ void ec_slave_state_ack(ec_slave_t *slave,
|
|||
start = get_cycles();
|
||||
timeout = cpu_khz; // 1ms
|
||||
|
||||
do
|
||||
while (1)
|
||||
{
|
||||
udelay(100); // Dem Slave etwas Zeit lassen...
|
||||
|
||||
ec_command_init_nprd(&command, slave->station_address, 0x0130, 2);
|
||||
if (unlikely(ec_master_simple_io(slave->master, &command))) {
|
||||
EC_WARN("State %02X acknowledge checking failed on slave %i!\n",
|
||||
|
|
@ -231,13 +232,12 @@ void ec_slave_state_ack(ec_slave_t *slave,
|
|||
slave->ring_position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
while (likely((end - start) < timeout));
|
||||
|
||||
if (unlikely((end - start) >= timeout)) {
|
||||
EC_WARN("Could not check state acknowledgement %02X of slave %i -"
|
||||
" Timeout while checking!\n", state, slave->ring_position);
|
||||
return;
|
||||
if (unlikely((end - start) >= timeout)) {
|
||||
EC_WARN("Could not check state acknowledgement %02X of slave %i -"
|
||||
" Timeout while checking!\n", state, slave->ring_position);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -271,7 +271,7 @@ int ec_slave_state_change(ec_slave_t *slave,
|
|||
start = get_cycles();
|
||||
timeout = cpu_khz; // 1ms
|
||||
|
||||
do
|
||||
while (1)
|
||||
{
|
||||
udelay(100); // Dem Slave etwas Zeit lassen...
|
||||
|
||||
|
|
@ -294,18 +294,15 @@ int ec_slave_state_change(ec_slave_t *slave,
|
|||
|
||||
if (likely(EC_READ_U8(command.data) == (state & 0x0F))) {
|
||||
// State change successful
|
||||
break;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (unlikely((end - start) >= timeout)) {
|
||||
EC_ERR("Could not check state %02X of slave %i - Timeout!\n",
|
||||
state, slave->ring_position);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
while (likely((end - start) < timeout));
|
||||
|
||||
if (unlikely((end - start) >= timeout)) {
|
||||
EC_ERR("Could not check state %02X of slave %i - Timeout!\n", state,
|
||||
slave->ring_position);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
Loading…
Reference in New Issue