diff --git a/Makefile b/Makefile index 542fe86f..8d172222 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ ifneq ($(KERNELRELEASE),) #------------------------------------------------------------------------------ # Kbuild-Abschnitt -obj-m := master/ devices/ libec/ rt/ mini/ +obj-m := master/ devices/ rt/ mini/ #------------------------------------------------------------------------------ diff --git a/include/EtherCAT_si.h b/include/EtherCAT_si.h new file mode 100644 index 00000000..60ca417e --- /dev/null +++ b/include/EtherCAT_si.h @@ -0,0 +1,46 @@ +/****************************************************************************** + * + * E t h e r C A T _ s i . h + * + * EtherCAT Slave-Interface. + * + * $Id$ + * + *****************************************************************************/ + +#define EC_PROC_DATA(SLAVE) ((unsigned char *) ((SLAVE)->process_data)) + +/*****************************************************************************/ + +#define EC_READ_EL10XX(SLAVE, CHANNEL) \ + ((EC_PROC_DATA(SLAVE)[0] >> (CHANNEL)) & 0x01) + +/*****************************************************************************/ + +#define EC_READ_EL31XX(SLAVE, CHANNEL) \ + ((short int) ((EC_PROC_DATA(SLAVE)[(CHANNEL) * 3 + 2] << 8) | \ + EC_PROC_DATA(SLAVE)[(CHANNEL) * 3 + 1])) + +/*****************************************************************************/ + +#define EC_WRITE_EL20XX(SLAVE, CHANNEL, VALUE) \ + do { \ + if (VALUE) EC_PROC_DATA(SLAVE)[0] |= (1 << (CHANNEL)); \ + else EC_PROC_DATA(SLAVE)[0] &= ~(1 << (CHANNEL)); \ + } while (0) + +/*****************************************************************************/ + +#define EC_WRITE_EL41XX(SLAVE, CHANNEL, VALUE) \ + do { \ + EC_PROC_DATA(SLAVE)[(CHANNEL) * 3 + 1] = ((VALUE) & 0xFF00) >> 8; \ + EC_PROC_DATA(SLAVE)[(CHANNEL) * 3 + 2] = (VALUE) & 0xFF; \ + } while (0) + +/*****************************************************************************/ + +/* Emacs-Konfiguration +;;; Local Variables: *** +;;; c-basic-offset:4 *** +;;; End: *** +*/ diff --git a/libec/Makefile b/libec/Makefile deleted file mode 100644 index a847f3c4..00000000 --- a/libec/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -#------------------------------------------------------------------------------ -# -# Makefile -# -# EtherCAT-Library -# -# $Id$ -# -#------------------------------------------------------------------------------ - -ifneq ($(KERNELRELEASE),) - -#------------------------------------------------------------------------------ -# Kbuild-Abschnitt - -lib-m := libec.o - -#------------------------------------------------------------------------------ - -else - -#------------------------------------------------------------------------------ -# Default-Abschnitt - -ifneq ($(wildcard ethercat.conf),) -include ethercat.conf -else -KERNELDIR = /lib/modules/`uname -r`/build -endif - -modules: - $(MAKE) -C $(KERNELDIR) M=`pwd` - -clean: - $(MAKE) -C $(KERNELDIR) M=`pwd` clean - -#------------------------------------------------------------------------------ - -endif - - diff --git a/libec/libec.c b/libec/libec.c deleted file mode 100644 index 3c4f787a..00000000 --- a/libec/libec.c +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** - * - * l i b e c . c - * - * EtherCAT-Library fuer Echtzeitmodule - * - * $Id$ - * - *****************************************************************************/ - -#include "libec.h" - -/*****************************************************************************/ - -int LEC_read_EL10XX(ec_slave_t *slave, unsigned int channel) -{ - unsigned char *data = slave->process_data; - - return (data[0] >> channel) & 0x01; -} - -/*****************************************************************************/ - -int LEC_read_EL31XX(ec_slave_t *slave, unsigned int channel) -{ - unsigned char *data = slave->process_data; - - return (short int) ((data[channel * 3 + 2] << 8) | data[channel * 3 + 1]); -} - -/*****************************************************************************/ - -void LEC_write_EL20XX(ec_slave_t *slave, unsigned int channel, int value) -{ - unsigned char *data = slave->process_data; - - if (value) data[0] |= (1 << channel); - else data[0] &= ~(1 << channel); -} - -/*****************************************************************************/ - -void LEC_write_EL41XX(ec_slave_t *slave, unsigned int channel, int value) -{ - unsigned char *data = slave->process_data; - - data[channel * 3 + 1] = (value & 0xFF00) >> 8; - data[channel * 3 + 2] = value & 0xFF; -} - -/*****************************************************************************/ - -/* Emacs-Konfiguration -;;; Local Variables: *** -;;; c-basic-offset:4 *** -;;; End: *** -*/ diff --git a/libec/libec.h b/libec/libec.h deleted file mode 100644 index d182356b..00000000 --- a/libec/libec.h +++ /dev/null @@ -1,34 +0,0 @@ -/****************************************************************************** - * - * l i b e c . h - * - * EtherCAT-Library fuer Echtzeitmodule - * - * $Id$ - * - *****************************************************************************/ - -#ifndef _LIBEC_H_ -#define _LIBEC_H_ - -#ifndef _ETHERCAT_RT_H_ -#include "../include/EtherCAT_rt.h" -#endif - -/*****************************************************************************/ - -int LEC_read_EL10XX(ec_slave_t *slave, unsigned int channel); -int LEC_read_EL31XX(ec_slave_t *slave, unsigned int channel); - -void LEC_write_EL20XX(ec_slave_t *slave, unsigned int channel, int value); -void LEC_write_EL41XX(ec_slave_t *slave, unsigned int channel, int value); - -/*****************************************************************************/ - -#endif - -/* Emacs-Konfiguration -;;; Local Variables: *** -;;; c-basic-offset:4 *** -;;; End: *** -*/ diff --git a/rt/Makefile b/rt/Makefile index 8b083e90..36e8a2d3 100644 --- a/rt/Makefile +++ b/rt/Makefile @@ -25,7 +25,7 @@ msr_modul-objs := msr_module.o \ rt_lib/msr-core/msr_error_reg.o \ rt_lib/msr-utils/msr_utils.o \ rt_lib/msr-math/msr_base64.o \ - libm.o libec.o + libm.o EXTRA_CFLAGS := -I $(src)/rt_lib/msr-include -D_SIMULATION \ -I/usr/include -mhard-float diff --git a/rt/libec.o_shipped b/rt/libec.o_shipped deleted file mode 120000 index 8cac39cd..00000000 --- a/rt/libec.o_shipped +++ /dev/null @@ -1 +0,0 @@ -../libec/lib.a \ No newline at end of file diff --git a/rt/msr_module.c b/rt/msr_module.c index ebda6392..229a61a3 100644 --- a/rt/msr_module.c +++ b/rt/msr_module.c @@ -33,7 +33,7 @@ // EtherCAT #include "../include/EtherCAT_rt.h" -#include "../libec/libec.h" +#include "../include/EtherCAT_si.h" // Defines/Makros #define TSC2US(T1, T2) ((T2 - T1) * 1000UL / cpu_khz) @@ -86,22 +86,22 @@ static void msr_controller_run(void) } else { // "Star Trek"-Effekte - LEC_write_EL20XX(s_out1, 0, jiffies & 1); - LEC_write_EL20XX(s_out1, 1, (jiffies >> 1) & 1); - LEC_write_EL20XX(s_out1, 2, (jiffies >> 2) & 1); - LEC_write_EL20XX(s_out1, 3, (jiffies >> 3) & 1); - LEC_write_EL20XX(s_out2, 0, (jiffies >> 4) & 1); - LEC_write_EL20XX(s_out2, 1, (jiffies >> 3) & 1); - LEC_write_EL20XX(s_out2, 2, (jiffies >> 2) & 1); - LEC_write_EL20XX(s_out2, 3, (jiffies >> 6) & 1); - LEC_write_EL20XX(s_out3, 0, (jiffies >> 7) & 1); - LEC_write_EL20XX(s_out3, 1, (jiffies >> 2) & 1); - LEC_write_EL20XX(s_out3, 2, (jiffies >> 8) & 1); + EC_WRITE_EL20XX(s_out1, 0, jiffies & 1); + EC_WRITE_EL20XX(s_out1, 1, (jiffies >> 1) & 1); + EC_WRITE_EL20XX(s_out1, 2, (jiffies >> 2) & 1); + EC_WRITE_EL20XX(s_out1, 3, (jiffies >> 3) & 1); + EC_WRITE_EL20XX(s_out2, 0, (jiffies >> 4) & 1); + EC_WRITE_EL20XX(s_out2, 1, (jiffies >> 3) & 1); + EC_WRITE_EL20XX(s_out2, 2, (jiffies >> 2) & 1); + EC_WRITE_EL20XX(s_out2, 3, (jiffies >> 6) & 1); + EC_WRITE_EL20XX(s_out3, 0, (jiffies >> 7) & 1); + EC_WRITE_EL20XX(s_out3, 1, (jiffies >> 2) & 1); + EC_WRITE_EL20XX(s_out3, 2, (jiffies >> 8) & 1); counter = MSR_ABTASTFREQUENZ / 4; } - LEC_write_EL20XX(s_out3, 3, LEC_read_EL31XX(s_in1, 0) < 0); + EC_WRITE_EL20XX(s_out3, 3, EC_READ_EL31XX(s_in1, 0) < 0); // Prozessdaten lesen und schreiben EtherCAT_rt_domain_xio(master, 0, 40);