master/master.h
changeset 195 674071846ee3
parent 191 ca805255a935
child 197 b9a6e2c22745
child 1618 5cff10efb927
equal deleted inserted replaced
194:c21e7c12dd50 195:674071846ee3
     1 /******************************************************************************
     1 /******************************************************************************
     2  *
     2  *
     3  *  m a s t e r . h
     3  *  m a s t e r . h
     4  *
     4  *
     5  *  Struktur für einen EtherCAT-Master.
     5  *  EtherCAT master structure.
     6  *
     6  *
     7  *  $Id$
     7  *  $Id$
     8  *
     8  *
     9  *****************************************************************************/
     9  *****************************************************************************/
    10 
    10 
    33 ec_master_mode_t;
    33 ec_master_mode_t;
    34 
    34 
    35 /*****************************************************************************/
    35 /*****************************************************************************/
    36 
    36 
    37 /**
    37 /**
    38    EtherCAT-Rahmen-Statistiken.
    38    Cyclic EtherCAT statistics.
    39 */
    39 */
    40 
    40 
    41 typedef struct
    41 typedef struct
    42 {
    42 {
    43     unsigned int timeouts; /**< Kommando-Timeouts */
    43     unsigned int timeouts; /**< command timeouts */
    44     unsigned int delayed; /**< Verzögerte Kommandos */
    44     unsigned int delayed; /**< delayed commands */
    45     unsigned int corrupted; /**< Verfälschte Rahmen */
    45     unsigned int corrupted; /**< corrupted frames */
    46     unsigned int unmatched; /**< Unpassende Kommandos */
    46     unsigned int unmatched; /**< unmatched commands */
    47     unsigned int eoe_errors; /**< Ethernet-over-EtherCAT Fehler */
    47     unsigned int eoe_errors; /**< Ethernet-over-EtherCAT errors */
    48     cycles_t t_last; /**< Timestamp-Counter bei der letzten Ausgabe */
    48     cycles_t t_last; /**< time of last output */
    49 }
    49 }
    50 ec_stats_t;
    50 ec_stats_t;
    51 
    51 
    52 /*****************************************************************************/
    52 /*****************************************************************************/
    53 
    53 
    54 /**
    54 /**
    55    EtherCAT-Master
    55    EtherCAT-Master.
    56 
    56    Manages slaves, domains and IO.
    57    Verwaltet die EtherCAT-Slaves und kommuniziert mit
       
    58    dem zugewiesenen EtherCAT-Gerät.
       
    59 */
    57 */
    60 
    58 
    61 struct ec_master
    59 struct ec_master
    62 {
    60 {
    63     struct list_head list; /**< Noetig fuer Master-Liste */
    61     struct list_head list; /**< list item */
    64     struct kobject kobj; /**< Kernel-Object */
    62     struct kobject kobj; /**< kobject */
    65     unsigned int index; /**< Master-Index */
    63     unsigned int index; /**< master index */
    66     struct list_head slaves; /**< Liste der Slaves auf dem Bus */
    64     struct list_head slaves; /**< list of slaves on the bus */
    67     unsigned int slave_count; /**< Anzahl Slaves auf dem Bus */
    65     unsigned int slave_count; /**< number of slaves on the bus */
    68     ec_device_t *device; /**< EtherCAT-Gerät */
    66     ec_device_t *device; /**< EtherCAT device */
    69     struct list_head command_queue; /**< Kommando-Warteschlange */
    67     struct list_head command_queue; /**< command queue */
    70     uint8_t command_index; /**< Aktueller Kommando-Index */
    68     uint8_t command_index; /**< current command index */
    71     struct list_head domains; /**< Liste der Prozessdatendomänen */
    69     struct list_head domains; /**< list of domains */
    72     ec_command_t simple_command; /**< Kommando für Initialisierungsphase */
    70     ec_command_t simple_command; /**< command structure for initialization */
    73     ec_command_t watch_command; /**< Kommando zum Überwachen der Slaves */
    71     ec_command_t watch_command; /**< command for watching the slaves */
    74     unsigned int slaves_responding; /**< Anzahl antwortender Slaves */
    72     unsigned int slaves_responding; /**< number of responding slaves */
    75     ec_slave_state_t slave_states; /**< Zustände der antwortenden Slaves */
    73     ec_slave_state_t slave_states; /**< states of the responding slaves */
    76     int debug_level; /**< Debug-Level im Master-Code */
    74     int debug_level; /**< master debug level */
    77     ec_stats_t stats; /**< Rahmen-Statistiken */
    75     ec_stats_t stats; /**< cyclic statistics */
    78     unsigned int timeout; /**< Timeout für synchronen Datenaustausch */
    76     unsigned int timeout; /**< timeout in synchronous IO */
    79     struct list_head eoe_slaves; /**< Ethernet over EtherCAT Slaves */
    77     struct list_head eoe_slaves; /**< Ethernet-over-EtherCAT slaves */
    80     unsigned int reserved; /**< Master durch Echtzeitprozess reserviert */
    78     unsigned int reserved; /**< true, if the master is reserved for RT */
    81     struct timer_list freerun_timer; /**< Timer fuer Free-Run-Modus. */
    79     struct timer_list freerun_timer; /**< timer object for free run mode */
    82     ec_master_mode_t mode; /**< Modus des Masters */
    80     ec_master_mode_t mode; /**< master mode */
    83 };
    81 };
    84 
    82 
    85 /*****************************************************************************/
    83 /*****************************************************************************/
    86 
    84 
    87 // Master creation and deletion
    85 // master creation and deletion
    88 int ec_master_init(ec_master_t *, unsigned int);
    86 int ec_master_init(ec_master_t *, unsigned int);
    89 void ec_master_clear(struct kobject *);
    87 void ec_master_clear(struct kobject *);
    90 void ec_master_reset(ec_master_t *);
    88 void ec_master_reset(ec_master_t *);
    91 
    89 
    92 // Free-Run
    90 // free run
    93 void ec_master_freerun_start(ec_master_t *);
    91 void ec_master_freerun_start(ec_master_t *);
    94 void ec_master_freerun_stop(ec_master_t *);
    92 void ec_master_freerun_stop(ec_master_t *);
    95 
    93 
    96 // IO
    94 // IO
    97 void ec_master_receive(ec_master_t *, const uint8_t *, size_t);
    95 void ec_master_receive(ec_master_t *, const uint8_t *, size_t);
    98 void ec_master_queue_command(ec_master_t *, ec_command_t *);
    96 void ec_master_queue_command(ec_master_t *, ec_command_t *);
    99 int ec_master_simple_io(ec_master_t *, ec_command_t *);
    97 int ec_master_simple_io(ec_master_t *, ec_command_t *);
   100 
    98 
   101 // Slave management
    99 // slave management
   102 int ec_master_bus_scan(ec_master_t *);
   100 int ec_master_bus_scan(ec_master_t *);
   103 
   101 
   104 // Misc
   102 // misc.
   105 void ec_master_debug(const ec_master_t *);
   103 void ec_master_debug(const ec_master_t *);
   106 void ec_master_output_stats(ec_master_t *);
   104 void ec_master_output_stats(ec_master_t *);
   107 void ec_master_run_eoe(ec_master_t *);
   105 void ec_master_run_eoe(ec_master_t *);
   108 
   106 
   109 /*****************************************************************************/
   107 /*****************************************************************************/
   110 
   108 
   111 #endif
   109 #endif
   112 
       
   113 /* Emacs-Konfiguration
       
   114 ;;; Local Variables: ***
       
   115 ;;; c-basic-offset:4 ***
       
   116 ;;; End: ***
       
   117 */