fp@39: /****************************************************************************** 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@39: * $Id$ fp@0: * fp@39: *****************************************************************************/ 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@42: #include "ec_domain.h" fp@0: fp@39: /*****************************************************************************/ 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@42: struct EtherCAT_master fp@0: { fp@0: EtherCAT_device_t *dev; /**< Zeiger auf das zugewiesene EtherCAT-Gerät */ fp@0: unsigned char command_index; /**< Aktueller Kommando-Index */ 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@19: unsigned int rx_data_length; /**< Länge der Daten im Empfangsspeicher */ fp@42: EtherCAT_domain_t domains[ECAT_MAX_DOMAINS]; /** Prozessdatendomänen */ fp@42: unsigned int domain_count; fp@2: int debug_level; /**< Debug-Level im Master-Code */ fp@47: unsigned int bus_time; /**< Letzte Bus-Zeit in Mikrosekunden */ fp@48: unsigned int frames_lost; /**< Anzahl verlorene Frames */ fp@48: unsigned long t_lost_output; /*<< Timer-Ticks bei der letzten Ausgabe von fp@48: verlorenen Frames */ fp@42: }; fp@0: fp@39: /*****************************************************************************/ fp@0: fp@0: // Master creation and deletion fp@27: void EtherCAT_master_init(EtherCAT_master_t *); fp@0: void EtherCAT_master_clear(EtherCAT_master_t *); fp@0: fp@27: // Registration of devices fp@33: int EtherCAT_master_open(EtherCAT_master_t *, EtherCAT_device_t *); fp@33: void EtherCAT_master_close(EtherCAT_master_t *, EtherCAT_device_t *); fp@27: 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@42: int EtherCAT_check_slaves(EtherCAT_master_t *, EtherCAT_slave_t *, fp@42: unsigned int); fp@42: int EtherCAT_read_slave_information(EtherCAT_master_t *, unsigned short int, fp@42: unsigned short int, 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@42: int EtherCAT_state_change(EtherCAT_master_t *, EtherCAT_slave_t *, fp@42: unsigned char); fp@0: fp@17: // Process data fp@47: int EtherCAT_process_data_cycle(EtherCAT_master_t *, unsigned int, fp@47: unsigned int); fp@0: fp@0: // Private functions fp@19: void output_debug_data(const EtherCAT_master_t *); fp@48: void ecat_output_lost_frames(EtherCAT_master_t *); fp@0: fp@39: /*****************************************************************************/ fp@0: fp@0: #endif fp@42: fp@42: /* Emacs-Konfiguration fp@42: ;;; Local Variables: *** fp@42: ;;; c-basic-offset:2 *** fp@42: ;;; End: *** fp@42: */