rt/msr_module.c
author Florian Pose <fp@igh-essen.com>
Tue, 12 Jan 2010 23:42:35 +0100
branchkernel2.6
changeset 1767 7993a7c9eadc
parent 36 6e9de6fbf74c
child 38 3213cbbd58b7
permissions -rwxr-xr-x
Closed branch.
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
     1
/**************************************************************************************************
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
     2
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
     3
*                          msr_module.c
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
     4
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
     5
*           Kernelmodul für 2.6 Kernel zur Meßdatenerfassung, Steuerung und Regelung
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
     6
*           Zeitgeber ist der Timerinterrupt (tq)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
     7
*           
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
     8
*           Autor: Wilhelm Hagemeister
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
     9
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    10
*           (C) Copyright IgH 2002
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    11
*           Ingenieurgemeinschaft IgH
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    12
*           Heinz-Bäcker Str. 34
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    13
*           D-45356 Essen
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    14
*           Tel.: +49 201/61 99 31
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    15
*           Fax.: +49 201/61 98 36
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    16
*           E-mail: hm@igh-essen.com
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    17
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    18
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    19
*           $RCSfile: msr_module.c,v $
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    20
*           $Revision: 1.1 $
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    21
*           $Author: hm $
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    22
*           $Date: 2005/11/14 20:32:57 $
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    23
*           $State: Exp $
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    24
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    25
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    26
*           $Log: msr_module.c,v $
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    27
*           Revision 1.1  2005/11/14 20:32:57  hm
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    28
*           Initial revision
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    29
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    30
*           Revision 1.13  2005/06/17 11:35:13  hm
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    31
*           *** empty log message ***
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    32
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    33
*
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
    34
*           Hello Emacs: -*- c-basic-offset: 2; -*-
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    35
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    36
**************************************************************************************************/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    37
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    38
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    39
/*--includes-------------------------------------------------------------------------------------*/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    40
 
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    41
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    42
#ifndef __KERNEL__
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    43
#  define __KERNEL__
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    44
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    45
#ifndef MODULE
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    46
#  define MODULE
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    47
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    48
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    49
#include <linux/config.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    50
#include <linux/module.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    51
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    52
#include <linux/sched.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    53
#include <linux/kernel.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    54
#include <linux/vmalloc.h> 
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    55
#include <linux/fs.h>     /* everything... */
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    56
#include <linux/proc_fs.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    57
#include <linux/time.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    58
#include <linux/timer.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    59
#include <linux/timex.h>  /* fuer get_cycles */
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    60
#include <linux/errno.h>  /* error codes */
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    61
#include <asm/msr.h> /* maschine-specific registers */
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    62
#include <linux/param.h> /* fuer HZ */
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    63
#include <linux/ipipe.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    64
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    65
#include "msr_param.h"   //wird im Projektverzeichnis erwartet
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    66
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    67
//#include <msr_control.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    68
#include <msr_lists.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    69
#include <msr_charbuf.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    70
#include <msr_reg.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    71
#include <msr_error_reg.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    72
#include <msr_messages.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    73
#include <msr_proc.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    74
#include <msr_utils.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    75
#include <msr_main.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    76
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    77
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    78
#include <msr_float.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    79
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    80
#include "../drivers/ec_master.h"
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    81
#include "../drivers/ec_device.h"
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    82
#include "../drivers/ec_types.h"
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    83
#include "../drivers/ec_module.h"
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    84
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    85
#include "msr_jitter.h"
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    86
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    87
MODULE_AUTHOR("Wilhelm Hagemeister, Ingenieurgemeinschaft IgH");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    88
MODULE_LICENSE("GPL");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    89
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    90
/*--external functions---------------------------------------------------------------------------*/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    91
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    92
/*--external data--------------------------------------------------------------------------------*/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    93
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    94
#define HZREDUCTION (MSR_ABTASTFREQUENZ/HZ)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    95
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    96
extern wait_queue_head_t msr_read_waitqueue;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    97
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    98
extern struct msr_char_buf *msr_kanal_puffer;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    99
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   100
extern int proc_abtastfrequenz;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   101
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   102
/*--public data----------------------------------------------------------------------------------*/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   103
/*--local data-----------------------------------------------------------------------------------*/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   104
//struct timer_list timer;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   105
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   106
extern struct timeval process_time;           
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   107
struct timeval msr_time_increment;                    // Increment per Interrupt
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   108
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   109
//adeos
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   110
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   111
static struct ipipe_domain this_domain;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   112
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   113
static struct ipipe_sysinfo sys_info;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   114
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   115
static EtherCAT_master_t *ecat_master = NULL;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   116
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   117
static EtherCAT_slave_t ecat_slaves[] =
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   118
{
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   119
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   120
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   121
#if 1
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   122
    // Block 1
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   123
    ECAT_INIT_SLAVE(Beckhoff_EK1100),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   124
    ECAT_INIT_SLAVE(Beckhoff_EL4102),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   125
    ECAT_INIT_SLAVE(Beckhoff_EL1014),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   126
    ECAT_INIT_SLAVE(Beckhoff_EL3162),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   127
    ECAT_INIT_SLAVE(Beckhoff_EL2004),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   128
    ECAT_INIT_SLAVE(Beckhoff_EL3102),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   129
    ECAT_INIT_SLAVE(Beckhoff_EL2004),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   130
    ECAT_INIT_SLAVE(Beckhoff_EL2004),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   131
    ECAT_INIT_SLAVE(Beckhoff_EL2004),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   132
    ECAT_INIT_SLAVE(Beckhoff_EL2004),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   133
    ECAT_INIT_SLAVE(Beckhoff_EL2004),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   134
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   135
    // Block 2
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   136
    ECAT_INIT_SLAVE(Beckhoff_EK1100),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   137
    ECAT_INIT_SLAVE(Beckhoff_EL1014),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   138
    ECAT_INIT_SLAVE(Beckhoff_EL1014),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   139
    ECAT_INIT_SLAVE(Beckhoff_EL1014),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   140
    ECAT_INIT_SLAVE(Beckhoff_EL1014),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   141
    ECAT_INIT_SLAVE(Beckhoff_EL1014),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   142
    ECAT_INIT_SLAVE(Beckhoff_EL2004),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   143
    ECAT_INIT_SLAVE(Beckhoff_EL2004),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   144
    ECAT_INIT_SLAVE(Beckhoff_EL2004),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   145
    ECAT_INIT_SLAVE(Beckhoff_EL2004),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   146
    ECAT_INIT_SLAVE(Beckhoff_EL1014),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   147
    ECAT_INIT_SLAVE(Beckhoff_EL1014),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   148
    ECAT_INIT_SLAVE(Beckhoff_EL1014)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   149
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   150
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   151
#if 1
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   152
    // Block 3
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   153
   ,ECAT_INIT_SLAVE(Beckhoff_EK1100),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   154
    ECAT_INIT_SLAVE(Beckhoff_EL3162),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   155
    ECAT_INIT_SLAVE(Beckhoff_EL3162),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   156
    ECAT_INIT_SLAVE(Beckhoff_EL3162),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   157
    ECAT_INIT_SLAVE(Beckhoff_EL3162),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   158
    ECAT_INIT_SLAVE(Beckhoff_EL3102),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   159
    ECAT_INIT_SLAVE(Beckhoff_EL3102),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   160
    ECAT_INIT_SLAVE(Beckhoff_EL3102),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   161
    ECAT_INIT_SLAVE(Beckhoff_EL3102),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   162
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   163
    ECAT_INIT_SLAVE(Beckhoff_EL4102),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   164
    ECAT_INIT_SLAVE(Beckhoff_EL4102),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   165
    ECAT_INIT_SLAVE(Beckhoff_EL4102),
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   166
    ECAT_INIT_SLAVE(Beckhoff_EL4102),
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   167
    ECAT_INIT_SLAVE(Beckhoff_EL4132)
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   168
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   169
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   170
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   171
};
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   172
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   173
#define ECAT_SLAVES_COUNT (sizeof(ecat_slaves) / sizeof(EtherCAT_slave_t))
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   174
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   175
#define USE_MSR_LIB
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   176
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   177
#ifdef USE_MSR_LIB
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   178
double value;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   179
int dig1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   180
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   181
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   182
/******************************************************************************
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   183
 *
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   184
 * Function: next2004
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   185
 *
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   186
 *****************************************************************************/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   187
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   188
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   189
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   190
static int next2004(int *wrap)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   191
{
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   192
    static int i = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   193
    unsigned int j = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   194
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   195
    *wrap = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   196
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   197
    for (j = 0; j < ECAT_SLAVES_COUNT; j++)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   198
    {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   199
        i++;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   200
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   201
        i %= ECAT_SLAVES_COUNT;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   202
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   203
        if (i == 0) *wrap = 1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   204
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   205
        if (ecat_slaves[i].desc == Beckhoff_EL2004)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   206
        {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   207
            return i;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   208
        }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   209
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   210
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   211
    return -1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   212
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   213
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   214
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   215
/******************************************************************************
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   216
 *
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   217
 * Function: msr_controller_run()
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   218
 *
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   219
 *****************************************************************************/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   220
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   221
static void msr_controller_run(void)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   222
{
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   223
    static int ms = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   224
    static int cnt = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   225
    static unsigned long int k = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   226
    static int firstrun = 1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   227
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   228
    static int klemme = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   229
    static int kanal = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   230
    static int up_down = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   231
    int wrap = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   232
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   233
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   234
    // Prozessdaten lesen
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   235
    msr_jitter_run(MSR_ABTASTFREQUENZ);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   236
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   237
    if (!firstrun)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   238
    {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   239
        EtherCAT_read_process_data(ecat_master);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   240
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   241
        // Daten lesen und skalieren
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   242
#ifdef USE_MSR_LIB
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   243
        value = EtherCAT_read_value(&ecat_master->slaves[5], 0) / 3276.0; 
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   244
        dig1 = EtherCAT_read_value(&ecat_master->slaves[2], 0);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   245
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   246
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   247
    else
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   248
        klemme = next2004(&wrap);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   249
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   250
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   251
    ms++;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   252
    ms %= 1000;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   253
    if (cnt++ > 20)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   254
    {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   255
        cnt = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   256
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   257
        if (++kanal > 3)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   258
        {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   259
            kanal = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   260
            klemme = next2004(&wrap);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   261
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   262
            if (wrap == 1)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   263
            {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   264
                if (up_down == 1) up_down = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   265
                else up_down = 1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   266
            }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   267
        }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   268
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   269
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   270
    if (klemme >= 0) {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   271
        EtherCAT_write_value(&ecat_master->slaves[klemme], kanal,up_down);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   272
	//printk("ECAT write: Klemme: %d, Kanal: %d, Wert: %d\n",klemme,kanal,up_down); 
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   273
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   274
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   275
#if 0
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   276
    EtherCAT_write_value(&ecat_master->slaves[13], 1, ms > 500 ? 0 : 1);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   277
    EtherCAT_write_value(&ecat_master->slaves[14], 2, ms > 500 ? 0 : 1);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   278
    EtherCAT_write_value(&ecat_master->slaves[15], 3, ms > 500 ? 1 : 0);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   279
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   280
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   281
    // Prozessdaten schreiben
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   282
    rdtscl(k);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   283
    EtherCAT_write_process_data(ecat_master);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   284
    firstrun = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   285
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   286
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   287
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   288
/*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   289
***************************************************************************************************
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   290
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   291
* Function: msr_run(_interrupt)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   292
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   293
* Beschreibung: Routine wird zyklisch im Timerinterrupt ausgeführt
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   294
*               (hier muß alles rein, was Echtzeit ist ...)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   295
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   296
* Parameter: Zeiger auf msr_data
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   297
*
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   298
* Rückgabe:
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   299
*
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   300
* Status: exp
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   301
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   302
***************************************************************************************************
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   303
*/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   304
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   305
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   306
void msr_run(unsigned irq)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   307
{
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   308
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   309
  static int counter = 0;
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   310
#ifdef USE_MSR_LIB
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   311
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   312
    timeval_add(&process_time,&process_time,&msr_time_increment);
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   313
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   314
    MSR_ADEOS_INTERRUPT_CODE(
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   315
	msr_controller_run();
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   316
	msr_write_kanal_list();
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   317
	);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   318
#else
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   319
    msr_controller_run();
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   320
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   321
    /* und wieder in die Timerliste eintragen */
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   322
    /* und neu in die Taskqueue eintragen */
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   323
//    timer.expires += 1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   324
//    add_timer(&timer);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   325
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   326
    ipipe_control_irq(irq,0,IPIPE_ENABLE_MASK);  //nicht weiterreichen
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   327
    if(counter++ > HZREDUCTION) {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   328
	ipipe_propagate_irq(irq);  //wie lange braucht der Rest der Pipeline ??
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   329
	counter = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   330
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   331
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   332
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   333
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   334
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   335
void domain_entry (int iflag) {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   336
    printk("Domain %s started.\n",	ipipe_current_domain->name);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   337
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   338
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   339
    ipipe_get_sysinfo(&sys_info);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   340
    ipipe_virtualize_irq(ipipe_current_domain,sys_info.archdep.tmirq,
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   341
			 &msr_run, NULL, IPIPE_HANDLE_MASK);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   342
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   343
    ipipe_tune_timer(1000000000UL/MSR_ABTASTFREQUENZ,0); 
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   344
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   345
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   346
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   347
/*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   348
*******************************************************************************
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   349
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   350
* Function: msr_register_channels
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   351
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   352
* Beschreibung: KanŽäle registrieren
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   353
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   354
* Parameter:
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   355
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   356
* RŽückgabe: 
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   357
*               
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   358
* Status: exp
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   359
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   360
*******************************************************************************
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   361
*/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   362
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   363
int msr_globals_register(void)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   364
{
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   365
#ifdef USE_MSR_LIB
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   366
    msr_reg_kanal("/value", "V", &value, TDBL);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   367
    msr_reg_kanal("/dig1", "", &dig1, TINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   368
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   369
/*  msr_reg_kanal("/Taskinfo/Ecat/TX-Delay","us",&ecat_tx_delay,TUINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   370
  msr_reg_kanal("/Taskinfo/Ecat/RX-Delay","us",&ecat_rx_delay,TUINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   371
  msr_reg_kanal("/Taskinfo/Ecat/TX-Cnt","",&tx_intr,TUINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   372
  msr_reg_kanal("/Taskinfo/Ecat/RX-Cnt","",&rx_intr,TUINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   373
  msr_reg_kanal("/Taskinfo/Ecat/Total-Cnt","",&total_intr,TUINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   374
*/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   375
  return 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   376
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   377
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   378
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   379
/****************************************************************************************************
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   380
 * the init/clean material
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   381
 ****************************************************************************************************/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   382
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   383
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   384
int __init init_module()
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   385
{
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   386
    struct ipipe_domain_attr attr; //ipipe
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   387
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   388
    // Als allererstes die RT-lib initialisieren
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   389
#ifdef USE_MSR_LIB
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   390
    if (msr_rtlib_init(1,MSR_ABTASTFREQUENZ,10,&msr_globals_register) < 0) {
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   391
        msr_print_warn("msr_modul: can't initialize rtlib!");
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   392
        goto out_return;
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   393
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   394
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   395
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   396
    msr_jitter_init();
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   397
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   398
    printk(KERN_INFO "=== Starting EtherCAT environment... ===\n");
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   399
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   400
    if ((ecat_master = EtherCAT_request(0)) == NULL) {
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   401
        printk(KERN_ERR "EtherCAT master 0 not available!\n");
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   402
        goto out_msr_cleanup;
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   403
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   404
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   405
    printk("Checking EtherCAT slaves.\n");
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   406
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   407
    if (EtherCAT_check_slaves(ecat_master, ecat_slaves, ECAT_SLAVES_COUNT) != 0) {
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   408
        printk(KERN_ERR "EtherCAT: Could not init slaves!\n");
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   409
        goto out_release_master;
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   410
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   411
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   412
    printk("Activating all EtherCAT slaves.\n");
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   413
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   414
    if (EtherCAT_activate_all_slaves(ecat_master) != 0) {
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   415
        printk(KERN_ERR "EtherCAT: Could not activate slaves!\n");
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   416
        goto out_release_master;
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   417
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   418
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   419
    do_gettimeofday(&process_time);
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   420
    msr_time_increment.tv_sec=0;
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   421
    msr_time_increment.tv_usec=(unsigned int)(1000000/MSR_ABTASTFREQUENZ);
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   422
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   423
    ipipe_init_attr (&attr);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   424
    attr.name     = "IPIPE-MSR-MODULE";
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   425
    attr.priority = IPIPE_ROOT_PRIO + 1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   426
    attr.entry    = &domain_entry;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   427
    ipipe_register_domain(&this_domain,&attr);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   428
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   429
    return 0;
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   430
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   431
 out_release_master:
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   432
    EtherCAT_release(ecat_master);
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   433
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   434
 out_msr_cleanup:
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   435
    msr_rtlib_cleanup();
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   436
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   437
 out_return:
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   438
    return -1;
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   439
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   440
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   441
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   442
//****************************************************************************
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   443
void __exit cleanup_module()
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   444
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   445
{
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   446
    msr_print_info("msk_modul: unloading...");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   447
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   448
    ipipe_tune_timer(1000000000UL/HZ,0); //alten Timertakt wieder herstellen
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   449
    ipipe_unregister_domain(&this_domain);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   450
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   451
    printk(KERN_INFO "=== Stopping EtherCAT environment... ===\n");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   452
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   453
    if (ecat_master)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   454
    {
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   455
        EtherCAT_clear_process_data(ecat_master);
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   456
        printk(KERN_INFO "Deactivating slaves.\n");
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   457
        EtherCAT_deactivate_all_slaves(ecat_master);
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   458
        EtherCAT_release(ecat_master);
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   459
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   460
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   461
    printk(KERN_INFO "=== EtherCAT environment stopped. ===\n");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   462
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   463
#ifdef USE_MSR_LIB
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   464
    msr_rtlib_cleanup();
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   465
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   466
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   467
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   468
MODULE_LICENSE("GPL");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   469
MODULE_AUTHOR ("Wilhelm Hagemeister <hm@igh-essen.com>");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   470
MODULE_DESCRIPTION ("EtherCAT test environment");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   471
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   472
module_init(init_module);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   473
module_exit(cleanup_module);
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   474
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   475
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   476
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   477
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   478
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   479
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   480
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   481
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   482
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   483
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   484
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   485
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   486
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   487
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   488
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   489