Neue Schnittstellen in Mini übertragen.
This commit is contained in:
parent
1a78254c0d
commit
152b545aaa
65
mini/mini.c
65
mini/mini.c
|
|
@ -13,17 +13,12 @@
|
|||
#include <linux/timer.h>
|
||||
|
||||
#include "../include/EtherCAT_rt.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
// Auskommentieren, wenn keine zyklischen Daten erwuenscht
|
||||
#define ECAT_CYCLIC_DATA
|
||||
#include "../include/EtherCAT_si.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
ec_master_t *master = NULL;
|
||||
|
||||
#ifdef ECAT_CYCLIC_DATA
|
||||
ec_slave_t *s_in, *s_out;
|
||||
|
||||
int value;
|
||||
int dig1;
|
||||
|
|
@ -31,31 +26,28 @@ int dig1;
|
|||
struct timer_list timer;
|
||||
unsigned long last_start_jiffies;
|
||||
|
||||
#endif // ECAT_CYCLIC_DATA
|
||||
/*****************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Function: run
|
||||
*
|
||||
* Beschreibung: Zyklischer Prozess
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef ECAT_CYCLIC_DATA
|
||||
|
||||
static void run(unsigned long data)
|
||||
int __init check_slaves(void)
|
||||
{
|
||||
static int ms = 0;
|
||||
s_in = EtherCAT_rt_register_slave(master, 1, "Beckhoff", "EL3102", 1);
|
||||
s_out = EtherCAT_rt_register_slave(master, 9, "Beckhoff", "EL2004", 1);
|
||||
|
||||
return s_in && s_out;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
void run(unsigned long data)
|
||||
{
|
||||
static int ms = 0;
|
||||
static unsigned long int k = 0;
|
||||
static int firstrun = 1;
|
||||
|
||||
ms++;
|
||||
ms %= 1000;
|
||||
|
||||
#if 0
|
||||
if (klemme >= 0)
|
||||
EtherCAT_write_value(&ecat_slaves[klemme], kanal, up_down);
|
||||
#endif
|
||||
EC_WRITE_EL20XX(s_out, 3, EC_READ_EL31XX(s_in, 0) < 0);
|
||||
|
||||
// Prozessdaten lesen und schreiben
|
||||
rdtscl(k);
|
||||
|
|
@ -66,13 +58,7 @@ static void run(unsigned long data)
|
|||
add_timer(&timer);
|
||||
}
|
||||
|
||||
#endif // ECAT_CYCLIC_DATA
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Function: init
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
int __init init_mini_module(void)
|
||||
{
|
||||
|
|
@ -83,7 +69,10 @@ int __init init_mini_module(void)
|
|||
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");
|
||||
|
||||
|
|
@ -92,19 +81,17 @@ int __init init_mini_module(void)
|
|||
goto out_release_master;
|
||||
}
|
||||
|
||||
#ifdef ECAT_CYCLIC_DATA
|
||||
printk("Starting cyclic sample thread.\n");
|
||||
|
||||
init_timer(&timer);
|
||||
|
||||
timer.function = run;
|
||||
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;
|
||||
add_timer(&timer);
|
||||
|
||||
printk("Initialised sample thread.\n");
|
||||
#endif
|
||||
|
||||
printk(KERN_INFO "=== Minimal EtherCAT environment started. ===\n");
|
||||
|
||||
|
|
@ -117,11 +104,7 @@ int __init init_mini_module(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* Function: cleanup
|
||||
*
|
||||
*****************************************************************************/
|
||||
/*****************************************************************************/
|
||||
|
||||
void __exit cleanup_mini_module(void)
|
||||
{
|
||||
|
|
@ -129,9 +112,7 @@ void __exit cleanup_mini_module(void)
|
|||
|
||||
if (master)
|
||||
{
|
||||
#ifdef ECAT_CYCLIC_DATA
|
||||
del_timer_sync(&timer);
|
||||
#endif // ECAT_CYCLIC_DATA
|
||||
|
||||
printk(KERN_INFO "Deactivating slaves.\n");
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue