drivers/ec_command.h
author Florian Pose <fp@igh-essen.com>
Fri, 16 Dec 2005 15:23:56 +0000
branchkernel2.6
changeset 35 ed834aa98f89
parent 25 7d124bfba3ce
child 39 6965c23a6826
permissions -rw-r--r--
Klemme Beckhoff EL4132 hinzugef?gt.
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     1
/****************************************************************
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     2
 *
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     3
 *  e c _ c o m m a n d . h
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     4
 *
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     5
 *  Struktur für ein EtherCAT-Kommando.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     6
 *
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     7
 *  $Date$
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *  $Author$
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     9
 *
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    10
 ***************************************************************/
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    11
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
#ifndef _EC_COMMAND_H_
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
#define _EC_COMMAND_H_
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
#include "ec_globals.h"
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    16
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    17
/**
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
   Status eines EtherCAT-Kommandos.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
*/
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    20
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
typedef enum
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
{
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
  ECAT_CS_READY, ECAT_CS_SENT, ECAT_CS_RECEIVED
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
EtherCAT_command_state_t;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
/**
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    28
   EtherCAT-Adresse.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
   Im EtherCAT-Rahmen sind 4 Bytes für die Adresse reserviert, die
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
   ja nach Kommandoty eine andere bedeutung haben: Bei Autoinkrement-
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
   befehlen sind die ersten zwei Bytes die (negative)
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
   Autoinkrement-Adresse, bei Knoten-adressierten Befehlen entsprechen
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
   sie der Knotenadresse. Das dritte und vierte Byte entspricht in
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
   diesen Fällen der physikalischen Speicheradresse auf dem Slave.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
   Bei einer logischen Adressierung entsprechen alle vier Bytes
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
   der logischen Adresse.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
*/
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
typedef union
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    41
{
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    42
  struct
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
  {
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
    union
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
    {
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
      short pos; /**< (Negative) Ring-Position des Slaves */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
      unsigned short node; /**< Konfigurierte Knotenadresse */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    48
    }
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
    dev;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
    unsigned short mem; /**< Physikalische Speicheradresse im Slave */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
  }
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
  phy;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
  unsigned long logical; /**< Logische Adresse */
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    56
  unsigned char raw[4]; /**< Rohdaten für die Generierung des Frames */
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    57
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    58
EtherCAT_address_t;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    59
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    60
/***************************************************************/
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
/**
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    63
   EtherCAT-Kommando.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    64
*/
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    65
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    66
typedef struct EtherCAT_command
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    67
{
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    68
  EtherCAT_cmd_type_t type; /**< Typ des Kommandos (APRD, NPWR, etc...) */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
  EtherCAT_address_t address; /**< Adresse des/der Empfänger */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
  unsigned int data_length; /**< Länge der zu sendenden und/oder empfangenen Daten */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    72
  EtherCAT_command_state_t state; /**< Zustand des Kommandos (bereit, gesendet, etc...) */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    73
  unsigned char index; /**< Kommando-Index, mit der das Kommando gesendet wurde (wird
25
7d124bfba3ce IF's im rtl8139too-Treiber vereinfacht und kein Polling mehr.
Florian Pose <fp@igh-essen.com>
parents: 17
diff changeset
    74
                            vom Master beim Senden gesetzt. */
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
  unsigned int working_counter; /**< Working-Counter bei Empfang (wird vom Master gesetzt) */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    76
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    77
  unsigned char data[ECAT_FRAME_BUFFER_SIZE]; /**< Kommandodaten */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    78
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    79
EtherCAT_command_t;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    80
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    81
/***************************************************************/
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    82
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    83
void EtherCAT_command_init(EtherCAT_command_t *);
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
void EtherCAT_command_clear(EtherCAT_command_t *);
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    86
void EtherCAT_command_read(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    87
                           unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    88
                           unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    89
                           unsigned int);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    90
void EtherCAT_command_write(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    91
                            unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    92
                            unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    93
                            unsigned int,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    94
                            const unsigned char *);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    95
void EtherCAT_command_position_read(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    96
                                    short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    97
                                    unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    98
                                    unsigned int);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    99
void EtherCAT_command_position_write(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   100
                                     short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   101
                                     unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   102
                                     unsigned int,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   103
                                     const unsigned char *);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   104
void EtherCAT_command_broadcast_read(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   105
                                     unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   106
                                     unsigned int);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   107
void EtherCAT_command_broadcast_write(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   108
                                      unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   109
                                      unsigned int,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   110
                                      const unsigned char *);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   111
void EtherCAT_command_logical_read_write(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   112
                                         unsigned int,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   113
                                         unsigned int,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   114
                                         unsigned char *);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   115
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   116
/***************************************************************/
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   117
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   118
#endif