1 /****************************************************************************** |
|
2 * |
|
3 * e c _ m a s t e r . h |
|
4 * |
|
5 * Struktur für einen EtherCAT-Master. |
|
6 * |
|
7 * $Id$ |
|
8 * |
|
9 *****************************************************************************/ |
|
10 |
|
11 #ifndef _EC_MASTER_H_ |
|
12 #define _EC_MASTER_H_ |
|
13 |
|
14 #include "ec_device.h" |
|
15 #include "ec_slave.h" |
|
16 #include "ec_command.h" |
|
17 #include "ec_domain.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 struct EtherCAT_master |
|
29 { |
|
30 EtherCAT_slave_t *bus_slaves; /**< Array von Slaves auf dem Bus */ |
|
31 unsigned int bus_slaves_count; /**< Anzahl Slaves auf dem Bus */ |
|
32 EtherCAT_device_t *dev; /**< Zeiger auf das zugewiesene EtherCAT-Gerät */ |
|
33 unsigned char command_index; /**< Aktueller Kommando-Index */ |
|
34 unsigned char tx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statischer Speicher |
|
35 für zu sendende Daten */ |
|
36 unsigned int tx_data_length; /**< Länge der Daten im Sendespeicher */ |
|
37 unsigned char rx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statische Speicher für |
|
38 eine Kopie des Rx-Buffers |
|
39 im EtherCAT-Gerät */ |
|
40 unsigned int rx_data_length; /**< Länge der Daten im Empfangsspeicher */ |
|
41 EtherCAT_domain_t domains[ECAT_MAX_DOMAINS]; /** Prozessdatendomänen */ |
|
42 unsigned int domain_count; |
|
43 int debug_level; /**< Debug-Level im Master-Code */ |
|
44 unsigned int bus_time; /**< Letzte Bus-Zeit in Mikrosekunden */ |
|
45 unsigned int frames_lost; /**< Anzahl verlorene Frames */ |
|
46 unsigned long t_lost_output; /*<< Timer-Ticks bei der letzten Ausgabe von |
|
47 verlorenen Frames */ |
|
48 }; |
|
49 |
|
50 /*****************************************************************************/ |
|
51 |
|
52 // Public methods |
|
53 |
|
54 void *EtherCAT_register_slave(EtherCAT_master_t *, unsigned int, |
|
55 const char *, const char *, unsigned int); |
|
56 int EtherCAT_activate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); |
|
57 int EtherCAT_deactivate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); |
|
58 int EtherCAT_process_data_cycle(EtherCAT_master_t *, unsigned int, |
|
59 unsigned int); |
|
60 |
|
61 // Private Methods |
|
62 |
|
63 // Master creation and deletion |
|
64 void EtherCAT_master_init(EtherCAT_master_t *); |
|
65 void EtherCAT_master_clear(EtherCAT_master_t *); |
|
66 |
|
67 // Registration of devices |
|
68 int EtherCAT_master_open(EtherCAT_master_t *, EtherCAT_device_t *); |
|
69 void EtherCAT_master_close(EtherCAT_master_t *, EtherCAT_device_t *); |
|
70 |
|
71 // Sending and receiving |
|
72 int EtherCAT_simple_send_receive(EtherCAT_master_t *, EtherCAT_command_t *); |
|
73 int EtherCAT_simple_send(EtherCAT_master_t *, EtherCAT_command_t *); |
|
74 int EtherCAT_simple_receive(EtherCAT_master_t *, EtherCAT_command_t *); |
|
75 |
|
76 // Slave management |
|
77 int EtherCAT_scan_for_slaves(EtherCAT_master_t *); |
|
78 int EtherCAT_read_slave_information(EtherCAT_master_t *, unsigned short int, |
|
79 unsigned short int, unsigned int *); |
|
80 int EtherCAT_state_change(EtherCAT_master_t *, EtherCAT_slave_t *, |
|
81 unsigned char); |
|
82 |
|
83 // Misc. |
|
84 |
|
85 void output_debug_data(const EtherCAT_master_t *); |
|
86 void ecat_output_lost_frames(EtherCAT_master_t *); |
|
87 |
|
88 /*****************************************************************************/ |
|
89 |
|
90 #endif |
|
91 |
|
92 /* Emacs-Konfiguration |
|
93 ;;; Local Variables: *** |
|
94 ;;; c-basic-offset:2 *** |
|
95 ;;; End: *** |
|
96 */ |
|