drivers/ec_command.h
author Florian Pose <fp@igh-essen.com>
Fri, 06 Jan 2006 13:20:29 +0000
changeset 47 ad5f969f263b
parent 41 42c66194c0c8
permissions -rw-r--r--
Prozessdatentimeout, Buszeit und weniger Klemmen.
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
     1
/******************************************************************************
0
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
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
     7
 *  $Id$
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
     8
 *
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
     9
 *****************************************************************************/
0
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
#ifndef _EC_COMMAND_H_
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
#define _EC_COMMAND_H_
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
#include "ec_globals.h"
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    15
41
42c66194c0c8 Schoenheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
    16
/*****************************************************************************/
42c66194c0c8 Schoenheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
    17
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    18
/**
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    19
   Status eines EtherCAT-Kommandos.
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
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    22
typedef enum
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
{
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    24
  ECAT_CS_READY, ECAT_CS_SENT, ECAT_CS_RECEIVED
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    25
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
EtherCAT_command_state_t;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    27
41
42c66194c0c8 Schoenheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
    28
/*****************************************************************************/
42c66194c0c8 Schoenheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 39
diff changeset
    29
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
/**
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
   EtherCAT-Adresse.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
   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
    34
   ja nach Kommandoty eine andere bedeutung haben: Bei Autoinkrement-
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
   befehlen sind die ersten zwei Bytes die (negative)
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    36
   Autoinkrement-Adresse, bei Knoten-adressierten Befehlen entsprechen
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
   sie der Knotenadresse. Das dritte und vierte Byte entspricht in
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    38
   diesen Fällen der physikalischen Speicheradresse auf dem Slave.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    39
   Bei einer logischen Adressierung entsprechen alle vier Bytes
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
   der logischen Adresse.
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
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
typedef union
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    44
{
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    45
  struct
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
  {
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
    union
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
      short pos; /**< (Negative) Ring-Position des Slaves */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
      unsigned short node; /**< Konfigurierte Knotenadresse */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    51
    }
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    52
    dev;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    53
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    54
    unsigned short mem; /**< Physikalische Speicheradresse im Slave */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    55
  }
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    56
  phy;
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
  unsigned long logical; /**< Logische Adresse */
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    59
  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
    60
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    61
EtherCAT_address_t;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    62
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
    63
/*****************************************************************************/
0
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
   EtherCAT-Kommando.
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
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    69
typedef struct EtherCAT_command
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    70
{
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    71
  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
    72
  EtherCAT_address_t address; /**< Adresse des/der Empfänger */
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
    73
  unsigned int data_length; /**< Länge der zu sendenden und/oder
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
    74
                               empfangenen Daten */
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    75
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
    76
  EtherCAT_command_state_t state; /**< Zustand des Kommandos
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
    77
                                     (bereit, gesendet, etc...) */
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
    78
  unsigned char index; /**< Kommando-Index, mit der das Kommando gesendet
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
    79
                          wurde (wird vom Master beim Senden gesetzt. */
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
    80
  unsigned int working_counter; /**< Working-Counter bei Empfang (wird
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
    81
                                   vom Master gesetzt) */
0
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
  unsigned char data[ECAT_FRAME_BUFFER_SIZE]; /**< Kommandodaten */
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    84
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    85
EtherCAT_command_t;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    86
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
    87
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    88
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    89
void EtherCAT_command_init(EtherCAT_command_t *);
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    90
void EtherCAT_command_clear(EtherCAT_command_t *);
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    91
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    92
void EtherCAT_command_read(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    93
                           unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    94
                           unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    95
                           unsigned int);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    96
void EtherCAT_command_write(EtherCAT_command_t *,
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 short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    99
                            unsigned int,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   100
                            const unsigned char *);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   101
void EtherCAT_command_position_read(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   102
                                    short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   103
                                    unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   104
                                    unsigned int);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   105
void EtherCAT_command_position_write(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   106
                                     short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   107
                                     unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   108
                                     unsigned int,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   109
                                     const unsigned char *);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   110
void EtherCAT_command_broadcast_read(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   111
                                     unsigned short,
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
void EtherCAT_command_broadcast_write(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   114
                                      unsigned short,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   115
                                      unsigned int,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   116
                                      const unsigned char *);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   117
void EtherCAT_command_logical_read_write(EtherCAT_command_t *,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   118
                                         unsigned int,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   119
                                         unsigned int,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   120
                                         unsigned char *);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   121
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 25
diff changeset
   122
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   123
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
   124
#endif