fp@0: /**************************************************************** fp@0: * fp@0: * e c _ m a s t e r . h fp@0: * fp@0: * Struktur für einen EtherCAT-Master. fp@0: * fp@0: * $Date$ fp@0: * $Author$ fp@0: * fp@0: ***************************************************************/ fp@0: fp@0: #ifndef _EC_MASTER_H_ fp@0: #define _EC_MASTER_H_ fp@0: fp@0: #include "ec_device.h" fp@0: #include "ec_slave.h" fp@0: #include "ec_command.h" fp@0: fp@0: /***************************************************************/ fp@0: fp@0: /** fp@0: EtherCAT-Master fp@0: fp@0: Verwaltet die EtherCAT-Slaves und kommuniziert mit fp@0: dem zugewiesenen EtherCAT-Gerät. fp@0: */ fp@0: fp@0: typedef struct fp@0: { fp@0: EtherCAT_slave_t *slaves; /**< Zeiger auf statischen Speicher fp@0: mit Slave-Informationen */ fp@0: unsigned int slave_count; /**< Anzahl der Slaves in slaves */ fp@0: fp@13: EtherCAT_command_t process_data_command; /**< Kommando zum Senden und fp@13: Empfangen der Prozessdaten */ fp@0: fp@0: EtherCAT_device_t *dev; /**< Zeiger auf das zugewiesene EtherCAT-Gerät */ fp@0: fp@0: unsigned char command_index; /**< Aktueller Kommando-Index */ fp@0: fp@0: unsigned char tx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statischer Speicher fp@0: für zu sendende Daten */ fp@0: unsigned int tx_data_length; /**< Länge der Daten im Sendespeicher */ fp@0: unsigned char rx_data[ECAT_FRAME_BUFFER_SIZE]; /**< Statische Speicher für fp@0: eine Kopie des Rx-Buffers fp@0: im EtherCAT-Gerät */ fp@0: fp@0: unsigned char *process_data; /**< Zeiger auf Speicher mit Prozessdaten */ fp@0: unsigned int process_data_length; /**< Länge der Prozessdaten */ fp@0: fp@2: int debug_level; /**< Debug-Level im Master-Code */ fp@0: } fp@0: EtherCAT_master_t; fp@0: fp@0: /***************************************************************/ fp@0: fp@0: // Master creation and deletion fp@0: int EtherCAT_master_init(EtherCAT_master_t *, EtherCAT_device_t *); fp@0: void EtherCAT_master_clear(EtherCAT_master_t *); fp@0: fp@17: // Sending and receiving fp@17: int EtherCAT_simple_send_receive(EtherCAT_master_t *, EtherCAT_command_t *); fp@17: int EtherCAT_simple_send(EtherCAT_master_t *, EtherCAT_command_t *); fp@17: int EtherCAT_simple_receive(EtherCAT_master_t *, EtherCAT_command_t *); fp@17: fp@0: // Slave management fp@0: int EtherCAT_check_slaves(EtherCAT_master_t *, EtherCAT_slave_t *, unsigned int); fp@0: void EtherCAT_clear_slaves(EtherCAT_master_t *); fp@17: int EtherCAT_read_slave_information(EtherCAT_master_t *, fp@17: unsigned short int, fp@17: unsigned short int, fp@17: unsigned int *); fp@0: int EtherCAT_activate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); fp@0: int EtherCAT_deactivate_slave(EtherCAT_master_t *, EtherCAT_slave_t *); fp@0: int EtherCAT_activate_all_slaves(EtherCAT_master_t *); fp@0: int EtherCAT_deactivate_all_slaves(EtherCAT_master_t *); fp@17: int EtherCAT_state_change(EtherCAT_master_t *, EtherCAT_slave_t *, unsigned char); fp@0: fp@17: // Process data fp@0: int EtherCAT_write_process_data(EtherCAT_master_t *); fp@0: int EtherCAT_read_process_data(EtherCAT_master_t *); fp@2: void EtherCAT_clear_process_data(EtherCAT_master_t *); fp@0: fp@0: // Private functions fp@0: void set_byte(unsigned char *, unsigned int, unsigned char); fp@0: void set_word(unsigned char *, unsigned int, unsigned int); fp@11: void output_debug_data(unsigned char *, unsigned int); fp@0: fp@0: /***************************************************************/ fp@0: fp@0: #endif