master/master.h
author Florian Pose <fp@igh-essen.com>
Thu, 20 Apr 2006 13:38:48 +0000
branchstable-1.0
changeset 1616 f009a710e8a3
parent 195 674071846ee3
child 197 b9a6e2c22745
child 1618 5cff10efb927
permissions -rw-r--r--
(Re-) Creating stable-1.0 branch
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
     1
/******************************************************************************
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
     3
 *  m a s t e r . h
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
     5
 *  EtherCAT master structure.
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
     7
 *  $Id$
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
     9
 *****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
#ifndef _EC_MASTER_H_
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
#define _EC_MASTER_H_
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
95
0066de7a456d Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents: 94
diff changeset
    14
#include <linux/list.h>
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
    15
#include <linux/sysfs.h>
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    16
#include <linux/timer.h>
95
0066de7a456d Domains als Liste verwaltet.
Florian Pose <fp@igh-essen.com>
parents: 94
diff changeset
    17
54
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    18
#include "device.h"
7506e67dd122 Vereinheitlichte Schnittstellen, Include-Verzeichnis und Module getrennt.
Florian Pose <fp@igh-essen.com>
parents: 52
diff changeset
    19
#include "domain.h"
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    21
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
/**
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    24
   EtherCAT master mode.
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    25
*/
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    26
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    27
typedef enum
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    28
{
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    29
    EC_MASTER_MODE_IDLE,
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    30
    EC_MASTER_MODE_FREERUN,
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    31
    EC_MASTER_MODE_RUNNING
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    32
}
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    33
ec_master_mode_t;
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    34
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    35
/*****************************************************************************/
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    36
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    37
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    38
   Cyclic EtherCAT statistics.
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    39
*/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    40
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    41
typedef struct
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    42
{
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    43
    unsigned int timeouts; /**< command timeouts */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    44
    unsigned int delayed; /**< delayed commands */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    45
    unsigned int corrupted; /**< corrupted frames */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    46
    unsigned int unmatched; /**< unmatched commands */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    47
    unsigned int eoe_errors; /**< Ethernet-over-EtherCAT errors */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    48
    cycles_t t_last; /**< time of last output */
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    49
}
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    50
ec_stats_t;
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    51
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    52
/*****************************************************************************/
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    53
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    54
/**
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    55
   EtherCAT-Master.
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    56
   Manages slaves, domains and IO.
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
*/
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
55
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
    59
struct ec_master
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
{
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    61
    struct list_head list; /**< list item */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    62
    struct kobject kobj; /**< kobject */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    63
    unsigned int index; /**< master index */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    64
    struct list_head slaves; /**< list of slaves on the bus */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    65
    unsigned int slave_count; /**< number of slaves on the bus */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    66
    ec_device_t *device; /**< EtherCAT device */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    67
    struct list_head command_queue; /**< command queue */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    68
    uint8_t command_index; /**< current command index */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    69
    struct list_head domains; /**< list of domains */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    70
    ec_command_t simple_command; /**< command structure for initialization */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    71
    ec_command_t watch_command; /**< command for watching the slaves */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    72
    unsigned int slaves_responding; /**< number of responding slaves */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    73
    ec_slave_state_t slave_states; /**< states of the responding slaves */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    74
    int debug_level; /**< master debug level */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    75
    ec_stats_t stats; /**< cyclic statistics */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    76
    unsigned int timeout; /**< timeout in synchronous IO */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    77
    struct list_head eoe_slaves; /**< Ethernet-over-EtherCAT slaves */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    78
    unsigned int reserved; /**< true, if the master is reserved for RT */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    79
    struct timer_list freerun_timer; /**< timer object for free run mode */
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    80
    ec_master_mode_t mode; /**< master mode */
55
059a9e712aa7 Mit neuer Schnittstelle wieder lauff?hig.
Florian Pose <fp@igh-essen.com>
parents: 54
diff changeset
    81
};
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    83
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    85
// master creation and deletion
178
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
    86
int ec_master_init(ec_master_t *, unsigned int);
b84f69db8566 MERGE branches/sysfs -> trunk (whole SysFS implementation)
Florian Pose <fp@igh-essen.com>
parents: 151
diff changeset
    87
void ec_master_clear(struct kobject *);
56
36d1fa37f5e1 Bugfix im Master, ec_master_reset() und laufendes Beispiel in rt.
Florian Pose <fp@igh-essen.com>
parents: 55
diff changeset
    88
void ec_master_reset(ec_master_t *);
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    89
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    90
// free run
191
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    91
void ec_master_freerun_start(ec_master_t *);
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    92
void ec_master_freerun_stop(ec_master_t *);
ca805255a935 Prepared Free-Run mode
Florian Pose <fp@igh-essen.com>
parents: 182
diff changeset
    93
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    94
// IO
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    95
void ec_master_receive(ec_master_t *, const uint8_t *, size_t);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
    96
void ec_master_queue_command(ec_master_t *, ec_command_t *);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
    97
int ec_master_simple_io(ec_master_t *, ec_command_t *);
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    98
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
    99
// slave management
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   100
int ec_master_bus_scan(ec_master_t *);
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   101
195
674071846ee3 Translated all comments and documentation to english language.
Florian Pose <fp@igh-essen.com>
parents: 191
diff changeset
   102
// misc.
98
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   103
void ec_master_debug(const ec_master_t *);
f564d0929292 MERGE branches/async 222:233 -> trunk (Kommando-Warteschlangen).
Florian Pose <fp@igh-essen.com>
parents: 95
diff changeset
   104
void ec_master_output_stats(ec_master_t *);
145
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   105
void ec_master_run_eoe(ec_master_t *);
11a82e4fd31b Mailbox-Interface ausgelagert, erster EOE-Ansatz.
Florian Pose <fp@igh-essen.com>
parents: 144
diff changeset
   106
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   107
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   108
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   109
#endif