diff --git a/examples/dc_rtai/dc_rtai_sample.c b/examples/dc_rtai/dc_rtai_sample.c index 4e82b212..94f4c1ca 100644 --- a/examples/dc_rtai/dc_rtai_sample.c +++ b/examples/dc_rtai/dc_rtai_sample.c @@ -161,7 +161,7 @@ void check_master_state(void) void run(long data) { int i; - struct timeval tv; + struct timeval tv; unsigned int sync_ref_counter = 0; count2timeval(nano2count(rt_get_real_time_ns()), &tv); @@ -181,18 +181,18 @@ void run(long data) if (counter) { counter--; } else { - u32 c; - + u32 c; + counter = FREQUENCY; // check for master state (optional) check_master_state(); - c = EC_READ_U32(domain1_pd + off_counter_in); - if (counter_value != c) { - counter_value = c; - printk(KERN_INFO PFX "counter=%u\n", counter_value); - } + c = EC_READ_U32(domain1_pd + off_counter_in); + if (counter_value != c) { + counter_value = c; + printk(KERN_INFO PFX "counter=%u\n", counter_value); + } } @@ -210,10 +210,10 @@ void run(long data) EC_WRITE_U8(domain1_pd + off_dig_out[i], blink ? 0x66 : 0x99); } - EC_WRITE_U8(domain1_pd + off_counter_out, blink ? 0x00 : 0x02); + EC_WRITE_U8(domain1_pd + off_counter_out, blink ? 0x00 : 0x02); rt_sem_wait(&master_sem); - + tv.tv_usec += 1000; if (tv.tv_usec >= 1000000) { tv.tv_usec -= 1000000; @@ -227,11 +227,11 @@ void run(long data) sync_ref_counter = 9; ecrt_master_sync_reference_clock(master); } - ecrt_master_sync_slave_clocks(master); + ecrt_master_sync_slave_clocks(master); ecrt_domain_queue(domain1); ecrt_master_send(master); rt_sem_signal(&master_sem); - + rt_task_wait_period(); } } @@ -292,10 +292,10 @@ int __init init_mod(void) printk(KERN_INFO PFX "Configuring PDOs...\n"); // create configuration for reference clock FIXME - if (!(sc = ecrt_master_slave_config(master, 0, 0, Beckhoff_EK1100))) { - printk(KERN_ERR PFX "Failed to get slave configuration.\n"); - goto out_release_master; - } + if (!(sc = ecrt_master_slave_config(master, 0, 0, Beckhoff_EK1100))) { + printk(KERN_ERR PFX "Failed to get slave configuration.\n"); + goto out_release_master; + } for (i = 0; i < NUM_DIG_OUT; i++) { if (!(sc = ecrt_master_slave_config(master, @@ -316,22 +316,22 @@ int __init init_mod(void) goto out_release_master; } - if (!(sc = ecrt_master_slave_config(master, - CounterSlavePos, IDS_Counter))) { - printk(KERN_ERR PFX "Failed to get slave configuration.\n"); - goto out_release_master; - } - off_counter_in = ecrt_slave_config_reg_pdo_entry(sc, - 0x6020, 0x11, domain1, NULL); - if (off_counter_in < 0) - goto out_release_master; - off_counter_out = ecrt_slave_config_reg_pdo_entry(sc, - 0x7020, 1, domain1, NULL); - if (off_counter_out < 0) - goto out_release_master; + if (!(sc = ecrt_master_slave_config(master, + CounterSlavePos, IDS_Counter))) { + printk(KERN_ERR PFX "Failed to get slave configuration.\n"); + goto out_release_master; + } + off_counter_in = ecrt_slave_config_reg_pdo_entry(sc, + 0x6020, 0x11, domain1, NULL); + if (off_counter_in < 0) + goto out_release_master; + off_counter_out = ecrt_slave_config_reg_pdo_entry(sc, + 0x7020, 1, domain1, NULL); + if (off_counter_out < 0) + goto out_release_master; // configure SYNC signals for this slave - ecrt_slave_config_dc(sc, 0x0700, 1000000, 440000, 0, 0); + ecrt_slave_config_dc(sc, 0x0700, 1000000, 440000, 0, 0); printk(KERN_INFO PFX "Activating master...\n"); if (ecrt_master_activate(master)) { diff --git a/examples/rtai/rtai_sample.c b/examples/rtai/rtai_sample.c index 874c1e4b..2b804dd9 100644 --- a/examples/rtai/rtai_sample.c +++ b/examples/rtai/rtai_sample.c @@ -236,7 +236,7 @@ void run(long data) ecrt_domain_queue(domain1); ecrt_master_send(master); rt_sem_signal(&master_sem); - + rt_task_wait_period(); } } diff --git a/examples/user/main.c b/examples/user/main.c index 06b41239..7ad304bf 100644 --- a/examples/user/main.c +++ b/examples/user/main.c @@ -92,9 +92,9 @@ static unsigned int off_dig_out; const static ec_pdo_entry_reg_t domain1_regs[] = { {AnaInSlavePos, Beckhoff_EL3102, 0x3101, 1, &off_ana_in_status}, {AnaInSlavePos, Beckhoff_EL3102, 0x3101, 2, &off_ana_in_value}, - {AnaOutSlavePos, Beckhoff_EL4102, 0x3001, 1, &off_ana_out}, - {DigOutSlavePos, Beckhoff_EL2032, 0x3001, 1, &off_dig_out}, - {} + {AnaOutSlavePos, Beckhoff_EL4102, 0x3001, 1, &off_ana_out}, + {DigOutSlavePos, Beckhoff_EL2032, 0x3001, 1, &off_dig_out}, + {} }; static unsigned int counter = 0; @@ -316,13 +316,13 @@ void signal_handler(int signum) { int main(int argc, char **argv) { - ec_slave_config_t *sc; + ec_slave_config_t *sc; struct sigaction sa; struct itimerval tv; master = ecrt_request_master(0); - if (!master) - return -1; + if (!master) + return -1; domain1 = ecrt_master_create_domain(master); if (!domain1) @@ -380,7 +380,7 @@ int main(int argc, char **argv) if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) { fprintf(stderr, "PDO entry registration failed!\n"); - return -1; + return -1; } printf("Activating master...\n"); @@ -417,7 +417,7 @@ int main(int argc, char **argv) } printf("Started.\n"); - while (1) { + while (1) { pause(); #if 0 @@ -430,9 +430,9 @@ int main(int argc, char **argv) cyclic_task(); user_alarms++; } - } + } - return 0; + return 0; } /****************************************************************************/ diff --git a/lib/master.c b/lib/master.c index 3ad42a71..fe5bdfc5 100644 --- a/lib/master.c +++ b/lib/master.c @@ -116,17 +116,17 @@ ec_slave_config_t *ecrt_master_slave_config(ec_master_t *master, int ecrt_master(ec_master_t* master, ec_master_info_t *master_info) { - ec_ioctl_master_t data; + ec_ioctl_master_t data; - if (ioctl(master->fd, EC_IOCTL_MASTER, &data) < 0) { + if (ioctl(master->fd, EC_IOCTL_MASTER, &data) < 0) { fprintf(stderr, "Failed to get master info: %s\n", strerror(errno)); - return -1; - } + return -1; + } - master_info->slave_count = data.slave_count; - master_info->link_up = data.devices[0].link_state; - master_info->app_time = data.app_time; - return 0; + master_info->slave_count = data.slave_count; + master_info->link_up = data.devices[0].link_state; + master_info->app_time = data.app_time; + return 0; } /*****************************************************************************/ diff --git a/lib/slave_config.c b/lib/slave_config.c index dde679a9..8f1f11ec 100644 --- a/lib/slave_config.c +++ b/lib/slave_config.c @@ -252,10 +252,10 @@ void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate, data.config_index = sc->index; data.dc_assign_activate = assign_activate; - data.dc_sync[0].cycle_time = sync0_cycle_time; - data.dc_sync[0].shift_time = sync0_shift_time; - data.dc_sync[1].cycle_time = sync1_cycle_time; - data.dc_sync[1].shift_time = sync1_shift_time; + data.dc_sync[0].cycle_time = sync0_cycle_time; + data.dc_sync[0].shift_time = sync0_shift_time; + data.dc_sync[1].cycle_time = sync1_cycle_time; + data.dc_sync[1].shift_time = sync1_shift_time; if (ioctl(sc->master->fd, EC_IOCTL_SC_DC, &data) == -1) { fprintf(stderr, "Failed to set assign_activate word.\n");