fp@39: /****************************************************************************** fp@0: * fp@54: * s l a v e . h fp@0: * fp@0: * Struktur für einen EtherCAT-Slave. fp@0: * fp@39: * $Id$ fp@0: * fp@39: *****************************************************************************/ fp@0: fp@0: #ifndef _EC_SLAVE_H_ fp@0: #define _EC_SLAVE_H_ fp@0: fp@54: #include "types.h" fp@0: fp@39: /*****************************************************************************/ fp@0: fp@73: /** fp@98: Zustand eines EtherCAT-Slaves. fp@98: */ fp@98: fp@98: typedef enum fp@98: { fp@98: EC_SLAVE_STATE_UNKNOWN = 0x00, /**< Status unbekannt */ fp@98: EC_SLAVE_STATE_INIT = 0x01, /**< Init-Zustand (Keine Mailbox- fp@98: Kommunikation, Kein I/O) */ fp@98: EC_SLAVE_STATE_PREOP = 0x02, /**< Pre-Operational (Mailbox- fp@98: Kommunikation, Kein I/O) */ fp@98: EC_SLAVE_STATE_SAVEOP = 0x04, /**< Save-Operational (Mailbox- fp@98: Kommunikation und Input Update) */ fp@98: EC_SLAVE_STATE_OP = 0x08, /**< Operational, (Mailbox- fp@98: Kommunikation und Input/Output Update) */ fp@98: EC_ACK = 0x10 /**< Acknoledge-Bit beim Zustandswechsel fp@98: (dies ist kein eigener Zustand) */ fp@98: } fp@98: ec_slave_state_t; fp@98: fp@98: /*****************************************************************************/ fp@98: fp@98: /** fp@73: FMMU-Konfiguration. fp@73: */ fp@73: fp@73: typedef struct fp@73: { fp@73: const ec_domain_t *domain; fp@73: const ec_sync_t *sync; fp@73: uint32_t logical_start_address; fp@73: } fp@73: ec_fmmu_t; fp@0: fp@39: /*****************************************************************************/ fp@0: fp@73: /** fp@118: EEPROM-String. fp@118: */ fp@118: fp@118: typedef struct fp@118: { fp@118: struct list_head list; fp@121: size_t size; fp@118: char *data; fp@118: } fp@118: ec_slave_string_t; fp@118: fp@118: /*****************************************************************************/ fp@118: fp@118: /** fp@73: EtherCAT-Slave fp@73: */ fp@73: fp@73: struct ec_slave fp@73: { fp@73: ec_master_t *master; /**< EtherCAT-Master, zu dem der Slave gehört. */ fp@73: fp@73: // Addresses fp@73: uint16_t ring_position; /**< Position des Slaves im Bus */ fp@73: uint16_t station_address; /**< Konfigurierte Slave-Adresse */ fp@73: fp@73: // Base data fp@73: uint8_t base_type; /**< Slave-Typ */ fp@73: uint8_t base_revision; /**< Revision */ fp@73: uint16_t base_build; /**< Build-Nummer */ fp@73: uint16_t base_fmmu_count; /**< Anzahl unterstützter FMMUs */ fp@73: uint16_t base_sync_count; /**< Anzahl unterstützter Sync-Manager */ fp@73: fp@73: // Slave information interface fp@114: uint16_t sii_alias; /**< Configured station alias */ fp@73: uint32_t sii_vendor_id; /**< Identifikationsnummer des Herstellers */ fp@73: uint32_t sii_product_code; /**< Herstellerspezifischer Produktcode */ fp@73: uint32_t sii_revision_number; /**< Revisionsnummer */ fp@73: uint32_t sii_serial_number; /**< Seriennummer der Klemme */ fp@73: fp@73: const ec_slave_type_t *type; /**< Zeiger auf die Beschreibung fp@73: des Slave-Typs */ fp@73: fp@73: uint8_t registered; /**< Der Slave wurde registriert */ fp@73: fp@73: ec_fmmu_t fmmus[EC_MAX_FMMUS]; /**< FMMU-Konfigurationen */ fp@73: uint8_t fmmu_count; /**< Wieviele FMMUs schon benutzt sind. */ fp@118: fp@121: struct list_head eeprom_strings; /**< Strings im EEPROM */ fp@121: fp@121: const char *eeprom_name; /**< Slave-Name laut Hersteller */ fp@121: const char *eeprom_group; /**< Slave-Beschreibung laut Hersteller */ fp@121: const char *eeprom_desc; /**< Slave-Beschreibung laut Hersteller */ fp@73: }; fp@73: fp@73: /*****************************************************************************/ fp@73: fp@73: // Slave construction/destruction fp@73: void ec_slave_init(ec_slave_t *, ec_master_t *); fp@73: void ec_slave_clear(ec_slave_t *); fp@73: fp@73: // Slave control fp@73: int ec_slave_fetch(ec_slave_t *); fp@101: int ec_slave_sii_read(ec_slave_t *, uint16_t, uint32_t *); fp@114: int ec_slave_sii_write(ec_slave_t *, uint16_t, uint16_t); fp@73: int ec_slave_state_change(ec_slave_t *, uint8_t); fp@73: int ec_slave_set_fmmu(ec_slave_t *, const ec_domain_t *, const ec_sync_t *); fp@73: fp@73: // Misc fp@73: void ec_slave_print(const ec_slave_t *); fp@74: int ec_slave_check_crc(ec_slave_t *); fp@0: fp@39: /*****************************************************************************/ fp@0: fp@0: #endif fp@42: fp@42: /* Emacs-Konfiguration fp@42: ;;; Local Variables: *** fp@73: ;;; c-basic-offset:4 *** fp@42: ;;; End: *** fp@42: */