include/ecrt.h
changeset 1417 7c2d5d69134c
parent 1411 3ebef749275c
child 1434 4c6fe0ae37f1
equal deleted inserted replaced
1416:85d20ae6736e 1417:7c2d5d69134c
    44  * - Added the distributed clocks feature and the respective methods
    44  * - Added the distributed clocks feature and the respective methods
    45  *   ecrt_slave_config_dc_assign_activate(),
    45  *   ecrt_slave_config_dc_assign_activate(),
    46  *   ecrt_slave_config_dc_sync_cycle_times() and
    46  *   ecrt_slave_config_dc_sync_cycle_times() and
    47  *   ecrt_slave_config_dc_sync_shift_times() to configure a slave for cyclic
    47  *   ecrt_slave_config_dc_sync_shift_times() to configure a slave for cyclic
    48  *   operation, and ecrt_master_sync_reference_clock() and
    48  *   operation, and ecrt_master_sync_reference_clock() and
    49  *   ecrt_master_sync_slave_clocks() for drift compensation.
    49  *   ecrt_master_sync_slave_clocks() for drift compensation. The
       
    50  *   EC_TIMEVAL2NANO() macro can be used for epoch time conversion.
    50  * - Changed the meaning of the negative return values of
    51  * - Changed the meaning of the negative return values of
    51  *   ecrt_slave_config_reg_pdo_entry() and ecrt_slave_config_sdo*().
    52  *   ecrt_slave_config_reg_pdo_entry() and ecrt_slave_config_sdo*().
    52  * - Imlemented the Vendor-specific over EtherCAT mailbox protocol. See
    53  * - Imlemented the Vendor-specific over EtherCAT mailbox protocol. See
    53  *   ecrt_slave_config_create_voe_handler().
    54  *   ecrt_slave_config_create_voe_handler().
    54  * - Renamed ec_sdo_request_state_t to ec_request_state_t, because it is also
    55  * - Renamed ec_sdo_request_state_t to ec_request_state_t, because it is also
   111 /** Maximum string length.
   112 /** Maximum string length.
   112  *
   113  *
   113  * Used in ec_slave_info_t.
   114  * Used in ec_slave_info_t.
   114  */
   115  */
   115 #define EC_MAX_STRING_LENGTH 64
   116 #define EC_MAX_STRING_LENGTH 64
       
   117 
       
   118 /** Timeval to nanoseconds conversion.
       
   119  *
       
   120  * This macro converts a unix epoch time to EtherCAT DC time.
       
   121  *
       
   122  * \see ecrt_master_sync_reference_clock()
       
   123  *
       
   124  * \param TV Pointer to struct timeval.
       
   125  */
       
   126 #define EC_TIMEVAL2NANO(TV) \
       
   127     (((TV)->tv_sec - 946684800ULL) * 1000000000ULL + (TV)->tv_usec * 1000ULL)
   116 
   128 
   117 /******************************************************************************
   129 /******************************************************************************
   118  * Data types 
   130  * Data types 
   119  *****************************************************************************/
   131  *****************************************************************************/
   120 
   132 
   508         ec_master_state_t *state /**< Structure to store the information. */
   520         ec_master_state_t *state /**< Structure to store the information. */
   509         );
   521         );
   510 
   522 
   511 /** Queues the DC reference clock drift compensation datagram for sending.
   523 /** Queues the DC reference clock drift compensation datagram for sending.
   512  *
   524  *
   513  * The reference clock will by synchronized to the \a app_time.
   525  * The reference clock will by synchronized to the \a app_time. The time is
       
   526  * defined as nanoseconds from 2000-01-01 00:00. Converting an epoch time can
       
   527  * be done with the EC_TIMEVAL2NANO() macro.
   514  */
   528  */
   515 void ecrt_master_sync_reference_clock(
   529 void ecrt_master_sync_reference_clock(
   516         ec_master_t *master, /**< EtherCAT master. */
   530         ec_master_t *master, /**< EtherCAT master. */
   517         const struct timeval *app_time /**< Application time. */
   531         uint64_t app_time /**< Application time. */
   518         );
   532         );
   519 
   533 
   520 /** Queues the DC clock drift compensation datagram for sending.
   534 /** Queues the DC clock drift compensation datagram for sending.
   521  *
   535  *
   522  * All slave clocks synchronized to the reference clock.
   536  * All slave clocks synchronized to the reference clock.