master/master.h
changeset 1989 6aa393418fb3
parent 1987 f452c93f7723
parent 1925 29161abef052
child 1995 7d748d9cf9e8
equal deleted inserted replaced
1988:ea38efeeb7b3 1989:6aa393418fb3
    52 #include "device.h"
    52 #include "device.h"
    53 #include "domain.h"
    53 #include "domain.h"
    54 #include "ethernet.h"
    54 #include "ethernet.h"
    55 #include "fsm_master.h"
    55 #include "fsm_master.h"
    56 #include "cdev.h"
    56 #include "cdev.h"
       
    57 
       
    58 /*****************************************************************************/
       
    59 
       
    60 /** Convenience macro for printing master-specific information to syslog.
       
    61  *
       
    62  * This will print the message in \a fmt with a prefixed "EtherCAT <INDEX>: ",
       
    63  * where INDEX is the master index.
       
    64  *
       
    65  * \param master EtherCAT master
       
    66  * \param fmt format string (like in printf())
       
    67  * \param args arguments (optional)
       
    68  */
       
    69 #define EC_MASTER_INFO(master, fmt, args...) \
       
    70     printk(KERN_INFO "EtherCAT %u: " fmt, master->index, ##args)
       
    71 
       
    72 /** Convenience macro for printing master-specific errors to syslog.
       
    73  *
       
    74  * This will print the message in \a fmt with a prefixed "EtherCAT <INDEX>: ",
       
    75  * where INDEX is the master index.
       
    76  *
       
    77  * \param master EtherCAT master
       
    78  * \param fmt format string (like in printf())
       
    79  * \param args arguments (optional)
       
    80  */
       
    81 #define EC_MASTER_ERR(master, fmt, args...) \
       
    82     printk(KERN_ERR "EtherCAT ERROR %u: " fmt, master->index, ##args)
       
    83 
       
    84 /** Convenience macro for printing master-specific warnings to syslog.
       
    85  *
       
    86  * This will print the message in \a fmt with a prefixed "EtherCAT <INDEX>: ",
       
    87  * where INDEX is the master index.
       
    88  *
       
    89  * \param master EtherCAT master
       
    90  * \param fmt format string (like in printf())
       
    91  * \param args arguments (optional)
       
    92  */
       
    93 #define EC_MASTER_WARN(master, fmt, args...) \
       
    94     printk(KERN_WARNING "EtherCAT WARNING %u: " fmt, master->index, ##args)
       
    95 
       
    96 /** Convenience macro for printing master-specific debug messages to syslog.
       
    97  *
       
    98  * This will print the message in \a fmt with a prefixed "EtherCAT <INDEX>: ",
       
    99  * where INDEX is the master index.
       
   100  *
       
   101  * \param master EtherCAT master
       
   102  * \param fmt format string (like in printf())
       
   103  * \param args arguments (optional)
       
   104  */
       
   105 #define EC_MASTER_DBG(master, level, fmt, args...) \
       
   106     do { \
       
   107         if (master->debug_level >= level) { \
       
   108             printk(KERN_DEBUG "EtherCAT DEBUG %u: " fmt, \
       
   109                     master->index, ##args); \
       
   110         } \
       
   111     } while (0)
    57 
   112 
    58 /*****************************************************************************/
   113 /*****************************************************************************/
    59 
   114 
    60 /** EtherCAT master phase.
   115 /** EtherCAT master phase.
    61  */
   116  */
   107 
   162 
   108     ec_fsm_master_t fsm; /**< Master state machine. */
   163     ec_fsm_master_t fsm; /**< Master state machine. */
   109     ec_datagram_t fsm_datagram; /**< Datagram used for state machines. */
   164     ec_datagram_t fsm_datagram; /**< Datagram used for state machines. */
   110     ec_master_phase_t phase; /**< Master phase. */
   165     ec_master_phase_t phase; /**< Master phase. */
   111     unsigned int active; /**< Master has been activated. */
   166     unsigned int active; /**< Master has been activated. */
       
   167     unsigned int config_changed; /**< The configuration changed. */
   112     unsigned int injection_seq_fsm; /**< Datagram injection sequence number
   168     unsigned int injection_seq_fsm; /**< Datagram injection sequence number
   113                                       for the FSM side. */
   169                                       for the FSM side. */
   114     unsigned int injection_seq_rt; /**< Datagram injection sequence number
   170     unsigned int injection_seq_rt; /**< Datagram injection sequence number
   115                                      for the realtime side. */
   171                                      for the realtime side. */
   116 
   172 
   120 
   176 
   121     struct list_head configs; /**< List of slave configurations. */
   177     struct list_head configs; /**< List of slave configurations. */
   122     
   178     
   123     u64 app_time; /**< Time of the last ecrt_master_sync() call. */
   179     u64 app_time; /**< Time of the last ecrt_master_sync() call. */
   124     u64 app_start_time; /**< Application start time. */
   180     u64 app_start_time; /**< Application start time. */
   125     u8 has_start_time; /**< Start time already taken. */
   181     u8 has_app_time; /**< Application time is valid. */
   126     ec_datagram_t ref_sync_datagram; /**< Datagram used for synchronizing the
   182     ec_datagram_t ref_sync_datagram; /**< Datagram used for synchronizing the
   127                                        reference clock to the master clock. */
   183                                        reference clock to the master clock. */
   128     ec_datagram_t sync_datagram; /**< Datagram used for DC drift
   184     ec_datagram_t sync_datagram; /**< Datagram used for DC drift
   129                                    compensation. */
   185                                    compensation. */
   130     ec_datagram_t sync_mon_datagram; /**< Datagram used for DC synchronisation
   186     ec_datagram_t sync_mon_datagram; /**< Datagram used for DC synchronisation
   253 ec_domain_t *ecrt_master_create_domain_err(ec_master_t *);
   309 ec_domain_t *ecrt_master_create_domain_err(ec_master_t *);
   254 ec_slave_config_t *ecrt_master_slave_config_err(ec_master_t *, uint16_t,
   310 ec_slave_config_t *ecrt_master_slave_config_err(ec_master_t *, uint16_t,
   255         uint16_t, uint32_t, uint32_t);
   311         uint16_t, uint32_t, uint32_t);
   256 
   312 
   257 void ec_master_calc_dc(ec_master_t *);
   313 void ec_master_calc_dc(ec_master_t *);
       
   314 void ec_master_request_op(ec_master_t *);
   258 
   315 
   259 void ec_master_internal_send_cb(void *);
   316 void ec_master_internal_send_cb(void *);
   260 void ec_master_internal_receive_cb(void *);
   317 void ec_master_internal_receive_cb(void *);
   261 
   318 
   262 /*****************************************************************************/
   319 /*****************************************************************************/