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