equal
deleted
inserted
replaced
10 |
10 |
11 #include <linux/module.h> |
11 #include <linux/module.h> |
12 #include <linux/delay.h> |
12 #include <linux/delay.h> |
13 #include <linux/timer.h> |
13 #include <linux/timer.h> |
14 |
14 |
15 #include "../include/EtherCAT_rt.h" |
15 #include "../include/EtherCAT_rt.h" // Echtzeitschnittstelle |
16 #include "../include/EtherCAT_si.h" |
16 #include "../include/EtherCAT_si.h" // Slave-Interface-Makros |
17 |
17 |
18 /*****************************************************************************/ |
18 /*****************************************************************************/ |
19 |
19 |
20 ec_master_t *master = NULL; |
20 ec_master_t *master = NULL; |
21 ec_slave_t *s_in, *s_out; |
21 ec_slave_t *s_in, *s_out; |
24 int dig1; |
24 int dig1; |
25 |
25 |
26 struct timer_list timer; |
26 struct timer_list timer; |
27 unsigned long last_start_jiffies; |
27 unsigned long last_start_jiffies; |
28 |
28 |
29 /*****************************************************************************/ |
29 ec_slave_init_t slaves[] = { |
|
30 // Zeiger, Index, Herstellername, Produktname, Domäne |
|
31 { &s_out, 9, "Beckhoff", "EL2004", 1 }, |
|
32 { &s_in, 1, "Beckhoff", "EL3102", 1 } |
|
33 }; |
30 |
34 |
31 int __init check_slaves(void) |
35 #define SLAVE_COUNT (sizeof(slaves) / sizeof(ec_slave_init_t)) |
32 { |
|
33 s_in = EtherCAT_rt_register_slave(master, 1, "Beckhoff", "EL3102", 1); |
|
34 s_out = EtherCAT_rt_register_slave(master, 9, "Beckhoff", "EL2004", 1); |
|
35 |
|
36 return s_in && s_out; |
|
37 } |
|
38 |
36 |
39 /*****************************************************************************/ |
37 /*****************************************************************************/ |
40 |
38 |
41 void run(unsigned long data) |
39 void run(unsigned long data) |
42 { |
40 { |
67 if ((master = EtherCAT_rt_request_master(0)) == NULL) { |
65 if ((master = EtherCAT_rt_request_master(0)) == NULL) { |
68 printk(KERN_ERR "EtherCAT master 0 not available!\n"); |
66 printk(KERN_ERR "EtherCAT master 0 not available!\n"); |
69 goto out_return; |
67 goto out_return; |
70 } |
68 } |
71 |
69 |
72 if (!check_slaves()) { |
70 //EtherCAT_rt_debug_level(master, 2); |
|
71 |
|
72 if (EtherCAT_rt_register_slave_list(master, slaves, SLAVE_COUNT)) { |
73 printk(KERN_ERR "Could not register slaves!\n"); |
73 printk(KERN_ERR "Could not register slaves!\n"); |
74 goto out_release_master; |
74 goto out_release_master; |
75 } |
75 } |
76 |
76 |
77 printk("Activating all EtherCAT slaves.\n"); |
77 printk("Activating all EtherCAT slaves.\n"); |
78 |
78 |
79 if (EtherCAT_rt_activate_slaves(master) != 0) { |
79 if (EtherCAT_rt_activate_slaves(master)) { |
80 printk(KERN_ERR "EtherCAT: Could not activate slaves!\n"); |
80 printk(KERN_ERR "EtherCAT: Could not activate slaves!\n"); |
81 goto out_release_master; |
81 goto out_release_master; |
82 } |
82 } |
83 |
83 |
84 printk("Starting cyclic sample thread.\n"); |
84 printk("Starting cyclic sample thread.\n"); |