--- a/include/ecrt.h Tue May 05 10:01:55 2009 +0000
+++ b/include/ecrt.h Tue May 05 15:03:59 2009 +0000
@@ -41,9 +41,8 @@
*
* Changes in version 1.5:
*
- * - Added the distributed clocks feature and the respective methods
- * ecrt_slave_config_dc_assign_activate() and
- * ecrt_slave_config_dc_sync_signals() to configure a slave for cyclic
+ * - Added the distributed clocks feature and the respective method
+ * ecrt_slave_config_dc() to configure a slave for cyclic
* operation, and ecrt_master_application_time(),
* ecrt_master_sync_reference_clock() and ecrt_master_sync_slave_clocks()
* for offset and drift compensation. The EC_TIMEVAL2NANO() macro can be
@@ -772,21 +771,18 @@
is desired */
);
-/** Sets the AssignActivate word necessary for DC operation.
+/** Configure distributed clocks.
+ *
+ * Sets the AssignActivate word and the cycle and shift times for the sync
+ * signals.
*
* The AssignActivate word is vendor-specific and can be taken from the XML
* device description file (Device -> Dc -> AssignActivate). Set this to zero,
* if the slave shall be operated without distributed clocks (default).
*/
-void ecrt_slave_config_dc_assign_activate(
+void ecrt_slave_config_dc(
ec_slave_config_t *sc, /**< Slave configuration. */
- uint16_t assign_activate /**< AssignActivate word. */
- );
-
-/** Sets the cycle and shift times for the sync signals.
- */
-void ecrt_slave_config_dc_sync_signals(
- ec_slave_config_t *sc, /**< Slave configuration. */
+ uint16_t assign_activate, /**< AssignActivate word. */
uint32_t sync0_cycle, /**< SYNC0 cycle time [ns]. */
uint32_t sync0_shift, /**< SYNC0 shift time [ns]. */
uint32_t sync1_cycle, /**< SYNC1 cycle time [ns]. */
--- a/lib/slave_config.c Tue May 05 10:01:55 2009 +0000
+++ b/lib/slave_config.c Tue May 05 15:03:59 2009 +0000
@@ -244,34 +244,20 @@
/*****************************************************************************/
-void ecrt_slave_config_dc_assign_activate(ec_slave_config_t *sc,
- uint16_t assign_activate)
-{
- ec_ioctl_sc_dc_t data;
-
- data.config_index = sc->index;
- data.assign_activate = assign_activate;
-
- if (ioctl(sc->master->fd, EC_IOCTL_SC_DC_ASSIGN, &data) == -1) {
- fprintf(stderr, "Failed to set assign_activate word.\n");
- }
-}
-
-/*****************************************************************************/
-
-void ecrt_slave_config_dc_sync_signals(ec_slave_config_t *sc,
+void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate,
uint32_t sync0_cycle_time, uint32_t sync0_shift_time,
uint32_t sync1_cycle_time, uint32_t sync1_shift_time)
{
ec_ioctl_sc_dc_t data;
data.config_index = sc->index;
+ data.assign_activate = assign_activate;
data.sync[0].cycle_time = sync0_cycle_time;
data.sync[0].shift_time = sync0_shift_time;
data.sync[1].cycle_time = sync1_cycle_time;
data.sync[1].shift_time = sync1_shift_time;
- if (ioctl(sc->master->fd, EC_IOCTL_SC_DC_SYNC, &data) == -1) {
+ if (ioctl(sc->master->fd, EC_IOCTL_SC_DC, &data) == -1) {
fprintf(stderr, "Failed to set assign_activate word.\n");
}
}
--- a/master/cdev.c Tue May 05 10:01:55 2009 +0000
+++ b/master/cdev.c Tue May 05 15:03:59 2009 +0000
@@ -1905,9 +1905,9 @@
/*****************************************************************************/
-/** Sets the DC AssignActivate word.
- */
-int ec_cdev_ioctl_sc_dc_assign(
+/** Sets the DC AssignActivate word and the sync signal times.
+ */
+int ec_cdev_ioctl_sc_dc(
ec_master_t *master, /**< EtherCAT master. */
unsigned long arg, /**< ioctl() argument. */
ec_cdev_priv_t *priv /**< Private data structure of file handle. */
@@ -1930,41 +1930,7 @@
return -ENOENT;
}
- ecrt_slave_config_dc_assign_activate(sc, data.assign_activate);
-
- up(&master->master_sem);
-
- return 0;
-}
-
-/*****************************************************************************/
-
-/** Sets the DC cycle times.
- */
-int ec_cdev_ioctl_sc_dc_sync_signals(
- ec_master_t *master, /**< EtherCAT master. */
- unsigned long arg, /**< ioctl() argument. */
- ec_cdev_priv_t *priv /**< Private data structure of file handle. */
- )
-{
- ec_ioctl_sc_dc_t data;
- ec_slave_config_t *sc;
-
- if (unlikely(!priv->requested))
- return -EPERM;
-
- if (copy_from_user(&data, (void __user *) arg, sizeof(data)))
- return -EFAULT;
-
- if (down_interruptible(&master->master_sem))
- return -EINTR;
-
- if (!(sc = ec_master_get_config(master, data.config_index))) {
- up(&master->master_sem);
- return -ENOENT;
- }
-
- ecrt_slave_config_dc_sync_signals(sc,
+ ecrt_slave_config_dc(sc, data.assign_activate,
data.sync[0].cycle_time,
data.sync[0].shift_time,
data.sync[1].cycle_time,
@@ -3196,14 +3162,10 @@
if (!(filp->f_mode & FMODE_WRITE))
return -EPERM;
return ec_cdev_ioctl_sc_reg_pdo_entry(master, arg, priv);
- case EC_IOCTL_SC_DC_ASSIGN:
+ case EC_IOCTL_SC_DC:
if (!(filp->f_mode & FMODE_WRITE))
return -EPERM;
- return ec_cdev_ioctl_sc_dc_assign(master, arg, priv);
- case EC_IOCTL_SC_DC_SYNC:
- if (!(filp->f_mode & FMODE_WRITE))
- return -EPERM;
- return ec_cdev_ioctl_sc_dc_sync_signals(master, arg, priv);
+ return ec_cdev_ioctl_sc_dc(master, arg, priv);
case EC_IOCTL_SC_SDO:
if (!(filp->f_mode & FMODE_WRITE))
return -EPERM;
--- a/master/ioctl.h Tue May 05 10:01:55 2009 +0000
+++ b/master/ioctl.h Tue May 05 15:03:59 2009 +0000
@@ -95,28 +95,27 @@
#define EC_IOCTL_SC_ADD_ENTRY EC_IOW(0x25, ec_ioctl_add_pdo_entry_t)
#define EC_IOCTL_SC_CLEAR_ENTRIES EC_IOW(0x26, ec_ioctl_config_pdo_t)
#define EC_IOCTL_SC_REG_PDO_ENTRY EC_IOWR(0x27, ec_ioctl_reg_pdo_entry_t)
-#define EC_IOCTL_SC_DC_ASSIGN EC_IOW(0x28, ec_ioctl_sc_dc_t)
-#define EC_IOCTL_SC_DC_SYNC EC_IOW(0x29, ec_ioctl_sc_dc_t)
-#define EC_IOCTL_SC_SDO EC_IOW(0x2a, ec_ioctl_sc_sdo_t)
-#define EC_IOCTL_SC_SDO_REQUEST EC_IOWR(0x2b, ec_ioctl_sdo_request_t)
-#define EC_IOCTL_SC_VOE EC_IOWR(0x2c, ec_ioctl_voe_t)
-#define EC_IOCTL_SC_STATE EC_IOWR(0x2d, ec_ioctl_sc_state_t)
-#define EC_IOCTL_DOMAIN_OFFSET EC_IO(0x2e)
-#define EC_IOCTL_DOMAIN_PROCESS EC_IO(0x2f)
-#define EC_IOCTL_DOMAIN_QUEUE EC_IO(0x30)
-#define EC_IOCTL_DOMAIN_STATE EC_IOWR(0x31, ec_ioctl_domain_state_t)
-#define EC_IOCTL_SDO_REQUEST_TIMEOUT EC_IOWR(0x32, ec_ioctl_sdo_request_t)
-#define EC_IOCTL_SDO_REQUEST_STATE EC_IOWR(0x33, ec_ioctl_sdo_request_t)
-#define EC_IOCTL_SDO_REQUEST_READ EC_IOWR(0x34, ec_ioctl_sdo_request_t)
-#define EC_IOCTL_SDO_REQUEST_WRITE EC_IOWR(0x35, ec_ioctl_sdo_request_t)
-#define EC_IOCTL_SDO_REQUEST_DATA EC_IOWR(0x36, ec_ioctl_sdo_request_t)
-#define EC_IOCTL_VOE_SEND_HEADER EC_IOW(0x37, ec_ioctl_voe_t)
-#define EC_IOCTL_VOE_REC_HEADER EC_IOWR(0x38, ec_ioctl_voe_t)
-#define EC_IOCTL_VOE_READ EC_IOW(0x39, ec_ioctl_voe_t)
-#define EC_IOCTL_VOE_READ_NOSYNC EC_IOW(0x3a, ec_ioctl_voe_t)
-#define EC_IOCTL_VOE_WRITE EC_IOWR(0x3b, ec_ioctl_voe_t)
-#define EC_IOCTL_VOE_EXEC EC_IOWR(0x3c, ec_ioctl_voe_t)
-#define EC_IOCTL_VOE_DATA EC_IOWR(0x3d, ec_ioctl_voe_t)
+#define EC_IOCTL_SC_DC EC_IOW(0x28, ec_ioctl_sc_dc_t)
+#define EC_IOCTL_SC_SDO EC_IOW(0x29, ec_ioctl_sc_sdo_t)
+#define EC_IOCTL_SC_SDO_REQUEST EC_IOWR(0x2a, ec_ioctl_sdo_request_t)
+#define EC_IOCTL_SC_VOE EC_IOWR(0x2b, ec_ioctl_voe_t)
+#define EC_IOCTL_SC_STATE EC_IOWR(0x2c, ec_ioctl_sc_state_t)
+#define EC_IOCTL_DOMAIN_OFFSET EC_IO(0x2d)
+#define EC_IOCTL_DOMAIN_PROCESS EC_IO(0x2e)
+#define EC_IOCTL_DOMAIN_QUEUE EC_IO(0x2f)
+#define EC_IOCTL_DOMAIN_STATE EC_IOWR(0x30, ec_ioctl_domain_state_t)
+#define EC_IOCTL_SDO_REQUEST_TIMEOUT EC_IOWR(0x31, ec_ioctl_sdo_request_t)
+#define EC_IOCTL_SDO_REQUEST_STATE EC_IOWR(0x32, ec_ioctl_sdo_request_t)
+#define EC_IOCTL_SDO_REQUEST_READ EC_IOWR(0x33, ec_ioctl_sdo_request_t)
+#define EC_IOCTL_SDO_REQUEST_WRITE EC_IOWR(0x34, ec_ioctl_sdo_request_t)
+#define EC_IOCTL_SDO_REQUEST_DATA EC_IOWR(0x35, ec_ioctl_sdo_request_t)
+#define EC_IOCTL_VOE_SEND_HEADER EC_IOW(0x36, ec_ioctl_voe_t)
+#define EC_IOCTL_VOE_REC_HEADER EC_IOWR(0x37, ec_ioctl_voe_t)
+#define EC_IOCTL_VOE_READ EC_IOW(0x38, ec_ioctl_voe_t)
+#define EC_IOCTL_VOE_READ_NOSYNC EC_IOW(0x39, ec_ioctl_voe_t)
+#define EC_IOCTL_VOE_WRITE EC_IOWR(0x3a, ec_ioctl_voe_t)
+#define EC_IOCTL_VOE_EXEC EC_IOWR(0x3b, ec_ioctl_voe_t)
+#define EC_IOCTL_VOE_DATA EC_IOWR(0x3c, ec_ioctl_voe_t)
/*****************************************************************************/
--- a/master/slave_config.c Tue May 05 10:01:55 2009 +0000
+++ b/master/slave_config.c Tue May 05 15:03:59 2009 +0000
@@ -675,18 +675,11 @@
/*****************************************************************************/
-void ecrt_slave_config_dc_assign_activate(ec_slave_config_t *sc,
- uint16_t assign_activate)
-{
- sc->dc_assign_activate = assign_activate;
-}
-
-/*****************************************************************************/
-
-void ecrt_slave_config_dc_sync_signals(ec_slave_config_t *sc,
+void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate,
uint32_t sync0_cycle_time, uint32_t sync0_shift_time,
uint32_t sync1_cycle_time, uint32_t sync1_shift_time)
{
+ sc->dc_assign_activate = assign_activate;
sc->dc_sync[0].cycle_time = sync0_cycle_time;
sc->dc_sync[0].shift_time = sync0_shift_time;
sc->dc_sync[1].cycle_time = sync1_cycle_time;
@@ -907,8 +900,7 @@
EXPORT_SYMBOL(ecrt_slave_config_pdo_mapping_clear);
EXPORT_SYMBOL(ecrt_slave_config_pdos);
EXPORT_SYMBOL(ecrt_slave_config_reg_pdo_entry);
-EXPORT_SYMBOL(ecrt_slave_config_dc_assign_activate);
-EXPORT_SYMBOL(ecrt_slave_config_dc_sync_signals);
+EXPORT_SYMBOL(ecrt_slave_config_dc);
EXPORT_SYMBOL(ecrt_slave_config_sdo);
EXPORT_SYMBOL(ecrt_slave_config_sdo8);
EXPORT_SYMBOL(ecrt_slave_config_sdo16);