master/slave.h
changeset 1425 c1322a8793c0
parent 1421 043a518831b2
child 1426 af45bba80d85
equal deleted inserted replaced
1424:cb02dbe4076f 1425:c1322a8793c0
    43 #include "globals.h"
    43 #include "globals.h"
    44 #include "datagram.h"
    44 #include "datagram.h"
    45 #include "pdo.h"
    45 #include "pdo.h"
    46 #include "sync.h"
    46 #include "sync.h"
    47 #include "sdo.h"
    47 #include "sdo.h"
       
    48 
       
    49 /*****************************************************************************/
       
    50 
       
    51 /** Slave port.
       
    52  */
       
    53 typedef struct {
       
    54     ec_slave_port_desc_t desc; /**< Port descriptors. */
       
    55     ec_slave_port_link_t link; /**< Port link status. */
       
    56     ec_slave_t *next_slave; /**< Connected slaves. */
       
    57     uint32_t receive_time; /**< Port receive times for delay
       
    58                                             measurement. */
       
    59     uint32_t delay_to_next_dc; /**< Delay to next slave with DC support behind
       
    60                                  this port [ns]. */
       
    61 } ec_slave_port_t;
    48 
    62 
    49 /*****************************************************************************/
    63 /*****************************************************************************/
    50 
    64 
    51 /** Slave information interface data.
    65 /** Slave information interface data.
    52  */
    66  */
   100 
   114 
   101     // addresses
   115     // addresses
   102     uint16_t ring_position; /**< Ring position. */
   116     uint16_t ring_position; /**< Ring position. */
   103     uint16_t station_address; /**< Configured station address. */
   117     uint16_t station_address; /**< Configured station address. */
   104 
   118 
       
   119     ec_slave_port_t ports[EC_MAX_PORTS]; /**< Ports. */
       
   120 
   105     // configuration
   121     // configuration
   106     ec_slave_config_t *config; /**< Current configuration. */
   122     ec_slave_config_t *config; /**< Current configuration. */
   107     ec_slave_state_t requested_state; /**< Requested application state. */
   123     ec_slave_state_t requested_state; /**< Requested application state. */
   108     ec_slave_state_t current_state; /**< Current application state. */
   124     ec_slave_state_t current_state; /**< Current application state. */
   109     unsigned int error_flag; /**< Stop processing after an error. */
   125     unsigned int error_flag; /**< Stop processing after an error. */
   117     uint8_t base_type; /**< Slave type. */
   133     uint8_t base_type; /**< Slave type. */
   118     uint8_t base_revision; /**< Revision. */
   134     uint8_t base_revision; /**< Revision. */
   119     uint16_t base_build; /**< Build number. */
   135     uint16_t base_build; /**< Build number. */
   120     uint8_t base_fmmu_count; /**< Number of supported FMMUs. */
   136     uint8_t base_fmmu_count; /**< Number of supported FMMUs. */
   121     uint8_t base_sync_count; /**< Number of supported sync managers. */
   137     uint8_t base_sync_count; /**< Number of supported sync managers. */
   122     ec_slave_port_desc_t base_ports[EC_MAX_PORTS]; /**< Port descriptors. */
       
   123     uint8_t base_fmmu_bit_operation; /**< FMMU bit operation is supported. */
   138     uint8_t base_fmmu_bit_operation; /**< FMMU bit operation is supported. */
   124     uint8_t base_dc_supported; /**< Distributed clocks are supported. */
   139     uint8_t base_dc_supported; /**< Distributed clocks are supported. */
   125     ec_slave_dc_range_t base_dc_range; /**< DC range. */
   140     ec_slave_dc_range_t base_dc_range; /**< DC range. */
   126     uint8_t has_dc_system_time; /**< The slave supports the DC system time
   141     uint8_t has_dc_system_time; /**< The slave supports the DC system time
   127                                   register. Otherwise it can only be used for
   142                                   register. Otherwise it can only be used for
   128                                   delay measurement. */
   143                                   delay measurement. */
   129     uint32_t dc_receive_times[EC_MAX_PORTS]; /**< Port receive times for delay
   144     uint32_t transition_delay; /**< DC transition delay (from reference
   130                                                measurement. */
   145                                  clock). */
   131 
       
   132     // data link status
       
   133     ec_slave_port_t ports[EC_MAX_PORTS]; /**< Port link status. */
       
   134     ec_slave_t *next_slave[EC_MAX_PORTS]; /**< Connected slaves. */
       
   135 
   146 
   136     // SII
   147     // SII
   137     uint16_t *sii_words; /**< Complete SII image. */
   148     uint16_t *sii_words; /**< Complete SII image. */
   138     size_t sii_nwords; /**< Size of the SII contents in words. */
   149     size_t sii_nwords; /**< Size of the SII contents in words. */
   139 
   150 
   173 const ec_sdo_t *ec_slave_get_sdo_by_pos_const(const ec_slave_t *, uint16_t);
   184 const ec_sdo_t *ec_slave_get_sdo_by_pos_const(const ec_slave_t *, uint16_t);
   174 uint16_t ec_slave_sdo_count(const ec_slave_t *);
   185 uint16_t ec_slave_sdo_count(const ec_slave_t *);
   175 const ec_pdo_t *ec_slave_find_pdo(const ec_slave_t *, uint16_t);
   186 const ec_pdo_t *ec_slave_find_pdo(const ec_slave_t *, uint16_t);
   176 void ec_slave_attach_pdo_names(ec_slave_t *);
   187 void ec_slave_attach_pdo_names(ec_slave_t *);
   177 
   188 
       
   189 void ec_slave_calc_port_delays(ec_slave_t *);
       
   190 void ec_slave_calc_transition_delays_rec(ec_slave_t *, uint32_t *);
       
   191 
   178 /*****************************************************************************/
   192 /*****************************************************************************/
   179 
   193 
   180 #endif
   194 #endif