likely/unlikely, Fehlermeldungen in zyklischem Code begrenzt und Kommentare geÀndert.
This commit is contained in:
parent
3a941b769a
commit
7a6b06244e
|
|
@ -6,8 +6,8 @@
|
|||
*
|
||||
* Autoren: Wilhelm Hagemeister, Florian Pose
|
||||
*
|
||||
* $Date: 2005-11-18 11:30:01 +0100 (Fre, 18 Nov 2005) $
|
||||
* $Author: fp $
|
||||
* $Date$
|
||||
* $Author$
|
||||
*
|
||||
* (C) Copyright IgH 2005
|
||||
* Ingenieurgemeinschaft IgH
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
/****************************************************************
|
||||
/******************************************************************************
|
||||
*
|
||||
* e c _ c o m m a n d . c
|
||||
*
|
||||
* Methoden für ein EtherCAT-Kommando.
|
||||
*
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#include <linux/slab.h>
|
||||
|
||||
#include "ec_command.h"
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Kommando-Konstruktor.
|
||||
|
|
@ -34,7 +33,7 @@ void EtherCAT_command_init(EtherCAT_command_t *cmd)
|
|||
cmd->working_counter = 0;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Kommando-Destruktor.
|
||||
|
|
@ -49,7 +48,7 @@ void EtherCAT_command_clear(EtherCAT_command_t *cmd)
|
|||
EtherCAT_command_init(cmd);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define ECAT_FUNC_HEADER \
|
||||
EtherCAT_command_init(cmd)
|
||||
|
|
@ -61,7 +60,7 @@ void EtherCAT_command_clear(EtherCAT_command_t *cmd)
|
|||
#define ECAT_FUNC_READ_FOOTER \
|
||||
cmd->data_length = length;
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-NPRD-Kommando.
|
||||
|
|
@ -77,8 +76,8 @@ void EtherCAT_command_read(EtherCAT_command_t *cmd,
|
|||
unsigned short offset,
|
||||
unsigned int length)
|
||||
{
|
||||
if (node_address == 0x0000)
|
||||
printk(KERN_WARNING "EtherCAT: Using node address 0x0000!\n");
|
||||
if (unlikely(node_address == 0x0000))
|
||||
printk(KERN_WARNING "EtherCAT: Warning - Using node address 0x0000!\n");
|
||||
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
|
|
@ -89,7 +88,7 @@ void EtherCAT_command_read(EtherCAT_command_t *cmd,
|
|||
ECAT_FUNC_READ_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-NPWR-Kommando.
|
||||
|
|
@ -110,8 +109,8 @@ void EtherCAT_command_write(EtherCAT_command_t *cmd,
|
|||
unsigned int length,
|
||||
const unsigned char *data)
|
||||
{
|
||||
if (node_address == 0x0000)
|
||||
printk(KERN_WARNING "EtherCAT: Using node address 0x0000!\n");
|
||||
if (unlikely(node_address == 0x0000))
|
||||
printk(KERN_WARNING "EtherCAT: Warning - Using node address 0x0000!\n");
|
||||
|
||||
ECAT_FUNC_HEADER;
|
||||
|
||||
|
|
@ -122,7 +121,7 @@ void EtherCAT_command_write(EtherCAT_command_t *cmd,
|
|||
ECAT_FUNC_WRITE_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-APRD-Kommando.
|
||||
|
|
@ -150,7 +149,7 @@ void EtherCAT_command_position_read(EtherCAT_command_t *cmd,
|
|||
ECAT_FUNC_READ_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-APWR-Kommando.
|
||||
|
|
@ -180,7 +179,7 @@ void EtherCAT_command_position_write(EtherCAT_command_t *cmd,
|
|||
ECAT_FUNC_WRITE_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-BRD-Kommando.
|
||||
|
|
@ -206,7 +205,7 @@ void EtherCAT_command_broadcast_read(EtherCAT_command_t *cmd,
|
|||
ECAT_FUNC_READ_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-BWR-Kommando.
|
||||
|
|
@ -234,7 +233,7 @@ void EtherCAT_command_broadcast_write(EtherCAT_command_t *cmd,
|
|||
ECAT_FUNC_WRITE_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Initialisiert ein EtherCAT-LRW-Kommando.
|
||||
|
|
@ -261,4 +260,4 @@ void EtherCAT_command_logical_read_write(EtherCAT_command_t *cmd,
|
|||
ECAT_FUNC_WRITE_FOOTER;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
/****************************************************************
|
||||
/******************************************************************************
|
||||
*
|
||||
* e c _ c o m m a n d . h
|
||||
*
|
||||
* Struktur für ein EtherCAT-Kommando.
|
||||
*
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _EC_COMMAND_H_
|
||||
#define _EC_COMMAND_H_
|
||||
|
|
@ -57,7 +56,7 @@ typedef union
|
|||
}
|
||||
EtherCAT_address_t;
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
EtherCAT-Kommando.
|
||||
|
|
@ -67,18 +66,21 @@ typedef struct EtherCAT_command
|
|||
{
|
||||
EtherCAT_cmd_type_t type; /**< Typ des Kommandos (APRD, NPWR, etc...) */
|
||||
EtherCAT_address_t address; /**< Adresse des/der Empfänger */
|
||||
unsigned int data_length; /**< Länge der zu sendenden und/oder empfangenen Daten */
|
||||
unsigned int data_length; /**< Länge der zu sendenden und/oder
|
||||
empfangenen Daten */
|
||||
|
||||
EtherCAT_command_state_t state; /**< Zustand des Kommandos (bereit, gesendet, etc...) */
|
||||
unsigned char index; /**< Kommando-Index, mit der das Kommando gesendet wurde (wird
|
||||
vom Master beim Senden gesetzt. */
|
||||
unsigned int working_counter; /**< Working-Counter bei Empfang (wird vom Master gesetzt) */
|
||||
EtherCAT_command_state_t state; /**< Zustand des Kommandos
|
||||
(bereit, gesendet, etc...) */
|
||||
unsigned char index; /**< Kommando-Index, mit der das Kommando gesendet
|
||||
wurde (wird vom Master beim Senden gesetzt. */
|
||||
unsigned int working_counter; /**< Working-Counter bei Empfang (wird
|
||||
vom Master gesetzt) */
|
||||
|
||||
unsigned char data[ECAT_FRAME_BUFFER_SIZE]; /**< Kommandodaten */
|
||||
}
|
||||
EtherCAT_command_t;
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void EtherCAT_command_init(EtherCAT_command_t *);
|
||||
void EtherCAT_command_clear(EtherCAT_command_t *);
|
||||
|
|
@ -113,6 +115,6 @@ void EtherCAT_command_logical_read_write(EtherCAT_command_t *,
|
|||
unsigned int,
|
||||
unsigned char *);
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
/****************************************************************
|
||||
/******************************************************************************
|
||||
*
|
||||
* e c _ d e v i c e . c
|
||||
*
|
||||
* Methoden für ein EtherCAT-Gerät.
|
||||
*
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/skbuff.h>
|
||||
|
|
@ -17,7 +16,7 @@
|
|||
|
||||
#include "ec_device.h"
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
EtherCAT-Geräte-Konstuktor.
|
||||
|
|
@ -42,9 +41,10 @@ void EtherCAT_device_init(EtherCAT_device_t *ecd)
|
|||
ecd->rx_data_length = 0;
|
||||
ecd->isr = NULL;
|
||||
ecd->module = NULL;
|
||||
ecd->error_reported = 0;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
EtherCAT-Geräte-Destuktor.
|
||||
|
|
@ -59,20 +59,18 @@ void EtherCAT_device_clear(EtherCAT_device_t *ecd)
|
|||
{
|
||||
ecd->dev = NULL;
|
||||
|
||||
if (ecd->tx_skb)
|
||||
{
|
||||
if (ecd->tx_skb) {
|
||||
dev_kfree_skb(ecd->tx_skb);
|
||||
ecd->tx_skb = NULL;
|
||||
}
|
||||
|
||||
if (ecd->rx_skb)
|
||||
{
|
||||
if (ecd->rx_skb) {
|
||||
dev_kfree_skb(ecd->rx_skb);
|
||||
ecd->rx_skb = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Weist einem EtherCAT-Gerät das entsprechende net_device zu.
|
||||
|
|
@ -90,23 +88,19 @@ void EtherCAT_device_clear(EtherCAT_device_t *ecd)
|
|||
int EtherCAT_device_assign(EtherCAT_device_t *ecd,
|
||||
struct net_device *dev)
|
||||
{
|
||||
if (!dev)
|
||||
{
|
||||
if (!dev) {
|
||||
printk("EtherCAT: Device is NULL!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ecd->tx_skb = dev_alloc_skb(ECAT_FRAME_BUFFER_SIZE)) == NULL)
|
||||
{
|
||||
if ((ecd->tx_skb = dev_alloc_skb(ECAT_FRAME_BUFFER_SIZE)) == NULL) {
|
||||
printk(KERN_ERR "EtherCAT: Could not allocate device tx socket buffer!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ecd->rx_skb = dev_alloc_skb(ECAT_FRAME_BUFFER_SIZE)) == NULL)
|
||||
{
|
||||
if ((ecd->rx_skb = dev_alloc_skb(ECAT_FRAME_BUFFER_SIZE)) == NULL) {
|
||||
dev_kfree_skb(ecd->tx_skb);
|
||||
ecd->tx_skb = NULL;
|
||||
|
||||
printk(KERN_ERR "EtherCAT: Could not allocate device rx socket buffer!\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -120,7 +114,7 @@ int EtherCAT_device_assign(EtherCAT_device_t *ecd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Führt die open()-Funktion des Netzwerktreibers aus.
|
||||
|
|
@ -137,14 +131,12 @@ int EtherCAT_device_assign(EtherCAT_device_t *ecd,
|
|||
|
||||
int EtherCAT_device_open(EtherCAT_device_t *ecd)
|
||||
{
|
||||
if (!ecd)
|
||||
{
|
||||
if (!ecd) {
|
||||
printk(KERN_ERR "EtherCAT: Trying to open a NULL device!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!ecd->dev)
|
||||
{
|
||||
if (!ecd->dev) {
|
||||
printk(KERN_ERR "EtherCAT: No net_device to open!\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -157,7 +149,7 @@ int EtherCAT_device_open(EtherCAT_device_t *ecd)
|
|||
return ecd->dev->open(ecd->dev);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Führt die stop()-Funktion des net_devices aus.
|
||||
|
|
@ -169,8 +161,7 @@ int EtherCAT_device_open(EtherCAT_device_t *ecd)
|
|||
|
||||
int EtherCAT_device_close(EtherCAT_device_t *ecd)
|
||||
{
|
||||
if (!ecd->dev)
|
||||
{
|
||||
if (!ecd->dev) {
|
||||
printk("EtherCAT: No device to close!\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -182,7 +173,7 @@ int EtherCAT_device_close(EtherCAT_device_t *ecd)
|
|||
return ecd->dev->stop(ecd->dev);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Sendet einen Rahmen über das EtherCAT-Gerät.
|
||||
|
|
@ -206,28 +197,34 @@ int EtherCAT_device_send(EtherCAT_device_t *ecd,
|
|||
unsigned char *frame_data;
|
||||
struct ethhdr *eth;
|
||||
|
||||
if (ecd->state == ECAT_DS_SENT)
|
||||
{
|
||||
printk(KERN_WARNING "EtherCAT: Trying to send frame while last was not received!\n");
|
||||
if (unlikely(ecd->state == ECAT_DS_SENT)) {
|
||||
printk(KERN_WARNING "EtherCAT: Warning - Trying to send frame"
|
||||
" while last was not received!\n");
|
||||
}
|
||||
|
||||
skb_trim(ecd->tx_skb, 0); // Clear transmit socket buffer
|
||||
skb_reserve(ecd->tx_skb, ETH_HLEN); // Reserve space for Ethernet-II header
|
||||
// Clear transmit socket buffer and reserve
|
||||
// space for Ethernet-II header
|
||||
skb_trim(ecd->tx_skb, 0);
|
||||
skb_reserve(ecd->tx_skb, ETH_HLEN);
|
||||
|
||||
// Copy data to socket buffer
|
||||
frame_data = skb_put(ecd->tx_skb, length);
|
||||
memcpy(frame_data, data, length);
|
||||
|
||||
// Add Ethernet-II-Header
|
||||
if ((eth = (struct ethhdr *) skb_push(ecd->tx_skb, ETH_HLEN)) == NULL)
|
||||
{
|
||||
printk(KERN_ERR "EtherCAT: device_send - Could not allocate Ethernet-II header!\n");
|
||||
if (unlikely((eth = (struct ethhdr *)
|
||||
skb_push(ecd->tx_skb, ETH_HLEN)) == NULL)) {
|
||||
printk(KERN_ERR "EtherCAT: device_send -"
|
||||
" Could not allocate Ethernet-II header!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
eth->h_proto = htons(0x88A4); // Protocol type
|
||||
memcpy(eth->h_source, ecd->dev->dev_addr, ecd->dev->addr_len); // Hardware address
|
||||
memset(eth->h_dest, 0xFF, ecd->dev->addr_len); // Broadcast address
|
||||
// Protocol type
|
||||
eth->h_proto = htons(0x88A4);
|
||||
// Hardware address
|
||||
memcpy(eth->h_source, ecd->dev->dev_addr, ecd->dev->addr_len);
|
||||
// Broadcast address
|
||||
memset(eth->h_dest, 0xFF, ecd->dev->addr_len);
|
||||
|
||||
rdtscl(ecd->tx_time); // Get CPU cycles
|
||||
|
||||
|
|
@ -238,14 +235,14 @@ int EtherCAT_device_send(EtherCAT_device_t *ecd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Holt einen empfangenen Rahmen von der Netzwerkkarte.
|
||||
|
||||
Zuerst wird geprüft, ob überhaupt ein Rahmen empfangen
|
||||
wurde. Wenn ja, wird diesem mit Hilfe eines Spin-Locks
|
||||
in den angegebenen Speicherbereich kopiert.
|
||||
wurde. Wenn ja, wird dieser in den angegebenen
|
||||
Speicherbereich kopiert.
|
||||
|
||||
@param ecd EtherCAT-Gerät
|
||||
@param data Zeiger auf den Speicherbereich, in den die
|
||||
|
|
@ -257,25 +254,34 @@ int EtherCAT_device_send(EtherCAT_device_t *ecd,
|
|||
int EtherCAT_device_receive(EtherCAT_device_t *ecd,
|
||||
unsigned char *data)
|
||||
{
|
||||
if (ecd->state != ECAT_DS_RECEIVED)
|
||||
{
|
||||
printk(KERN_ERR "EtherCAT: receive - Nothing received!\n");
|
||||
if (unlikely(ecd->state != ECAT_DS_RECEIVED)) {
|
||||
if (likely(ecd->error_reported)) {
|
||||
printk(KERN_ERR "EtherCAT: receive - Nothing received!\n");
|
||||
ecd->error_reported = 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ecd->rx_data_length > ECAT_FRAME_BUFFER_SIZE)
|
||||
{
|
||||
printk(KERN_ERR "EtherCAT: receive - Reveived frame too long (%i Bytes)!\n",
|
||||
ecd->rx_data_length);
|
||||
if (unlikely(ecd->rx_data_length > ECAT_FRAME_BUFFER_SIZE)) {
|
||||
if (likely(ecd->error_reported)) {
|
||||
printk(KERN_ERR "EtherCAT: receive - "
|
||||
" Reveived frame too long (%i Bytes)!\n",
|
||||
ecd->rx_data_length);
|
||||
ecd->error_reported = 1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (unlikely(ecd->error_reported)) {
|
||||
ecd->error_reported = 0;
|
||||
}
|
||||
|
||||
memcpy(data, ecd->rx_data, ecd->rx_data_length);
|
||||
|
||||
return ecd->rx_data_length;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Ruft manuell die Interrupt-Routine der Netzwerkkarte auf.
|
||||
|
|
@ -287,10 +293,10 @@ int EtherCAT_device_receive(EtherCAT_device_t *ecd,
|
|||
|
||||
void EtherCAT_device_call_isr(EtherCAT_device_t *ecd)
|
||||
{
|
||||
if (ecd->isr) ecd->isr(0, ecd->dev, NULL);
|
||||
if (likely(ecd->isr)) ecd->isr(0, ecd->dev, NULL);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Gibt alle Informationen über das Device-Objekt aus.
|
||||
|
|
@ -304,16 +310,26 @@ void EtherCAT_device_debug(EtherCAT_device_t *ecd)
|
|||
|
||||
if (ecd)
|
||||
{
|
||||
printk(KERN_DEBUG "Assigned net_device: %X\n", (unsigned) ecd->dev);
|
||||
printk(KERN_DEBUG "Transmit socket buffer: %X\n", (unsigned) ecd->tx_skb);
|
||||
printk(KERN_DEBUG "Receive socket buffer: %X\n", (unsigned) ecd->rx_skb);
|
||||
printk(KERN_DEBUG "Time of last transmission: %u\n", (unsigned) ecd->tx_time);
|
||||
printk(KERN_DEBUG "Time of last receive: %u\n", (unsigned) ecd->rx_time);
|
||||
printk(KERN_DEBUG "Number of transmit interrupts: %u\n", (unsigned) ecd->tx_intr_cnt);
|
||||
printk(KERN_DEBUG "Number of receive interrupts: %u\n", (unsigned) ecd->rx_intr_cnt);
|
||||
printk(KERN_DEBUG "Total Number of interrupts: %u\n", (unsigned) ecd->intr_cnt);
|
||||
printk(KERN_DEBUG "Actual device state: %i\n", (int) ecd->state);
|
||||
printk(KERN_DEBUG "Receive buffer: %X\n", (unsigned) ecd->rx_data);
|
||||
printk(KERN_DEBUG "Assigned net_device: %X\n",
|
||||
(unsigned) ecd->dev);
|
||||
printk(KERN_DEBUG "Transmit socket buffer: %X\n",
|
||||
(unsigned) ecd->tx_skb);
|
||||
printk(KERN_DEBUG "Receive socket buffer: %X\n",
|
||||
(unsigned) ecd->rx_skb);
|
||||
printk(KERN_DEBUG "Time of last transmission: %u\n",
|
||||
(unsigned) ecd->tx_time);
|
||||
printk(KERN_DEBUG "Time of last receive: %u\n",
|
||||
(unsigned) ecd->rx_time);
|
||||
printk(KERN_DEBUG "Number of transmit interrupts: %u\n",
|
||||
(unsigned) ecd->tx_intr_cnt);
|
||||
printk(KERN_DEBUG "Number of receive interrupts: %u\n",
|
||||
(unsigned) ecd->rx_intr_cnt);
|
||||
printk(KERN_DEBUG "Total Number of interrupts: %u\n",
|
||||
(unsigned) ecd->intr_cnt);
|
||||
printk(KERN_DEBUG "Actual device state: %i\n",
|
||||
(int) ecd->state);
|
||||
printk(KERN_DEBUG "Receive buffer: %X\n",
|
||||
(unsigned) ecd->rx_data);
|
||||
printk(KERN_DEBUG "Receive buffer fill state: %u/%u\n",
|
||||
(unsigned) ecd->rx_data_length, ECAT_FRAME_BUFFER_SIZE);
|
||||
}
|
||||
|
|
@ -325,7 +341,7 @@ void EtherCAT_device_debug(EtherCAT_device_t *ecd)
|
|||
printk(KERN_DEBUG "---EtherCAT device information end---\n");
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
EXPORT_SYMBOL(EtherCAT_device_init);
|
||||
EXPORT_SYMBOL(EtherCAT_device_clear);
|
||||
|
|
@ -333,4 +349,4 @@ EXPORT_SYMBOL(EtherCAT_device_assign);
|
|||
EXPORT_SYMBOL(EtherCAT_device_open);
|
||||
EXPORT_SYMBOL(EtherCAT_device_close);
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
/****************************************************************
|
||||
/******************************************************************************
|
||||
*
|
||||
* e c _ d e v i c e . h
|
||||
*
|
||||
* Struktur für ein EtherCAT-Gerät.
|
||||
*
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _EC_DEVICE_H_
|
||||
#define _EC_DEVICE_H_
|
||||
|
|
@ -36,7 +35,7 @@ typedef enum
|
|||
}
|
||||
EtherCAT_device_state_t;
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
EtherCAT-Gerät.
|
||||
|
|
@ -65,10 +64,12 @@ typedef struct
|
|||
irqreturn_t (*isr)(int, void *, struct pt_regs *); /**< Adresse der ISR */
|
||||
struct module *module; /**< Zeiger auf das Modul, das das Gerät zur
|
||||
Verfügung stellt. */
|
||||
int error_reported; /**< Zeigt an, ob ein Fehler im zyklischen Code
|
||||
bereits gemeldet wurde. */
|
||||
}
|
||||
EtherCAT_device_t;
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void EtherCAT_device_init(EtherCAT_device_t *);
|
||||
int EtherCAT_device_assign(EtherCAT_device_t *, struct net_device *);
|
||||
|
|
@ -83,6 +84,6 @@ void EtherCAT_device_call_isr(EtherCAT_device_t *);
|
|||
|
||||
void EtherCAT_device_debug(EtherCAT_device_t *);
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
/****************************************************************
|
||||
/******************************************************************************
|
||||
*
|
||||
* e c _ g l o b a l s . h
|
||||
*
|
||||
* Globale Definitionen und Makros für das EtherCAT-Protokoll.
|
||||
*
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _EC_GLOBALS_
|
||||
#define _EC_GLOBALS_
|
||||
|
|
@ -62,6 +61,6 @@ typedef enum
|
|||
}
|
||||
EtherCAT_state_t;
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,13 +1,12 @@
|
|||
/****************************************************************
|
||||
/******************************************************************************
|
||||
*
|
||||
* e c _ m a s t e r . h
|
||||
*
|
||||
* Struktur für einen EtherCAT-Master.
|
||||
*
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _EC_MASTER_H_
|
||||
#define _EC_MASTER_H_
|
||||
|
|
@ -16,7 +15,7 @@
|
|||
#include "ec_slave.h"
|
||||
#include "ec_command.h"
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
EtherCAT-Master
|
||||
|
|
@ -53,7 +52,7 @@ typedef struct
|
|||
}
|
||||
EtherCAT_master_t;
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// Master creation and deletion
|
||||
void EtherCAT_master_init(EtherCAT_master_t *);
|
||||
|
|
@ -89,6 +88,6 @@ void EtherCAT_clear_process_data(EtherCAT_master_t *);
|
|||
// Private functions
|
||||
void output_debug_data(const EtherCAT_master_t *);
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* Fax.: +49 201/61 98 36
|
||||
* E-mail: sp@igh-essen.com
|
||||
*
|
||||
******************************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
|
@ -24,30 +24,32 @@
|
|||
|
||||
#include "ec_module.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#define LITERAL(X) #X
|
||||
#define STRINGIFY(X) LITERAL(X)
|
||||
#define LIT(X) #X
|
||||
#define STR(X) LIT(X)
|
||||
|
||||
#define COMPILE_INFO "Revision " STRINGIFY(EC_REV) \
|
||||
", compiled by " STRINGIFY(EC_USER) \
|
||||
" at " STRINGIFY(EC_DATE)
|
||||
#define COMPILE_INFO "Revision " STR(EC_REV) \
|
||||
", compiled by " STR(EC_USER) \
|
||||
" at " STR(EC_DATE)
|
||||
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
int ecat_master_count = 1;
|
||||
EtherCAT_master_t *ecat_masters = NULL;
|
||||
int *ecat_masters_reserved = NULL;
|
||||
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
MODULE_AUTHOR ("Wilhelm Hagemeister <hm@igh-essen.com>, Florian Pose <fp@igh-essen.com>");
|
||||
MODULE_AUTHOR ("Wilhelm Hagemeister <hm@igh-essen.com>,"
|
||||
"Florian Pose <fp@igh-essen.com>");
|
||||
MODULE_DESCRIPTION ("EtherCAT master driver module");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_VERSION(COMPILE_INFO);
|
||||
|
||||
module_param(ecat_master_count, int, 1);
|
||||
MODULE_PARM_DESC(ecat_master_count, "Number of EtherCAT master to initialize.");
|
||||
MODULE_PARM_DESC(ecat_master_count,
|
||||
"Number of EtherCAT master to initialize.");
|
||||
|
||||
module_init(ecat_init_module);
|
||||
module_exit(ecat_cleanup_module);
|
||||
|
|
@ -57,7 +59,7 @@ EXPORT_SYMBOL(EtherCAT_unregister_device);
|
|||
EXPORT_SYMBOL(EtherCAT_request);
|
||||
EXPORT_SYMBOL(EtherCAT_release);
|
||||
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Init-Funktion des EtherCAT-Master-Treibermodules
|
||||
|
|
@ -75,28 +77,29 @@ int __init ecat_init_module(void)
|
|||
|
||||
printk(KERN_ERR "EtherCAT: Master driver, %s\n", COMPILE_INFO);
|
||||
|
||||
if (ecat_master_count < 1)
|
||||
{
|
||||
printk(KERN_ERR "EtherCAT: Error - Illegal ecat_master_count: %i\n",
|
||||
ecat_master_count);
|
||||
if (ecat_master_count < 1) {
|
||||
printk(KERN_ERR "EtherCAT: Error - Illegal"
|
||||
" ecat_master_count: %i\n", ecat_master_count);
|
||||
return -1;
|
||||
}
|
||||
|
||||
printk(KERN_ERR "EtherCAT: Initializing %i EtherCAT master(s)...\n",
|
||||
ecat_master_count);
|
||||
|
||||
if ((ecat_masters = (EtherCAT_master_t *) kmalloc(sizeof(EtherCAT_master_t)
|
||||
* ecat_master_count,
|
||||
GFP_KERNEL)) == NULL)
|
||||
{
|
||||
printk(KERN_ERR "EtherCAT: Could not allocate memory for EtherCAT master(s)!\n");
|
||||
if ((ecat_masters =
|
||||
(EtherCAT_master_t *) kmalloc(sizeof(EtherCAT_master_t)
|
||||
* ecat_master_count,
|
||||
GFP_KERNEL)) == NULL) {
|
||||
printk(KERN_ERR "EtherCAT: Could not allocate"
|
||||
" memory for EtherCAT master(s)!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ecat_masters_reserved = (int *) kmalloc(sizeof(int) * ecat_master_count,
|
||||
GFP_KERNEL)) == NULL)
|
||||
{
|
||||
printk(KERN_ERR "EtherCAT: Could not allocate memory for reservation flags!\n");
|
||||
if ((ecat_masters_reserved =
|
||||
(int *) kmalloc(sizeof(int) * ecat_master_count,
|
||||
GFP_KERNEL)) == NULL) {
|
||||
printk(KERN_ERR "EtherCAT: Could not allocate"
|
||||
" memory for reservation flags!\n");
|
||||
kfree(ecat_masters);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -112,7 +115,7 @@ int __init ecat_init_module(void)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Cleanup-Funktion des EtherCAT-Master-Treibermoduls
|
||||
|
|
@ -131,7 +134,8 @@ void __exit ecat_cleanup_module(void)
|
|||
for (i = 0; i < ecat_master_count; i++)
|
||||
{
|
||||
if (ecat_masters_reserved[i]) {
|
||||
printk(KERN_WARNING "EtherCAT: Warning - Master %i is still in use!\n", i);
|
||||
printk(KERN_WARNING "EtherCAT: Warning -"
|
||||
" Master %i is still in use!\n", i);
|
||||
}
|
||||
|
||||
EtherCAT_master_clear(&ecat_masters[i]);
|
||||
|
|
@ -143,7 +147,7 @@ void __exit ecat_cleanup_module(void)
|
|||
printk(KERN_ERR "EtherCAT: Master driver cleaned up.\n");
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Setzt das EtherCAT-Geraet, auf dem der Master arbeitet.
|
||||
|
|
@ -159,8 +163,7 @@ void __exit ecat_cleanup_module(void)
|
|||
|
||||
int EtherCAT_register_device(int index, EtherCAT_device_t *device)
|
||||
{
|
||||
if (index < 0 || index >= ecat_master_count)
|
||||
{
|
||||
if (index < 0 || index >= ecat_master_count) {
|
||||
printk(KERN_ERR "EtherCAT: Master %i does not exist!\n", index);
|
||||
return -1;
|
||||
}
|
||||
|
|
@ -168,7 +171,7 @@ int EtherCAT_register_device(int index, EtherCAT_device_t *device)
|
|||
return EtherCAT_master_open(&ecat_masters[index], device);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Loescht das EtherCAT-Geraet, auf dem der Master arbeitet.
|
||||
|
|
@ -179,8 +182,7 @@ int EtherCAT_register_device(int index, EtherCAT_device_t *device)
|
|||
|
||||
void EtherCAT_unregister_device(int index, EtherCAT_device_t *device)
|
||||
{
|
||||
if (index < 0 || index >= ecat_master_count)
|
||||
{
|
||||
if (index < 0 || index >= ecat_master_count) {
|
||||
printk(KERN_WARNING "EtherCAT: Master %i does not exist!\n", index);
|
||||
return;
|
||||
}
|
||||
|
|
@ -188,7 +190,7 @@ void EtherCAT_unregister_device(int index, EtherCAT_device_t *device)
|
|||
EtherCAT_master_close(&ecat_masters[index], device);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Reserviert einen bestimmten EtherCAT-Master und das zugehörige Gerät.
|
||||
|
|
@ -212,7 +214,8 @@ EtherCAT_master_t *EtherCAT_request(int index)
|
|||
}
|
||||
|
||||
if (!ecat_masters[index].dev) {
|
||||
printk(KERN_ERR "EtherCAT: Master %i has no device assigned yet!\n", index);
|
||||
printk(KERN_ERR "EtherCAT: Master %i has no device assigned yet!\n",
|
||||
index);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +236,7 @@ EtherCAT_master_t *EtherCAT_request(int index)
|
|||
return &ecat_masters[index];
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Gibt einen zuvor reservierten EtherCAT-Master wieder frei.
|
||||
|
|
@ -268,4 +271,4 @@ void EtherCAT_release(EtherCAT_master_t *master)
|
|||
(unsigned int) master);
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
* Fax.: +49 201/61 98 36
|
||||
* E-mail: sp@igh-essen.com
|
||||
*
|
||||
******************************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#include "ec_master.h"
|
||||
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
int __init ecat_init_module(void);
|
||||
void __exit ecat_cleanup_module(void);
|
||||
|
|
@ -36,4 +36,4 @@ void EtherCAT_unregister_device(int, EtherCAT_device_t *);
|
|||
EtherCAT_master_t *EtherCAT_request(int);
|
||||
void EtherCAT_release(EtherCAT_master_t *);
|
||||
|
||||
/******************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,20 +1,19 @@
|
|||
/****************************************************************
|
||||
/******************************************************************************
|
||||
*
|
||||
* e c _ s l a v e . c
|
||||
*
|
||||
* Methoden für einen EtherCAT-Slave.
|
||||
*
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#include <linux/module.h>
|
||||
|
||||
#include "ec_globals.h"
|
||||
#include "ec_slave.h"
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
EtherCAT-Slave-Konstruktor.
|
||||
|
|
@ -29,24 +28,20 @@ void EtherCAT_slave_init(EtherCAT_slave_t *slave)
|
|||
slave->type = 0;
|
||||
slave->revision = 0;
|
||||
slave->build = 0;
|
||||
|
||||
slave->ring_position = 0;
|
||||
slave->station_address = 0;
|
||||
|
||||
slave->vendor_id = 0;
|
||||
slave->product_code = 0;
|
||||
slave->revision_number = 0;
|
||||
slave->serial_number = 0;
|
||||
|
||||
slave->desc = 0;
|
||||
|
||||
slave->desc = NULL;
|
||||
slave->logical_address0 = 0;
|
||||
|
||||
slave->current_state = ECAT_STATE_UNKNOWN;
|
||||
slave->requested_state = ECAT_STATE_UNKNOWN;
|
||||
slave->error_reported = 0;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
EtherCAT-Slave-Destruktor.
|
||||
|
|
@ -61,7 +56,7 @@ void EtherCAT_slave_clear(EtherCAT_slave_t *slave)
|
|||
// Nothing yet...
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Liest einen bestimmten Kanal des Slaves als Integer-Wert.
|
||||
|
|
@ -81,37 +76,46 @@ void EtherCAT_slave_clear(EtherCAT_slave_t *slave)
|
|||
int EtherCAT_read_value(EtherCAT_slave_t *slave,
|
||||
unsigned int channel)
|
||||
{
|
||||
if (!slave->desc)
|
||||
{
|
||||
printk(KERN_WARNING "EtherCAT: Reading failed on slave %04X (addr %0X)"
|
||||
" - Slave has no description.\n",
|
||||
slave->station_address, (unsigned int) slave);
|
||||
if (unlikely(!slave->desc)) {
|
||||
if (likely(slave->error_reported)) {
|
||||
printk(KERN_WARNING "EtherCAT: Reading failed on slave %04X (addr %0X)"
|
||||
" - Slave has no description.\n",
|
||||
slave->station_address, (unsigned int) slave);
|
||||
slave->error_reported = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!slave->desc->read)
|
||||
{
|
||||
printk(KERN_WARNING "EtherCAT: Reading failed on slave %04X (addr %0X)"
|
||||
" - Slave type (%s %s) has no read method.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name);
|
||||
if (unlikely(!slave->desc->read)) {
|
||||
if (likely(slave->error_reported)) {
|
||||
printk(KERN_WARNING "EtherCAT: Reading failed on slave %04X (addr %0X)"
|
||||
" - Slave type (%s %s) has no read method.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name);
|
||||
slave->error_reported = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (channel >= slave->desc->channels)
|
||||
{
|
||||
printk(KERN_WARNING "EtherCAT: Reading failed on slave %4X (addr %0X)"
|
||||
" - Type (%s %s) has no channel %i.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name,
|
||||
channel);
|
||||
if (unlikely(channel >= slave->desc->channels)) {
|
||||
if (likely(slave->error_reported)) {
|
||||
printk(KERN_WARNING "EtherCAT: Reading failed on slave %4X (addr %0X)"
|
||||
" - Type (%s %s) has no channel %i.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name,
|
||||
channel);
|
||||
slave->error_reported = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (unlikely(slave->error_reported))
|
||||
slave->error_reported = 0;
|
||||
|
||||
return slave->desc->read(slave->process_data, channel);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Schreibt einen bestimmten Kanal des Slaves als Integer-Wert .
|
||||
|
|
@ -131,37 +135,48 @@ void EtherCAT_write_value(EtherCAT_slave_t *slave,
|
|||
unsigned int channel,
|
||||
int value)
|
||||
{
|
||||
if (!slave->desc)
|
||||
{
|
||||
printk(KERN_WARNING "EtherCAT: Writing failed on slave %04X (addr %0X)"
|
||||
" - Slave has no description.\n",
|
||||
slave->station_address, (unsigned int) slave);
|
||||
if (unlikely(!slave->desc)) {
|
||||
if (likely(slave->error_reported)) {
|
||||
printk(KERN_WARNING "EtherCAT: Writing failed on slave %04X (addr %0X)"
|
||||
" - Slave has no description.\n",
|
||||
slave->station_address, (unsigned int) slave);
|
||||
slave->error_reported = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (!slave->desc->write)
|
||||
{
|
||||
printk(KERN_WARNING "EtherCAT: Writing failed on slave %04X (addr %0X)"
|
||||
" - Type (%s %s) has no write method.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name);
|
||||
if (unlikely(!slave->desc->write)) {
|
||||
if (likely(slave->error_reported)) {
|
||||
printk(KERN_WARNING "EtherCAT: Writing failed on slave %04X (addr %0X)"
|
||||
" - Type (%s %s) has no write method.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name);
|
||||
slave->error_reported = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (channel >= slave->desc->channels)
|
||||
{
|
||||
printk(KERN_WARNING "EtherCAT: Writing failed on slave %4X (addr %0X)"
|
||||
" - Type (%s %s) has no channel %i.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name,
|
||||
channel);
|
||||
if (unlikely(channel >= slave->desc->channels)) {
|
||||
if (likely(slave->error_reported)) {
|
||||
printk(KERN_WARNING "EtherCAT: Writing failed on slave %4X (addr %0X)"
|
||||
" - Type (%s %s) has no channel %i.\n",
|
||||
slave->station_address, (unsigned int) slave,
|
||||
slave->desc->vendor_name, slave->desc->product_name,
|
||||
channel);
|
||||
slave->error_reported = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (unlikely(slave->error_reported))
|
||||
slave->error_reported = 0;
|
||||
|
||||
slave->desc->write(slave->process_data, channel, value);
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
EXPORT_SYMBOL(EtherCAT_write_value);
|
||||
EXPORT_SYMBOL(EtherCAT_read_value);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,20 +1,19 @@
|
|||
/****************************************************************
|
||||
/******************************************************************************
|
||||
*
|
||||
* e c _ s l a v e . h
|
||||
*
|
||||
* Struktur für einen EtherCAT-Slave.
|
||||
*
|
||||
* $Date$
|
||||
* $Author$
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _EC_SLAVE_H_
|
||||
#define _EC_SLAVE_H_
|
||||
|
||||
#include "ec_types.h"
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
EtherCAT-Slave
|
||||
|
|
@ -50,6 +49,7 @@ typedef struct
|
|||
|
||||
unsigned char *process_data; /**< Zeiger auf den Speicherbereich
|
||||
im Prozessdatenspeicher des Masters */
|
||||
int error_reported; /**< Ein Zugriffsfehler wurde bereits gemeldet. */
|
||||
}
|
||||
EtherCAT_slave_t;
|
||||
|
||||
|
|
@ -57,7 +57,7 @@ EtherCAT_slave_t;
|
|||
TYPE, 0, ECAT_STATE_UNKNOWN, \
|
||||
ECAT_STATE_UNKNOWN, NULL}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
// Slave construction and deletion
|
||||
void EtherCAT_slave_init(EtherCAT_slave_t *);
|
||||
|
|
@ -66,6 +66,6 @@ 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
|
||||
|
|
|
|||
|
|
@ -1,20 +1,21 @@
|
|||
/****************************************************************
|
||||
/******************************************************************************
|
||||
*
|
||||
* e c _ t y p e s . c
|
||||
*
|
||||
* EtherCAT-Slave-Typen.
|
||||
*
|
||||
* $Date: 2005-09-07 17:50:50 +0200 (Mit, 07 Sep 2005) $
|
||||
* $Author: fp $
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#include <linux/module.h>
|
||||
|
||||
#include "ec_globals.h"
|
||||
#include "ec_types.h"
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Konfigurationen der Sync-Manager */
|
||||
|
||||
unsigned char sm0_multi[] = {0x00, 0x18, 0xF6, 0x00, 0x26, 0x00, 0x01, 0x00};
|
||||
unsigned char sm1_multi[] = {0xF6, 0x18, 0xF6, 0x00, 0x22, 0x00, 0x01, 0x00};
|
||||
|
|
@ -28,6 +29,7 @@ unsigned char sm3_31xx[] = {0x00, 0x11, 0x06, 0x00, 0x20, 0x00, 0x01, 0x00};
|
|||
|
||||
unsigned char sm2_41xx[] = {0x00, 0x10, 0x04, 0x00, 0x24, 0x00, 0x01, 0x00};
|
||||
|
||||
/* Konfigurationen der Memory-Management-Units */
|
||||
|
||||
unsigned char fmmu0_1014[] = {0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x07,
|
||||
0x00, 0x10, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00};
|
||||
|
|
@ -41,6 +43,10 @@ unsigned char fmmu0_31xx[] = {0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x07,
|
|||
unsigned char fmmu0_41xx[] = {0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07,
|
||||
0x00, 0x10, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00};
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Lese- und Schreibfunktionen */
|
||||
|
||||
int read_1014(unsigned char *data, unsigned int channel)
|
||||
{
|
||||
return (data[0] >> channel) & 0x01;
|
||||
|
|
@ -69,7 +75,9 @@ void write_41xx(unsigned char *data, unsigned int channel, int value)
|
|||
data[channel * 3 + 2] = value & 0xFF;
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Klemmen-Objekte */
|
||||
|
||||
EtherCAT_slave_desc_t Beckhoff_EK1100[] =
|
||||
{{
|
||||
|
|
@ -151,11 +159,17 @@ EtherCAT_slave_desc_t Beckhoff_EL5001[] =
|
|||
NULL, NULL
|
||||
}};
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
unsigned int slave_idents_count = 7;
|
||||
/**
|
||||
Beziehung zwischen Identifikationsnummern und Klemmen-Objekt.
|
||||
|
||||
struct slave_ident slave_idents[] =
|
||||
Diese Tabelle stellt die Beziehungen zwischen bestimmten Kombinationen
|
||||
aus Vendor-IDs und Product-Codes und der entsprechenden Klemme her.
|
||||
Neue Klemmen müssen hier eingetragen werden.
|
||||
*/
|
||||
|
||||
EtherCAT_slave_ident_t slave_idents[] =
|
||||
{
|
||||
{0x00000002, 0x03F63052, Beckhoff_EL1014},
|
||||
{0x00000002, 0x044C2C52, Beckhoff_EK1100},
|
||||
|
|
@ -167,7 +181,11 @@ struct slave_ident slave_idents[] =
|
|||
{0x00000002, 0x13893052, Beckhoff_EL5001}
|
||||
};
|
||||
|
||||
/***************************************************************/
|
||||
unsigned int slave_ident_count = sizeof(slave_idents)
|
||||
/ sizeof(EtherCAT_slave_ident_t);
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
EXPORT_SYMBOL(Beckhoff_EK1100);
|
||||
EXPORT_SYMBOL(Beckhoff_EL1014);
|
||||
|
|
@ -177,3 +195,5 @@ EXPORT_SYMBOL(Beckhoff_EL3162);
|
|||
EXPORT_SYMBOL(Beckhoff_EL4102);
|
||||
EXPORT_SYMBOL(Beckhoff_EL4132);
|
||||
EXPORT_SYMBOL(Beckhoff_EL5001);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
/****************************************************************
|
||||
/******************************************************************************
|
||||
*
|
||||
* e c _ t y p e s . h
|
||||
*
|
||||
* EtherCAT-Slave-Typen.
|
||||
*
|
||||
* $Date: 2005-09-07 17:50:50 +0200 (Mit, 07 Sep 2005) $
|
||||
* $Author: fp $
|
||||
* $Id$
|
||||
*
|
||||
***************************************************************/
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef _EC_TYPES_H_
|
||||
#define _EC_TYPES_H_
|
||||
|
|
@ -26,7 +25,7 @@ typedef enum
|
|||
}
|
||||
EtherCAT_slave_type_t;
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Beschreibung eines EtherCAT-Slave-Typs.
|
||||
|
|
@ -67,7 +66,7 @@ typedef struct slave_desc
|
|||
}
|
||||
EtherCAT_slave_desc_t;
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
/**
|
||||
Identifikation eines Slave-Typs.
|
||||
|
|
@ -76,20 +75,21 @@ EtherCAT_slave_desc_t;
|
|||
Produktcodes zu den einzelnen Slave-Typen verwendet.
|
||||
*/
|
||||
|
||||
struct slave_ident
|
||||
typedef struct slave_ident
|
||||
{
|
||||
const unsigned int vendor_id; /**< Hersteller-Code */
|
||||
const unsigned int product_code; /**< Herstellerspezifischer Produktcode */
|
||||
const EtherCAT_slave_desc_t *desc; /**< Zeiger auf den dazugehörigen
|
||||
Slave-Typ */
|
||||
};
|
||||
}
|
||||
EtherCAT_slave_ident_t;
|
||||
|
||||
extern struct slave_ident slave_idents[]; /**< Statisches Array der
|
||||
Slave-Identifikationen */
|
||||
extern unsigned int slave_idents_count; /**< Anzahl der bekannten Slave-
|
||||
Identifikationen */
|
||||
extern EtherCAT_slave_ident_t slave_idents[]; /**< Statisches Array der
|
||||
Slave-Identifikationen */
|
||||
extern unsigned int slave_ident_count; /**< Anzahl der vorhandenen
|
||||
Slave-Identifikationen */
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
extern EtherCAT_slave_desc_t Beckhoff_EK1100[];
|
||||
extern EtherCAT_slave_desc_t Beckhoff_EL1014[];
|
||||
|
|
@ -100,6 +100,6 @@ extern EtherCAT_slave_desc_t Beckhoff_EL4102[];
|
|||
extern EtherCAT_slave_desc_t Beckhoff_EL4132[];
|
||||
extern EtherCAT_slave_desc_t Beckhoff_EL5001[];
|
||||
|
||||
/***************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue