Skip to content
Snippets Groups Projects
Commit d8ce4abb authored by Florian Pose's avatar Florian Pose
Browse files

Neue Schnittstellen in Mini übertragen.

parent 634b016a
No related branches found
No related tags found
No related merge requests found
...@@ -13,17 +13,12 @@ ...@@ -13,17 +13,12 @@
#include <linux/timer.h> #include <linux/timer.h>
#include "../include/EtherCAT_rt.h" #include "../include/EtherCAT_rt.h"
#include "../include/EtherCAT_si.h"
/*****************************************************************************/
// Auskommentieren, wenn keine zyklischen Daten erwuenscht
#define ECAT_CYCLIC_DATA
/*****************************************************************************/ /*****************************************************************************/
ec_master_t *master = NULL; ec_master_t *master = NULL;
ec_slave_t *s_in, *s_out;
#ifdef ECAT_CYCLIC_DATA
int value; int value;
int dig1; int dig1;
...@@ -31,31 +26,28 @@ int dig1; ...@@ -31,31 +26,28 @@ int dig1;
struct timer_list timer; struct timer_list timer;
unsigned long last_start_jiffies; unsigned long last_start_jiffies;
#endif // ECAT_CYCLIC_DATA /*****************************************************************************/
/****************************************************************************** int __init check_slaves(void)
* {
* Function: run s_in = EtherCAT_rt_register_slave(master, 1, "Beckhoff", "EL3102", 1);
* s_out = EtherCAT_rt_register_slave(master, 9, "Beckhoff", "EL2004", 1);
* Beschreibung: Zyklischer Prozess
*
*****************************************************************************/
#ifdef ECAT_CYCLIC_DATA return s_in && s_out;
}
/*****************************************************************************/
static void run(unsigned long data) void run(unsigned long data)
{ {
static int ms = 0; static int ms = 0;
static unsigned long int k = 0; static unsigned long int k = 0;
static int firstrun = 1; static int firstrun = 1;
ms++; ms++;
ms %= 1000; ms %= 1000;
#if 0 EC_WRITE_EL20XX(s_out, 3, EC_READ_EL31XX(s_in, 0) < 0);
if (klemme >= 0)
EtherCAT_write_value(&ecat_slaves[klemme], kanal, up_down);
#endif
// Prozessdaten lesen und schreiben // Prozessdaten lesen und schreiben
rdtscl(k); rdtscl(k);
...@@ -66,13 +58,7 @@ static void run(unsigned long data) ...@@ -66,13 +58,7 @@ static void run(unsigned long data)
add_timer(&timer); add_timer(&timer);
} }
#endif // ECAT_CYCLIC_DATA /*****************************************************************************/
/******************************************************************************
*
* Function: init
*
*****************************************************************************/
int __init init_mini_module(void) int __init init_mini_module(void)
{ {
...@@ -83,7 +69,10 @@ int __init init_mini_module(void) ...@@ -83,7 +69,10 @@ int __init init_mini_module(void)
goto out_return; goto out_return;
} }
//check_slaves(); if (!check_slaves()) {
printk(KERN_ERR "Could not register slaves!\n");
goto out_release_master;
}
printk("Activating all EtherCAT slaves.\n"); printk("Activating all EtherCAT slaves.\n");
...@@ -92,19 +81,17 @@ int __init init_mini_module(void) ...@@ -92,19 +81,17 @@ int __init init_mini_module(void)
goto out_release_master; goto out_release_master;
} }
#ifdef ECAT_CYCLIC_DATA
printk("Starting cyclic sample thread.\n"); printk("Starting cyclic sample thread.\n");
init_timer(&timer); init_timer(&timer);
timer.function = run; timer.function = run;
timer.data = 0; timer.data = 0;
timer.expires = jiffies+10; // Das erste Mal sofort feuern timer.expires = jiffies + 10; // Das erste Mal sofort feuern
last_start_jiffies = timer.expires; last_start_jiffies = timer.expires;
add_timer(&timer); add_timer(&timer);
printk("Initialised sample thread.\n"); printk("Initialised sample thread.\n");
#endif
printk(KERN_INFO "=== Minimal EtherCAT environment started. ===\n"); printk(KERN_INFO "=== Minimal EtherCAT environment started. ===\n");
...@@ -117,11 +104,7 @@ int __init init_mini_module(void) ...@@ -117,11 +104,7 @@ int __init init_mini_module(void)
return -1; return -1;
} }
/****************************************************************************** /*****************************************************************************/
*
* Function: cleanup
*
*****************************************************************************/
void __exit cleanup_mini_module(void) void __exit cleanup_mini_module(void)
{ {
...@@ -129,9 +112,7 @@ void __exit cleanup_mini_module(void) ...@@ -129,9 +112,7 @@ void __exit cleanup_mini_module(void)
if (master) if (master)
{ {
#ifdef ECAT_CYCLIC_DATA
del_timer_sync(&timer); del_timer_sync(&timer);
#endif // ECAT_CYCLIC_DATA
printk(KERN_INFO "Deactivating slaves.\n"); printk(KERN_INFO "Deactivating slaves.\n");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment