examples/mini/mini.c
changeset 909 3b3087d4cdc5
parent 880 f6212c54a5e3
child 1022 8e49b519e6ba
equal deleted inserted replaced
908:386b908033be 909:3b3087d4cdc5
    35 #include <linux/timer.h>
    35 #include <linux/timer.h>
    36 #include <linux/spinlock.h>
    36 #include <linux/spinlock.h>
    37 #include <linux/interrupt.h>
    37 #include <linux/interrupt.h>
    38 
    38 
    39 #include "../../include/ecrt.h" // EtherCAT realtime interface
    39 #include "../../include/ecrt.h" // EtherCAT realtime interface
    40 #include "../../include/ecdb.h" // EtherCAT slave database
       
    41 
    40 
    42 /*****************************************************************************/
    41 /*****************************************************************************/
    43 
    42 
    44 // Module parameters
    43 // Module parameters
    45 #define FREQUENCY 100
    44 #define FREQUENCY 100
    71 
    70 
    72 static unsigned int off_ana_in; // offsets for Pdo entries
    71 static unsigned int off_ana_in; // offsets for Pdo entries
    73 static unsigned int off_dig_out;
    72 static unsigned int off_dig_out;
    74 
    73 
    75 static unsigned int blink = 0;
    74 static unsigned int blink = 0;
       
    75 
       
    76 #define Beckhoff_EL2004 0x00000002, 0x07D43052
       
    77 #define Beckhoff_EL3162 0x00000002, 0x0C5A3052
    76 
    78 
    77 const static ec_pdo_entry_reg_t domain1_regs[] = {
    79 const static ec_pdo_entry_reg_t domain1_regs[] = {
    78     {0, 1, Beckhoff_EL3162, 0x3101, 2, &off_ana_in},
    80     {0, 1, Beckhoff_EL3162, 0x3101, 2, &off_ana_in},
    79     {0, 3, Beckhoff_EL2004, 0x3001, 1, &off_dig_out},
    81     {0, 3, Beckhoff_EL2004, 0x3001, 1, &off_dig_out},
    80     {}
    82     {}
   146 
   148 
   147     spin_lock(&master_lock);
   149     spin_lock(&master_lock);
   148     ecrt_master_state(master, &ms);
   150     ecrt_master_state(master, &ms);
   149     spin_unlock(&master_lock);
   151     spin_unlock(&master_lock);
   150 
   152 
   151     if (ms.bus_state != master_state.bus_state) {
       
   152         printk(KERN_INFO PFX "bus state changed to %i.\n", ms.bus_state);
       
   153     }
       
   154     if (ms.bus_tainted != master_state.bus_tainted) {
       
   155         printk(KERN_INFO PFX "tainted flag changed to %u.\n",
       
   156                 ms.bus_tainted);
       
   157     }
       
   158     if (ms.slaves_responding != master_state.slaves_responding) {
   153     if (ms.slaves_responding != master_state.slaves_responding) {
   159         printk(KERN_INFO PFX "slaves_responding changed to %u.\n",
   154         printk(KERN_INFO PFX "slaves_responding changed to %u.\n",
   160                 ms.slaves_responding);
   155                 ms.slaves_responding);
   161     }
   156     }
   162 
   157