author | Florian Pose <fp@igh-essen.com> |
Fri, 18 Nov 2005 09:35:04 +0000 | |
changeset 16 | f04e93b8af0f |
parent 14 | 28b57b073f58 |
child 17 | 1b5aea4d5147 |
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 |
||
14
28b57b073f58
Kommandoring und Co. entfernt.
Florian Pose <fp@igh-essen.com>
parents:
13
diff
changeset
|
34 |
#if 0 |
0 | 35 |
EtherCAT_command_t *first_command; /**< Zeiger auf das erste |
36 |
Kommando in der Liste */ |
|
14
28b57b073f58
Kommandoring und Co. entfernt.
Florian Pose <fp@igh-essen.com>
parents:
13
diff
changeset
|
37 |
#endif |
13
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
38 |
EtherCAT_command_t process_data_command; /**< Kommando zum Senden und |
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
39 |
Empfangen der Prozessdaten */ |
0 | 40 |
|
41 |
EtherCAT_device_t *dev; /**< Zeiger auf das zugewiesene EtherCAT-Gerät */ |
|
42 |
||
43 |
unsigned char command_index; /**< Aktueller Kommando-Index */ |
|
44 |
||
45 |
unsigned char tx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statischer Speicher |
|
46 |
für zu sendende Daten */ |
|
47 |
unsigned int tx_data_length; /**< Länge der Daten im Sendespeicher */ |
|
48 |
unsigned char rx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statische Speicher für |
|
49 |
eine Kopie des Rx-Buffers |
|
50 |
im EtherCAT-Gerät */ |
|
51 |
||
52 |
unsigned char *process_data; /**< Zeiger auf Speicher mit Prozessdaten */ |
|
53 |
unsigned int process_data_length; /**< Länge der Prozessdaten */ |
|
54 |
||
14
28b57b073f58
Kommandoring und Co. entfernt.
Florian Pose <fp@igh-essen.com>
parents:
13
diff
changeset
|
55 |
#if 0 |
2
b0a7a4745bf9
?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents:
0
diff
changeset
|
56 |
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
|
57 |
int cmd_reserved[ECAT_COMMAND_RING_SIZE]; /**< Reservierungsflags für die Kommandos */ |
0 | 58 |
unsigned int cmd_ring_index; /**< Index des nächsten Kommandos im Ring */ |
14
28b57b073f58
Kommandoring und Co. entfernt.
Florian Pose <fp@igh-essen.com>
parents:
13
diff
changeset
|
59 |
#endif |
2
b0a7a4745bf9
?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents:
0
diff
changeset
|
60 |
|
b0a7a4745bf9
?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents:
0
diff
changeset
|
61 |
int debug_level; /**< Debug-Level im Master-Code */ |
0 | 62 |
} |
63 |
EtherCAT_master_t; |
|
64 |
||
65 |
/***************************************************************/ |
|
66 |
||
67 |
// Master creation and deletion |
|
68 |
int EtherCAT_master_init(EtherCAT_master_t *, EtherCAT_device_t *); |
|
69 |
void EtherCAT_master_clear(EtherCAT_master_t *); |
|
70 |
||
71 |
// Slave management |
|
72 |
int EtherCAT_check_slaves(EtherCAT_master_t *, EtherCAT_slave_t *, unsigned int); |
|
73 |
void EtherCAT_clear_slaves(EtherCAT_master_t *); |
|
74 |
int EtherCAT_activate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); |
|
75 |
int EtherCAT_deactivate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); |
|
76 |
int EtherCAT_activate_all_slaves(EtherCAT_master_t *); |
|
77 |
int EtherCAT_deactivate_all_slaves(EtherCAT_master_t *); |
|
78 |
||
79 |
// Sending and receiving |
|
13
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
80 |
#if 0 |
0 | 81 |
int EtherCAT_async_send_receive(EtherCAT_master_t *); |
82 |
int EtherCAT_send(EtherCAT_master_t *); |
|
83 |
int EtherCAT_receive(EtherCAT_master_t *); |
|
13
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
84 |
#endif |
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
85 |
int EtherCAT_simple_send_receive(EtherCAT_master_t *, EtherCAT_command_t *); |
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
86 |
int EtherCAT_simple_send(EtherCAT_master_t *, EtherCAT_command_t *); |
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
87 |
int EtherCAT_simple_receive(EtherCAT_master_t *, EtherCAT_command_t *); |
11
e58d78234412
EtherCAT_send_receive_command() zum Senden eines einzelnen Kommandos hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
2
diff
changeset
|
88 |
|
0 | 89 |
int EtherCAT_write_process_data(EtherCAT_master_t *); |
90 |
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
|
91 |
void EtherCAT_clear_process_data(EtherCAT_master_t *); |
0 | 92 |
|
93 |
/***************************************************************/ |
|
94 |
||
95 |
// Slave information interface |
|
96 |
int EtherCAT_read_slave_information(EtherCAT_master_t *, |
|
97 |
unsigned short int, |
|
98 |
unsigned short int, |
|
99 |
unsigned int *); |
|
100 |
||
101 |
// EtherCAT commands |
|
13
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
102 |
#if 0 |
0 | 103 |
EtherCAT_command_t *EtherCAT_read(EtherCAT_master_t *, |
104 |
unsigned short, |
|
105 |
unsigned short, |
|
106 |
unsigned int); |
|
107 |
EtherCAT_command_t *EtherCAT_write(EtherCAT_master_t *, |
|
108 |
unsigned short, |
|
109 |
unsigned short, |
|
110 |
unsigned int, |
|
111 |
const unsigned char *); |
|
112 |
EtherCAT_command_t *EtherCAT_position_read(EtherCAT_master_t *, |
|
113 |
short, |
|
114 |
unsigned short, |
|
115 |
unsigned int); |
|
116 |
EtherCAT_command_t *EtherCAT_position_write(EtherCAT_master_t *, |
|
117 |
short, |
|
118 |
unsigned short, |
|
119 |
unsigned int, |
|
120 |
const unsigned char *); |
|
121 |
EtherCAT_command_t *EtherCAT_broadcast_read(EtherCAT_master_t *, |
|
122 |
unsigned short, |
|
123 |
unsigned int); |
|
124 |
EtherCAT_command_t *EtherCAT_broadcast_write(EtherCAT_master_t *, |
|
125 |
unsigned short, |
|
126 |
unsigned int, |
|
127 |
const unsigned char *); |
|
128 |
EtherCAT_command_t *EtherCAT_logical_read_write(EtherCAT_master_t *, |
|
129 |
unsigned int, |
|
130 |
unsigned int, |
|
131 |
unsigned char *); |
|
132 |
||
133 |
void EtherCAT_remove_command(EtherCAT_master_t *, EtherCAT_command_t *); |
|
13
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
134 |
#endif |
0 | 135 |
|
136 |
// Slave states |
|
137 |
int EtherCAT_state_change(EtherCAT_master_t *, EtherCAT_slave_t *, unsigned char); |
|
138 |
||
139 |
/***************************************************************/ |
|
140 |
||
141 |
// Private functions |
|
13
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
142 |
#if 0 |
0 | 143 |
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
|
144 |
int add_command(EtherCAT_master_t *, EtherCAT_command_t *); |
13
db0742533c10
Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents:
11
diff
changeset
|
145 |
#endif |
0 | 146 |
void set_byte(unsigned char *, unsigned int, unsigned char); |
147 |
void set_word(unsigned char *, unsigned int, unsigned int); |
|
11
e58d78234412
EtherCAT_send_receive_command() zum Senden eines einzelnen Kommandos hinzugef?gt.
Florian Pose <fp@igh-essen.com>
parents:
2
diff
changeset
|
148 |
void output_debug_data(unsigned char *, unsigned int); |
0 | 149 |
|
150 |
/***************************************************************/ |
|
151 |
||
152 |
#endif |