drivers/ec_command.c
author Florian Pose <fp@igh-essen.com>
Fri, 06 Jan 2006 13:20:29 +0000
changeset 47 ad5f969f263b
parent 39 6965c23a6826
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: 26
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 . c
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
 *  Methoden 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: 26
diff changeset
     7
 *  $Id$
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
     8
 *
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
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
#include <linux/slab.h>
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    12
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    13
#include "ec_command.h"
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    14
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    15
/*****************************************************************************/
0
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
   Kommando-Konstruktor.
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
   Initialisiert alle Variablen innerhalb des Kommandos auf die
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    21
   Default-Werte.
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    22
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    23
   @param cmd Zeiger auf das zu initialisierende Kommando.
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
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    26
void EtherCAT_command_init(EtherCAT_command_t *cmd)
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
  cmd->type = ECAT_CMD_NONE;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    29
  cmd->address.logical = 0x00000000;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    30
  cmd->data_length = 0;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    31
  cmd->state = ECAT_CS_READY;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    32
  cmd->index = 0;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    33
  cmd->working_counter = 0;
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    34
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    35
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    36
/*****************************************************************************/
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    37
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
   Kommando-Destruktor.
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    40
2
b0a7a4745bf9 ?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents: 0
diff changeset
    41
   Setzt alle Attribute auf den Anfangswert zurueck.
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    42
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    43
   @param cmd Zeiger auf das zu initialisierende Kommando.
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
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    46
void EtherCAT_command_clear(EtherCAT_command_t *cmd)
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    47
{
2
b0a7a4745bf9 ?nderungen an no_rtai r110:110 in drivers gemergt.
Florian Pose <fp@igh-essen.com>
parents: 0
diff changeset
    48
  EtherCAT_command_init(cmd);
0
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    49
}
05c992bf5847 trunk, tags und branches
Florian Pose <fp@igh-essen.com>
parents:
diff changeset
    50
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    51
/*****************************************************************************/
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    52
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    53
#define ECAT_FUNC_HEADER \
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    54
  EtherCAT_command_init(cmd)
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    55
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    56
#define ECAT_FUNC_WRITE_FOOTER \
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    57
  cmd->data_length = length; \
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    58
  memcpy(cmd->data, data, length);
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    59
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    60
#define ECAT_FUNC_READ_FOOTER \
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    61
  cmd->data_length = length;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    62
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    63
/*****************************************************************************/
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    64
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    65
/**
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    66
   Initialisiert ein EtherCAT-NPRD-Kommando.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    67
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    68
   @param cmd Zeiger auf das Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    69
   @param node_address Adresse des Knotens (Slaves)
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    70
   @param offset Physikalische Speicheradresse im Slave
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    71
   @param length Länge der zu lesenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    72
*/
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    73
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    74
void EtherCAT_command_read(EtherCAT_command_t *cmd,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    75
                           unsigned short node_address,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    76
                           unsigned short offset,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    77
                           unsigned int length)
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    78
{
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    79
  if (unlikely(node_address == 0x0000))
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    80
    printk(KERN_WARNING "EtherCAT: Warning - Using node address 0x0000!\n");
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    81
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    82
  ECAT_FUNC_HEADER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    83
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    84
  cmd->type = ECAT_CMD_NPRD;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    85
  cmd->address.phy.dev.node = node_address;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    86
  cmd->address.phy.mem = offset;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    87
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    88
  ECAT_FUNC_READ_FOOTER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    89
}
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    90
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
    91
/*****************************************************************************/
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    92
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    93
/**
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    94
   Initialisiert ein EtherCAT-NPWR-Kommando.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    95
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    96
   Alloziert ein "node-adressed physical write"-Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    97
   und fügt es in die Liste des Masters ein.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    98
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
    99
   @param cmd Zeiger auf das Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   100
   @param node_address Adresse des Knotens (Slaves)
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   101
   @param offset Physikalische Speicheradresse im Slave
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   102
   @param length Länge der zu schreibenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   103
   @param data Zeiger auf Speicher mit zu schreibenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   104
*/
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   105
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   106
void EtherCAT_command_write(EtherCAT_command_t *cmd,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   107
                            unsigned short node_address,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   108
                            unsigned short offset,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   109
                            unsigned int length,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   110
                            const unsigned char *data)
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   111
{
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   112
  if (unlikely(node_address == 0x0000))
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   113
    printk(KERN_WARNING "EtherCAT: Warning - Using node address 0x0000!\n");
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   114
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   115
  ECAT_FUNC_HEADER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   116
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   117
  cmd->type = ECAT_CMD_NPWR;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   118
  cmd->address.phy.dev.node = node_address;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   119
  cmd->address.phy.mem = offset;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   120
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   121
  ECAT_FUNC_WRITE_FOOTER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   122
}
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   123
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   124
/*****************************************************************************/
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   125
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   126
/**
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   127
   Initialisiert ein EtherCAT-APRD-Kommando.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   128
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   129
   Alloziert ein "autoincerement physical read"-Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   130
   und fügt es in die Liste des Masters ein.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   131
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   132
   @param cmd Zeiger auf das Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   133
   @param ring_position (Negative) Position des Slaves im Bus
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   134
   @param offset Physikalische Speicheradresse im Slave
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   135
   @param length Länge der zu lesenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   136
*/
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   137
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   138
void EtherCAT_command_position_read(EtherCAT_command_t *cmd,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   139
                                    short ring_position,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   140
                                    unsigned short offset,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   141
                                    unsigned int length)
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   142
{
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   143
  ECAT_FUNC_HEADER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   144
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   145
  cmd->type = ECAT_CMD_APRD;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   146
  cmd->address.phy.dev.pos = ring_position;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   147
  cmd->address.phy.mem = offset;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   148
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   149
  ECAT_FUNC_READ_FOOTER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   150
}
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   151
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   152
/*****************************************************************************/
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   153
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   154
/**
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   155
   Initialisiert ein EtherCAT-APWR-Kommando.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   156
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   157
   Alloziert ein "autoincrement physical write"-Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   158
   und fügt es in die Liste des Masters ein.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   159
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   160
   @param cmd Zeiger auf das Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   161
   @param ring_position (Negative) Position des Slaves im Bus
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   162
   @param offset Physikalische Speicheradresse im Slave
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   163
   @param length Länge der zu schreibenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   164
   @param data Zeiger auf Speicher mit zu schreibenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   165
*/
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   166
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   167
void EtherCAT_command_position_write(EtherCAT_command_t *cmd,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   168
                                     short ring_position,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   169
                                     unsigned short offset,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   170
                                     unsigned int length,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   171
                                     const unsigned char *data)
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   172
{
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   173
  ECAT_FUNC_HEADER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   174
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   175
  cmd->type = ECAT_CMD_APWR;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   176
  cmd->address.phy.dev.pos = ring_position;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   177
  cmd->address.phy.mem = offset;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   178
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   179
  ECAT_FUNC_WRITE_FOOTER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   180
}
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   181
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   182
/*****************************************************************************/
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   183
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   184
/**
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   185
   Initialisiert ein EtherCAT-BRD-Kommando.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   186
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   187
   Alloziert ein "broadcast read"-Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   188
   und fügt es in die Liste des Masters ein.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   189
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   190
   @param cmd Zeiger auf das Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   191
   @param offset Physikalische Speicheradresse im Slave
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   192
   @param length Länge der zu lesenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   193
*/
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   194
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   195
void EtherCAT_command_broadcast_read(EtherCAT_command_t *cmd,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   196
                                     unsigned short offset,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   197
                                     unsigned int length)
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   198
{
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   199
  ECAT_FUNC_HEADER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   200
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   201
  cmd->type = ECAT_CMD_BRD;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   202
  cmd->address.phy.dev.node = 0x0000;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   203
  cmd->address.phy.mem = offset;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   204
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   205
  ECAT_FUNC_READ_FOOTER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   206
}
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   207
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   208
/*****************************************************************************/
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   209
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   210
/**
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   211
   Initialisiert ein EtherCAT-BWR-Kommando.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   212
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   213
   Alloziert ein "broadcast write"-Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   214
   und fügt es in die Liste des Masters ein.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   215
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   216
   @param cmd Zeiger auf das Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   217
   @param offset Physikalische Speicheradresse im Slave
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   218
   @param length Länge der zu schreibenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   219
   @param data Zeiger auf Speicher mit zu schreibenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   220
*/
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   221
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   222
void EtherCAT_command_broadcast_write(EtherCAT_command_t *cmd,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   223
                                      unsigned short offset,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   224
                                      unsigned int length,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   225
                                      const unsigned char *data)
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   226
{
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   227
  ECAT_FUNC_HEADER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   228
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   229
  cmd->type = ECAT_CMD_BWR;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   230
  cmd->address.phy.dev.node = 0x0000;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   231
  cmd->address.phy.mem = offset;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   232
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   233
  ECAT_FUNC_WRITE_FOOTER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   234
}
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   235
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   236
/*****************************************************************************/
13
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   237
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   238
/**
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   239
   Initialisiert ein EtherCAT-LRW-Kommando.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   240
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   241
   Alloziert ein "logical read write"-Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   242
   und fügt es in die Liste des Masters ein.
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   243
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   244
   @param cmd Zeiger auf das Kommando
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   245
   @param offset Logische Speicheradresse
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   246
   @param length Länge der zu lesenden/schreibenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   247
   @param data Zeiger auf Speicher mit zu lesenden/schreibenden Daten
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   248
*/
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   249
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   250
void EtherCAT_command_logical_read_write(EtherCAT_command_t *cmd,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   251
                                         unsigned int offset,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   252
                                         unsigned int length,
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   253
                                         unsigned char *data)
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   254
{
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   255
  ECAT_FUNC_HEADER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   256
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   257
  cmd->type = ECAT_CMD_LRW;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   258
  cmd->address.logical = offset;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   259
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   260
  ECAT_FUNC_WRITE_FOOTER;
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   261
}
db0742533c10 Simple Send/Receive Funktionen.
Florian Pose <fp@igh-essen.com>
parents: 2
diff changeset
   262
39
6965c23a6826 likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare ge??ndert.
Florian Pose <fp@igh-essen.com>
parents: 26
diff changeset
   263
/*****************************************************************************/