1 /****************************************************************************** |
|
2 * |
|
3 * e c _ c o m m a n d . h |
|
4 * |
|
5 * Struktur für ein EtherCAT-Kommando. |
|
6 * |
|
7 * $Id$ |
|
8 * |
|
9 *****************************************************************************/ |
|
10 |
|
11 #ifndef _EC_COMMAND_H_ |
|
12 #define _EC_COMMAND_H_ |
|
13 |
|
14 #include "ec_globals.h" |
|
15 |
|
16 /*****************************************************************************/ |
|
17 |
|
18 /** |
|
19 Status eines EtherCAT-Kommandos. |
|
20 */ |
|
21 |
|
22 typedef enum |
|
23 { |
|
24 ECAT_CS_READY, ECAT_CS_SENT, ECAT_CS_RECEIVED |
|
25 } |
|
26 EtherCAT_command_state_t; |
|
27 |
|
28 /*****************************************************************************/ |
|
29 |
|
30 /** |
|
31 EtherCAT-Adresse. |
|
32 |
|
33 Im EtherCAT-Rahmen sind 4 Bytes für die Adresse reserviert, die |
|
34 ja nach Kommandoty eine andere bedeutung haben: Bei Autoinkrement- |
|
35 befehlen sind die ersten zwei Bytes die (negative) |
|
36 Autoinkrement-Adresse, bei Knoten-adressierten Befehlen entsprechen |
|
37 sie der Knotenadresse. Das dritte und vierte Byte entspricht in |
|
38 diesen Fällen der physikalischen Speicheradresse auf dem Slave. |
|
39 Bei einer logischen Adressierung entsprechen alle vier Bytes |
|
40 der logischen Adresse. |
|
41 */ |
|
42 |
|
43 typedef union |
|
44 { |
|
45 struct |
|
46 { |
|
47 union |
|
48 { |
|
49 short pos; /**< (Negative) Ring-Position des Slaves */ |
|
50 unsigned short node; /**< Konfigurierte Knotenadresse */ |
|
51 } |
|
52 dev; |
|
53 |
|
54 unsigned short mem; /**< Physikalische Speicheradresse im Slave */ |
|
55 } |
|
56 phy; |
|
57 |
|
58 unsigned long logical; /**< Logische Adresse */ |
|
59 unsigned char raw[4]; /**< Rohdaten für die Generierung des Frames */ |
|
60 } |
|
61 EtherCAT_address_t; |
|
62 |
|
63 /*****************************************************************************/ |
|
64 |
|
65 /** |
|
66 EtherCAT-Kommando. |
|
67 */ |
|
68 |
|
69 typedef struct EtherCAT_command |
|
70 { |
|
71 EtherCAT_cmd_type_t type; /**< Typ des Kommandos (APRD, NPWR, etc...) */ |
|
72 EtherCAT_address_t address; /**< Adresse des/der Empfänger */ |
|
73 unsigned int data_length; /**< Länge der zu sendenden und/oder |
|
74 empfangenen Daten */ |
|
75 |
|
76 EtherCAT_command_state_t state; /**< Zustand des Kommandos |
|
77 (bereit, gesendet, etc...) */ |
|
78 unsigned char index; /**< Kommando-Index, mit der das Kommando gesendet |
|
79 wurde (wird vom Master beim Senden gesetzt. */ |
|
80 unsigned int working_counter; /**< Working-Counter bei Empfang (wird |
|
81 vom Master gesetzt) */ |
|
82 |
|
83 unsigned char data[ECAT_FRAME_BUFFER_SIZE]; /**< Kommandodaten */ |
|
84 } |
|
85 EtherCAT_command_t; |
|
86 |
|
87 /*****************************************************************************/ |
|
88 |
|
89 void EtherCAT_command_init(EtherCAT_command_t *); |
|
90 void EtherCAT_command_clear(EtherCAT_command_t *); |
|
91 |
|
92 void EtherCAT_command_read(EtherCAT_command_t *, |
|
93 unsigned short, |
|
94 unsigned short, |
|
95 unsigned int); |
|
96 void EtherCAT_command_write(EtherCAT_command_t *, |
|
97 unsigned short, |
|
98 unsigned short, |
|
99 unsigned int, |
|
100 const unsigned char *); |
|
101 void EtherCAT_command_position_read(EtherCAT_command_t *, |
|
102 short, |
|
103 unsigned short, |
|
104 unsigned int); |
|
105 void EtherCAT_command_position_write(EtherCAT_command_t *, |
|
106 short, |
|
107 unsigned short, |
|
108 unsigned int, |
|
109 const unsigned char *); |
|
110 void EtherCAT_command_broadcast_read(EtherCAT_command_t *, |
|
111 unsigned short, |
|
112 unsigned int); |
|
113 void EtherCAT_command_broadcast_write(EtherCAT_command_t *, |
|
114 unsigned short, |
|
115 unsigned int, |
|
116 const unsigned char *); |
|
117 void EtherCAT_command_logical_read_write(EtherCAT_command_t *, |
|
118 unsigned int, |
|
119 unsigned int, |
|
120 unsigned char *); |
|
121 |
|
122 /*****************************************************************************/ |
|
123 |
|
124 #endif |
|