mirror of
https://gitlab.com/etherlab.org/ethercat.git
synced 2026-02-06 11:51:45 +08:00
Simple Send/Receive Funktionen.
This commit is contained in:
2
Doxyfile
2
Doxyfile
@@ -52,7 +52,7 @@ OUTPUT_DIRECTORY = ../src-docs
|
||||
# (Japanese with english messages), Korean, Norwegian, Polish, Portuguese,
|
||||
# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish and Ukrainian.
|
||||
|
||||
OUTPUT_LANGUAGE = German
|
||||
OUTPUT_LANGUAGE =
|
||||
|
||||
# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in
|
||||
# documentation are documented, even if no documentation was available.
|
||||
|
||||
@@ -18,21 +18,21 @@ RTAIDIR = /vol/projekte/msr_messen_steuern_regeln/linux/kernel/2.4.20/include/
|
||||
RTLIBDIR = rt_lib
|
||||
endif
|
||||
|
||||
CFLAGS = -O2 -Wall -Wuninitialized -D__KERNEL__ -DMODULE \
|
||||
-I$(KERNELDIR)/include -D_RTAI -I$(RTAIDIR)/include \
|
||||
-I$(RTLIBDIR)/msr-include
|
||||
CFLAGS = -O2 -Wall -Wuninitialized -D__KERNEL__ \
|
||||
-DMODULE -I$(KERNELDIR)/include
|
||||
|
||||
ifdef CONFIG_SMP
|
||||
CFLAGS += -D__SMP__ -DSMP
|
||||
endif
|
||||
|
||||
MODULE = ecat_8139too.o
|
||||
OBJ = ec_device.o ec_master.o ec_slave.o ec_command.o ec_types.o
|
||||
OBJ = drv_8139too.o ec_device.o ec_master.o \
|
||||
ec_slave.o ec_command.o ec_types.o
|
||||
SRC = $(OBJ:.o=.c)
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
||||
all: .output_dirs .depend $(MODULE)
|
||||
all: .output_dirs depend $(MODULE)
|
||||
|
||||
$(MODULE): $(OBJ)
|
||||
$(LD) -r $(OBJ) -o $@
|
||||
@@ -50,7 +50,7 @@ doc docs:
|
||||
@echo "| RT_lib $(RTLIBDIR)"
|
||||
@echo "x----------------------------"
|
||||
|
||||
.depend:
|
||||
.depend depend dep:
|
||||
$(CC) $(CFLAGS) -M $(SRC) > .depend
|
||||
|
||||
clean:
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "ec_command.h"
|
||||
#include "ec_dbg.h"
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
@@ -20,7 +21,7 @@
|
||||
|
||||
Initialisiert alle Variablen innerhalb des Kommandos auf die
|
||||
Default-Werte.
|
||||
|
||||
|
||||
@param cmd Zeiger auf das zu initialisierende Kommando.
|
||||
*/
|
||||
|
||||
@@ -41,7 +42,7 @@ void EtherCAT_command_init(EtherCAT_command_t *cmd)
|
||||
Kommando-Destruktor.
|
||||
|
||||
Setzt alle Attribute auf den Anfangswert zurueck.
|
||||
|
||||
|
||||
@param cmd Zeiger auf das zu initialisierende Kommando.
|
||||
*/
|
||||
|
||||
@@ -51,3 +52,215 @@ void EtherCAT_command_clear(EtherCAT_command_t *cmd)
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#define ECAT_FUNC_HEADER \
|
||||
EtherCAT_command_init(cmd)
|
||||
|
||||
#define ECAT_FUNC_WRITE_FOOTER \
|
||||
cmd->data_length = length; \
|
||||
memcpy(cmd->data, data, length);
|
||||
|
||||
#define ECAT_FUNC_READ_FOOTER \
|
||||
cmd->data_length = length;
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-NPRD-Kommando.
|
||||
|
||||
@param cmd Zeiger auf das Kommando
|
||||
@param node_address Adresse des Knotens (Slaves)
|
||||
@param offset Physikalische Speicheradresse im Slave
|
||||
@param length Länge der zu lesenden Daten
|
||||
*/
|
||||
|
||||
void EtherCAT_command_read(EtherCAT_command_t *cmd,
|
||||
unsigned short node_address,
|
||||
unsigned short offset,
|
||||
unsigned int length)
|
||||
{
|
||||
if (node_address == 0x0000)
|
||||
EC_DBG(KERN_WARNING "EtherCAT: Using node address 0x0000!\n");
|
||||
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
cmd->type = ECAT_CMD_NPRD;
|
||||
cmd->address.phy.dev.node = node_address;
|
||||
cmd->address.phy.mem = offset;
|
||||
|
||||
ECAT_FUNC_READ_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-NPWR-Kommando.
|
||||
|
||||
Alloziert ein "node-adressed physical write"-Kommando
|
||||
und fügt es in die Liste des Masters ein.
|
||||
|
||||
@param cmd Zeiger auf das Kommando
|
||||
@param node_address Adresse des Knotens (Slaves)
|
||||
@param offset Physikalische Speicheradresse im Slave
|
||||
@param length Länge der zu schreibenden Daten
|
||||
@param data Zeiger auf Speicher mit zu schreibenden Daten
|
||||
*/
|
||||
|
||||
void EtherCAT_command_write(EtherCAT_command_t *cmd,
|
||||
unsigned short node_address,
|
||||
unsigned short offset,
|
||||
unsigned int length,
|
||||
const unsigned char *data)
|
||||
{
|
||||
if (node_address == 0x0000)
|
||||
EC_DBG(KERN_WARNING "WARNING: Using node address 0x0000!\n");
|
||||
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
cmd->type = ECAT_CMD_NPWR;
|
||||
cmd->address.phy.dev.node = node_address;
|
||||
cmd->address.phy.mem = offset;
|
||||
|
||||
ECAT_FUNC_WRITE_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-APRD-Kommando.
|
||||
|
||||
Alloziert ein "autoincerement physical read"-Kommando
|
||||
und fügt es in die Liste des Masters ein.
|
||||
|
||||
@param cmd Zeiger auf das Kommando
|
||||
@param ring_position (Negative) Position des Slaves im Bus
|
||||
@param offset Physikalische Speicheradresse im Slave
|
||||
@param length Länge der zu lesenden Daten
|
||||
*/
|
||||
|
||||
void EtherCAT_command_position_read(EtherCAT_command_t *cmd,
|
||||
short ring_position,
|
||||
unsigned short offset,
|
||||
unsigned int length)
|
||||
{
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
cmd->type = ECAT_CMD_APRD;
|
||||
cmd->address.phy.dev.pos = ring_position;
|
||||
cmd->address.phy.mem = offset;
|
||||
|
||||
ECAT_FUNC_READ_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-APWR-Kommando.
|
||||
|
||||
Alloziert ein "autoincrement physical write"-Kommando
|
||||
und fügt es in die Liste des Masters ein.
|
||||
|
||||
@param cmd Zeiger auf das Kommando
|
||||
@param ring_position (Negative) Position des Slaves im Bus
|
||||
@param offset Physikalische Speicheradresse im Slave
|
||||
@param length Länge der zu schreibenden Daten
|
||||
@param data Zeiger auf Speicher mit zu schreibenden Daten
|
||||
*/
|
||||
|
||||
void EtherCAT_command_position_write(EtherCAT_command_t *cmd,
|
||||
short ring_position,
|
||||
unsigned short offset,
|
||||
unsigned int length,
|
||||
const unsigned char *data)
|
||||
{
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
cmd->type = ECAT_CMD_APWR;
|
||||
cmd->address.phy.dev.pos = ring_position;
|
||||
cmd->address.phy.mem = offset;
|
||||
|
||||
ECAT_FUNC_WRITE_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-BRD-Kommando.
|
||||
|
||||
Alloziert ein "broadcast read"-Kommando
|
||||
und fügt es in die Liste des Masters ein.
|
||||
|
||||
@param cmd Zeiger auf das Kommando
|
||||
@param offset Physikalische Speicheradresse im Slave
|
||||
@param length Länge der zu lesenden Daten
|
||||
*/
|
||||
|
||||
void EtherCAT_command_broadcast_read(EtherCAT_command_t *cmd,
|
||||
unsigned short offset,
|
||||
unsigned int length)
|
||||
{
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
cmd->type = ECAT_CMD_BRD;
|
||||
cmd->address.phy.dev.node = 0x0000;
|
||||
cmd->address.phy.mem = offset;
|
||||
|
||||
ECAT_FUNC_READ_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-BWR-Kommando.
|
||||
|
||||
Alloziert ein "broadcast write"-Kommando
|
||||
und fügt es in die Liste des Masters ein.
|
||||
|
||||
@param cmd Zeiger auf das Kommando
|
||||
@param offset Physikalische Speicheradresse im Slave
|
||||
@param length Länge der zu schreibenden Daten
|
||||
@param data Zeiger auf Speicher mit zu schreibenden Daten
|
||||
*/
|
||||
|
||||
void EtherCAT_command_broadcast_write(EtherCAT_command_t *cmd,
|
||||
unsigned short offset,
|
||||
unsigned int length,
|
||||
const unsigned char *data)
|
||||
{
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
cmd->type = ECAT_CMD_BWR;
|
||||
cmd->address.phy.dev.node = 0x0000;
|
||||
cmd->address.phy.mem = offset;
|
||||
|
||||
ECAT_FUNC_WRITE_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-LRW-Kommando.
|
||||
|
||||
Alloziert ein "logical read write"-Kommando
|
||||
und fügt es in die Liste des Masters ein.
|
||||
|
||||
@param cmd Zeiger auf das Kommando
|
||||
@param offset Logische Speicheradresse
|
||||
@param length Länge der zu lesenden/schreibenden Daten
|
||||
@param data Zeiger auf Speicher mit zu lesenden/schreibenden Daten
|
||||
*/
|
||||
|
||||
void EtherCAT_command_logical_read_write(EtherCAT_command_t *cmd,
|
||||
unsigned int offset,
|
||||
unsigned int length,
|
||||
unsigned char *data)
|
||||
{
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
cmd->type = ECAT_CMD_LRW;
|
||||
cmd->address.logical = offset;
|
||||
|
||||
ECAT_FUNC_WRITE_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
@@ -53,7 +53,7 @@ typedef union
|
||||
phy;
|
||||
|
||||
unsigned long logical; /**< Logische Adresse */
|
||||
unsigned char raw[4]; /**< Rohdaten für die generierung des Frames */
|
||||
unsigned char raw[4]; /**< Rohdaten für die Generierung des Frames */
|
||||
}
|
||||
EtherCAT_address_t;
|
||||
|
||||
@@ -86,6 +86,36 @@ EtherCAT_command_t;
|
||||
void EtherCAT_command_init(EtherCAT_command_t *);
|
||||
void EtherCAT_command_clear(EtherCAT_command_t *);
|
||||
|
||||
void EtherCAT_command_read(EtherCAT_command_t *,
|
||||
unsigned short,
|
||||
unsigned short,
|
||||
unsigned int);
|
||||
void EtherCAT_command_write(EtherCAT_command_t *,
|
||||
unsigned short,
|
||||
unsigned short,
|
||||
unsigned int,
|
||||
const unsigned char *);
|
||||
void EtherCAT_command_position_read(EtherCAT_command_t *,
|
||||
short,
|
||||
unsigned short,
|
||||
unsigned int);
|
||||
void EtherCAT_command_position_write(EtherCAT_command_t *,
|
||||
short,
|
||||
unsigned short,
|
||||
unsigned int,
|
||||
const unsigned char *);
|
||||
void EtherCAT_command_broadcast_read(EtherCAT_command_t *,
|
||||
unsigned short,
|
||||
unsigned int);
|
||||
void EtherCAT_command_broadcast_write(EtherCAT_command_t *,
|
||||
unsigned short,
|
||||
unsigned int,
|
||||
const unsigned char *);
|
||||
void EtherCAT_command_logical_read_write(EtherCAT_command_t *,
|
||||
unsigned int,
|
||||
unsigned int,
|
||||
unsigned char *);
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
/**
|
||||
Zustand eines EtherCAT-Gerätes.
|
||||
|
||||
|
||||
Eine Für EtherCAT reservierte Netzwerkkarte kann bestimmte Zustände haben.
|
||||
*/
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,9 +33,8 @@ typedef struct
|
||||
|
||||
EtherCAT_command_t *first_command; /**< Zeiger auf das erste
|
||||
Kommando in der Liste */
|
||||
EtherCAT_command_t *process_data_command; /**< Zeiger Auf das Kommando
|
||||
zum Senden und Empfangen
|
||||
der Prozessdaten */
|
||||
EtherCAT_command_t process_data_command; /**< Kommando zum Senden und
|
||||
Empfangen der Prozessdaten */
|
||||
|
||||
EtherCAT_device_t *dev; /**< Zeiger auf das zugewiesene EtherCAT-Gerät */
|
||||
|
||||
@@ -74,10 +73,14 @@ int EtherCAT_activate_all_slaves(EtherCAT_master_t *);
|
||||
int EtherCAT_deactivate_all_slaves(EtherCAT_master_t *);
|
||||
|
||||
// Sending and receiving
|
||||
#if 0
|
||||
int EtherCAT_async_send_receive(EtherCAT_master_t *);
|
||||
int EtherCAT_send_receive_command(EtherCAT_master_t *, EtherCAT_command_t *);
|
||||
int EtherCAT_send(EtherCAT_master_t *);
|
||||
int EtherCAT_receive(EtherCAT_master_t *);
|
||||
#endif
|
||||
int EtherCAT_simple_send_receive(EtherCAT_master_t *, EtherCAT_command_t *);
|
||||
int EtherCAT_simple_send(EtherCAT_master_t *, EtherCAT_command_t *);
|
||||
int EtherCAT_simple_receive(EtherCAT_master_t *, EtherCAT_command_t *);
|
||||
|
||||
int EtherCAT_write_process_data(EtherCAT_master_t *);
|
||||
int EtherCAT_read_process_data(EtherCAT_master_t *);
|
||||
@@ -92,6 +95,7 @@ int EtherCAT_read_slave_information(EtherCAT_master_t *,
|
||||
unsigned int *);
|
||||
|
||||
// EtherCAT commands
|
||||
#if 0
|
||||
EtherCAT_command_t *EtherCAT_read(EtherCAT_master_t *,
|
||||
unsigned short,
|
||||
unsigned short,
|
||||
@@ -123,6 +127,7 @@ EtherCAT_command_t *EtherCAT_logical_read_write(EtherCAT_master_t *,
|
||||
unsigned char *);
|
||||
|
||||
void EtherCAT_remove_command(EtherCAT_master_t *, EtherCAT_command_t *);
|
||||
#endif
|
||||
|
||||
// Slave states
|
||||
int EtherCAT_state_change(EtherCAT_master_t *, EtherCAT_slave_t *, unsigned char);
|
||||
@@ -130,8 +135,10 @@ int EtherCAT_state_change(EtherCAT_master_t *, EtherCAT_slave_t *, unsigned char
|
||||
/***************************************************************/
|
||||
|
||||
// Private functions
|
||||
#if 0
|
||||
EtherCAT_command_t *alloc_cmd(EtherCAT_master_t *);
|
||||
int add_command(EtherCAT_master_t *, EtherCAT_command_t *);
|
||||
#endif
|
||||
void set_byte(unsigned char *, unsigned int, unsigned char);
|
||||
void set_word(unsigned char *, unsigned int, unsigned int);
|
||||
void output_debug_data(unsigned char *, unsigned int);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* ec_mini.c
|
||||
*
|
||||
* Minimalmodul für EtherCAT
|
||||
*
|
||||
*
|
||||
* $Id$
|
||||
*
|
||||
******************************************************************************/
|
||||
@@ -278,7 +278,7 @@ int init()
|
||||
goto out_master;
|
||||
}
|
||||
|
||||
ecat_master->debug_level = 1;
|
||||
//ecat_master->debug_level = 1;
|
||||
#endif
|
||||
|
||||
#ifdef ECAT_SLAVES
|
||||
|
||||
Reference in New Issue
Block a user