rt/msr_module.c
author Florian Pose <fp@igh-essen.com>
Fri, 23 Dec 2005 08:23:35 +0000
changeset 41 42c66194c0c8
parent 40 d07ebafe62dd
child 42 a22a202d0f42
permissions -rwxr-xr-x
Schoenheitskorrekturen.
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_EL4102),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   162
    ECAT_INIT_SLAVE(Beckhoff_EL4102),
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   163
    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
   164
    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
   165
    ECAT_INIT_SLAVE(Beckhoff_EL4132)
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   166
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   167
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   168
#endif
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
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   171
#define ECAT_SLAVES_COUNT (sizeof(ecat_slaves) / sizeof(EtherCAT_slave_t))
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 USE_MSR_LIB
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
#ifdef USE_MSR_LIB
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   176
double value;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   177
int dig1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   178
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   179
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   180
/******************************************************************************
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
 * Function: next2004
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
 *****************************************************************************/
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
static int next2004(int *wrap)
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 i = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   191
    unsigned int j = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   192
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   193
    *wrap = 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
    for (j = 0; j < ECAT_SLAVES_COUNT; j++)
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
        i++;
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 %= ECAT_SLAVES_COUNT;
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
        if (i == 0) *wrap = 1;
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 (ecat_slaves[i].desc == Beckhoff_EL2004)
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
            return i;
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
    }
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
    return -1;
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
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
 * Function: msr_controller_run()
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
 *****************************************************************************/
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
static void msr_controller_run(void)
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 int ms = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   222
    static int cnt = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   223
    static unsigned long int k = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   224
    static int firstrun = 1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   225
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   226
    static int klemme = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   227
    static int kanal = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   228
    static int up_down = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   229
    int wrap = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   230
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   231
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   232
    // Prozessdaten lesen
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   233
    msr_jitter_run(MSR_ABTASTFREQUENZ);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   234
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   235
    if (!firstrun)
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
        EtherCAT_read_process_data(ecat_master);
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
        // Daten lesen und skalieren
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   240
#ifdef USE_MSR_LIB
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   241
        value = EtherCAT_read_value(&ecat_master->slaves[5], 0) / 3276.0; 
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   242
        dig1 = EtherCAT_read_value(&ecat_master->slaves[2], 0);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   243
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   244
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   245
    else
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   246
        klemme = next2004(&wrap);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   247
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   248
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   249
    ms++;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   250
    ms %= 1000;
40
d07ebafe62dd 20kHz, Wilhelm
Florian Pose <fp@igh-essen.com>
parents: 38
diff changeset
   251
    if (cnt++ > 200)
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   252
    {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   253
        cnt = 0;
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
        if (++kanal > 3)
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
            kanal = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   258
            klemme = next2004(&wrap);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   259
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   260
            if (wrap == 1)
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 (up_down == 1) up_down = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   263
                else up_down = 1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   264
            }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   265
        }
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
    if (klemme >= 0) {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   269
        EtherCAT_write_value(&ecat_master->slaves[klemme], kanal,up_down);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   270
	//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
   271
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   272
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   273
#if 0
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   274
    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
   275
    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
   276
    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
   277
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   278
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   279
    // Prozessdaten schreiben
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   280
    rdtscl(k);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   281
    EtherCAT_write_process_data(ecat_master);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   282
    firstrun = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   283
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   284
}
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
* Function: msr_run(_interrupt)
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
* Beschreibung: Routine wird zyklisch im Timerinterrupt ausgeführt
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   292
*               (hier muß alles rein, was Echtzeit ist ...)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   293
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   294
* Parameter: Zeiger auf msr_data
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   295
*
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   296
* Rückgabe:
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   297
*
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   298
* Status: exp
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   299
*
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   300
***************************************************************************************************
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
void msr_run(unsigned irq)
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
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   307
  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
   308
#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
   309
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   310
    timeval_add(&process_time,&process_time,&msr_time_increment);
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   311
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   312
    MSR_ADEOS_INTERRUPT_CODE(
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   313
	msr_controller_run();
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   314
	msr_write_kanal_list();
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   315
	);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   316
#else
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   317
    msr_controller_run();
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   318
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   319
    /* 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
   320
    /* und neu in die Taskqueue eintragen */
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   321
//    timer.expires += 1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   322
//    add_timer(&timer);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   323
40
d07ebafe62dd 20kHz, Wilhelm
Florian Pose <fp@igh-essen.com>
parents: 38
diff changeset
   324
    ipipe_control_irq(irq,0,IPIPE_ENABLE_MASK);  //Interrupt bestŽätigen
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   325
    if(counter++ > HZREDUCTION) {
40
d07ebafe62dd 20kHz, Wilhelm
Florian Pose <fp@igh-essen.com>
parents: 38
diff changeset
   326
	ipipe_propagate_irq(irq);  //und weiterreichen
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   327
	counter = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   328
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   329
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
40
d07ebafe62dd 20kHz, Wilhelm
Florian Pose <fp@igh-essen.com>
parents: 38
diff changeset
   333
void domain_entry (void) {
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   334
    printk("Domain %s started.\n",	ipipe_current_domain->name);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   335
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   336
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   337
    ipipe_get_sysinfo(&sys_info);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   338
    ipipe_virtualize_irq(ipipe_current_domain,sys_info.archdep.tmirq,
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   339
			 &msr_run, NULL, IPIPE_HANDLE_MASK);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   340
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   341
    ipipe_tune_timer(1000000000UL/MSR_ABTASTFREQUENZ,0); 
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
}
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
* Function: msr_register_channels
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
* Beschreibung: KanŽäle registrieren
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
* Parameter:
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
* RŽückgabe: 
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
* Status: exp
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
*******************************************************************************
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
int msr_globals_register(void)
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
#ifdef USE_MSR_LIB
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   364
    msr_reg_kanal("/value", "V", &value, TDBL);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   365
    msr_reg_kanal("/dig1", "", &dig1, TINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   366
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   367
/*  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
   368
  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
   369
  msr_reg_kanal("/Taskinfo/Ecat/TX-Cnt","",&tx_intr,TUINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   370
  msr_reg_kanal("/Taskinfo/Ecat/RX-Cnt","",&rx_intr,TUINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   371
  msr_reg_kanal("/Taskinfo/Ecat/Total-Cnt","",&total_intr,TUINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   372
*/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   373
  return 0;
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
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
 * the init/clean material
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
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
int __init init_module()
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
    struct ipipe_domain_attr attr; //ipipe
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   385
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   386
    // 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
   387
#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
   388
    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
   389
        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
   390
        goto out_return;
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   391
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   392
#endif
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
    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
   395
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   396
    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
   397
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   398
    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
   399
        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
   400
        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
   401
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   402
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   403
    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
   404
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   405
    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
   406
        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
   407
        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
   408
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   409
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   410
    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
   411
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   412
    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
   413
        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
   414
        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
   415
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   416
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   417
    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
   418
    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
   419
    msr_time_increment.tv_usec=(unsigned int)(1000000/MSR_ABTASTFREQUENZ);
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   420
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   421
    ipipe_init_attr (&attr);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   422
    attr.name     = "IPIPE-MSR-MODULE";
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   423
    attr.priority = IPIPE_ROOT_PRIO + 1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   424
    attr.entry    = &domain_entry;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   425
    ipipe_register_domain(&this_domain,&attr);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   426
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   427
    return 0;
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   428
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   429
 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
   430
    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
   431
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   432
 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
   433
    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
   434
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   435
 out_return:
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   436
    return -1;
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   437
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   438
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
void __exit cleanup_module()
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
{
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   444
    msr_print_info("msk_modul: unloading...");
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
    ipipe_tune_timer(1000000000UL/HZ,0); //alten Timertakt wieder herstellen
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   447
    ipipe_unregister_domain(&this_domain);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   448
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   449
    printk(KERN_INFO "=== Stopping EtherCAT environment... ===\n");
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
    if (ecat_master)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   452
    {
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   453
        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
   454
        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
   455
        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
   456
        EtherCAT_release(ecat_master);
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   457
    }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   458
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   459
    printk(KERN_INFO "=== EtherCAT environment stopped. ===\n");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   460
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   461
#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
   462
    msr_rtlib_cleanup();
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   463
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   464
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   465
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   466
MODULE_LICENSE("GPL");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   467
MODULE_AUTHOR ("Wilhelm Hagemeister <hm@igh-essen.com>");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   468
MODULE_DESCRIPTION ("EtherCAT test environment");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   469
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   470
module_init(init_module);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   471
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
   472
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   473
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