drivers/ec_slave.h
author Florian Pose <fp@igh-essen.com>
Fri, 11 Nov 2005 13:46:41 +0000
changeset 13 db0742533c10
parent 5 6f2508af550c
child 39 6965c23a6826
permissions -rw-r--r--
Simple Send/Receive Funktionen.
/****************************************************************
 *
 *  e c _ s l a v e . h
 *
 *  Struktur für einen EtherCAT-Slave.
 *
 *  $Date$
 *  $Author$
 *
 ***************************************************************/

#ifndef _EC_SLAVE_H_
#define _EC_SLAVE_H_

#include "ec_types.h"

/***************************************************************/

/**
   EtherCAT-Slave

   Achtung: Bei Änderungen dieser Struktur immer das Define
   ECAT_INIT_SLAVE anpassen!
*/

typedef struct
{
  // Base data
  unsigned char type; /**< Slave-Typ */
  unsigned char revision; /**< Revision */
  unsigned short build; /**< Build-Nummer */

  // Addresses
  short ring_position; /**< (Negative) Position des Slaves im Bus */
  unsigned short station_address; /**< Konfigurierte Slave-Adresse */

  // Slave information interface
  unsigned int vendor_id; /**< Identifikationsnummer des Herstellers */
  unsigned int product_code; /**< Herstellerspezifischer Produktcode */
  unsigned int revision_number; /**< Revisionsnummer */
  unsigned int serial_number; /**< Seriennummer der Klemme */

  const EtherCAT_slave_desc_t *desc; /**< Zeiger auf die Beschreibung
                                        des Slave-Typs */

  unsigned int logical_address0; /**< Konfigurierte, logische adresse */

  EtherCAT_state_t current_state; /**< Aktueller Zustand */
  EtherCAT_state_t requested_state; /**< Angeforderter Zustand */

  unsigned char *process_data; /**< Zeiger auf den Speicherbereich
                                  im Prozessdatenspeicher des Masters */
}
EtherCAT_slave_t;

#define ECAT_INIT_SLAVE(TYPE) {0, 0, 0, 0, 0, 0, 0, 0, 0, \
                               TYPE, 0, ECAT_STATE_UNKNOWN, \
                               ECAT_STATE_UNKNOWN, NULL}

/***************************************************************/

// Slave construction and deletion
void EtherCAT_slave_init(EtherCAT_slave_t *);
void EtherCAT_slave_clear(EtherCAT_slave_t *);

int EtherCAT_read_value(EtherCAT_slave_t *, unsigned int);
void EtherCAT_write_value(EtherCAT_slave_t *, unsigned int, int);

/***************************************************************/

#endif