rt/msr_module.c
author Florian Pose <fp@igh-essen.com>
Thu, 05 Jan 2006 14:13:34 +0000
changeset 44 68d5b57cf038
parent 43 35120a61d55e
child 45 f525f7db2d90
permissions -rw-r--r--
TODO-Liste erg?nzt.
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
     1
/******************************************************************************
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
     2
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
     3
 *  msr_module.c
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
     4
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
     5
 *  Kernelmodul für 2.6 Kernel zur Meßdatenerfassung, Steuerung und Regelung.
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
     6
 *  Zeitgeber ist der Timerinterrupt (tq)
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
     7
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
     8
 *  Autor: Wilhelm Hagemeister
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
     9
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    10
 *  (C) Copyright IgH 2002
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    11
 *  Ingenieurgemeinschaft IgH
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    12
 *  Heinz-Bäcker Str. 34
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    13
 *  D-45356 Essen
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    14
 *  Tel.: +49 201/61 99 31
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    15
 *  Fax.: +49 201/61 98 36
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    16
 *  E-mail: hm@igh-essen.com
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    17
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    18
 *  $Id$
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    19
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    20
 *****************************************************************************/
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    21
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    22
#ifndef __KERNEL__
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    23
#  define __KERNEL__
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    24
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    25
#ifndef MODULE
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    26
#  define MODULE
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    27
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    29
#include <linux/config.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    30
#include <linux/module.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    31
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    32
#include <linux/sched.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    33
#include <linux/kernel.h>
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    34
#include <linux/vmalloc.h>
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    35
#include <linux/fs.h>     /* everything... */
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    36
#include <linux/proc_fs.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    37
#include <linux/time.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    38
#include <linux/timer.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    39
#include <linux/timex.h>  /* fuer get_cycles */
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    40
#include <linux/errno.h>  /* error codes */
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    41
#include <asm/msr.h> /* maschine-specific registers */
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    42
#include <linux/param.h> /* fuer HZ */
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    43
#include <linux/ipipe.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    44
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    45
#include "msr_param.h"   //wird im Projektverzeichnis erwartet
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    46
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    47
//#include <msr_control.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    48
#include <msr_lists.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    49
#include <msr_charbuf.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    50
#include <msr_reg.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    51
#include <msr_error_reg.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    52
#include <msr_messages.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    53
#include <msr_proc.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    54
#include <msr_utils.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    55
#include <msr_main.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    56
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    57
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    58
#include <msr_float.h>
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    59
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    60
#include "../drivers/ec_master.h"
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    61
#include "../drivers/ec_device.h"
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    62
#include "../drivers/ec_types.h"
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    63
#include "../drivers/ec_module.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_jitter.h"
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    66
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    67
#define TSC2US(T) ((unsigned long) (T) * 1000UL / cpu_khz)
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    68
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    69
/*--external data------------------------------------------------------------*/
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    70
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    71
#define HZREDUCTION (MSR_ABTASTFREQUENZ/HZ)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    72
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    73
extern wait_queue_head_t msr_read_waitqueue;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    74
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    75
extern struct msr_char_buf *msr_kanal_puffer;
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
extern int proc_abtastfrequenz;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    78
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    79
/*--local data---------------------------------------------------------------*/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    80
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    81
extern struct timeval process_time;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    82
struct timeval msr_time_increment; // Increment per Interrupt
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    83
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    84
//adeos
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    85
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    86
static struct ipipe_domain this_domain;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    87
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    88
static struct ipipe_sysinfo sys_info;
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
static EtherCAT_master_t *ecat_master = NULL;
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
static EtherCAT_slave_t ecat_slaves[] =
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
#if 1
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
    95
    // Block 1
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    96
    ECAT_INIT_SLAVE(Beckhoff_EK1100, 0),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    97
    ECAT_INIT_SLAVE(Beckhoff_EL4102, 0),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    98
    ECAT_INIT_SLAVE(Beckhoff_EL1014, 0),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
    99
    ECAT_INIT_SLAVE(Beckhoff_EL3162, 0),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   100
    ECAT_INIT_SLAVE(Beckhoff_EL2004, 0),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   101
    ECAT_INIT_SLAVE(Beckhoff_EL3102, 0),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   102
    ECAT_INIT_SLAVE(Beckhoff_EL2004, 0),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   103
    ECAT_INIT_SLAVE(Beckhoff_EL2004, 0),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   104
    ECAT_INIT_SLAVE(Beckhoff_EL2004, 0),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   105
    ECAT_INIT_SLAVE(Beckhoff_EL2004, 0),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   106
    ECAT_INIT_SLAVE(Beckhoff_EL2004, 0),
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   107
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   108
    // Block 2
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   109
    ECAT_INIT_SLAVE(Beckhoff_EK1100, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   110
    ECAT_INIT_SLAVE(Beckhoff_EL1014, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   111
    ECAT_INIT_SLAVE(Beckhoff_EL1014, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   112
    ECAT_INIT_SLAVE(Beckhoff_EL1014, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   113
    ECAT_INIT_SLAVE(Beckhoff_EL1014, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   114
    ECAT_INIT_SLAVE(Beckhoff_EL1014, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   115
    ECAT_INIT_SLAVE(Beckhoff_EL2004, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   116
    ECAT_INIT_SLAVE(Beckhoff_EL2004, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   117
    ECAT_INIT_SLAVE(Beckhoff_EL2004, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   118
    ECAT_INIT_SLAVE(Beckhoff_EL2004, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   119
    ECAT_INIT_SLAVE(Beckhoff_EL1014, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   120
    ECAT_INIT_SLAVE(Beckhoff_EL1014, 1),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   121
    ECAT_INIT_SLAVE(Beckhoff_EL1014, 1)
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   122
#endif
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   123
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   124
#if 0
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   125
    // Block 3
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   126
   ,ECAT_INIT_SLAVE(Beckhoff_EK1100, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   127
    ECAT_INIT_SLAVE(Beckhoff_EL3162, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   128
    ECAT_INIT_SLAVE(Beckhoff_EL3162, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   129
    ECAT_INIT_SLAVE(Beckhoff_EL3162, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   130
    ECAT_INIT_SLAVE(Beckhoff_EL3162, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   131
    ECAT_INIT_SLAVE(Beckhoff_EL3102, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   132
    ECAT_INIT_SLAVE(Beckhoff_EL3102, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   133
    ECAT_INIT_SLAVE(Beckhoff_EL3102, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   134
    ECAT_INIT_SLAVE(Beckhoff_EL4102, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   135
    ECAT_INIT_SLAVE(Beckhoff_EL4102, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   136
    ECAT_INIT_SLAVE(Beckhoff_EL4102, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   137
    ECAT_INIT_SLAVE(Beckhoff_EL4102, 2),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   138
    ECAT_INIT_SLAVE(Beckhoff_EL4132, 2)
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   139
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   140
};
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   141
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   142
#define ECAT_SLAVES_COUNT (sizeof(ecat_slaves) / sizeof(EtherCAT_slave_t))
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   143
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   144
#define USE_MSR_LIB
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   145
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   146
#ifdef USE_MSR_LIB
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   147
double value;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   148
int dig1;
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
/******************************************************************************
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   152
 *
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   153
 * Function: next2004
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   154
 *
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   155
 *****************************************************************************/
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   156
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   157
static int next2004(int *wrap)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   158
{
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   159
    static int i = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   160
    unsigned int j = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   161
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   162
    *wrap = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   163
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   164
    for (j = 0; j < ECAT_SLAVES_COUNT; j++)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   165
    {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   166
        i++;
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
        i %= ECAT_SLAVES_COUNT;
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
        if (i == 0) *wrap = 1;
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
        if (ecat_slaves[i].desc == Beckhoff_EL2004)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   173
        {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   174
            return i;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   175
        }
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
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   178
    return -1;
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
/******************************************************************************
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: msr_controller_run()
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 void msr_controller_run(void)
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 ms = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   191
    static int cnt = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   192
    static unsigned long int k = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   193
    static int firstrun = 1;
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
    static int klemme = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   196
    static int kanal = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   197
    static int up_down = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   198
    int wrap = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   199
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   200
    static unsigned int debug_counter = 0;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   201
    unsigned long t1, t2, t3, t4, t5, t6, t7;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   202
    static unsigned long lt = 0;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   203
    unsigned int tr1, tr2;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   204
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   205
    rdtscl(t1);
28
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
    // Prozessdaten lesen
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   208
    msr_jitter_run(MSR_ABTASTFREQUENZ);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   209
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   210
    if (firstrun) klemme = next2004(&wrap);
28
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
    ms++;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   213
    ms %= 1000;
40
d07ebafe62dd 20kHz, Wilhelm
Florian Pose <fp@igh-essen.com>
parents: 38
diff changeset
   214
    if (cnt++ > 200)
28
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
        cnt = 0;
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
        if (++kanal > 3)
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
            kanal = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   221
            klemme = next2004(&wrap);
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
            if (wrap == 1)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   224
            {
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   225
                if (up_down == 1) up_down = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   226
                else up_down = 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
        }
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   229
    }
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
    if (klemme >= 0) {
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   232
        EtherCAT_write_value(&ecat_slaves[klemme], kanal, up_down);
28
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
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   235
#if 0
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   236
    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
   237
    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
   238
    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
   239
#endif
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
    // Prozessdaten schreiben
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   242
    rdtscl(k);
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   243
    rdtscl(t2);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   244
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   245
    EtherCAT_process_data_cycle(ecat_master, 0);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   246
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   247
    t3 = ecat_master->tx_time;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   248
    t4 = ecat_master->rx_time;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   249
    tr1 = ecat_master->rx_tries;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   250
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   251
    EtherCAT_process_data_cycle(ecat_master, 1);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   252
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   253
    t5 = ecat_master->tx_time;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   254
    t6 = ecat_master->rx_time;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   255
    tr2 = ecat_master->rx_tries;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   256
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   257
    //EtherCAT_process_data_cycle(ecat_master, 2);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   258
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   259
    // Daten lesen und skalieren
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   260
#ifdef USE_MSR_LIB
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   261
    value = EtherCAT_read_value(&ecat_slaves[5], 0) / 3276.0;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   262
    dig1 = EtherCAT_read_value(&ecat_slaves[2], 0);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   263
#endif
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   264
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   265
    rdtscl(t7);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   266
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   267
    if (debug_counter == MSR_ABTASTFREQUENZ) {
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   268
      printk(KERN_DEBUG "%lu: %luŽµs + %luŽµs + %luŽµs + %luŽµs + %luŽµs +"
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   269
             " %luŽµs = %luŽµs (%u %u)\n",
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   270
             TSC2US(t1 - lt),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   271
             TSC2US(t2 - t1), TSC2US(t3 - t2), TSC2US(t4 - t3),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   272
             TSC2US(t5 - t4), TSC2US(t6 - t5), TSC2US(t7 - t6),
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   273
             TSC2US(t7 - t1), tr1, tr2);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   274
      debug_counter = 0;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   275
    }
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   276
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   277
    lt = t1;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   278
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   279
    firstrun = 0;
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   280
    debug_counter++;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   281
}
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   282
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   283
/******************************************************************************
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   284
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   285
 *  Function: msr_run(_interrupt)
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   286
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   287
 *  Beschreibung: Routine wird zyklisch im Timerinterrupt ausgeführt
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   288
 *                (hier muß alles rein, was Echtzeit ist ...)
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   289
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   290
 *  Parameter: Zeiger auf msr_data
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   291
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   292
 *  Rückgabe:
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   293
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   294
 *  Status: exp
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   295
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   296
 *****************************************************************************/
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   297
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   298
void msr_run(unsigned irq)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   299
{
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   300
  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
   301
#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
   302
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   303
    timeval_add(&process_time,&process_time,&msr_time_increment);
28
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
    MSR_ADEOS_INTERRUPT_CODE(
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   306
	msr_controller_run();
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   307
	msr_write_kanal_list();
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   308
	);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   309
#else
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   310
    msr_controller_run();
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   311
#endif
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   312
    /* 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
   313
    /* und neu in die Taskqueue eintragen */
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   314
    //timer.expires += 1;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   315
    //add_timer(&timer);
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   316
40
d07ebafe62dd 20kHz, Wilhelm
Florian Pose <fp@igh-essen.com>
parents: 38
diff changeset
   317
    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
   318
    if(counter++ > HZREDUCTION) {
40
d07ebafe62dd 20kHz, Wilhelm
Florian Pose <fp@igh-essen.com>
parents: 38
diff changeset
   319
	ipipe_propagate_irq(irq);  //und weiterreichen
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   320
	counter = 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   321
    }
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   322
}
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   323
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   324
void domain_entry (void)
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   325
{
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   326
    printk("Domain %s started.\n", ipipe_current_domain->name);
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   327
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   328
    ipipe_get_sysinfo(&sys_info);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   329
    ipipe_virtualize_irq(ipipe_current_domain,sys_info.archdep.tmirq,
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   330
			 &msr_run, NULL, IPIPE_HANDLE_MASK);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   331
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   332
    ipipe_tune_timer(1000000000UL/MSR_ABTASTFREQUENZ,0);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   333
}
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   334
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   335
/******************************************************************************
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   336
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   337
 *  Function: msr_register_channels
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   338
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   339
 *  Beschreibung: KanŽäle registrieren
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   340
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   341
 *  Parameter:
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   342
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   343
 *  RŽückgabe:
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   344
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   345
 *  Status: exp
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   346
 *
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   347
 *****************************************************************************/
28
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
int msr_globals_register(void)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   350
{
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   351
#ifdef USE_MSR_LIB
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   352
    msr_reg_kanal("/value", "V", &value, TDBL);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   353
    msr_reg_kanal("/dig1", "", &dig1, TINT);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   354
#endif
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   355
#if 0
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   356
    msr_reg_kanal("/Taskinfo/Ecat/TX-Delay","us",&ecat_tx_delay,TUINT);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   357
    msr_reg_kanal("/Taskinfo/Ecat/RX-Delay","us",&ecat_rx_delay,TUINT);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   358
    msr_reg_kanal("/Taskinfo/Ecat/TX-Cnt","",&tx_intr,TUINT);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   359
    msr_reg_kanal("/Taskinfo/Ecat/RX-Cnt","",&rx_intr,TUINT);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   360
    msr_reg_kanal("/Taskinfo/Ecat/Total-Cnt","",&total_intr,TUINT);
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   361
#endif
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   362
  return 0;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   363
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   364
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   365
/******************************************************************************
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   366
 * the init/clean material
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   367
 *****************************************************************************/
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   368
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   369
int __init init_module()
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   370
{
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   371
    unsigned int i;
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   372
    struct ipipe_domain_attr attr; //ipipe
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   373
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   374
    // 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
   375
#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
   376
    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
   377
        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
   378
        goto out_return;
28
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
#endif
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
    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
   383
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   384
    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
   385
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   386
    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
   387
        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
   388
        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
   389
    }
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   390
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   391
    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
   392
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   393
    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
   394
        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
   395
        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
   396
    }
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("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
   399
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   400
    for (i = 0; i < ECAT_SLAVES_COUNT; i++) {
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   401
        if (EtherCAT_activate_slave(ecat_master, ecat_slaves + i) < 0) {
43
35120a61d55e Sch?nheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   402
            printk(KERN_ERR "EtherCAT: Could not activate slave %i!\n", i);
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   403
            goto out_release_master;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   404
        }
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   405
    }
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
    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
   408
    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
   409
    msr_time_increment.tv_usec=(unsigned int)(1000000/MSR_ABTASTFREQUENZ);
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   410
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   411
    ipipe_init_attr (&attr);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   412
    attr.name     = "IPIPE-MSR-MODULE";
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   413
    attr.priority = IPIPE_ROOT_PRIO + 1;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   414
    attr.entry    = &domain_entry;
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   415
    ipipe_register_domain(&this_domain,&attr);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   416
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   417
    return 0;
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
 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
   420
    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
   421
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   422
 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
   423
    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
   424
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   425
 out_return:
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   426
    return -1;
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   427
}
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   428
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   429
/*****************************************************************************/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   430
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   431
void __exit cleanup_module()
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   432
{
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   433
    unsigned int i;
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   434
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   435
    msr_print_info("msk_modul: unloading...");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   436
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   437
    ipipe_tune_timer(1000000000UL/HZ,0); //alten Timertakt wieder herstellen
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   438
    ipipe_unregister_domain(&this_domain);
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
    if (ecat_master)
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   441
    {
43
35120a61d55e Sch?nheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   442
        printk(KERN_INFO "=== Stopping EtherCAT environment... ===\n");
35120a61d55e Sch?nheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   443
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   444
        printk(KERN_INFO "Deactivating slaves.\n");
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   445
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   446
        for (i = 0; i < ECAT_SLAVES_COUNT; i++) {
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   447
            if (EtherCAT_deactivate_slave(ecat_master, ecat_slaves + i) < 0) {
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   448
                printk(KERN_WARNING "Warning - Could not deactivate slave!\n");
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   449
            }
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   450
        }
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   451
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   452
        EtherCAT_release(ecat_master);
43
35120a61d55e Sch?nheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   453
35120a61d55e Sch?nheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   454
        printk(KERN_INFO "=== EtherCAT environment stopped. ===\n");
35120a61d55e Sch?nheitskorrekturen.
Florian Pose <fp@igh-essen.com>
parents: 42
diff changeset
   455
    }
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   456
36
6e9de6fbf74c EtherCAT_release() im Fehlerfall beim Laden von Modulen mini und rt.
Florian Pose <fp@igh-essen.com>
parents: 33
diff changeset
   457
#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
   458
    msr_rtlib_cleanup();
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   459
#endif
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
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   462
/*****************************************************************************/
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   463
28
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   464
MODULE_LICENSE("GPL");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   465
MODULE_AUTHOR ("Wilhelm Hagemeister <hm@igh-essen.com>");
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   466
MODULE_DESCRIPTION ("EtherCAT test environment");
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_init(init_module);
801dc7eabf51 IPIPE,floatpoint,rtlib
Wilhelm Hagemeister <hm@igh-essen.com>
parents:
diff changeset
   469
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
   470
42
a22a202d0f42 Domains, Warten beim Senden, 10kHz.
Florian Pose <fp@igh-essen.com>
parents: 40
diff changeset
   471
/*****************************************************************************/