19 #include "types.h" |
19 #include "types.h" |
20 |
20 |
21 /*****************************************************************************/ |
21 /*****************************************************************************/ |
22 |
22 |
23 /** |
23 /** |
24 Zustand eines EtherCAT-Slaves. |
24 State of an EtherCAT slave. |
25 */ |
25 */ |
26 |
26 |
27 typedef enum |
27 typedef enum |
28 { |
28 { |
29 EC_SLAVE_STATE_UNKNOWN = 0x00, |
29 EC_SLAVE_STATE_UNKNOWN = 0x00, |
30 /**< Status unbekannt */ |
30 /**< unknown state */ |
31 EC_SLAVE_STATE_INIT = 0x01, |
31 EC_SLAVE_STATE_INIT = 0x01, |
32 /**< Init-Zustand (Keine Mailbox-Kommunikation, Kein I/O) */ |
32 /**< INIT state (no mailbox communication, no IO) */ |
33 EC_SLAVE_STATE_PREOP = 0x02, |
33 EC_SLAVE_STATE_PREOP = 0x02, |
34 /**< Pre-Operational (Mailbox-Kommunikation, Kein I/O) */ |
34 /**< PREOP state (mailbox communication, no IO) */ |
35 EC_SLAVE_STATE_SAVEOP = 0x04, |
35 EC_SLAVE_STATE_SAVEOP = 0x04, |
36 /**< Save-Operational (Mailbox-Kommunikation und Input Update) */ |
36 /**< SAVEOP (mailbox communication and input update) */ |
37 EC_SLAVE_STATE_OP = 0x08, |
37 EC_SLAVE_STATE_OP = 0x08, |
38 /**< Operational, (Mailbox-Kommunikation und Input/Output Update) */ |
38 /**< OP (mailbox communication and input/output update) */ |
39 EC_ACK = 0x10 |
39 EC_ACK = 0x10 |
40 /**< Acknoledge-Bit beim Zustandswechsel (kein eigener Zustand) */ |
40 /**< Acknoledge bit (no state) */ |
41 } |
41 } |
42 ec_slave_state_t; |
42 ec_slave_state_t; |
43 |
43 |
44 /*****************************************************************************/ |
44 /*****************************************************************************/ |
45 |
45 |
46 /** |
46 /** |
47 Unterstützte Mailbox-Protokolle. |
47 Supported mailbox protocols. |
48 */ |
48 */ |
49 |
49 |
50 enum |
50 enum |
51 { |
51 { |
52 EC_MBOX_AOE = 0x01, /**< ADS-over-EtherCAT */ |
52 EC_MBOX_AOE = 0x01, /**< ADS-over-EtherCAT */ |
58 }; |
58 }; |
59 |
59 |
60 /*****************************************************************************/ |
60 /*****************************************************************************/ |
61 |
61 |
62 /** |
62 /** |
63 FMMU-Konfiguration. |
63 FMMU configuration. |
64 */ |
64 */ |
65 |
65 |
66 typedef struct |
66 typedef struct |
67 { |
67 { |
68 const ec_domain_t *domain; |
68 const ec_domain_t *domain; /**< domain */ |
69 const ec_sync_t *sync; |
69 const ec_sync_t *sync; /**< sync manager */ |
70 uint32_t logical_start_address; |
70 uint32_t logical_start_address; /**< logical start address */ |
71 } |
71 } |
72 ec_fmmu_t; |
72 ec_fmmu_t; |
73 |
73 |
74 /*****************************************************************************/ |
74 /*****************************************************************************/ |
75 |
75 |
76 /** |
76 /** |
77 String im EEPROM eines EtherCAT-Slaves. |
77 String object (EEPROM). |
78 */ |
78 */ |
79 |
79 |
80 typedef struct |
80 typedef struct |
81 { |
81 { |
82 struct list_head list; |
82 struct list_head list; /**< list item */ |
83 size_t size; |
83 size_t size; /**< size in bytes */ |
84 char *data; |
84 char *data; /**< string data */ |
85 } |
85 } |
86 ec_eeprom_string_t; |
86 ec_eeprom_string_t; |
87 |
87 |
88 /*****************************************************************************/ |
88 /*****************************************************************************/ |
89 |
89 |
90 /** |
90 /** |
91 Sync-Manager-Konfiguration laut EEPROM. |
91 Sync manager configuration (EEPROM). |
92 */ |
92 */ |
93 |
93 |
94 typedef struct |
94 typedef struct |
95 { |
95 { |
96 struct list_head list; |
96 struct list_head list; /**< list item */ |
97 unsigned int index; |
97 unsigned int index; /**< sync manager index */ |
98 uint16_t physical_start_address; |
98 uint16_t physical_start_address; /**< physical start address */ |
99 uint16_t length; |
99 uint16_t length; /**< data length in bytes */ |
100 uint8_t control_register; |
100 uint8_t control_register; /**< control register value */ |
101 uint8_t enable; |
101 uint8_t enable; /**< enable bit */ |
102 } |
102 } |
103 ec_eeprom_sync_t; |
103 ec_eeprom_sync_t; |
104 |
104 |
105 /*****************************************************************************/ |
105 /*****************************************************************************/ |
106 |
106 |
107 /** |
107 /** |
108 PDO-Typ. |
108 PDO type. |
109 */ |
109 */ |
110 |
110 |
111 typedef enum |
111 typedef enum |
112 { |
112 { |
113 EC_RX_PDO, |
113 EC_RX_PDO, /**< Reveive PDO */ |
114 EC_TX_PDO |
114 EC_TX_PDO /**< Transmit PDO */ |
115 } |
115 } |
116 ec_pdo_type_t; |
116 ec_pdo_type_t; |
117 |
117 |
118 /*****************************************************************************/ |
118 /*****************************************************************************/ |
119 |
119 |
120 /** |
120 /** |
121 PDO-Beschreibung im EEPROM. |
121 PDO description (EEPROM). |
122 */ |
122 */ |
123 |
123 |
124 typedef struct |
124 typedef struct |
125 { |
125 { |
126 struct list_head list; |
126 struct list_head list; /**< list item */ |
127 ec_pdo_type_t type; |
127 ec_pdo_type_t type; /**< PDO type */ |
128 uint16_t index; |
128 uint16_t index; /**< PDO index */ |
129 uint8_t sync_manager; |
129 uint8_t sync_manager; /**< assigned sync manager */ |
130 char *name; |
130 char *name; /**< PDO name */ |
131 struct list_head entries; |
131 struct list_head entries; /**< entry list */ |
132 } |
132 } |
133 ec_eeprom_pdo_t; |
133 ec_eeprom_pdo_t; |
134 |
134 |
135 /*****************************************************************************/ |
135 /*****************************************************************************/ |
136 |
136 |
137 /** |
137 /** |
138 PDO-Entry-Beschreibung im EEPROM. |
138 PDO entry description (EEPROM). |
139 */ |
139 */ |
140 |
140 |
141 typedef struct |
141 typedef struct |
142 { |
142 { |
143 struct list_head list; |
143 struct list_head list; /**< list item */ |
144 uint16_t index; |
144 uint16_t index; /**< PDO index */ |
145 uint8_t subindex; |
145 uint8_t subindex; /**< entry subindex */ |
146 char *name; |
146 char *name; /**< entry name */ |
147 uint8_t bit_length; |
147 uint8_t bit_length; /**< entry length in bit */ |
148 } |
148 } |
149 ec_eeprom_pdo_entry_t; |
149 ec_eeprom_pdo_entry_t; |
150 |
150 |
151 /*****************************************************************************/ |
151 /*****************************************************************************/ |
152 |
152 |
153 /** |
153 /** |
154 CANopen-SDO. |
154 CANopen SDO. |
155 */ |
155 */ |
156 |
156 |
157 typedef struct |
157 typedef struct |
158 { |
158 { |
159 struct list_head list; |
159 struct list_head list; /**< list item */ |
160 uint16_t index; |
160 uint16_t index; /**< SDO index */ |
161 //uint16_t type; |
161 //uint16_t type; |
162 uint8_t object_code; |
162 uint8_t object_code; /**< object code */ |
163 char *name; |
163 char *name; /**< SDO name */ |
164 struct list_head entries; |
164 struct list_head entries; /**< entry list */ |
165 } |
165 } |
166 ec_sdo_t; |
166 ec_sdo_t; |
167 |
167 |
168 /*****************************************************************************/ |
168 /*****************************************************************************/ |
169 |
169 |
170 /** |
170 /** |
171 CANopen-SDO-Entry. |
171 CANopen SDO entry. |
172 */ |
172 */ |
173 |
173 |
174 typedef struct |
174 typedef struct |
175 { |
175 { |
176 struct list_head list; |
176 struct list_head list; /**< list item */ |
177 uint8_t subindex; |
177 uint8_t subindex; /**< entry subindex */ |
178 uint16_t data_type; |
178 uint16_t data_type; /**< entry data type */ |
179 uint16_t bit_length; |
179 uint16_t bit_length; /**< entry length in bit */ |
180 char *name; |
180 char *name; /**< entry name */ |
181 } |
181 } |
182 ec_sdo_entry_t; |
182 ec_sdo_entry_t; |
183 |
183 |
184 /*****************************************************************************/ |
184 /*****************************************************************************/ |
185 |
185 |
187 EtherCAT-Slave |
187 EtherCAT-Slave |
188 */ |
188 */ |
189 |
189 |
190 struct ec_slave |
190 struct ec_slave |
191 { |
191 { |
192 struct list_head list; /**< Noetig fuer Slave-Liste im Master */ |
192 struct list_head list; /**< list item */ |
193 struct kobject kobj; /**< Kernel-Object */ |
193 struct kobject kobj; /**< kobject */ |
194 ec_master_t *master; /**< EtherCAT-Master, zu dem der Slave gehört. */ |
194 ec_master_t *master; /**< master owning the slave */ |
195 |
195 |
196 // Addresses |
196 // addresses |
197 uint16_t ring_position; /**< Position des Slaves im Bus */ |
197 uint16_t ring_position; /**< ring position */ |
198 uint16_t station_address; /**< Konfigurierte Slave-Adresse */ |
198 uint16_t station_address; /**< configured station address */ |
199 uint16_t coupler_index; /**< Letzter Buskoppler */ |
199 uint16_t coupler_index; /**< index of the last bus coupler */ |
200 uint16_t coupler_subindex; /**< Index hinter letztem Buskoppler */ |
200 uint16_t coupler_subindex; /**< index of this slave after last coupler */ |
201 |
201 |
202 // Base data |
202 // base data |
203 uint8_t base_type; /**< Slave-Typ */ |
203 uint8_t base_type; /**< slave type */ |
204 uint8_t base_revision; /**< Revision */ |
204 uint8_t base_revision; /**< revision */ |
205 uint16_t base_build; /**< Build-Nummer */ |
205 uint16_t base_build; /**< build number */ |
206 uint16_t base_fmmu_count; /**< Anzahl unterstützter FMMUs */ |
206 uint16_t base_fmmu_count; /**< number of supported FMMUs */ |
207 uint16_t base_sync_count; /**< Anzahl unterstützter Sync-Manager */ |
207 uint16_t base_sync_count; /**< number of supported sync managers */ |
208 |
208 |
209 // Data link status |
209 // data link status |
210 uint8_t dl_link[4]; /**< Verbindung erkannt */ |
210 uint8_t dl_link[4]; /**< link detected */ |
211 uint8_t dl_loop[4]; /**< Loop geschlossen */ |
211 uint8_t dl_loop[4]; /**< loop closed */ |
212 uint8_t dl_signal[4]; /**< Signal an RX-Seite erkannt */ |
212 uint8_t dl_signal[4]; /**< detected signal on RX port */ |
213 |
213 |
214 // Slave information interface |
214 // slave information interface |
215 uint16_t sii_alias; /**< Configured station alias */ |
215 uint16_t sii_alias; /**< configured station alias */ |
216 uint32_t sii_vendor_id; /**< Identifikationsnummer des Herstellers */ |
216 uint32_t sii_vendor_id; /**< vendor id */ |
217 uint32_t sii_product_code; /**< Herstellerspezifischer Produktcode */ |
217 uint32_t sii_product_code; /**< vendor's product code */ |
218 uint32_t sii_revision_number; /**< Revisionsnummer */ |
218 uint32_t sii_revision_number; /**< revision number */ |
219 uint32_t sii_serial_number; /**< Seriennummer der Klemme */ |
219 uint32_t sii_serial_number; /**< serial number */ |
220 uint16_t sii_rx_mailbox_offset; /**< Adresse der Mailbox (Master->Slave) */ |
220 uint16_t sii_rx_mailbox_offset; /**< mailbox address (master to slave) */ |
221 uint16_t sii_rx_mailbox_size; /**< Adresse der Mailbox (Master->Slave) */ |
221 uint16_t sii_rx_mailbox_size; /**< mailbox size (master to slave) */ |
222 uint16_t sii_tx_mailbox_offset; /**< Adresse der Mailbox (Slave->Master) */ |
222 uint16_t sii_tx_mailbox_offset; /**< mailbox address (slave to master) */ |
223 uint16_t sii_tx_mailbox_size; /**< Adresse der Mailbox (Slave->Master) */ |
223 uint16_t sii_tx_mailbox_size; /**< mailbox size (slave to master) */ |
224 uint16_t sii_mailbox_protocols; /**< Unterstützte Mailbox-Protokolle */ |
224 uint16_t sii_mailbox_protocols; /**< supported mailbox protocols */ |
225 uint8_t sii_physical_layer[4]; /**< Uebertragungsarten der Ports */ |
225 uint8_t sii_physical_layer[4]; /**< port media */ |
226 |
226 |
227 const ec_slave_type_t *type; /**< Zeiger auf die Beschreibung |
227 const ec_slave_type_t *type; /**< pointer to slave type object */ |
228 des Slave-Typs */ |
228 |
229 |
229 uint8_t registered; /**< true, if slave has been registered */ |
230 uint8_t registered; /**< Der Slave wurde registriert */ |
230 |
231 |
231 ec_fmmu_t fmmus[EC_MAX_FMMUS]; /**< FMMU configurations */ |
232 ec_fmmu_t fmmus[EC_MAX_FMMUS]; /**< FMMU-Konfigurationen */ |
232 uint8_t fmmu_count; /**< number of FMMUs used */ |
233 uint8_t fmmu_count; /**< Wieviele FMMUs schon benutzt sind. */ |
233 |
234 |
234 struct list_head eeprom_strings; /**< EEPROM STRING categories */ |
235 struct list_head eeprom_strings; /**< Strings im EEPROM */ |
235 struct list_head eeprom_syncs; /**< EEPROM SYNC MANAGER categories */ |
236 struct list_head eeprom_syncs; /**< Syncmanager-Konfigurationen (EEPROM) */ |
236 struct list_head eeprom_pdos; /**< EEPROM [RT]XPDO categories */ |
237 struct list_head eeprom_pdos; /**< PDO-Beschreibungen im EEPROM */ |
237 |
238 |
238 char *eeprom_name; /**< slave name acc. to EEPROM */ |
239 char *eeprom_name; /**< Slave-Name laut Hersteller */ |
239 char *eeprom_group; /**< slave group acc. to EEPROM */ |
240 char *eeprom_group; /**< Slave-Beschreibung laut Hersteller */ |
240 char *eeprom_desc; /**< slave description acc. to EEPROM */ |
241 char *eeprom_desc; /**< Slave-Beschreibung laut Hersteller */ |
241 |
242 |
242 struct list_head sdo_dictionary; /**< SDO directory list */ |
243 struct list_head sdo_dictionary; /**< SDO-Verzeichnis des Slaves */ |
243 |
244 |
244 ec_command_t mbox_command; /**< mailbox command */ |
245 ec_command_t mbox_command; /**< Kommando für Mailbox-Kommunikation */ |
|
246 }; |
245 }; |
247 |
246 |
248 /*****************************************************************************/ |
247 /*****************************************************************************/ |
249 |
248 |
250 // Slave construction/destruction |
249 // slave construction/destruction |
251 int ec_slave_init(ec_slave_t *, ec_master_t *, uint16_t, uint16_t); |
250 int ec_slave_init(ec_slave_t *, ec_master_t *, uint16_t, uint16_t); |
252 void ec_slave_clear(struct kobject *); |
251 void ec_slave_clear(struct kobject *); |
253 |
252 |
254 // Slave control |
253 // slave control |
255 int ec_slave_fetch(ec_slave_t *); |
254 int ec_slave_fetch(ec_slave_t *); |
256 int ec_slave_sii_read16(ec_slave_t *, uint16_t, uint16_t *); |
255 int ec_slave_sii_read16(ec_slave_t *, uint16_t, uint16_t *); |
257 int ec_slave_sii_read32(ec_slave_t *, uint16_t, uint32_t *); |
256 int ec_slave_sii_read32(ec_slave_t *, uint16_t, uint32_t *); |
258 int ec_slave_sii_write16(ec_slave_t *, uint16_t, uint16_t); |
257 int ec_slave_sii_write16(ec_slave_t *, uint16_t, uint16_t); |
259 int ec_slave_state_change(ec_slave_t *, uint8_t); |
258 int ec_slave_state_change(ec_slave_t *, uint8_t); |
260 int ec_slave_prepare_fmmu(ec_slave_t *, const ec_domain_t *, |
259 int ec_slave_prepare_fmmu(ec_slave_t *, const ec_domain_t *, |
261 const ec_sync_t *); |
260 const ec_sync_t *); |
262 |
261 |
263 // CANopen over EtherCAT |
262 // CoE |
264 int ec_slave_fetch_sdo_list(ec_slave_t *); |
263 int ec_slave_fetch_sdo_list(ec_slave_t *); |
265 |
264 |
266 // Misc |
265 // misc. |
267 void ec_slave_print(const ec_slave_t *, unsigned int); |
266 void ec_slave_print(const ec_slave_t *, unsigned int); |
268 int ec_slave_check_crc(ec_slave_t *); |
267 int ec_slave_check_crc(ec_slave_t *); |
269 |
268 |
270 /*****************************************************************************/ |
269 /*****************************************************************************/ |
271 |
270 |
272 #endif |
271 #endif |
273 |
|
274 /* Emacs-Konfiguration |
|
275 ;;; Local Variables: *** |
|
276 ;;; c-basic-offset:4 *** |
|
277 ;;; End: *** |
|
278 */ |
|