12 #define _EC_MASTER_H_ |
12 #define _EC_MASTER_H_ |
13 |
13 |
14 #include "ec_device.h" |
14 #include "ec_device.h" |
15 #include "ec_slave.h" |
15 #include "ec_slave.h" |
16 #include "ec_command.h" |
16 #include "ec_command.h" |
|
17 #include "ec_domain.h" |
17 |
18 |
18 /*****************************************************************************/ |
19 /*****************************************************************************/ |
19 |
20 |
20 /** |
21 /** |
21 EtherCAT-Master |
22 EtherCAT-Master |
22 |
23 |
23 Verwaltet die EtherCAT-Slaves und kommuniziert mit |
24 Verwaltet die EtherCAT-Slaves und kommuniziert mit |
24 dem zugewiesenen EtherCAT-Gerät. |
25 dem zugewiesenen EtherCAT-Gerät. |
25 */ |
26 */ |
26 |
27 |
27 typedef struct |
28 struct EtherCAT_master |
28 { |
29 { |
29 EtherCAT_slave_t *slaves; /**< Zeiger auf statischen Speicher |
|
30 mit Slave-Informationen */ |
|
31 unsigned int slave_count; /**< Anzahl der Slaves in slaves */ |
|
32 |
|
33 EtherCAT_command_t process_data_command; /**< Kommando zum Senden und |
|
34 Empfangen der Prozessdaten */ |
|
35 |
|
36 EtherCAT_device_t *dev; /**< Zeiger auf das zugewiesene EtherCAT-Gerät */ |
30 EtherCAT_device_t *dev; /**< Zeiger auf das zugewiesene EtherCAT-Gerät */ |
37 |
|
38 unsigned char command_index; /**< Aktueller Kommando-Index */ |
31 unsigned char command_index; /**< Aktueller Kommando-Index */ |
39 |
|
40 unsigned char tx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statischer Speicher |
32 unsigned char tx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statischer Speicher |
41 für zu sendende Daten */ |
33 für zu sendende Daten */ |
42 unsigned int tx_data_length; /**< Länge der Daten im Sendespeicher */ |
34 unsigned int tx_data_length; /**< Länge der Daten im Sendespeicher */ |
43 unsigned char rx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statische Speicher für |
35 unsigned char rx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statische Speicher für |
44 eine Kopie des Rx-Buffers |
36 eine Kopie des Rx-Buffers |
45 im EtherCAT-Gerät */ |
37 im EtherCAT-Gerät */ |
46 unsigned int rx_data_length; /**< Länge der Daten im Empfangsspeicher */ |
38 unsigned int rx_data_length; /**< Länge der Daten im Empfangsspeicher */ |
47 |
39 EtherCAT_domain_t domains[ECAT_MAX_DOMAINS]; /** Prozessdatendomänen */ |
48 unsigned char *process_data; /**< Zeiger auf Speicher mit Prozessdaten */ |
40 unsigned int domain_count; |
49 unsigned int process_data_length; /**< Länge der Prozessdaten */ |
|
50 |
|
51 int debug_level; /**< Debug-Level im Master-Code */ |
41 int debug_level; /**< Debug-Level im Master-Code */ |
52 } |
42 unsigned long tx_time; /**< Zeit des letzten Sendens */ |
53 EtherCAT_master_t; |
43 unsigned long rx_time; /**< Zeit des letzten Empfangs */ |
|
44 unsigned int rx_tries; /**< Anzahl Warteschleifen beim letzen Enpfang */ |
|
45 }; |
54 |
46 |
55 /*****************************************************************************/ |
47 /*****************************************************************************/ |
56 |
48 |
57 // Master creation and deletion |
49 // Master creation and deletion |
58 void EtherCAT_master_init(EtherCAT_master_t *); |
50 void EtherCAT_master_init(EtherCAT_master_t *); |
66 int EtherCAT_simple_send_receive(EtherCAT_master_t *, EtherCAT_command_t *); |
58 int EtherCAT_simple_send_receive(EtherCAT_master_t *, EtherCAT_command_t *); |
67 int EtherCAT_simple_send(EtherCAT_master_t *, EtherCAT_command_t *); |
59 int EtherCAT_simple_send(EtherCAT_master_t *, EtherCAT_command_t *); |
68 int EtherCAT_simple_receive(EtherCAT_master_t *, EtherCAT_command_t *); |
60 int EtherCAT_simple_receive(EtherCAT_master_t *, EtherCAT_command_t *); |
69 |
61 |
70 // Slave management |
62 // Slave management |
71 int EtherCAT_check_slaves(EtherCAT_master_t *, EtherCAT_slave_t *, unsigned int); |
63 int EtherCAT_check_slaves(EtherCAT_master_t *, EtherCAT_slave_t *, |
72 void EtherCAT_clear_slaves(EtherCAT_master_t *); |
64 unsigned int); |
73 int EtherCAT_read_slave_information(EtherCAT_master_t *, |
65 int EtherCAT_read_slave_information(EtherCAT_master_t *, unsigned short int, |
74 unsigned short int, |
66 unsigned short int, unsigned int *); |
75 unsigned short int, |
|
76 unsigned int *); |
|
77 int EtherCAT_activate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); |
67 int EtherCAT_activate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); |
78 int EtherCAT_deactivate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); |
68 int EtherCAT_deactivate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); |
79 int EtherCAT_activate_all_slaves(EtherCAT_master_t *); |
69 int EtherCAT_state_change(EtherCAT_master_t *, EtherCAT_slave_t *, |
80 int EtherCAT_deactivate_all_slaves(EtherCAT_master_t *); |
70 unsigned char); |
81 int EtherCAT_state_change(EtherCAT_master_t *, EtherCAT_slave_t *, unsigned char); |
|
82 |
71 |
83 // Process data |
72 // Process data |
84 int EtherCAT_write_process_data(EtherCAT_master_t *); |
73 int EtherCAT_process_data_cycle(EtherCAT_master_t *, unsigned int); |
85 int EtherCAT_read_process_data(EtherCAT_master_t *); |
|
86 void EtherCAT_clear_process_data(EtherCAT_master_t *); |
|
87 |
74 |
88 // Private functions |
75 // Private functions |
89 void output_debug_data(const EtherCAT_master_t *); |
76 void output_debug_data(const EtherCAT_master_t *); |
90 |
77 |
91 /*****************************************************************************/ |
78 /*****************************************************************************/ |
92 |
79 |
93 #endif |
80 #endif |
|
81 |
|
82 /* Emacs-Konfiguration |
|
83 ;;; Local Variables: *** |
|
84 ;;; c-basic-offset:2 *** |
|
85 ;;; End: *** |
|
86 */ |