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@145: #include fp@145: fp@145: #include "globals.h" fp@145: #include "command.h" 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@126: EC_SLAVE_STATE_UNKNOWN = 0x00, fp@126: /**< Status unbekannt */ fp@126: EC_SLAVE_STATE_INIT = 0x01, fp@126: /**< Init-Zustand (Keine Mailbox-Kommunikation, Kein I/O) */ fp@126: EC_SLAVE_STATE_PREOP = 0x02, fp@126: /**< Pre-Operational (Mailbox-Kommunikation, Kein I/O) */ fp@126: EC_SLAVE_STATE_SAVEOP = 0x04, fp@126: /**< Save-Operational (Mailbox-Kommunikation und Input Update) */ fp@126: EC_SLAVE_STATE_OP = 0x08, fp@126: /**< Operational, (Mailbox-Kommunikation und Input/Output Update) */ fp@126: EC_ACK = 0x10 fp@126: /**< Acknoledge-Bit beim Zustandswechsel (kein eigener Zustand) */ fp@98: } fp@98: ec_slave_state_t; fp@98: fp@98: /*****************************************************************************/ fp@98: fp@98: /** fp@133: Unterstützte Mailbox-Protokolle. fp@133: */ fp@133: fp@133: enum fp@133: { fp@145: EC_MBOX_AOE = 0x01, /**< ADS-over-EtherCAT */ fp@145: EC_MBOX_EOE = 0x02, /**< Ethernet-over-EtherCAT */ fp@145: EC_MBOX_COE = 0x04, /**< CANopen-over-EtherCAT */ fp@145: EC_MBOX_FOE = 0x08, /**< File-Access-over-EtherCAT */ fp@145: EC_MBOX_SOE = 0x10, /**< Servo-Profile-over-EtherCAT */ fp@133: EC_MBOX_VOE = 0x20 /**< Vendor specific */ fp@133: }; fp@133: fp@133: /*****************************************************************************/ fp@133: fp@133: /** 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@126: String im EEPROM eines EtherCAT-Slaves. 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@126: ec_eeprom_string_t; fp@126: fp@126: /*****************************************************************************/ fp@126: fp@126: /** fp@126: Sync-Manager-Konfiguration laut EEPROM. fp@126: */ fp@126: fp@126: typedef struct fp@126: { fp@126: struct list_head list; fp@126: unsigned int index; fp@126: uint16_t physical_start_address; fp@126: uint16_t length; fp@126: uint8_t control_register; fp@126: uint8_t enable; fp@126: } fp@126: ec_eeprom_sync_t; fp@126: fp@126: /*****************************************************************************/ fp@126: fp@126: /** fp@126: PDO-Typ. fp@126: */ fp@126: fp@126: typedef enum fp@126: { fp@126: EC_RX_PDO, fp@126: EC_TX_PDO fp@126: } fp@126: ec_pdo_type_t; fp@126: fp@126: /*****************************************************************************/ fp@126: fp@126: /** fp@126: PDO-Beschreibung im EEPROM. fp@126: */ fp@126: fp@126: typedef struct fp@126: { fp@126: struct list_head list; fp@126: ec_pdo_type_t type; fp@126: uint16_t index; fp@126: uint8_t sync_manager; fp@126: char *name; fp@126: struct list_head entries; fp@126: } fp@126: ec_eeprom_pdo_t; fp@126: fp@126: /*****************************************************************************/ fp@126: fp@126: /** fp@126: PDO-Entry-Beschreibung im EEPROM. fp@126: */ fp@126: fp@126: typedef struct fp@126: { fp@126: struct list_head list; fp@126: uint16_t index; fp@126: uint8_t subindex; fp@126: char *name; fp@126: uint8_t bit_length; fp@126: } fp@126: ec_eeprom_pdo_entry_t; fp@118: fp@118: /*****************************************************************************/ fp@118: fp@118: /** fp@135: CANopen-SDO. fp@135: */ fp@135: fp@135: typedef struct fp@135: { fp@135: struct list_head list; fp@135: uint16_t index; fp@135: uint16_t type; fp@135: uint8_t features; fp@135: char *name; fp@139: struct list_head entries; fp@135: } fp@135: ec_sdo_t; fp@135: fp@135: /*****************************************************************************/ fp@135: fp@135: /** fp@139: CANopen-SDO-Entry. fp@139: */ fp@139: fp@139: typedef struct fp@139: { fp@139: struct list_head list; fp@139: uint8_t subindex; fp@139: uint16_t data_type; fp@139: uint16_t bit_length; fp@139: char *name; fp@139: } fp@139: ec_sdo_entry_t; fp@139: fp@139: /*****************************************************************************/ fp@139: fp@139: /** 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@142: // Data link status fp@142: uint8_t dl_status_link[2]; /**< Verbindung erkannt */ fp@142: uint8_t dl_status_loop[2]; /**< Loop geschlossen */ fp@142: uint8_t dl_status_comm[2]; /**< Kommunikation */ fp@142: 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@136: uint16_t sii_rx_mailbox_offset; /**< Adresse der Mailbox (Master->Slave) */ fp@136: uint16_t sii_rx_mailbox_size; /**< Adresse der Mailbox (Master->Slave) */ fp@136: uint16_t sii_tx_mailbox_offset; /**< Adresse der Mailbox (Slave->Master) */ fp@136: uint16_t sii_tx_mailbox_size; /**< Adresse der Mailbox (Slave->Master) */ fp@136: uint16_t sii_mailbox_protocols; /**< Unterstützte Mailbox-Protokolle */ 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@126: struct list_head eeprom_syncs; /**< Syncmanager-Konfigurationen (EEPROM) */ fp@126: struct list_head eeprom_pdos; /**< PDO-Beschreibungen im EEPROM */ fp@121: fp@123: char *eeprom_name; /**< Slave-Name laut Hersteller */ fp@123: char *eeprom_group; /**< Slave-Beschreibung laut Hersteller */ fp@123: char *eeprom_desc; /**< Slave-Beschreibung laut Hersteller */ fp@135: fp@135: struct list_head sdo_dictionary; /**< SDO-Verzeichnis des Slaves */ fp@145: fp@145: ec_command_t mbox_command; /**< Kommando für Mailbox-Kommunikation */ 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@136: int ec_slave_sii_read16(ec_slave_t *, uint16_t, uint16_t *); fp@136: int ec_slave_sii_read32(ec_slave_t *, uint16_t, uint32_t *); fp@136: int ec_slave_sii_write16(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@133: // CANopen over EtherCAT fp@133: int ec_slave_fetch_sdo_list(ec_slave_t *); fp@133: fp@73: // Misc fp@140: void ec_slave_print(const ec_slave_t *, unsigned int); 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: */