author | Florian Pose <fp@igh-essen.com> |
Fri, 04 Nov 2005 16:47:23 +0000 | |
changeset 5 | 6f2508af550c |
parent 2 | b0a7a4745bf9 |
child 11 | e58d78234412 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************** |
2 |
* |
|
3 |
* e c _ m a s t e r . h |
|
4 |
* |
|
5 |
* Struktur für einen EtherCAT-Master. |
|
6 |
* |
|
7 |
* $Date$ |
|
8 |
* $Author$ |
|
9 |
* |
|
10 |
***************************************************************/ |
|
11 |
||
12 |
#ifndef _EC_MASTER_H_ |
|
13 |
#define _EC_MASTER_H_ |
|
14 |
||
15 |
#include "ec_device.h" |
|
16 |
#include "ec_slave.h" |
|
17 |
#include "ec_command.h" |
|
18 |
||
19 |
/***************************************************************/ |
|
20 |
||
21 |
/** |
|
22 |
EtherCAT-Master |
|
23 |
||
24 |
Verwaltet die EtherCAT-Slaves und kommuniziert mit |
|
25 |
dem zugewiesenen EtherCAT-Gerät. |
|
26 |
*/ |
|
27 |
||
28 |
typedef struct |
|
29 |
{ |
|
30 |
EtherCAT_slave_t *slaves; /**< Zeiger auf statischen Speicher |
|
31 |
mit Slave-Informationen */ |
|
32 |
unsigned int slave_count; /**< Anzahl der Slaves in slaves */ |
|
33 |
||
34 |
EtherCAT_command_t *first_command; /**< Zeiger auf das erste |
|
35 |
Kommando in der Liste */ |
|
36 |
EtherCAT_command_t *process_data_command; /**< Zeiger Auf das Kommando |
|
37 |
zum Senden und Empfangen |
|
38 |
der Prozessdaten */ |
|
39 |
||
40 |
EtherCAT_device_t *dev; /**< Zeiger auf das zugewiesene EtherCAT-Gerät */ |
|
41 |
||
42 |
unsigned char command_index; /**< Aktueller Kommando-Index */ |
|
43 |
||
44 |
unsigned char tx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statischer Speicher |
|
45 |
für zu sendende Daten */ |
|
46 |
unsigned int tx_data_length; /**< Länge der Daten im Sendespeicher */ |
|
47 |
unsigned char rx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statische Speicher für |
|
48 |
eine Kopie des Rx-Buffers |
|
49 |
im EtherCAT-Gerät */ |
|
50 |
||
51 |
unsigned char *process_data; /**< Zeiger auf Speicher mit Prozessdaten */ |
|
52 |
unsigned int process_data_length; /**< Länge der Prozessdaten */ |
|
53 |
||
2
b0a7a4745bf9
?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents:
0
diff
changeset
|
54 |
EtherCAT_command_t cmd_ring[ECAT_COMMAND_RING_SIZE]; /**< Statischer Kommandoring */ |
b0a7a4745bf9
?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents:
0
diff
changeset
|
55 |
int cmd_reserved[ECAT_COMMAND_RING_SIZE]; /**< Reservierungsflags für die Kommandos */ |
0 | 56 |
unsigned int cmd_ring_index; /**< Index des nächsten Kommandos im Ring */ |
2
b0a7a4745bf9
?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents:
0
diff
changeset
|
57 |
|
b0a7a4745bf9
?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents:
0
diff
changeset
|
58 |
int debug_level; /**< Debug-Level im Master-Code */ |
0 | 59 |
} |
60 |
EtherCAT_master_t; |
|
61 |
||
62 |
/***************************************************************/ |
|
63 |
||
64 |
// Master creation and deletion |
|
65 |
int EtherCAT_master_init(EtherCAT_master_t *, EtherCAT_device_t *); |
|
66 |
void EtherCAT_master_clear(EtherCAT_master_t *); |
|
67 |
||
68 |
// Slave management |
|
69 |
int EtherCAT_check_slaves(EtherCAT_master_t *, EtherCAT_slave_t *, unsigned int); |
|
70 |
void EtherCAT_clear_slaves(EtherCAT_master_t *); |
|
71 |
int EtherCAT_activate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); |
|
72 |
int EtherCAT_deactivate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); |
|
73 |
int EtherCAT_activate_all_slaves(EtherCAT_master_t *); |
|
74 |
int EtherCAT_deactivate_all_slaves(EtherCAT_master_t *); |
|
75 |
||
76 |
// Sending and receiving |
|
77 |
int EtherCAT_async_send_receive(EtherCAT_master_t *); |
|
78 |
int EtherCAT_send(EtherCAT_master_t *); |
|
79 |
int EtherCAT_receive(EtherCAT_master_t *); |
|
80 |
int EtherCAT_write_process_data(EtherCAT_master_t *); |
|
81 |
int EtherCAT_read_process_data(EtherCAT_master_t *); |
|
2
b0a7a4745bf9
?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents:
0
diff
changeset
|
82 |
void EtherCAT_clear_process_data(EtherCAT_master_t *); |
0 | 83 |
|
84 |
/***************************************************************/ |
|
85 |
||
86 |
// Slave information interface |
|
87 |
int EtherCAT_read_slave_information(EtherCAT_master_t *, |
|
88 |
unsigned short int, |
|
89 |
unsigned short int, |
|
90 |
unsigned int *); |
|
91 |
||
92 |
// EtherCAT commands |
|
93 |
EtherCAT_command_t *EtherCAT_read(EtherCAT_master_t *, |
|
94 |
unsigned short, |
|
95 |
unsigned short, |
|
96 |
unsigned int); |
|
97 |
EtherCAT_command_t *EtherCAT_write(EtherCAT_master_t *, |
|
98 |
unsigned short, |
|
99 |
unsigned short, |
|
100 |
unsigned int, |
|
101 |
const unsigned char *); |
|
102 |
EtherCAT_command_t *EtherCAT_position_read(EtherCAT_master_t *, |
|
103 |
short, |
|
104 |
unsigned short, |
|
105 |
unsigned int); |
|
106 |
EtherCAT_command_t *EtherCAT_position_write(EtherCAT_master_t *, |
|
107 |
short, |
|
108 |
unsigned short, |
|
109 |
unsigned int, |
|
110 |
const unsigned char *); |
|
111 |
EtherCAT_command_t *EtherCAT_broadcast_read(EtherCAT_master_t *, |
|
112 |
unsigned short, |
|
113 |
unsigned int); |
|
114 |
EtherCAT_command_t *EtherCAT_broadcast_write(EtherCAT_master_t *, |
|
115 |
unsigned short, |
|
116 |
unsigned int, |
|
117 |
const unsigned char *); |
|
118 |
EtherCAT_command_t *EtherCAT_logical_read_write(EtherCAT_master_t *, |
|
119 |
unsigned int, |
|
120 |
unsigned int, |
|
121 |
unsigned char *); |
|
122 |
||
123 |
void EtherCAT_remove_command(EtherCAT_master_t *, EtherCAT_command_t *); |
|
124 |
||
125 |
// Slave states |
|
126 |
int EtherCAT_state_change(EtherCAT_master_t *, EtherCAT_slave_t *, unsigned char); |
|
127 |
||
128 |
/***************************************************************/ |
|
129 |
||
130 |
// Private functions |
|
131 |
EtherCAT_command_t *alloc_cmd(EtherCAT_master_t *); |
|
2
b0a7a4745bf9
?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents:
0
diff
changeset
|
132 |
int add_command(EtherCAT_master_t *, EtherCAT_command_t *); |
0 | 133 |
void set_byte(unsigned char *, unsigned int, unsigned char); |
134 |
void set_word(unsigned char *, unsigned int, unsigned int); |
|
135 |
||
136 |
/***************************************************************/ |
|
137 |
||
138 |
#endif |